schema.go 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. // Copyright 2018 The go-ethereum Authors
  2. // This file is part of the go-ethereum library.
  3. //
  4. // The go-ethereum library is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU Lesser General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // The go-ethereum library is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU Lesser General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU Lesser General Public License
  15. // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
  16. package graphql
  17. const schema string = `
  18. # Bytes32 is a 32 byte binary string, represented as 0x-prefixed hexadecimal.
  19. scalar Bytes32
  20. # Address is a 20 byte Ethereum address, represented as 0x-prefixed hexadecimal.
  21. scalar Address
  22. # Bytes is an arbitrary length binary string, represented as 0x-prefixed hexadecimal.
  23. scalar Bytes
  24. # BigInt is a large integer. Input is accepted as either a JSON number or as a string.
  25. # Strings may be either decimal or 0x-prefixed hexadecimal. Output values are all
  26. # 0x-prefixed hexadecimal.
  27. scalar BigInt
  28. # Long is a 64 bit unsigned integer.
  29. scalar Long
  30. schema {
  31. query: Query
  32. mutation: Mutation
  33. }
  34. # Account is an Ethereum account at a particular block.
  35. type Account {
  36. # Address is the address owning the account.
  37. address: Address!
  38. # Balance is the balance of the account, in wei.
  39. balance: BigInt!
  40. # TransactionCount is the number of transactions sent from this account,
  41. # or in the case of a contract, the number of contracts created. Otherwise
  42. # known as the nonce.
  43. transactionCount: Long!
  44. # Code contains the smart contract code for this account, if the account
  45. # is a (non-self-destructed) contract.
  46. code: Bytes!
  47. # Storage provides access to the storage of a contract account, indexed
  48. # by its 32 byte slot identifier.
  49. storage(slot: Bytes32!): Bytes32!
  50. }
  51. # Log is an Ethereum event log.
  52. type Log {
  53. # Index is the index of this log in the block.
  54. index: Int!
  55. # Account is the account which generated this log - this will always
  56. # be a contract account.
  57. account(block: Long): Account!
  58. # Topics is a list of 0-4 indexed topics for the log.
  59. topics: [Bytes32!]!
  60. # Data is unindexed data for this log.
  61. data: Bytes!
  62. # Transaction is the transaction that generated this log entry.
  63. transaction: Transaction!
  64. }
  65. # Transaction is an Ethereum transaction.
  66. type Transaction {
  67. # Hash is the hash of this transaction.
  68. hash: Bytes32!
  69. # Nonce is the nonce of the account this transaction was generated with.
  70. nonce: Long!
  71. # Index is the index of this transaction in the parent block. This will
  72. # be null if the transaction has not yet beenn mined.
  73. index: Int
  74. # From is the account that sent this transaction - this will always be
  75. # an externally owned account.
  76. from(block: Long): Account!
  77. # To is the account the transaction was sent to. This is null for
  78. # contract-creating transactions.
  79. to(block: Long): Account
  80. # Value is the value, in wei, sent along with this transaction.
  81. value: BigInt!
  82. # GasPrice is the price offered to miners for gas, in wei per unit.
  83. gasPrice: BigInt!
  84. # Gas is the maximum amount of gas this transaction can consume.
  85. gas: Long!
  86. # InputData is the data supplied to the target of the transaction.
  87. inputData: Bytes!
  88. # Block is the block this transaction was mined in. This will be null if
  89. # the transaction has not yet been mined.
  90. block: Block
  91. # Status is the return status of the transaction. This will be 1 if the
  92. # transaction succeeded, or 0 if it failed (due to a revert, or due to
  93. # running out of gas). If the transaction has not yet been mined, this
  94. # field will be null.
  95. status: Long
  96. # GasUsed is the amount of gas that was used processing this transaction.
  97. # If the transaction has not yet been mined, this field will be null.
  98. gasUsed: Long
  99. # CumulativeGasUsed is the total gas used in the block up to and including
  100. # this transaction. If the transaction has not yet been mined, this field
  101. # will be null.
  102. cumulativeGasUsed: Long
  103. # CreatedContract is the account that was created by a contract creation
  104. # transaction. If the transaction was not a contract creation transaction,
  105. # or it has not yet been mined, this field will be null.
  106. createdContract(block: Long): Account
  107. # Logs is a list of log entries emitted by this transaction. If the
  108. # transaction has not yet been mined, this field will be null.
  109. logs: [Log!]
  110. }
  111. # BlockFilterCriteria encapsulates log filter criteria for a filter applied
  112. # to a single block.
  113. input BlockFilterCriteria {
  114. # Addresses is list of addresses that are of interest. If this list is
  115. # empty, results will not be filtered by address.
  116. addresses: [Address!]
  117. # Topics list restricts matches to particular event topics. Each event has a list
  118. # of topics. Topics matches a prefix of that list. An empty element array matches any
  119. # topic. Non-empty elements represent an alternative that matches any of the
  120. # contained topics.
  121. #
  122. # Examples:
  123. # - [] or nil matches any topic list
  124. # - [[A]] matches topic A in first position
  125. # - [[], [B]] matches any topic in first position, B in second position
  126. # - [[A], [B]] matches topic A in first position, B in second position
  127. # - [[A, B]], [C, D]] matches topic (A OR B) in first position, (C OR D) in second position
  128. topics: [[Bytes32!]!]
  129. }
  130. # Block is an Ethereum block.
  131. type Block {
  132. # Number is the number of this block, starting at 0 for the genesis block.
  133. number: Long!
  134. # Hash is the block hash of this block.
  135. hash: Bytes32!
  136. # Parent is the parent block of this block.
  137. parent: Block
  138. # Nonce is the block nonce, an 8 byte sequence determined by the miner.
  139. nonce: Bytes!
  140. # TransactionsRoot is the keccak256 hash of the root of the trie of transactions in this block.
  141. transactionsRoot: Bytes32!
  142. # TransactionCount is the number of transactions in this block. if
  143. # transactions are not available for this block, this field will be null.
  144. transactionCount: Int
  145. # StateRoot is the keccak256 hash of the state trie after this block was processed.
  146. stateRoot: Bytes32!
  147. # ReceiptsRoot is the keccak256 hash of the trie of transaction receipts in this block.
  148. receiptsRoot: Bytes32!
  149. # Miner is the account that mined this block.
  150. miner(block: Long): Account!
  151. # ExtraData is an arbitrary data field supplied by the miner.
  152. extraData: Bytes!
  153. # GasLimit is the maximum amount of gas that was available to transactions in this block.
  154. gasLimit: Long!
  155. # GasUsed is the amount of gas that was used executing transactions in this block.
  156. gasUsed: Long!
  157. # Timestamp is the unix timestamp at which this block was mined.
  158. timestamp: BigInt!
  159. # LogsBloom is a bloom filter that can be used to check if a block may
  160. # contain log entries matching a filter.
  161. logsBloom: Bytes!
  162. # MixHash is the hash that was used as an input to the PoW process.
  163. mixHash: Bytes32!
  164. # Difficulty is a measure of the difficulty of mining this block.
  165. difficulty: BigInt!
  166. # TotalDifficulty is the sum of all difficulty values up to and including
  167. # this block.
  168. totalDifficulty: BigInt!
  169. # OmmerCount is the number of ommers (AKA uncles) associated with this
  170. # block. If ommers are unavailable, this field will be null.
  171. ommerCount: Int
  172. # Ommers is a list of ommer (AKA uncle) blocks associated with this block.
  173. # If ommers are unavailable, this field will be null. Depending on your
  174. # node, the transactions, transactionAt, transactionCount, ommers,
  175. # ommerCount and ommerAt fields may not be available on any ommer blocks.
  176. ommers: [Block]
  177. # OmmerAt returns the ommer (AKA uncle) at the specified index. If ommers
  178. # are unavailable, or the index is out of bounds, this field will be null.
  179. ommerAt(index: Int!): Block
  180. # OmmerHash is the keccak256 hash of all the ommers (AKA uncles)
  181. # associated with this block.
  182. ommerHash: Bytes32!
  183. # Transactions is a list of transactions associated with this block. If
  184. # transactions are unavailable for this block, this field will be null.
  185. transactions: [Transaction!]
  186. # TransactionAt returns the transaction at the specified index. If
  187. # transactions are unavailable for this block, or if the index is out of
  188. # bounds, this field will be null.
  189. transactionAt(index: Int!): Transaction
  190. # Logs returns a filtered set of logs from this block.
  191. logs(filter: BlockFilterCriteria!): [Log!]!
  192. }
  193. # CallData represents the data associated with a local contract call.
  194. # All fields are optional.
  195. input CallData {
  196. # From is the address making the call.
  197. from: Address
  198. # To is the address the call is sent to.
  199. to: Address
  200. # Gas is the amount of gas sent with the call.
  201. gas: Long
  202. # GasPrice is the price, in wei, offered for each unit of gas.
  203. gasPrice: BigInt
  204. # Value is the value, in wei, sent along with the call.
  205. value: BigInt
  206. # Data is the data sent to the callee.
  207. data: Bytes
  208. }
  209. # CallResult is the result of a local call operationn.
  210. type CallResult {
  211. # Data is the return data of the called contract.
  212. data: Bytes!
  213. # GasUsed is the amount of gas used by the call, after any refunds.
  214. gasUsed: Long!
  215. # Status is the result of the call - 1 for success or 0 for failure.
  216. status: Long!
  217. }
  218. # FilterCriteria encapsulates log filter criteria for searching log entries.
  219. input FilterCriteria {
  220. # FromBlock is the block at which to start searching, inclusive. Defaults
  221. # to the latest block if not supplied.
  222. fromBlock: Long
  223. # ToBlock is the block at which to stop searching, inclusive. Defaults
  224. # to the latest block if not supplied.
  225. toBlock: Long
  226. # Addresses is a list of addresses that are of interest. If this list is
  227. # empty, results will not be filtered by address.
  228. addresses: [Address!]
  229. # Topics list restricts matches to particular event topics. Each event has a list
  230. # of topics. Topics matches a prefix of that list. An empty element array matches any
  231. # topic. Non-empty elements represent an alternative that matches any of the
  232. # contained topics.
  233. #
  234. # Examples:
  235. # - [] or nil matches any topic list
  236. # - [[A]] matches topic A in first position
  237. # - [[], [B]] matches any topic in first position, B in second position
  238. # - [[A], [B]] matches topic A in first position, B in second position
  239. # - [[A, B]], [C, D]] matches topic (A OR B) in first position, (C OR D) in second position
  240. topics: [[Bytes32!]!]
  241. }
  242. # SyncState contains the current synchronisation state of the client.
  243. type SyncState{
  244. # StartingBlock is the block number at which synchronisation started.
  245. startingBlock: Long!
  246. # CurrentBlock is the point at which synchronisation has presently reached.
  247. currentBlock: Long!
  248. # HighestBlock is the latest known block number.
  249. highestBlock: Long!
  250. # PulledStates is the number of state entries fetched so far, or null
  251. # if this is not known or not relevant.
  252. pulledStates: Long
  253. # KnownStates is the number of states the node knows of so far, or null
  254. # if this is not known or not relevant.
  255. knownStates: Long
  256. }
  257. type Query {
  258. # Account fetches an Ethereum account at the specified block number.
  259. # If blockNumber is not provided, it defaults to the most recent block.
  260. account(address: Address!, blockNumber: Long): Account!
  261. # Block fetches an Ethereum block by number or by hash. If neither is
  262. # supplied, the most recent known block is returned.
  263. block(number: Long, hash: Bytes32): Block
  264. # Blocks returns all the blocks between two numbers, inclusive. If
  265. # to is not supplied, it defaults to the most recent known block.
  266. blocks(from: Long!, to: Long): [Block!]!
  267. # Transaction returns a transaction specified by its hash.
  268. transaction(hash: Bytes32!): Transaction
  269. # Call executes a local call operation. If blockNumber is not specified,
  270. # it defaults to the most recent known block.
  271. call(data: CallData!, blockNumber: Long): CallResult
  272. # EstimateGas estimates the amount of gas that will be required for
  273. # successful execution of a transaction. If blockNumber is not specified,
  274. # it defaults ot the most recent known block.
  275. estimateGas(data: CallData!, blockNumber: Long): Long!
  276. # Logs returns log entries matching the provided filter.
  277. logs(filter: FilterCriteria!): [Log!]!
  278. # GasPrice returns the node's estimate of a gas price sufficient to
  279. # ensure a transaction is mined in a timely fashion.
  280. gasPrice: BigInt!
  281. # ProtocolVersion returns the current wire protocol version number.
  282. protocolVersion: Int!
  283. # Syncing returns information on the current synchronisation state.
  284. syncing: SyncState
  285. }
  286. type Mutation {
  287. # SendRawTransaction sends an RLP-encoded transaction to the network.
  288. sendRawTransaction(data: Bytes!): Bytes32!
  289. }
  290. `