0G — Methods (3/3)
API reference for 0G. All methods ->
eth_getTransactionReceipt
Returns the receipt of a transaction by transaction hash.
The receipt is not available for pending transactions.
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 hash of the transaction.
Returns
-
object: a transaction receipt object, or null when no receipt was found:-
transactionHash(string; data, 32 bytes): a hash of the transaction. -
transactionIndex(string; quantity): the transactions index position in the block. -
blockHash(string; data, 32 bytes): a hash of the block containing the transaction. -
blockNumber(string; quantity): a number of the block containing the transaction. -
from(string; data, 20 bytes): an address of the sender. -
to(string; data, 20 bytes): an address of the receiver; null when it's a contract creation transaction. -
cumulativeGasUsed(string; quantity): the total amount of gas used when this transaction was executed in the block. -
effectiveGasPrice(string; quantity): the sum of the base fee and tip paid per unit of gas. -
gasUsed(string; quantity): the amount of gas used by this specific transaction alone. -
contractAddress(string; data, 20 bytes): the contract address created, if the transaction was a contract creation, otherwise null. -
logs(array): an array of log objects, which this transaction generated. -
logsBloom(string; data, 256 bytes): a bloom filter for light clients to quickly retrieve related logs. -
type(string; data): the transaction type,0x00for legacy transactions,0x01for access list types,0x02for dynamic fees. It also returns either of the following:root(string; data, 32 bytes): a post-transaction stateroot (pre Byzantium).status(string; quantity): either 1 (success) or 0 (failure).
-
Request example
curl -X POST https://rpc.ankr.com/0g_mainnet_evm/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"method": "eth_getTransactionReceipt",
"params": [
"0xf99dfedb84d403bac4b19d0e38557deb27a92fac6dd98494220cbfd96daaf69b"
],
"id": 1
}'
Response example
{
"id": 1,
"jsonrpc": "2.0",
"result": {
"blockHash": "0x48287946c4a82f8f3fa3994f2f3e4904bd0e2803140826f245a3fde3b3533b51",
"blockNumber": "0x2b2be99",
"contractAddress": null,
"cumulativeGasUsed": "0x7fb40",
"effectiveGasPrice": "0xf32fdc00",
"from": "0xdcc747948d131c6d7e7f7589d3ab8c8bf2eb624c",
"gasUsed": "0x4c669",
"logs": [
{
"address": "0x1cd0690ff9a693f5ef2dd976660a8dafc81a109c",
"topics": [
"0xe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c",
"0x0000000000000000000000000aa145a62153190b8f0d3ca00c441e451529f755"
],
"data": "0x0000000000000000000000000000000000000000000000001a85a979b8c892ed",
"blockNumber": "0x2b2be99",
"transactionHash": "0xf99dfedb84d403bac4b19d0e38557deb27a92fac6dd98494220cbfd96daaf69b",
"transactionIndex": "0x2",
"blockHash": "0x48287946c4a82f8f3fa3994f2f3e4904bd0e2803140826f245a3fde3b3533b51",
"logIndex": "0x2",
"removed": false
},
{
"address": "0x1cd0690ff9a693f5ef2dd976660a8dafc81a109c",
"topics": [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"0x0000000000000000000000000aa145a62153190b8f0d3ca00c441e451529f755",
"0x000000000000000000000000a132f089492cce5f1d79483a9e4552f37266ed01"
],
"data": "0x0000000000000000000000000000000000000000000000001a85a979b8c892ed",
"blockNumber": "0x2b2be99",
"transactionHash": "0xf99dfedb84d403bac4b19d0e38557deb27a92fac6dd98494220cbfd96daaf69b",
"transactionIndex": "0x2",
"blockHash": "0x48287946c4a82f8f3fa3994f2f3e4904bd0e2803140826f245a3fde3b3533b51",
"logIndex": "0x3",
"removed": false
},
{
"address": "0x76159c2b43ff6f630193e37ec68452169914c1bb",
"topics": [
"0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925",
"0x000000000000000000000000dcc747948d131c6d7e7f7589d3ab8c8bf2eb624c",
"0x0000000000000000000000000aa145a62153190b8f0d3ca00c441e451529f755"
],
"data": "0x000000000000000000000000000000000000000000000373f3353f1bff880000",
"blockNumber": "0x2b2be99",
"transactionHash": "0xf99dfedb84d403bac4b19d0e38557deb27a92fac6dd98494220cbfd96daaf69b",
"transactionIndex": "0x2",
"blockHash": "0x48287946c4a82f8f3fa3994f2f3e4904bd0e2803140826f245a3fde3b3533b51",
"logIndex": "0x4",
"removed": false
},
{
"address": "0x76159c2b43ff6f630193e37ec68452169914c1bb",
"topics": [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"0x000000000000000000000000dcc747948d131c6d7e7f7589d3ab8c8bf2eb624c",
"0x000000000000000000000000f81f4a748f8d2dbca48bfa704968a76fb062a358"
],
"data": "0x00000000000000000000000000000000000000000000000a844a7424d9c80000",
"blockNumber": "0x2b2be99",
"transactionHash": "0xf99dfedb84d403bac4b19d0e38557deb27a92fac6dd98494220cbfd96daaf69b",
"transactionIndex": "0x2",
"blockHash": "0x48287946c4a82f8f3fa3994f2f3e4904bd0e2803140826f245a3fde3b3533b51",
"logIndex": "0x5",
"removed": false
},
{
"address": "0xf81f4a748f8d2dbca48bfa704968a76fb062a358",
"topics": [
"0x1871cdf8010e63f2eb8384381a68dfa7416dc571a5517e66e88b2d2d0c0a690a"
],
"data": "0x00000000000000000000000000000000000000000000000a844a7424d9c80000",
"blockNumber": "0x2b2be99",
"transactionHash": "0xf99dfedb84d403bac4b19d0e38557deb27a92fac6dd98494220cbfd96daaf69b",
"transactionIndex": "0x2",
"blockHash": "0x48287946c4a82f8f3fa3994f2f3e4904bd0e2803140826f245a3fde3b3533b51",
"logIndex": "0x6",
"removed": false
},
{
"address": "0x76159c2b43ff6f630193e37ec68452169914c1bb",
"topics": [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"0x000000000000000000000000f81f4a748f8d2dbca48bfa704968a76fb062a358",
"0x0000000000000000000000000000000000000000000000000000000000000000"
],
"data": "0x00000000000000000000000000000000000000000000000a844a7424d9c80000",
"blockNumber": "0x2b2be99",
"transactionHash": "0xf99dfedb84d403bac4b19d0e38557deb27a92fac6dd98494220cbfd96daaf69b",
"transactionIndex": "0x2",
"blockHash": "0x48287946c4a82f8f3fa3994f2f3e4904bd0e2803140826f245a3fde3b3533b51",
"logIndex": "0x7",
"removed": false
},
{
"address": "0xf81f4a748f8d2dbca48bfa704968a76fb062a358",
"topics": [
"0x696de425f79f4a40bc6d2122ca50507f0efbeabbff86a84871b7196ab8ea8df7",
"0x000000000000000000000000a132f089492cce5f1d79483a9e4552f37266ed01"
],
"data": "0x00000000000000000000000000000000000000000000000a844a7424d9c80000",
"blockNumber": "0x2b2be99",
"transactionHash": "0xf99dfedb84d403bac4b19d0e38557deb27a92fac6dd98494220cbfd96daaf69b",
"transactionIndex": "0x2",
"blockHash": "0x48287946c4a82f8f3fa3994f2f3e4904bd0e2803140826f245a3fde3b3533b51",
"logIndex": "0x8",
"removed": false
},
{
"address": "0xa132f089492cce5f1d79483a9e4552f37266ed01",
"topics": [
"0x192442a2b2adb6a7948f097023cb6b57d29d3a7a5dd33e6666d33c39cc456f32",
"0x00000000000000000000000000000000000000000000000045849994fc9c7b15",
"0x00000000000000000000000000000000000000000000000000000000000009e7"
],
"data": "0x0000000000000000000000000000000000000000000000000000000000000020bf3a35778fe127176ad6069c3efcbdf04b5516fb1aadf4eacde298dda04175370000000000000000000000000000000000000000000000003d6d8f0fa1b00ccc00000000000000000000000000000000000000000000000045849994fc9c7b1500000000000000000000000000000000000000000000000000000000000009e7000000000000000000000000000000000000000000000000000000000000000000000000000000...",
"blockNumber": "0x2b2be99",
"transactionHash": "0xf99dfedb84d403bac4b19d0e38557deb27a92fac6dd98494220cbfd96daaf69b",
"transactionIndex": "0x2",
"blockHash": "0x48287946c4a82f8f3fa3994f2f3e4904bd0e2803140826f245a3fde3b3533b51",
"logIndex": "0x9",
"removed": false
}
],
"logsBloom": "0x01000000000000000000000020000004000000000000008000000200000000000000000000000000002000800000000000000000000000000000000000200000000000008000020000100008400040000000051000000000000000008000000000200000060000000000104000000802040000000000000000020010000000000000000000100020000010000000400400000001000002000000000000002000020020000000000020000000000000000000200000000000000000000000000000000002080000...",
"status": "0x1",
"to": "0x0aa145a62153190b8f0d3ca00c441e451529f755",
"transactionHash": "0xf99dfedb84d403bac4b19d0e38557deb27a92fac6dd98494220cbfd96daaf69b",
"transactionIndex": "0x2",
"type": "0x0"
}
}
eth_getUncleByBlockHashAndIndex
Returns information about an uncle of a block by hash and uncle 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): the hash of a block.<string>(quantity): the uncle's index position.
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/0g_mainnet_evm/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"method": "eth_getUncleByBlockHashAndIndex",
"params": [
"0x48287946c4a82f8f3fa3994f2f3e4904bd0e2803140826f245a3fde3b3533b51",
"0x0"
],
"id": 1
}'
Response example
{
"id": 1,
"jsonrpc": "2.0",
"result": null
}
eth_getUncleByBlockNumberAndIndex
Returns information about an uncle of a block by number and uncle 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): the hex value of a block number.<string>(quantity): the uncle's index position.
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/0g_mainnet_evm/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"method": "eth_getUncleByBlockNumberAndIndex",
"params": [
"0x2b2be99",
"0x0"
],
"id": 1
}'
Response example
{
"id": 1,
"jsonrpc": "2.0",
"result": null
}
eth_getLogs
Returns an array of all logs matching a given filter object.
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: the filter options:-
fromBlock(string; quantity|tag; optional; default: "latest"): either the block number or one of the following block tags:latest: for the last mined block.earliest: for the lowest numbered block available on the client.pending: for not yet mined transactions.
-
toBlock(string; quantity|tag; optional; default: "latest"): either the block number or one of the following block tags:latest: for the last mined block.earliest: for the lowest numbered block available on the client.pending: for not yet mined transactions.
-
address(array of strings; data, 20 bytes; optional): a contract address or a list of addresses from which logs should originate. -
topics(array of strings; data; optional): an array of 32 bytes data topics. Topics are order-dependent. Each topic can also be an array of data with "or" options. -
blockhash(string; data, 32 bytes; optional; future): with the addition of EIP-234,blockHashwill be a new filter option which restricts the logs returned to the single block with the 32-byte hash blockHash. Using blockHash is equivalent tofromBlock = toBlock = the blocknumber with hash blockHash. IfblockHashis present in the filter criteria, then neitherfromBlocknortoBlockare allowed.
-
-
Returns
removed(string; tag):truewhen the log was removed, due to a chain reorganization;falseif it's a valid log.logIndex(string; quantity): the log index position in the block; null when it's a pending log.transactionIndex(string; quantity): the transactions index position log was created from; null when it's a pending log.transactionHash(string; data, 32 bytes): a hash of the transactions this log was created from; null when it's a pending log.blockHash(string; data, 32 bytes): a hash of the block containing the log; null when it's pending; null when it's a pending log.blockNumber(string; quantity): the number of the block containing the log; null when it's pending; null when it's a pending log.address(string; data, 20 bytes): an address from which this log originated.data(string; data): contains one or more 32 bytes non-indexed arguments of the log.topics(array of strings; data): an array of 0 to 4 32 bytes data of indexed log arguments. (In solidity: The first topic is the hash of the signature of the event (e.g. Deposit(address,bytes32,uint256)), except you declared the event with the anonymous specifier.)
Request example
curl -X POST https://rpc.ankr.com/0g_mainnet_evm/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"method": "eth_getLogs",
"params": [
{
"fromBlock": "0x2b2be99",
"toBlock": "0x2b2be99",
"address": "0x1cd0690ff9a693f5ef2dd976660a8dafc81a109c"
}
],
"id": 1
}'
Response example
{
"id": 1,
"jsonrpc": "2.0",
"result": [
{
"address": "0x1cd0690ff9a693f5ef2dd976660a8dafc81a109c",
"topics": [
"0xe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c",
"0x0000000000000000000000000aa145a62153190b8f0d3ca00c441e451529f755"
],
"data": "0x0000000000000000000000000000000000000000000000001a85a979b8c892ed",
"blockNumber": "0x2b2be99",
"transactionHash": "0xf99dfedb84d403bac4b19d0e38557deb27a92fac6dd98494220cbfd96daaf69b",
"transactionIndex": "0x2",
"blockHash": "0x48287946c4a82f8f3fa3994f2f3e4904bd0e2803140826f245a3fde3b3533b51",
"logIndex": "0x2",
"removed": false
},
{
"address": "0x1cd0690ff9a693f5ef2dd976660a8dafc81a109c",
"topics": [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"0x0000000000000000000000000aa145a62153190b8f0d3ca00c441e451529f755",
"0x000000000000000000000000a132f089492cce5f1d79483a9e4552f37266ed01"
],
"data": "0x0000000000000000000000000000000000000000000000001a85a979b8c892ed",
"blockNumber": "0x2b2be99",
"transactionHash": "0xf99dfedb84d403bac4b19d0e38557deb27a92fac6dd98494220cbfd96daaf69b",
"transactionIndex": "0x2",
"blockHash": "0x48287946c4a82f8f3fa3994f2f3e4904bd0e2803140826f245a3fde3b3533b51",
"logIndex": "0x3",
"removed": false
}
]
}