Developers
JSON RPC API
39 min
the mova chain is fully compatible with the ethereum ecosystem, including smart contracts, core json rpc apis, block explorers, wallets, and sdks it supports calls from ethereum wallets, enabling seamless migration of ethereum dapps to the mova chain developers can refer to the supported ethereum apis listed below ${rpc url} as follow is the rpc link mova beta network https //mars rpc movachain com account api eth getbalance returns the balance of the account at the specified address parameter data 20 bytes, the address to check the balance quantity|tag integer block number, or string "latest", "earliest" or "pending" \[ "0xf60a4716edabdc1479c9b2562989a9ca106063da", "latest" ] return value quantity current balance, unit wei sample code request curl location ${rpc url} h "content type\ application/json" x post data '{ "jsonrpc" "2 0", "method" "eth getbalance", "params" \[ "0xf60a4716edabdc1479c9b2562989a9ca106063da", "latest" ], "id" 1 }' response { "jsonrpc" "2 0", "id" 1, "result" "0x52b7d2dcbef4847150bdc0" } eth gettransactioncount returns the number of transactions sent from an address parameter data 20 bytes, address quantity|tag integer block number, or string "latest", "earliest" or "pending" params \[ '0xf60a4716edabdc1479c9b2562989a9ca106063da', 'latest' // state at the latest block ] return value quantity the number of transactions sent from the specified address, integer sample code request curl location ${rpc url} h "content type\ application/json" x post data '{ "jsonrpc" "2 0", "method" "eth gettransactioncount", "params" \[ "0xf60a4716edabdc1479c9b2562989a9ca106063da", "latest" ], "id" 1 }' response { "jsonrpc" "2 0", "id" 1, "result" "0x3" } block api eth getblockbyhash returns information about a block by block hash parameter data, 32 bytes block hash boolean if true, return the complete transaction object, otherwise only return the transaction hash params \[ '0x5f5d529ca8439907834fad33cad684b2e316df4ea16865610b55cc54a4833088', true ] return value object the matching block object, if the block is not found, returns null, the structure is as follows number quantity block number, pending block is null hash data, 32 bytes block hash, pending block is null parenthash data, 32 bytes the hash of the parent block nonce data, 8 bytes the generated pow hash, the pending block is null sha3uncles data, 32 bytes sha3 hash of the uncle data in the block logsbloom data, 256 bytes bloom filter of fast log, pending block is null transactionsroot data, 32 bytes the root node of the transaction tree in the block stateroot data, 32 bytes the root node of the block final state tree receiptsroot data, 32 bytes the root node of the block transaction receipt tree miner data, 20 bytes receiving account for mining rewards difficulty quantity block difficulty, integer totaldifficulty quantity total difficulty on the chain as of this block extradata data block extra data size quantity number of bytes in this block gaslimit quantity maximum gas usage allowed in this block gasused quantity the total amount of gas used by all transactions in this block timestamp quantity block timestamp transactions array transaction object array, or 32 byte transaction hash array uncles array uncle hash array the following fields are only in ethereum's response parenthash data, 32 bytes the hash of the parent block receiptsroot data, 32 bytes the root node of the block transaction receipt tree sample code request curl location ${rpc url} h "content type\ application/json" x post data '{ "jsonrpc" "2 0", "method" "eth getblockbyhash", "params" \[ "0x5f5d529ca8439907834fad33cad684b2e316df4ea16865610b55cc54a4833088", true ], "id" 1 }' response { "jsonrpc" "2 0", "id" 1, "result" { "difficulty" null, "extradata" null, "gaslimit" "0xffffffff", "gasused" "0x9184e72a0000", "hash" "0x5f5d529ca8439907834fad33cad684b2e316df4ea16865610b55cc54a4833088", "logsbloom" "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "miner" "0x0000000000000000000000000000000000000000", "nonce" null, "number" "0xb960", "sha3uncles" null, "size" "0x2b1", "stateroot" "0x3d78925971ba8cdc4581f6e0aea30ce2a3e1193f2e3bc03a17080383a01dc4b3", "timestamp" "0x5fd07e18", "totaldifficulty" null, "transactions" \[ { "blockhash" "0x5f5d529ca8439907834fad33cad684b2e316df4ea16865610b55cc54a4833088", "blocknumber" "0xb960", "from" "0xf60a4716edabdc1479c9b2562989a9ca106063da", "gas" "0x10000", "gasprice" "0x9184e72a", "hash" "0x579c0bca0a06a5cece62605324ef437865df7f7070b46a29fde978d8e6de53cc", "input" "0x", "nonce" "0x5", "to" "0x5f9e2ff5bfcc135bbea6aa9587ae88564d35c1b4", "transactionindex" "0x0", "value" "0x200000000", "v" "0x4593", "r" "0x9f96a63d4127f7b7a8175c34cc88cd508704898ad955e167f0d0292be26c3bf3", "s" "0x1e7fa24c30ad6020b20439cabd902f5dac2c1cb9e7098b1d94db1524a5fa8c77" } ], "transactionsroot" "0x640ba1c7242e49b6523b0b583763640e3376179822ec77dbbca930c0ab63fe7a", "uncles" null } } eth getblockbynumber returns information about a block by block number parameter quantity|tag integer block number, or string "earliest", "latest" or "pending" boolean if true, return the complete transaction object, otherwise only return the transaction hash params \[ '0xb960', true ] return value object the matching block object, if the block is not found, returns null, the structure is as follows difficulty quantity ether square represents a "block difficulty", mova chains are not taken to make the block by miners right difficult, so this value is null extradata data block extra data gaslimit quantity the maximum amount of gas allowed in this block gasused quantity the total amount of gas used by all transactions in this block hash data, 32 bytes block hash logsbloom data, 256 bytes bloom filter for fast log miner data, 20 bytes receiving account for mining rewards nonce data, 8 bytes pow hash generated number quantity block number sha3uncles data, 32 bytes sha3 hash of the uncle data in the block size quantity number of bytes in this block stateroot data, 32 bytes the root node of the block final state tree timestamp quantity block timestamp totaldifficulty quantity ether square represents "off the chains of the block to the total difficulty", mova no such demand chain transactions transaction object array, or 32 byte transaction hash array transactionsroot data, 32 bytes the root node of the transaction tree in the block uncles array ether square indicates "tertiary bo haxi array", mova no such demand chain parenthash data, 32 bytes ethereum stands for "the hash of the parent block" the consensus algorithm of this chain is different from ethereum, and there is no such requirement receiptsroot data, 32 bytes ethereum stands for "the root node of the block transaction receipt tree" the consensus algorithm of this chain is different from ethereum, and there is no such requirement the following fields are only in ethereum's response parenthash data, 32 bytes the hash of the parent block receiptsroot data, 32 bytes the root node of the block transaction receipt tree sample code request curl location ${rpc url} h "content type\ application/json" x post data '{ "jsonrpc" "2 0", "method" "eth getblockbynumber", "params" \["0xb960",true], "id" 1 }' response { "jsonrpc" "2 0", "id" 1, "result" { "difficulty" null, "extradata" null, "gaslimit" "0xffffffff", "gasused" "0x9184e72a0000", "hash" "0x5f5d529ca8439907834fad33cad684b2e316df4ea16865610b55cc54a4833088", "logsbloom" "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "miner" "0x0000000000000000000000000000000000000000", "nonce" null, "number" "0xb960", "sha3uncles" null, "size" "0x2b1", "stateroot" "0x3d78925971ba8cdc4581f6e0aea30ce2a3e1193f2e3bc03a17080383a01dc4b3", "timestamp" "0x5fd07e18", "totaldifficulty" null, "transactions" \[ { "blockhash" "0x5f5d529ca8439907834fad33cad684b2e316df4ea16865610b55cc54a4833088", "blocknumber" "0xb960", "from" "0xf60a4716edabdc1479c9b2562989a9ca106063da", "gas" "0x10000", "gasprice" "0x9184e72a", "hash" "0x579c0bca0a06a5cece62605324ef437865df7f7070b46a29fde978d8e6de53cc", "input" "0x", "nonce" "0x5", "to" "0x5f9e2ff5bfcc135bbea6aa9587ae88564d35c1b4", "transactionindex" "0x0", "value" "0x200000000", "v" "0x4593", "r" "0x9f96a63d4127f7b7a8175c34cc88cd508704898ad955e167f0d0292be26c3bf3", "s" "0x1e7fa24c30ad6020b20439cabd902f5dac2c1cb9e7098b1d94db1524a5fa8c77" } ], "transactionsroot" "0x640ba1c7242e49b6523b0b583763640e3376179822ec77dbbca930c0ab63fe7a", "uncles" null } } trasaction api eth sendrawtransaction creates new message call transaction or a contract creation for the signed transaction parameter signed transaction message the original transaction object is from data, 20 bytes the source address of the transaction sent to data, 20 bytes the target address of the transaction, optional when creating a new contract gas quantity the amount of gas available for transaction execution, optional integer, the default value is 90000, unused gas will be returned gasprice quantity gas price, optional, default value to be determined value quantity amount sent by the transaction, optional integer "params" \[ "0xf86b04849184e72a83010000945f9e2ff5bfcc135bbea6aa9587ae88564d35c1b485010000000080824594a0ced51bb5f4f9eda5b533787ffc5dcc4e54201153ecd912ca37b3c080cbc7cd7ca04f91d891b9415173ec0b7c7ef975ad8c6b271ba52f557a2c154c066af9d5747d" ] return value data 32 bytes, transaction hash, if the transaction is not valid, all 0 hashes are returned when creating a contract, use eth gettransactionreceipt to obtain the contract address after the transaction takes effect sample code request curl location ${rpc url} h "content type\ application/json" x post data '{ "jsonrpc" "2 0", "method" "eth sendrawtransaction", "params" \[ "0xf86b04849184e72a83010000945f9e2ff5bfcc135bbea6aa9587ae88564d35c1b485010000000080824594a0ced51bb5f4f9eda5b533787ffc5dcc4e54201153ecd912ca37b3c080cbc7cd7ca04f91d891b9415173ec0b7c7ef975ad8c6b271ba52f557a2c154c066af9d5747d" ], "id" 1 }' response { "jsonrpc" "2 0", "id" 1, "result" "0x92c1c7403bf9a5880f3531b76e55e0bfe3f7db458483428128f9a91253bf673a" } eth gettransactionbyhash returns the information about a transaction requested by transaction hash parameter data, 32 bytes transaction hash params \[ '0x733f9ab3683b63ccd0ec0d6f990cfbea33c8bc414837bfecf462085122bb84e7' ] return value object the object of the transaction receipt, or null if the receipt does not exist the structure of the transaction object is as follows hash data, 32 bytes transaction hash nonce quantity the number of transactions that the sender has generated before this transaction blockhash data, 32 bytes the hash of the exchange in the block, for the pending block, the value is null blocknumber quantity the number of the exchange in the block, for the pending block, the value is null transactionindex quantity the index position of the transaction in the block, the value of the pending block is null from data, 20 bytes transaction sender address to data, 20 bytes the address of the transaction recipient for contract creation transactions, the value is null value quantity the amount of ether sent, unit wei gasprice quantity gas price provided by the sender, unit wei gas quantity the amount of gas available from the sender input data data sent with the transaction v r s sample code request curl location ${rpc url} h "content type\ application/json" x post data '{ "jsonrpc" "2 0", "method" "eth gettransactionbyhash", "params" \["0x733f9ab3683b63ccd0ec0d6f990cfbea33c8bc414837bfecf462085122bb84e7"], "id" 1 }' response { "jsonrpc" "2 0", "id" 1, "result" { "blockhash" "0x5f5d529ca8439907834fad33cad684b2e316df4ea16865610b55cc54a4833088", "blocknumber" "0xb960", "from" "0xf60a4716edabdc1479c9b2562989a9ca106063da", "gas" "0x10000", "gasprice" "0x9184e72a", "hash" "0x733f9ab3683b63ccd0ec0d6f990cfbea33c8bc414837bfecf462085122bb84e7", "input" "0x", "nonce" "0x5", "to" "0x5f9e2ff5bfcc135bbea6aa9587ae88564d35c1b4", "transactionindex" "0x0", "value" "0x200000000", "v" "0x4593", "r" "0x9f96a63d4127f7b7a8175c34cc88cd508704898ad955e167f0d0292be26c3bf3", "s" "0x1e7fa24c30ad6020b20439cabd902f5dac2c1cb9e7098b1d94db1524a5fa8c77" } } eth gettransactionbyblockhashandindex returns information about a transaction by block hash and transaction index position parameter data, 32 bytes transaction hash quantity the index number of the transaction in the block params \[ '0x5f5d529ca8439907834fad33cad684b2e316df4ea16865610b55cc54a4833088', '0x0' ] return value object the object of the transaction receipt, or null if the receipt does not exist the structure of the transaction object is as follows hash data, 32 bytes transaction hash nonce quantity the number of transactions that the sender has generated before this transaction blockhash data, 32 bytes the hash of the exchange in the block, for the pending block, the value is null blocknumber quantity the number of the exchange in the block, for the pending block, the value is null transactionindex quantity the index position of the transaction in the block, the value of the pending block is null from data, 20 bytes transaction sender address to data, 20 bytes the address of the transaction recipient for contract creation transactions, the value is null value quantity the amount of ether sent, unit wei gasprice quantity gas price provided by the sender, unit wei gas quantity the amount of gas available from the sender input data data sent with the transaction v r s sample code request curl location ${rpc url} h "content type\ application/json" x post data '{ "jsonrpc" "2 0", "method" "eth gettransactionbyblockhashandindex", "params" \["0x5f5d529ca8439907834fad33cad684b2e316df4ea16865610b55cc54a4833088","0x0"], "id" 1 }' response { "jsonrpc" "2 0", "id" 1, "result" { "blockhash" "0x5f5d529ca8439907834fad33cad684b2e316df4ea16865610b55cc54a4833088", "blocknumber" "0xb960", "from" "0xf60a4716edabdc1479c9b2562989a9ca106063da", "gas" "0x10000", "gasprice" "0x9184e72a", "hash" "0x579c0bca0a06a5cece62605324ef437865df7f7070b46a29fde978d8e6de53cc", "input" "0x", "nonce" "0x5", "to" "0x5f9e2ff5bfcc135bbea6aa9587ae88564d35c1b4", "transactionindex" "0x0", "value" "0x200000000", "v" "0x4593", "r" "0x9f96a63d4127f7b7a8175c34cc88cd508704898ad955e167f0d0292be26c3bf3", "s" "0x1e7fa24c30ad6020b20439cabd902f5dac2c1cb9e7098b1d94db1524a5fa8c77" } } eth gettransactionbyblocknumberandindex returns information about a transaction by block number and transaction index position parameter quantity|tag integer block number, or string "earliest", "latest" or "pending" quantity transaction index number params \[ '0xb960', '0x0' ] return value object the object of the transaction receipt, or null if the receipt does not exist the structure of the transaction object is as follows hash data, 32 bytes transaction hash nonce quantity the number of transactions that the sender has generated before this transaction blockhash data, 32 bytes the hash of the exchange in the block, for the pending block, the value is null blocknumber quantity the number of the exchange in the block, for the pending block, the value is null transactionindex quantity the index position of the transaction in the block, the value of the pending block is null from data, 20 bytes transaction sender address to data, 20 bytes the address of the transaction recipient for contract creation transactions, the value is null value quantity the amount of ether sent, unit wei gasprice quantity gas price provided by the sender, unit wei gas quantity the amount of gas available from the sender input data data sent with the transaction v r s sample code request curl location ${rpc url} h "content type\ application/json" x post data '{ "jsonrpc" "2 0", "method" "eth gettransactionbyblocknumberandindex", "params" \["0xb960","0x0"], "id" 1 }' response { "jsonrpc" "2 0", "id" 1, "result" { "blockhash" "0x5f5d529ca8439907834fad33cad684b2e316df4ea16865610b55cc54a4833088", "blocknumber" "0xb960", "from" "0xf60a4716edabdc1479c9b2562989a9ca106063da", "gas" "0x10000", "gasprice" "0x9184e72a", "hash" "0x579c0bca0a06a5cece62605324ef437865df7f7070b46a29fde978d8e6de53cc", "input" "0x", "nonce" "0x5", "to" "0x5f9e2ff5bfcc135bbea6aa9587ae88564d35c1b4", "transactionindex" "0x0", "value" "0x200000000", "v" "0x4593", "r" "0x9f96a63d4127f7b7a8175c34cc88cd508704898ad955e167f0d0292be26c3bf3", "s" "0x1e7fa24c30ad6020b20439cabd902f5dac2c1cb9e7098b1d94db1524a5fa8c77" } } eth gettransactionreceipt returns the receipt of a transaction by transaction hash it should be pointed out that the receipt of pending transactions is invalid parameter data, 32 bytes transaction hash params \[ '0x733f9ab3683b63ccd0ec0d6f990cfbea33c8bc414837bfecf462085122bb84e7' ] return value object the object of the transaction receipt, or null if the receipt does not exist the structure of the transaction object is as follows transactionhash data, 32 bytes transaction hash transactionindex quantity the index number of the transaction in the block blockhash data, 32 bytes the hash of the exchange in the block blocknumber quantity the number of the exchange in the block from data, 20 bytes transaction sender address to data, 20 bytes the address of the transaction recipient for contract creation transactions, the value is null cumulativegasused quantity the total amount of gas consumed by the exchange in the block gasused quantity the amount of gas consumed by the transaction contractaddress data, 20 bytes for contract creation transactions, the value is the newly created contract address, otherwise it is null logs array the array of log objects generated by this transaction logsbloom data, 256 bytes bloom filter, light client used to quickly extract related logs sample code request curl location ${rpc url} h "content type\ application/json" x post data '{ "jsonrpc" "2 0", "method" "eth gettransactionreceipt", "params" \["0x733f9ab3683b63ccd0ec0d6f990cfbea33c8bc414837bfecf462085122bb84e7"], "id" 1 }' response { "jsonrpc" "2 0", "id" 1, "result" { "blockhash" "0x5f5d529ca8439907834fad33cad684b2e316df4ea16865610b55cc54a4833088", "blocknumber" "0xb960", "contractaddress" null, "cumulativegasused" null, "from" "0xf60a4716edabdc1479c9b2562989a9ca106063da", "gasused" "0x0", "logs" null, "logsbloom" "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "status" "0x1", "to" "0x5f9e2ff5bfcc135bbea6aa9587ae88564d35c1b4", "transactionhash" "0x733f9ab3683b63ccd0ec0d6f990cfbea33c8bc414837bfecf462085122bb84e7", "transactionindex" "0x0" } } eth getlogs returns an array of all logs matching a given filter object parameters object the filter options fromblock quantity|tag (optional, default "latest") integer block number, or "latest" for the last mined block or "pending", "earliest" for not yet mined transactions toblock quantity|tag (optional, default "latest") integer block number, or "latest" for the last mined block or "pending", "earliest" for not yet mined transactions the value(toblock fromblock) must be less than 200 address data|array, 20 bytes (optional) contract address or a list of addresses from which logs should originate topics array of data, (optional) array of 32 bytes data topics topics are order dependent each topic can also be an array of data with "or" options blockhash data, 32 bytes (optional, future) with the addition of eip 234, blockhash will be a new filter option which restricts the logs returned to the single block with the 32 byte hash blockhash using blockhash is equivalent to fromblock = toblock = the block number with hash blockhash if blockhash is present in in the filter criteria, then neither fromblock nor toblock are allowed params \[ { topics \[ "0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b", ], }, ] return value data returns array array of log objects, or an empty array if nothing has changed since last poll sample code request curl location ${rpc url} x post h "content type\ application/json" data '{ "jsonrpc" "2 0", "method" "eth getlogs", "params" \[ { "topics" \[ "0x59ebeb90bc63057b6515673c3ecf9438e5058bca0f92585014eced636878c9a5" ] } ], "id" 1 }' response { "id" 1, "jsonrpc" "2 0", "result" \[{ "logindex" "0x1", "blocknumber" "0x1b4", "blockhash" "0x8216c5785ac562ff41e2dcfdf5785ac562ff41e2dcfdf829c5a142f1fccd7d", "transactionhash" "0xdf829c5a142f1fccd7d8216c5785ac562ff41e2dcfdf5785ac562ff41e2dcf", "transactionindex" "0x0", "address" "0x16c5785ac562ff41e2dcfdf829c5a142f1fccd7d", "data" "0x0000000000000000000000000000000000000000000000000000000000000000", "topics" \["0x59ebeb90bc63057b6515673c3ecf9438e5058bca0f92585014eced636878c9a5"] }] } contract api eth call executes a new message call immediately without creating a transaction on the block chain parameter object transaction call object from data, 20 bytes the original address to send the transaction, optional to data, 20 bytes transaction target address gas quantity the amount of gas available for the transaction, optional eth call does not consume gas, but some execution links require this parameter gasprice quantity gas price, optional data data method signature and hash of encoding parameters, optional return value data the return value of the executed contract sample code request curl location ${rpc url} h "content type\ application/json" x post data '{ jsonrpc" "2 0","method" "eth call", "params" \[ { "from" "0xf60a4716edabdc1479c9b2562989a9ca106063da", "to" "0x506fb30eeac47da87503a0c12223c9482b06891e", "gas" "0x10000", "gasprice" "0x9184e72a", "data" "0x55551669" }, "latest" ], "id" 1 }' response { "jsonrpc" "2 0", "id" 1, "result" "0x0000000000000000000000000000000000000000000000000000000000009855" } eth getcode returns the code of the specified contract parameter data 20 bytes, address quantity|tag integer block number, or string "latest", "earliest" or "pending" params \[ "0xf60a4716edabdc1479c9b2562989a9ca106063da", "latest" ] return value data code at specified address sample code request curl location ${rpc url} h "content type\ application/json" x post data '{ "jsonrpc" "2 0", "method" "eth getcode", "params" \[ "0xf60a4716edabdc1479c9b2562989a9ca106063da", "latest" ], "id" 1 }' response { "jsonrpc" "2 0", "id" 1, "result" "0x" } gas api eth gasprice returns the current gas price, unit wei parameter no return value quantity integer, the current gas price in wei sample code request curl location ${rpc url} h "content type\ application/json" x post data '{ "jsonrpc" "2 0", "method" "eth gasprice", "params" \[], "id" 73 }' response { "jsonrpc" "2 0", "id" 73, "result" "0x14" } eth estimategas makes a call or transaction, which won't be added to the blockchain and returns the used gas, which can be used for estimating the used gas parameter refer to the parameters of the eth call call, all attributes are optional if the upper limit of gas usage is not specified, geth will use the upper gas limit of the pending block in this case, the gas estimate returned may not be enough to execute the actual transaction return value quantity estimated gas usage sample code request curl location ${rpc url} h "content type\ application/json" x post data '{ "jsonrpc" "2 0", "method" "eth estimategas", "params" \[ { "from" "0xf60a4716edabdc1479c9b2562989a9ca106063da", "to" "0x506fb30eeac47da87503a0c12223c9482b06891e", "gas" "0x10000", "gasprice" "0x9184e72a", "data" "0x55551669" } ], "id" 1 }' response { "jsonrpc" "2 0", "id" 1, "result" "0x989680" }