web3
RPC request uses HTTP POST method. The contents in the request are in JSON format, in which the method field specifies the name of the RPC interface.
The following is a list of web3 RPCs that MCP current compatible with.
web3_clientVersion
Returns the current client version.
Parameters
None
Returns
String
- The current client version
Example
Request
Response
web3_sha3
Returns Keccak-256 (not the standardized SHA3-256) of the given data.
Parameters
String
- The data to convert into a SHA3 hash.
Returns
Data
- The Keccak-256 hash of the given string.
Example
Request
Response
eth_blockNumber
Returns the number of most recent block.
Parameters
None
Returns
Quantity
- integer of the current block number the client is on.
Example
Request
Response
eth_getTransactionCount
Returns the number of transactions sent from an address.
Parameters
Address
- 20 Bytes - address.Quantity
orTag
- (optional) integer block number, or the string'latest'
,'earliest'
or'pending'
, see the eth_getBlockByNumber.
Returns
Quantity
- integer of the number of transactions send from this address.
Example
Request
eth_chainId
Returns the chain ID used for transaction signing at the current best block. Null is returned if not available.
Parameters
None
Returns
Quantity
- Chain ID, ornull
if not available.
Example
Request
Response
eth_gasPrice
Returns the current price per gas in wei.
Parameters
None
Returns
Quantity
- integer of the current gas price in wei.
Example
Request
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.
Parameters
Object
- Transaction object wherefrom
field is optional andnonce
field is ommited.Quantity
orTag
- (optional) Integer block number, or the string'latest'
,'earliest'
or'pending'
, see the eth_getBlockByNumber.
Returns
Quantity
- The amount of gas used.
Example
Request
Response
eth_getBlockByNumber
Returns information about a block by block number.
Parameters
Quantity
orTag
- integer of a block number, or the string'earliest'
,'latest'
or'pending'
.Quantity
/Integer
- an integer block number;String "earliest"
- for the earliest/genesis block;String "latest"
- for the latest mined block;String "pending"
- for the pending state/transactions.
Boolean
- Iftrue
it returns the full transaction objects, iffalse
only the hashes of the transactions.
Returns
Object
- A block object, ornull
when no block was found.number
:Quantity
- The block number.null
when its pending blockhash
:Hash
- 32 Bytes - hash of the block.parentHash
:Hash
- 32 Bytes - hash of the parent blocknonce
:Data
-null
.extraData
:Data
- 0x00gasLimit
:Quantity
- the maximum gas allowed in this blockminGasPrice
:Quantity
- the minimum gas price allowed in this blockgasUsed
:Quantity
- the total used gas by all transactions in this blocktimestamp
:Quantity
- the unix timestamp for when the block was collatedtransactions
:Array
- Array of transaction objects, or 32 Bytes transaction hashes depending on the last given parameter
Example
Request
Response
eth_getBlockTransactionCountByHash
Returns the number of transactions in a block from a block matching the given block hash.
Parameters
Hash
- 32 Bytes - hash of a block.
Returns
Quantity
- integer of the number of transactions in this block.
Example
Request
Response
eth_getBlockTransactionCountByNumber
Returns the number of transactions in a block from a block matching the given block number.
Parameters
Quantity
orTag
- integer of a block number, or the string'earliest'
,'latest'
or'pending'
, see the eth_getBlockByNumber..
Returns
Quantity
- integer of the number of transactions in this block.
Example
Request
Response
eth_sendRawTransaction
Creates new message call transaction or a contract creation for signed transactions.
Parameters
Data
- The signed transaction data.
Returns
Hash
- 32 Bytes - the transaction hash, or the zero hash if the transaction is not yet available
Use eth_getTransactionReceipt to get the contract address, after the transaction was mined, when you created a contract.
Example
Request
Response
eth_sendTransaction
Creates new message call transaction or a contract creation, if the data field contains code.
Parameters
Object
- Transaction object.from
:Address
- 20 Bytes - The address the transaction is sent from.to
:Address
- (optional when creating new contract) 20 Bytes - The address the transaction is directed to.gas
:Quantity
- (optional) Integer of the gas provided for the transaction execution. eth_call consumes zero gas, but this parameter may be needed by some executions.gasPrice
:Quantity
- (optional) Integer of the gas price used for each paid gas.value
:Quantity
- (optional) Integer of the value sent with this transaction.data
:Data
- (optional) 4 byte hash of the method signature followed by encoded parameters. For details see Ethereum Contract ABI.nonce
:Quantity
- (optional) Integer of a nonce. This allows you to overwrite your own pending transactions that use the same nonce
Returns
Hash
- 32 Bytes - the transaction hash, or the zero hash if the transaction is not yet available.
Use eth_getTransactionReceipt to get the contract address, after the transaction was mined, when you created a contract.
Example
Request
Response
eth_call
Executes a new message call immediately without creating a transaction on the block chain.
Parameters
Object
- Transaction object wherefrom
field is optional andnonce
field is ommited.Quantity
orTag
- (optional) Integer block number, or the string'latest'
,'earliest'
or'pending'
, see the eth_getBlockByNumber.
Returns
Data
- the return value of executed contract.
Example
Request
Response
net_version
Returns the current network protocol version.
Parameters
None
Returns
String
- The current network protocol version
Example
Request
Response
net_listening
Returns true
if client is actively listening for network connections.
Parameters
None
Returns
Boolean
-true
when listening, otherwisefalse
.
Example
Request
Response
net_peerCount
Returns number of peers currently connected to the client.
Parameters
None
Returns
Quantity
- Integer of the number of connected peers
Example
Request
Response
eth_protocolVersion
Returns the current protocol version.
Parameters
None
Returns
String
- The current protocol version.
Example
Request
Response
eth_syncing
Returns an object with data about the sync status or false
.
Parameters
None
Returns
Object
- An object with sync status data orFALSE
, when not syncing.startingBlock
:Quantity
- The block at which the import started (will only be reset, after the sync reached this head)currentBlock
:Quantity
- The current block, same as eth_blockNumberhighestBlock
:Quantity
- The estimated highest block
Example
Request
Response
eth_getLogs
Returns an array of all logs matching a given filter object.
Parameters
Object
- The filter options:fromBlock
:Quantity
orTag
- (optional) (default:latest
) Integer block number, or'latest'
for the last mined block or'pending'
,'earliest'
for not yet mined transactions.toBlock
:Quantity
orTag
- (optional) (default:latest
) Integer block number, or'latest'
for the last mined block or'pending'
,'earliest'
for not yet mined transactions.address
:Address
- (optional) 20 Bytes - Contract address or a list of addresses from which logs should originate.topics
:Array
- (optional) Array of 32 BytesData
topics. Topics are order-dependent. It’s possible to pass innull
to match any topic, or a subarray of multiple topics of which one should be matching.limit
:Quantity
- (optional) The maximum number of entries to retrieve (latest first).
Returns
Array
- Array of log objects, or an empty array if nothing has changed since last poll.
Example
Request
Response
eth_getCode
Returns code at a given address.
Parameters
Address
- 20 Bytes - address.Quantity
orTag
- integer block number, or the string'latest'
,'earliest'
or'pending'
, see the eth_getBlockByNumber.
Returns
Data
- the code from the given address.
Example
Request
Response
eth_getStorageAt
Returns the value from a storage position at a given address.
Parameters
Address
- 20 Bytes - address of the storage.Quantity
- integer of the position in the storage.Quantity
orTag
- (optional) integer block number, or the string'latest'
,'earliest'
or'pending'
, see the eth_getBlockByNumber.
Returns
Data
- the value at this storage position.
Example
Request
Response
eth_getTransactionByHash
Returns the information about a transaction requested by transaction hash.
Parameters
Hash
- 32 Bytes - hash of a transaction.
Returns
Object
- Transaction Response Object, ornull
when no transaction was found.hash
:Hash
- 32 Bytes - hash of the transaction.nonce
:Quantity
- the number of transactions made by the sender prior to this one.blockHash
:Hash
- 32 Bytes - hash of the block where this transaction was in.null
when its pending.blockNumber
:Quantity
orTag
- block number where this transaction was in.null
when its pending.transactionIndex
:Quantity
- integer of the transactions index position in the block.null
when its pending.from
:Address
- 20 Bytes - address of the sender.to
:Address
- 20 Bytes - address of the receiver.null
when its a contract creation transaction.value
:Quantity
- value transferred in Wei.gasPrice
:Quantity
- gas price provided by the sender in Wei.gas
:Quantity
- gas provided by the sender.input
:Data
- the data send along with the transaction.v
:Quantity
- the standardised V field of the signature.r
:Quantity
- the R field of the signature.s
:Signature
- the signature of the transaction.
Example
Request
Response
eth_getTransactionByBlockHashAndIndex
Returns information about a transaction by block hash and transaction index position.
Parameters
Hash
- hash of a block.Quantity
- integer of the transaction index position.
Returns
Object
- Transaction Response Object, ornull
when no transaction
Example
Request
Response
eth_getTransactionByBlockNumberAndIndex
Returns information about a transaction by block number and transaction index position.
Parameters
Quantity
orTag
- a block number, or the string'earliest'
,'latest'
or'pending'
, see the eth_getBlockByNumber.Quantity
- The transaction index position.
Returns
Object
- Transaction Response Object, ornull
when no transaction
Example
Request
Response
eth_getTransactionReceipt
Returns the receipt of a transaction by transaction hash.
Parameters
Hash
- hash of a transaction.
Returns
Object
- Receipt objectblockHash
:Hash
- 32 Bytes - hash of the block this transaction was in.blockNumber
:Quantity
orTag
- block number this transaction was in.contractAddress
:Address
- 20 Bytes - The contract address created, if the transaction was a contract creation, otherwisenull
.cumulativeGasUsed
:Quantity
- The total amount of gas used when this transaction was executed in the block.from
:Address
- 20 Bytes - The address of the sender.to
:Address
- 20 Bytes - The address of the receiver.null
when it’s a contract creation transaction.gasUsed
:Quantity
- The amount of gas used by this specific transaction alone.logs
:Array
- Array of log objects, which this transaction generated.logsBloom
:Hash
- 256 Bytes - A bloom filter of logs/events generated by contracts during transaction execution. Used to efficiently rule out transactions without expected logs.status
:Quantity
-0x0
indicates transaction failure ,0x1
indicates transaction success. Set for blocks mined after Byzantium hard fork EIP609,null
before.transactionHash
:Hash
- 32 Bytes - hash of the transaction.transactionIndex
:Quantity
- Integer of the transaction’s index position in the block.
Example
Request
Response
eth_getBalance
Returns the balance of the account of given address.
Parameters
Address
- 20 Bytes - address to check for balance.Quantity
orTag
- (optional) integer block number, or the string'latest'
,'earliest'
or'pending'
, see the eth_getBlockByNumber.
Returns
Quantity
- integer of the current balance in wei.
Example
Request
Response
eth_getBlockByHash
Returns information about a block by hash.
Parameters
Hash
- Hash of a block.Boolean
- Iftrue
it returns the full transaction objects, iffalse
only the hashes of the transactions.
Returns
Object
- A block object, ornull
when no block was found.
Example
Request
Response
eth_accounts
Returns a list of addresses owned by client.
Parameters
None
Returns
Array
- 20 Bytes - addresses owned by the client.
Example
Request
Response
eth_sign
The sign method calculates an Ethereum specific signature with: sign(keccak256("Ethereum Signed Message: " + len(message) + message)))
.
Parameters
Address
- 20 Bytes - address.Data
- Data which hash to sign.
Returns
Data
- Signed data.
Example
Request
Response
eth_signTransaction
Signs transactions without dispatching it to the network. It can be later submitted using eth_sendRawTransaction.
Parameters
Object
- Transaction object.
Returns
Object
- Signed transaction and it’s details:raw
:Data
- The signed, RLP encoded transaction.tx
:Object
- Transaction Response Object
Example
Request
Response
personal_importRawKey
Imports the given unencrypted private key (hex string) into the key store, encrypting it with the passphrase.
Parameters
Private Key - 32 Bytes - The private key of the account to import
Passphrase - String - The Password for the account
Returns
Address - 20 Bytes - The imported account
Example
Request
Response
personal_listAccounts
Lists all stored accounts.
Parameters
None
Returns
Array
- A list of 20 byte account identifiers.
Example
Request
Response
personal_lockAccount
Removes the private key with given address from memory. The account can no longer be used to send transactions.
Parameters
Address
- 20 Bytes - The address of the account to lock
Returns
Result - Boolean - true: account is locked
personal_newAccount
Creates new account.
Note: it becomes the new current unlocked account. There can only be one unlocked account at a time.
Parameters
String
- Password for the new account.
Returns
Address
- 20 Bytes - The identifier of the new account.
Example
Request
Response
personal_unlockAccount
Decrypts the key with the given address from the key store. The unencrypted key will be held in memory until the unlock duration expires.
Parameters
Address
- 20 Bytes - The address of the account to unlockPassphrase - String - The password to unlock the account
Returns
Result - Boolean - true: account is unlocked
personal_sendTransaction
Sends transaction and signs it in a single call. The account does not need to be unlocked to make this call, and will not be left unlocked after.
Parameters
Object
- The transaction objectfrom
:Address
- 20 Bytes - The address the transaction is send from.to
:Address
- (optional) 20 Bytes - The address the transaction is directed to.gas
:Quantity
- (optional) Integer of the gas provided for the transaction execution. eth_call consumes zero gas, but this parameter may be needed by some executions.gasPrice
:Quantity
- (optional) Integer of the gas price used for each paid gas.value
:Quantity
- (optional) Integer of the value sent with this transaction.data
:Data
- (optional) 4 byte hash of the method signature followed by encoded parameters. For details see Ethereum Contract ABI.nonce
:Quantity
- (optional) Integer of a nonce. This allows to overwrite your own pending transactions that use the same nonce.
String
- Passphrase to unlock thefrom
account.
Returns
Data
- 32 Bytes - the transaction hash, or the zero hash if the transaction is not yet available
Example
Request
Response
personal_sign
Calculates an Ethereum specific signature with: sign(keccak256("Ethereum Signed Message: " + len(message) + message)))
.
Parameters
Data
- The data to signAddress
- 20 Bytes - The address of the account to sign withString
- Passphrase to unlock thefrom
account.
Returns
Data
- Signed data.
Example
Request
Response
personal_ecRecover
Returns the address associated with the private key that was used to calculate the signature in personal_sign
.
Parameters
Data
- The data which hash was signed.Data
- Signed data.
Returns
Address
- Address of the signer of the message.
Example
Request
Response
Last updated