Swell — web3, net, eth (2/3)
API reference for Swell. All methods ->
eth_estimateGas
Generates and returns an estimate of how much gas is necessary to allow the transaction to complete.
The transaction will not be added to the blockchain. Note that the estimate may be significantly more than the amount of gas actually used by the transaction, for a variety of reasons including EVM mechanics and node performance.
Parameters
-
id(integer; required): a request ID (example: 1). -
jsonrpc(string; required): a JSON RPC spec used (example: 2.0). -
method(string; required): a method used for the request. -
params(array; required):-
<object>(hex encoded): the transaction object:from(string; data, 20 bytes; optional): the address the transaction is sent from.to(string; data, 20 bytes; optional): the address the transaction is directed to.gas(string; quantity; optional): the gas provided for the transaction execution.eth_callconsumes zero gas, but this parameter may be needed by some executions.gasPrice(string; quantity; optional): the gas price willing to be paid by the sender in wei.value(string; quantity; optional): the value sent with this transaction, in wei.data(string; data; optional): the hash of the method signature and encoded parameters.
-
<string>(quantity|tag; optional): either a HEX value of a block number or one of the following block tags:earliest: the lowest numbered block available on the client.finalized: the most recent crypto-economically secure block; cannot be re-orged outside of manual intervention driven by community coordination.safe: the most recent block that is safe from re-orgs under honest majority and certain synchronicity assumptions.latest: the most recent block in the canonical chain observed by the client; this block can be re-orged out of the canonical chain even under healthy/normal conditions.pending: a sample next block built by the client on top of thelatestand containing the set of transactions usually taken from local mempool. In other words, it is the block that has not been mined yet.
-
Returns
<string>(quantity): the amount of gas used.
Request example
curl -X POST https://rpc.ankr.com/swell/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"method": "eth_estimateGas",
"params": [
{
"to": "0x1234567890abcdef1234567890abcdef12345678",
"data": "0x70a08231000000000000000000000000abcdefabcdefabcdefabcdefabcdefabcd",
"value": "0x0"
}
],
"id": 1
}'
Response example
{
"jsonrpc": "2.0",
"id": 1,
"result": "0x542e"
}
eth_getBlockByHash
Returns information for the block specified by block hash.
Parameters
-
id(integer; required): a request ID (example: 1). -
jsonrpc(string; required): a JSON RPC spec used (example: 2.0). -
method(string; required): a method used for the request. -
params(array; required):<string>(data, 32 bytes): the block hash.<boolean>: iftrueit returns the full transaction objects, iffalse— only the hashes of the transactions.
Returns
<object>: a block object, or null when no block was found:number(string; quantity): the block number; null when it's a pending block.hash(string; data, 32 bytes): the hash of the block; null when it's a pending block.parentHash(string; data, 32 bytes): the hash of the parent block.nonce(string; data, 8 bytes): the hash of the generated proof-of-work; null when it's a pending block.sha3Uncles(string; data, 32 bytes): SHA3 of the uncles data in the block.logsBloom(string; data, 256 bytes): the bloom filter for the logs of the block. null when its pending block.transactionsRoot(string; data, 32 bytes): the root of the transaction trie of the block.stateRoot(string; data, 32 bytes): the root of the final state trie of the block.receiptsRoot(string; data, 32 bytes): the root of the receipts trie of the block.miner(string; data, 20 bytes): the address of the beneficiary to whom the mining rewards were given.difficulty(string; quantity): the difficulty for this block.totalDifficulty(string; quantity): the total difficulty of the chain until this block.extraData(string; data): the extra data field of this block.size(string; quantity): the size of this block in bytes.gasLimit(string; quantity): the maximum gas allowed in this block.gasUsed(string; quantity): the total used gas by all transactions in this block.timestamp(string; quantity): the unix timestamp for when the block was collated.transactions(array of strings): an array of transaction objects, or 32 bytes transaction hashes depending on the last given parameter.uncles(array of strings): an array of uncle hashes.
Request example
curl -X POST https://rpc.ankr.com/swell/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"method": "eth_getBlockByHash",
"params": ["0x769826b11c626e76e7a0ec7a3291a84ae1aedad7cd3c15f77457883c037b3586", false],
"id": 1
}'
Response example
{
"id": 1,
"jsonrpc": "2.0",
"result": {
"baseFeePerGas": "0xfb",
"blobGasUsed": "0x0",
"difficulty": "0x0",
"excessBlobGas": "0x0",
"extraData": "0x",
"gasLimit": "0x3938700",
"gasUsed": "0xabae",
"hash": "0x769826b11c626e76e7a0ec7a3291a84ae1aedad7cd3c15f77457883c037b3586",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"miner": "0x4200000000000000000000000000000000000011",
"mixHash": "0x9e9afe7303914b5bc097077e2be0857eab4216b64e6352f251125496749035df",
"nonce": "0x0000000000000000",
"number": "0x35f23",
"parentBeaconBlockRoot": "0x7b06539c54dbd61653356c4d6c08fb3607d0449e98b72ff89d76b160f27f591c",
"parentHash": "0xf10fa814903d0ef7228bfbcdccc96b0d525a86572ee8e6b2a38828cfed1f5c18",
"receiptsRoot": "0x6d924b9af9cfeceb2e50af1eba38429fe3b70dc2760a40f0f5c394edca8bd9e2",
"sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
"size": "0x347",
"stateRoot": "0x634f29146c0fa964f512dc8f758dad1465f4897fee65f441e8c845b2ecedd2ae",
"timestamp": "0x674d98c5",
"transactions": [
"0xde6075fc8e8ce8bde41e8912de54be564e4cce7aec4cda4a985a10b4fb5f975c"
],
"transactionsRoot": "0xa4e1a0b5ab0573b3b7225bb8048b36586710707f7071b5538ae3478774bdaee4",
"uncles": [],
"withdrawals": [],
"withdrawalsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"
}
}
eth_getBlockByNumber
Returns information for the block specified by block number.
Parameters
-
id(integer; required): a request ID (example: 1). -
jsonrpc(string; required): a JSON RPC spec used (example: 2.0). -
method(string; required): a method used for the request. -
params(array; required):<string>(quantity|tag): either the hex value of a block number or one of the following block tags:earliest: the lowest numbered block available on the client.finalized: the most recent crypto-economically secure block; cannot be re-orged outside of manual intervention driven by community coordination.safe: the most recent block that is safe from re-orgs under honest majority and certain synchronicity assumptions.latest: the most recent block in the canonical chain observed by the client; this block can be re-orged out of the canonical chain even under healthy/normal conditions.pending: a sample next block built by the client on top of thelatestand containing the set of transactions usually taken from local mempool. In other words, it is the block that has not been mined yet.
<boolean>: iftrueit returns the full transaction objects, iffalse— only the hashes of the transactions.
Returns
<object>: a block object, or null when no block was found:number(string; quantity): the block number; null when it's a pending block.hash(string; data, 32 bytes): the hash of the block; null when it's a pending block.parentHash(string; data, 32 bytes): the hash of the parent block.nonce(string; data, 8 bytes): the hash of the generated proof-of-work; null when it's a pending block.sha3Uncles(string; data, 32 bytes): SHA3 of the uncles data in the block.logsBloom(string; data, 256 bytes): the bloom filter for the logs of the block. null when its pending block.transactionsRoot(string; data, 32 bytes): the root of the transaction trie of the block.stateRoot(string; data, 32 bytes): the root of the final state trie of the block.receiptsRoot(string; data, 32 bytes): the root of the receipts trie of the block.miner(string; data, 20 bytes): the address of the beneficiary to whom the mining rewards were given.difficulty(string; quantity): the difficulty for this block.totalDifficulty(string; quantity): the total difficulty of the chain until this block.extraData(string; data): the extra data field of this block.size(string; quantity): the size of this block in bytes.gasLimit(string; quantity): the maximum gas allowed in this block.gasUsed(string; quantity): the total used gas by all transactions in this block.timestamp(string; quantity): the unix timestamp for when the block was collated.transactions(array of strings): an array of transaction objects, or 32 bytes transaction hashes depending on the last given parameter.uncles(array of strings): an array of uncle hashes.
Request example
curl -X POST https://rpc.ankr.com/swell/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"method": "eth_getBlockByNumber",
"params": ["latest", true],
"id": 1
}'
Response example
{
"id": 1,
"jsonrpc": "2.0",
"result": {
"baseFeePerGas": "0xfb",
"blobGasUsed": "0x0",
"difficulty": "0x0",
"excessBlobGas": "0x0",
"extraData": "0x",
"gasLimit": "0x3938700",
"gasUsed": "0xaba2",
"hash": "0x2b20a26bb658529221dfb50ebffe41b2b1f4ff39f05edf539cac01783cc20d5f",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"miner": "0x4200000000000000000000000000000000000011",
"mixHash": "0xb3e0c9c39af6f6dfe601cd9b8572cd0e35938a36829e2fad16693afb24ac8fe4",
"nonce": "0x0000000000000000",
"number": "0x36153",
"parentBeaconBlockRoot": "0x74b8d4358ebe4ec4ff1b2f55955b4fa49df3416561f9a1f7d18a4188bfb98a46",
"parentHash": "0x6da3ab14e60e6b7a6877fb4ce9c280f246d0362d7b9fcf4d90d84b315eb34340",
"receiptsRoot": "0xeb7140663802eceb3b94ca80013b126215cbadda40021996755ea8a3161bb34d",
"sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
"size": "0x347",
"stateRoot": "0x3de5e46eb5d377cc5728d079cbc3139f8496d371e6575810dd0cc13dbba2778b",
"timestamp": "0x674d9d25",
"transactions": [
{
"blockHash": "0x2b20a26bb658529221dfb50ebffe41b2b1f4ff39f05edf539cac01783cc20d5f",
"blockNumber": "0x36153",
"from": "0xdeaddeaddeaddeaddeaddeaddeaddeaddead0001",
"gas": "0xf4240",
"gasPrice": "0x0",
"hash": "0x78470f5ee366204f270ea885a75766bb2052b63ac85a25cd5b877e7860d465d0",
"input": "0x440a5e2000000558000c5fc5000000000000000300000000674d9c5f0000000001453c150000000000000000000000000000000000000000000000000000000278f1173200000000000000000000000000000000000000000000000000000002325f0a24d25206ae1e32bf7993f8ade201b44bddb9543cca013e9deaaba9562a6d3dae00000000000000000000000000f854cd5b26bfd73d51236c0122798907ed65b1f2",
"nonce": "0x36152",
"to": "0x4200000000000000000000000000000000000015",
"transactionIndex": "0x0",
"value": "0x0",
"type": "0x7e",
"v": "0x0",
"r": "0x0",
"s": "0x0",
"sourceHash": "0xbdae1a568841db7c8938d4c3bacb6a9e5065caf68c889d0d0831531b0d50f9b4",
"mint": "0x0",
"depositReceiptVersion": "0x1"
}
],
"transactionsRoot": "0xf09a2a740879a46d38a610333ec9f7d32ad4aa6c62b04bb8bd7300a2669765e7",
"uncles": [],
"withdrawals": [],
"withdrawalsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"
}
}
eth_getTransactionByHash
Returns information on a transaction specified by transaction hash.
Parameters
-
id(integer; required): a request ID (example: 1). -
jsonrpc(string; required): a JSON RPC spec used (example: 2.0). -
method(string; required): a method used for the request. -
params(array; required):<string>(data, 32 bytes): a transaction hash.
Returns
blockHash(string; data, 32 bytes): a hash of the block containing the transaction; null when it's pending.blockNumber(string; quantity): a number of the block containing the transaction; null when it's pending.from(string; data, 20 bytes): an address of the sender.gas(string; quantity): the gas provided by the sender.gasPrice(string; quantity): the gas price provided by the sender in wei.hash(string; data, 32 bytes): the hash of the transaction.input(string; data): the data send along with the transaction.nonce(string; quantity): the number of transactions made by the sender prior to this one.to(string: data, 20 bytes): an address of the receiver: null when it's a contract creation transaction.transactionIndex(string; quantity): the transaction index position in the block; null when it's pending.value(string; quantity): the value transferred in wei.v(string; quantity): ECDSA recovery ID.r(string; quantity): ECDSA signature r.s(string; quantity): ECDSA signature s.
Request example
curl -X POST https://rpc.ankr.com/swell/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"method": "eth_getTransactionByHash",
"params": ["0xde6075fc8e8ce8bde41e8912de54be564e4cce7aec4cda4a985a10b4fb5f975c"],
"id": 1
}'
Response example
{
"id": 1,
"jsonrpc": "2.0",
"result": {
"blockHash": "0x769826b11c626e76e7a0ec7a3291a84ae1aedad7cd3c15f77457883c037b3586",
"blockNumber": "0x35f23",
"from": "0xdeaddeaddeaddeaddeaddeaddeaddeaddead0001",
"gas": "0xf4240",
"gasPrice": "0x0",
"hash": "0xde6075fc8e8ce8bde41e8912de54be564e4cce7aec4cda4a985a10b4fb5f975c",
"input": "0x440a5e2000000558000c5fc5000000000000000100000000674d98030000000001453bba00000000000000000000000000000000000000000000000000000003ef584454000000000000000000000000000000000000000000000000000000018af8a63999c6722a30f5a0cdd7622716d9d815c1dbac2983a989b8f8538de98f0b496676000000000000000000000000f854cd5b26bfd73d51236c0122798907ed65b1f2",
"nonce": "0x35f22",
"to": "0x4200000000000000000000000000000000000015",
"transactionIndex": "0x0",
"value": "0x0",
"type": "0x7e",
"v": "0x0",
"r": "0x0",
"s": "0x0",
"sourceHash": "0x57913ce50e6f4dca31cf61369737e6d13271fc8d50fdf74e542437a16e1b8883",
"mint": "0x0",
"depositReceiptVersion": "0x1"
}
}
eth_getTransactionByBlockHashAndIndex
Returns information on a transaction specified by block hash and transaction index position.
Parameters
-
id(integer; required): a request ID (example: 1). -
jsonrpc(string; required): a JSON RPC spec used (example: 2.0). -
method(string; required): a method used for the request. -
params(array; required):<string>(data, 32 bytes): a block hash.<string>(quantity): a transaction index position.
Returns
blockHash(string; data, 32 bytes): a hash of the block containing the transaction; null when it's pending.blockNumber(string; quantity): a number of the block containing the transaction; null when it's pending.from(string; data, 20 bytes): an address of the sender.gas(string; quantity): the gas provided by the sender.gasPrice(string; quantity): the gas price provided by the sender in wei.hash(string; data, 32 bytes): the hash of the transaction.input(string; data): the data send along with the transaction.nonce(string; quantity): the number of transactions made by the sender prior to this one.to(string: data, 20 bytes): an address of the receiver: null when it's a contract creation transaction.transactionIndex(string; quantity): the transaction index position in the block; null when it's pending.value(string; quantity): the value transferred in wei.v(string; quantity): ECDSA recovery ID.r(string; quantity): ECDSA signature r.s(string; quantity): ECDSA signature s.
Request example
curl -X POST https://rpc.ankr.com/swell/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"method": "eth_getTransactionByBlockHashAndIndex",
"params": ["0x769826b11c626e76e7a0ec7a3291a84ae1aedad7cd3c15f77457883c037b3586", "0x0"],
"id": 1
}'
Response example
{
"id": 1,
"jsonrpc": "2.0",
"result": {
"blockHash": "0x769826b11c626e76e7a0ec7a3291a84ae1aedad7cd3c15f77457883c037b3586",
"blockNumber": "0x35f23",
"from": "0xdeaddeaddeaddeaddeaddeaddeaddeaddead0001",
"gas": "0xf4240",
"gasPrice": "0x0",
"hash": "0xde6075fc8e8ce8bde41e8912de54be564e4cce7aec4cda4a985a10b4fb5f975c",
"input": "0x440a5e2000000558000c5fc5000000000000000100000000674d98030000000001453bba00000000000000000000000000000000000000000000000000000003ef584454000000000000000000000000000000000000000000000000000000018af8a63999c6722a30f5a0cdd7622716d9d815c1dbac2983a989b8f8538de98f0b496676000000000000000000000000f854cd5b26bfd73d51236c0122798907ed65b1f2",
"nonce": "0x35f22",
"to": "0x4200000000000000000000000000000000000015",
"transactionIndex": "0x0",
"value": "0x0",
"type": "0x7e",
"v": "0x0",
"r": "0x0",
"s": "0x0",
"sourceHash": "0x57913ce50e6f4dca31cf61369737e6d13271fc8d50fdf74e542437a16e1b8883",
"mint": "0x0",
"depositReceiptVersion": "0x1"
}
}
eth_getTransactionByBlockNumberAndIndex
Returns information on a transaction by block number and transaction index position.
Parameters
-
id(integer; required): a request ID (example: 1). -
jsonrpc(string; required): a JSON RPC spec used (example: 2.0). -
method(string; required): a method used for the request. -
params(array; required):<string>(quantity|tag): either the hex value of a block number or one of the following block tags:earliest: the lowest numbered block available on the client.finalized: the most recent crypto-economically secure block; cannot be re-orged outside of manual intervention driven by community coordination.safe: the most recent block that is safe from re-orgs under honest majority and certain synchronicity assumptions.latest: the most recent block in the canonical chain observed by the client; this block can be re-orged out of the canonical chain even under healthy/normal conditions.pending: a sample next block built by the client on top of thelatestand containing the set of transactions usually taken from local mempool. In other words, it is the block that has not been mined yet.
<string>(quantity): the transaction index position.
Returns
blockHash(string; data, 32 bytes): a hash of the block containing the transaction; null when it's pending.blockNumber(string; quantity): a number of the block containing the transaction; null when it's pending.from(string; data, 20 bytes): an address of the sender.gas(string; quantity): the gas provided by the sender.gasPrice(string; quantity): the gas price provided by the sender in wei.hash(string; data, 32 bytes): the hash of the transaction.input(string; data): the data send along with the transaction.nonce(string; quantity): the number of transactions made by the sender prior to this one.to(string: data, 20 bytes): an address of the receiver: null when it's a contract creation transaction.transactionIndex(string; quantity): the transaction index position in the block; null when it's pending.value(string; quantity): the value transferred in wei.v(string; quantity): ECDSA recovery ID.r(string; quantity): ECDSA signature r.s(string; quantity): ECDSA signature s.
Request example
curl -X POST https://rpc.ankr.com/swell/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"method": "eth_getTransactionByBlockNumberAndIndex",
"params": ["latest", "0x0"],
"id": 1
}'
Response example
{
"id": 1,
"jsonrpc": "2.0",
"result": {
"blockHash": "0x1b5eef1c675007f8939b68524bc6f38eb010cd2c695bdf89c1fdd72eeb0aa9c8",
"blockNumber": "0x361ab",
"from": "0xdeaddeaddeaddeaddeaddeaddeaddeaddead0001",
"gas": "0xf4240",
"gasPrice": "0x0",
"hash": "0xbbb818ceb584ce7b62b7a6c3b5d2ada60c0b49882cf5da282d87ec88fc5c0ec9",
"input": "0x440a5e2000000558000c5fc5000000000000000000000000674d9d130000000001453c24000000000000000000000000000000000000000000000000000000025de66ed500000000000000000000000000000000000000000000000000000001f3e2b33dbe5e0a51b94dcd58e0451944be920baaf602c5f2ae01e88f57d08253d9a85895000000000000000000000000f854cd5b26bfd73d51236c0122798907ed65b1f2",
"nonce": "0x361aa",
"to": "0x4200000000000000000000000000000000000015",
"transactionIndex": "0x0",
"value": "0x0",
"type": "0x7e",
"v": "0x0",
"r": "0x0",
"s": "0x0",
"sourceHash": "0x755da4065a732fd8cbf1599b00795c7ec8028bc8e2809fbcf7cee129db81da75",
"mint": "0x0",
"depositReceiptVersion": "0x1"
}
}