# Web3 API

Since the structure of transactions  on Ontology is different from those on Ethereum, Ontology currently supports the methods listed and described below.

## Method List

| Method Name                                                                                                              | Description                                                                                                 |
| ------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------- |
| [net\_version](/developer-tools/api/eth-web3-api.md#net_version)                                                         | Returns the current network ID                                                                              |
| [eth\_chainId](/developer-tools/api/eth-web3-api.md#eth_chainid)                                                         | Returns the current `chainId`                                                                               |
| [eth\_blockNumber](/developer-tools/api/eth-web3-api.md#eth_blocknumber)                                                 | Returns the number of most recent block                                                                     |
| [eth\_getBalance](/developer-tools/api/eth-web3-api.md#eth_getbalance)                                                   | Returns the balance of the account of given address                                                         |
| [eth\_protocolVersion](/developer-tools/api/eth-web3-api.md#eth_protocolversion)                                         | Returns the current Ethereum protocol version                                                               |
| [eth\_syncing](/developer-tools/api/eth-web3-api.md#eth_syncing)                                                         | Returns data about the sync status                                                                          |
| [eth\_gasPrice](/developer-tools/api/eth-web3-api.md#eth_gasprice)                                                       | Returns the current price per gas in ***wei***                                                              |
| [eth\_getStorageAt](/developer-tools/api/eth-web3-api.md#eth_getstorageat)                                               | Returns the value from a storage position at a given address                                                |
| [eth\_getTransactionCount](/developer-tools/api/eth-web3-api.md#eth_gettransactioncount)                                 | Returns the number of transactions sent from an address using Ontology EVM                                  |
| [eth\_getBlockTransactionCountByHash](/developer-tools/api/eth-web3-api.md#eth_getblocktransactioncountbyhash)           | Returns the number of transactions using Ontology EVM in a block from a block matching the given block hash |
| [eth\_getBlockTransactionCountByNumber](/developer-tools/api/eth-web3-api.md#eth_getblocktransactioncountbynumber)       | Returns the number of transactions in a block matching the given block number                               |
| [eth\_getCode](/developer-tools/api/eth-web3-api.md#eth_getcode)                                                         | Returns code at a given address                                                                             |
| [eth\_getTransactionLogs](/developer-tools/api/eth-web3-api.md#eth_gettransactionlogs)                                   | Returns transaction logs by a transaction hash                                                              |
| [eth\_sendRawTransaction](/developer-tools/api/eth-web3-api.md#eth_sendrawtransaction)                                   | Creates new message call transaction or a contract creation for signed transactions                         |
| [eth\_call](/developer-tools/api/eth-web3-api.md#eth_call)                                                               | Executes a new message call immediately without creating a transaction on the blockchain                    |
| [eth\_estimateGas](/developer-tools/api/eth-web3-api.md#eth_estimategas)                                                 | Generates and returns an estimate of gas                                                                    |
| [eth\_getBlockByNumber](/developer-tools/api/eth-web3-api.md#eth_getblockbynumber)                                       | Returns information about a block by block number                                                           |
| [eth\_getBlockByHash](/developer-tools/api/eth-web3-api.md#eth_getblockbyhash)                                           | Returns information about a block by hash                                                                   |
| [eth\_getTransactionByHash](/developer-tools/api/eth-web3-api.md#eth_gettransactionbyhash)                               | Returns information about a transaction by block hash                                                       |
| [eth\_getTransactionByBlockHashAndIndex](/developer-tools/api/eth-web3-api.md#eth_gettransactionbyblocknumberandindex)   | Returns information about a transaction by block hash and transaction index position                        |
| [eth\_getTransactionByBlockNumberAndIndex](/developer-tools/api/eth-web3-api.md#eth_gettransactionbyblocknumberandindex) | Returns information about a transaction by block number and transaction index position                      |
| [eth\_getTransactionReceipt](/developer-tools/api/eth-web3-api.md#eth_gettransactionreceipt)                             | Returns the receipt of a transaction by transaction hash                                                    |
| [eth\_pendingTransactions](/developer-tools/api/eth-web3-api.md#eth_pendingtransactions)                                 | Access all pending transactions                                                                             |
| [eth\_pendingTransactionsByHash](/developer-tools/api/eth-web3-api.md#eth_pendingtransactionsbyhash)                     | Access all pending transactions by transaction hash                                                         |

## `net_version`

Returns the current network ID.

**Parameters**

None

**Returns**

`String`- The current network ID

* **`58`** - Ontology Mainnet
* **`5851`** - Ontology Polaris Testnet
* **`12345`** - Solo node

**Sample Request**

```bash
curl -X POST http://127.0.0.1:20339 -H 'Content-Type: application/json' --data '{"jsonrpc":"2.0","method":"net_version","params":[],"id":67}'
```

**Sample Response**

```javascript
{
  "id": 67,
  "jsonrpc": "2.0",
  "result": "12345"
}
```

## `eth_chainId`

Returns the current `chainId`.

**Parameters**

None

**Returns**

`String` - the current `chainId`

**Sample Request**

```bash
curl -X POST http://127.0.0.1:20339 -H 'Content-Type: application/json' --data '{"jsonrpc":"2.0","method":"eth_chainId","params":[],"id":83}'
```

**Sample Response**

```javascript
{
  "id": 83,
  "jsonrpc": "2.0",
  "result": "12345"
}
```

## `eth_blockNumber`

Returns the number of most recent block.

**Parameters**

None

**Returns**

`QUANTITY` - integer of the current block number the client is on

**Sample Request**

```bash
curl -X POST http://127.0.0.1:20339 -H 'Content-Type: application/json' --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":83}'
```

**Sample Response**

```javascript
{
  "id":83,
  "jsonrpc": "2.0",
  "result": "0x4b7" // 1207
}
```

## `eth_getBalance`

Returns the balance of the account of given address.

**Parameters**

1. `DATA`, 20 Bytes - address to check for balance.
2. `QUANTITY|TAG` - integer block number, or the string `"latest"`, `"earliest"` or `"pending"`

```javascript
params: [
   '0x407d73d8a49eeb85d32cf465507dd71d507100c1',
   'latest'
]
```

**Returns**

`QUANTITY`- integer of the current balance in ***wei***.

**Sample Request**

```bash
curl -X POST http://127.0.0.1:20339 -H 'Content-Type: application/json' --data '{"jsonrpc":"2.0","method":"eth_getBalance","params":["0x407d73d8a49eeb85d32cf465507dd71d507100c1", "latest"],"id":1}'
```

**Sample Response**

```javascript
{
  "id":1,
  "jsonrpc": "2.0",
  "result": "0x0234c8a3397aab58" // 158972490234375000
}
```

## `eth_protocolVersion`

Returns the current Ethereum protocol version.

**Parameters**

None

**Returns**

`String` - The current Ethereum protocol version

**Sample Request**

```bash
curl -X POST http://127.0.0.1:20339 -H 'Content-Type: application/json' --data '{"jsonrpc":"2.0","method":"eth_protocolVersion","params":[],"id":67}'
```

**Sample Response**

```javascript
{
  "id":67,
  "jsonrpc": "2.0",
  "result": "0x41" // 65
}
```

## `eth_syncing`

Returns an object with data about the sync status or false.

**Parameters**

None

**Returns**

`Object|Boolean`，An object with sync status data or FALSE. Object structure:

* `startingBlock`: `QUANTITY`- The block at which the import started
* `currentBlock`: `QUANTITY` - The current block, same as `eth_blockNumber`
* `highestBlock`: `QUANTITY` - The estimated highest block

**Sample Request**

```bash
curl -X POST http://127.0.0.1:20339 -H 'Content-Type: application/json' --data '{"jsonrpc":"2.0","method":"eth_syncing","params":[],"id":1}'
```

**Sample Response**

```javascript
{
  "id":1,
  "jsonrpc": "2.0",
  "result": {
    startingBlock: '0',
    currentBlock: '0x386',
    highestBlock: '0x454'
  }
}
```

## `eth_gasPrice`

Returns the current price per gas in ***wei***.

**Parameters**

None

**Returns**

`QUANTITY` - integer of the current gas price in ***wei***.

**Sample Request**

```bash
curl -X POST http://127.0.0.1:20339 -H 'Content-Type: application/json' --data '{"jsonrpc":"2.0","method":"eth_gasPrice","params":[],"id":73}'
```

**Sample Response**

```javascript
{
  "id":73,
  "jsonrpc": "2.0",
  "result": "0x09184e72a000" // 10000000000000
}
```

## `eth_getStorageAt`

Returns the value from a storage position at a given address.

**Parameters**

1. `DATA`, 20 Bytes - address of the storage
2. `QUANTITY` - integer of the position in the storage
3. `QUANTITY|TAG`- integer block number, or the string `"latest"`, `"earliest"` or `pending"`

**Returns**

`DATA` - the value at this storage position.

**Example**

Calculating the correct position depends on the storage to retrieve. Consider the following contract deployed at `0x295a70b2de5e3953354a6a8344e616ed314d7251` by address `0x391694e7e0b0cce554cb130d723a9d27458f9298`:

```javascript
contract Storage {
    uint pos0;
    mapping(address => uint) pos1;

    function Storage() {
        pos0 = 1234;
        pos1[msg.sender] = 5678;
    }
}
```

Retrieving the value of pos0 is straight forward:

```bash
curl -X POST http://127.0.0.1:20339 -H 'Content-Type: application/json' --data '{"jsonrpc":"2.0", "method": "eth_getStorageAt", "params": ["0x295a70b2de5e3953354a6a8344e616ed314d7251", "0x0", "latest"], "id": 1}' localhost:8545
```

**Sample Response**

```javascript
{"jsonrpc":"2.0","id":1,"result":"0x00000000000000000000000000000000000000000000000000000000000004d2"}
```

Retrieving an element of the map is harder. The position of an element in the map is calculated with:

```javascript
keccack(LeftPad32(key, 0), LeftPad32(map position, 0))
```

This means to retrieve the storage on `pos1["0x391694e7e0b0cce554cb130d723a9d27458f9298"]` we need to calculate the position with:

```javascript
keccak(decodeHex("000000000000000000000000391694e7e0b0cce554cb130d723a9d27458f9298" + "0000000000000000000000000000000000000000000000000000000000000001"))
```

The geth console which comes with the web3 library can be used to make the calculation:

```javascript
> var key = "000000000000000000000000391694e7e0b0cce554cb130d723a9d27458f9298" + "0000000000000000000000000000000000000000000000000000000000000001"
undefined
> web3.sha3(key, {"encoding": "hex"})
"0x6661e9d6d8b923d5bbaab1b96e1dd51ff6ea2a93520fdc9eb75d059238b8c5e9"
```

Now to fetch the storage:

```bash
curl -X POST http://127.0.0.1:20339 -H 'Content-Type: application/json' --data '{"jsonrpc":"2.0", "method": "eth_getStorageAt", "params": ["0x295a70b2de5e3953354a6a8344e616ed314d7251", "0x6661e9d6d8b923d5bbaab1b96e1dd51ff6ea2a93520fdc9eb75d059238b8c5e9", "latest"], "id": 1}' localhost:8545
```

**Sample Response**

```javascript
{"jsonrpc":"2.0","id":1,"result":"0x000000000000000000000000000000000000000000000000000000000000162e"}
```

## `eth_getTransactionCount`

Returns the number of transactions sent from an address using Ontology EVM.

**Parameters**

1. `DATA`, 20 Bytes - address.
2. `QUANTITY|TAG` integer block number, or the string `"latest"`, `"earliest"` or `"pending"`

```javascript
params: [
   '0x407d73d8a49eeb85d32cf465507dd71d507100c1',
   'latest' // state at the latest block
]
```

**Returns**

`QUANTITY` - integer of the number of transactions send from this address

**Sample Request**

```bash
curl -X POST http://127.0.0.1:20339 -H 'Content-Type: application/json' --data '{"jsonrpc":"2.0","method":"eth_getTransactionCount","params":["0x407d73d8a49eeb85d32cf465507dd71d507100c1","latest"],"id":1}'
```

**Sample Response**

```javascript
{
  "id":1,
  "jsonrpc": "2.0",
  "result": "0x1" // 1
}
```

## `eth_getBlockTransactionCountByHash`

Returns the number of transactions using Ontology EVM in a block from a block matching the given block hash.

**Parameters**

`DATA`, 32 Bytes - hash of a block

```javascript
params: [
   '0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238'
]
```

**Returns**

`QUANTITY`- integer of the number of transactions in this block

**Sample Request**

```bash
curl -X POST http://127.0.0.1:20339 -H 'Content-Type: application/json' --data '{"jsonrpc":"2.0","method":"eth_getBlockTransactionCountByHash","params":["0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238"],"id":1}'
```

**Sample Response**

```javascript
{
  "id":1,
  "jsonrpc": "2.0",
  "result": "0xb" // 11
}
```

## `eth_getBlockTransactionCountByNumber`

Returns the number of transactions in a block matching the given block number.

**Parameters**

`QUANTITY|TAG`，- integer of a block number, or the string `"earliest"`, `"latest"` or `"pending"`.

```javascript
params: [
   '0xe8', // 232
]
```

**Returns**

`QUANTITY`- integer of the number of transactions in this block

**Sample Request**

```bash
curl -X POST http://127.0.0.1:20339 -H 'Content-Type: application/json' --data '{"jsonrpc":"2.0","method":"eth_getBlockTransactionCountByNumber","params":["0xe8"],"id":1}'
```

**Sample Response**

```javascript
{
  "id":1,
  "jsonrpc": "2.0",
  "result": "0xa" // 10
}
```

## `eth_getCode`

Returns code at a given address.

**Parameters**

1. `DATA`, 20 Bytes - address.
2. `QUANTITY|TAG`- integer of a block number, or the string `"earliest"`, `"latest"` or `"pending"` (Invalid Parameter).

```javascript
params: [
   '0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b',
   '0x2'  // 2
]
```

**Returns**

`DATA`- the code from the given address

**Sample Request**

```bash
curl -X POST http://127.0.0.1:20339 -H 'Content-Type: application/json' --data '{"jsonrpc":"2.0","method":"eth_getCode","params":["0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", "0x2"],"id":1}'
```

**Sample Response**

```javascript
{
  "id":1,
  "jsonrpc": "2.0",
  "result": "0x600160008035811a818181146012578301005b601b6001356025565b8060005260206000f25b600060078202905091905056"
}
```

## `eth_getTransactionLogs`

Returns transaction logs by a transaction hash.

**Parameters**

`txHash` - transaction hash

**Returns**

**Sample Request**

```bash
curl -X POST http://127.0.0.1:20339 -H 'Content-Type: application/json' --data '{
     "jsonrpc": "2.0",
     "id": 2233,
     "method": "eth_getTransactionLogs",
     "params": [
       "0x4a9e7c5ec484c1cb854d2831ff51f66f2771e8143362aa75c84f0c6544048fba"
     ]
   }'
```

**Sample Response**

```javascript
{
    "jsonrpc": "2.0",
    "id": 2233,
    "result": [
        {
            "address": "0x9ea0eff7153cebbdd18c2ca3bad818e29e556ba7",
            "topics": [
                "0x7ac369dbd14fa5ea3f473ed67cc9d598964a77501540ba6751eb0b3decf5870d"
            ],
            "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f4ffabb197396c7f48c9cd47ec462b54ed9ce84c",
            "blockNumber": "0x25b",
            "transactionHash": "0x4a9e7c5ec484c1cb854d2831ff51f66f2771e8143362aa75c84f0c6544048fba",
            "transactionIndex": "0x0",
            "blockHash": "0x77abadf9e4ad688212a70260244987f6623b54b56ea737a2cfbc7e7a6344eddc",
            "logIndex": "0x0",
            "removed": false
        }
    ]
}
```

## `eth_sendRawTransaction`

Creates new message call transaction or a contract creation for signed transactions.

**Parameters**

`DATA` - The signed transaction data

**Returns**

`DATA` 32 Bytes - the transaction hash, or the zero hash if the transaction is not yet available.

Use [eth\_getTransactionReceipt](https://github.com/ontio/ontology/blob/master/docs/specifications/evm_refernce/tutorial/README.md#-eth_getTransactionReceipt) to get the contract address, after the transaction was mined, when you created a contract.

**Sample Request**

```bash
curl -X POST http://127.0.0.1:20339 -H 'Content-Type: application/json' --data '{"jsonrpc":"2.0","method":"eth_sendRawTransaction","params":[{see above}],"id":1}'
```

**Sample Response**

```javascript
{
  "id":1,
  "jsonrpc": "2.0",
  "result": "0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331"
}
```

## `eth_call`

Executes a new message call immediately without creating a transaction on the blockchain.

**Parameters**

`Object` - The transaction call object:

* `from`: `DATA`，20 Bytes, 20 Bytes - (optional) The address the transaction is sent from.
* `to`: `DATA`, 20 Bytes, 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 gasPrice used for each paid gas.
* `value`：`QUANTITY` - (optional) Integer of the value sent with this transaction.
* `data`: `DATA` - (optional) Hash of the method signature and encoded parameters.
* `QUANTITY|TAG` - integer of a block number, or the string `"earliest"`, `"latest"` or `"pending"`.

**Returns**

`DATA` - the return value of executed contract.

**Sample Request**

```bash
curl -X POST http://127.0.0.1:20339 -H 'Content-Type: application/json' --data '{"jsonrpc":"2.0","method":"eth_call","params":[{see above}],"id":1}'
```

**Sample Response**

```javascript
{
  "id":1,
  "jsonrpc": "2.0",
  "result": "0x"
}
```

## `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.

{% hint style="info" %}
**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.
{% endhint %}

**Parameters**

See [**`eth_call`**](/developer-tools/api/eth-web3-api.md#eth_call) parameters. All properties are optional. If no gas limit is specified geth uses the block gas limit from the pending block as an upper bound. As a result the returned estimate might not be enough to execute the call/transaction when the amount of gas is higher than the pending block gas limit.

**Returns**

`QUANTITY` - the estimated amount of gas.

**Sample Request**

```bash
curl -X POST http://127.0.0.1:20339 -H 'Content-Type: application/json' --data '{"jsonrpc":"2.0","method":"eth_estimateGas","params":[{see above}],"id":1}'
```

**Sample Response**

```javascript
{
  "id":1,
  "jsonrpc": "2.0",
  "result": "0x5208" // 21000
}
```

## `eth_getBlockByNumber`

Returns information about a block by block number.

**Parameters**

1. `QUANTITY|TAG` - integer of a block number, or the string `"earliest"`, `"latest"` or `"pending"`.
2. `Boolean`- If `true` it returns the full transaction objects, if `false` only the hashes of the transactions.

**Returns**

`Object` - A block object, or `null` when no block was found:

* `number`: `QUANTITY` - the block number.
* `hash`: `DATA`, 32 Bytes - hash of the block.
* `parentHash`: `DATA`, 32 Bytes - hash of the parent block.
* `nonce`: `DATA` , 8 Bytes - null
* `logsBloom`: `DATA`, 256 Bytes - null
* `transactionsRoot`: `DATA` , 32 Bytes - the root of the transaction tree of the block.
* `stateRoot`: `DATA`, 32 Bytes - null
* `receiptsRoot`: `DATA`, 32 Bytes - null
* `miner`: `DATA`, 20 Bytes - null
* `difficulty`: `QUANTITY` - null
* `totalDifficulty`: `QUANTITY` - null
* `extraData`: `DATA` - null
* `size`: `QUANTITY` - the size of this block in bytes.
* `gasLimit`: `QUANTITY` - the maximum gas allowed in this block.
* `gasUsed`: `QUANTITY` - the total used gas by all transactions in this block.
* `timestamp`: `QUANTITY` - the timestamp for when the block was collated.
* `transactions`: `Array` - Array of transaction objects, or 32 Bytes transaction hashes depending on the last given parameter.
* `uncles`: `Array` - null

**Sample Request**

```bash
curl -X POST http://127.0.0.1:20339 -H 'Content-Type: application/json' --data '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["0x1b4", true],"id":1}'
```

**Sample Response**

```javascript
{
    "jsonrpc": "2.0",
    "id": 2233,
    "result": {
        "difficulty": "0x0",
        "extraData": "0x",
        "gasLimit": "0x0",
        "gasUsed": "0x0",
        "hash": "0x9e539021092397ec631cbb05fa5418e83b5cccb95dd4663180c243425f01d7b2",
        "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
        "miner": "0x0000000000000000000000000000000000000000",
        "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
        "nonce": "0x0000000000000000",
        "number": "0x1b4",
        "parentHash": "0xea06f581bb1e1c4a828f149106e697542bb484627e518ab905a67998d9b670dc",
        "receiptsRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
        "sha3Uncles": "0x0000000000000000000000000000000000000000000000000000000000000000",
        "size": "0xf2",
        "stateRoot": "0x",
        "timestamp": "0x60c04264",
        "totalDifficulty": "0x0",
        "transactions": [],
        "transactionsRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
        "uncles": []
    }
}
```

## `eth_getBlockByHash`

Returns information about a block by hash.

**Parameters**

1. `DATA`, 32 Bytes - Hash of a block.
2. `Boolean`- If `true` it returns the full transaction objects, if `false` only the hashes of the transactions.

**Returns**

See [`eth_getBlockByNumber`](/developer-tools/api/eth-web3-api.md#eth_getblockbynumber).

**Sample Request**

```bash
curl -X POST http://127.0.0.1:20339 -H 'Content-Type: application/json' --data '{"jsonrpc":"2.0","method":"eth_getBlockByHash","params":["0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331", true],"id":1}'
```

**Sample Response**

See [`eth_getBlockByNumber`](/developer-tools/api/eth-web3-api.md#eth_getblockbynumber).

## `eth_getTransactionByHash`

Returns information about a transaction by block hash.

**Parameters**

`DATA`, 32 Bytes - hash of a block.

**Returns**

`Object` - A transaction object, or `null` when no transaction was found：

* `hash`: `DATA` - 32 Bytes, transaction hash.
* `nonce`: `QUANTITY` - the number of transactions made by the sender using Ontology EVM prior to this one.
* `blockHash`: `DATA`, 32 Bytes - hash of the block where this transaction was in. null when its pending.
* `blockNumber`: `QUANTITY` - 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`: `DATA`, 20 Bytes - address of the sender.
* `to`: `DATA`, 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.

**Sample Request**

```bash
curl -X POST http://127.0.0.1:20339 -H 'Content-Type: application/json' --data '{"jsonrpc":"2.0","method":"eth_getTransactionByHash","params":["0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238"],"id":1}'
```

**Sample Response**

```javascript
{
"id":1,
"jsonrpc":"2.0",
"result": {
    "hash":"0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b",
    "nonce":"0x",
    "blockHash": "0xbeab0aa2411b7ab17f30a99d3cb9c6ef2fc5426d6ad6fd9e2a26a6aed1d1055b",
    "blockNumber": "0x15df", // 5599
    "transactionIndex":  "0x1", // 1
    "from":"0x407d73d8a49eeb85d32cf465507dd71d507100c1",
    "to":"0x85h43d8a49eeb85d32cf465507dd71d507100c1",
    "value":"0x7f110", // 520464
    "gas": "0x7f110", // 520464
    "gasPrice":"0x09184e72a000",
    "input":"0x603880600c6000396000f300603880600c6000396000f3603880600c6000396000f360",
  }
}
```

## `eth_getTransactionByBlockHashAndIndex`

Returns information about a transaction by block hash and transaction index position.

**Parameters**

1. `DATA`, 32 Bytes - hash of a block.
2. `QUANTITY`- integer of the transaction index position.

```javascript
params: [
   '0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331',
   '0x0' // 0
]
```

**Sample Request**

```bash
curl -X POST http://127.0.0.1:20339 -H 'Content-Type: application/json' --data '{"jsonrpc":"2.0","method":"eth_getTransactionByBlockHashAndIndex","params":["0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b", "0x0"],"id":1}'
```

**Returns**

See [`eth_getTransactionByHash`](/developer-tools/api/eth-web3-api.md#eth_gettransactionbyhash).

## **`eth_getTransactionByBlockNumberAndIndex`**

Returns information about a transaction by block number and transaction index position.

**Parameters**

1. `QUANTITY|TAG` - integer of a block number, or the string `"earliest"`, `"latest"` or `"pending"`.
2. `QUANTITY`- the transaction index position.

```bash
params: [
   '0x29c', // 668
   '0x0' // 0
]
```

**Returns**

See [`eth_getTransactionByHash`](/developer-tools/api/eth-web3-api.md#eth_gettransactionbyhash).

**Sample Request**

```bash
curl -X POST http://127.0.0.1:20339 -H 'Content-Type: application/json' --data '{"jsonrpc":"2.0","method":"eth_getTransactionByBlockNumberAndIndex","params":["0x29c", "0x0"],"id":1}'
```

see [`eth_getTransactionByHash`](/developer-tools/api/eth-web3-api.md#eth_gettransactionbyhash).

## `eth_getTransactionReceipt`

Returns the receipt of a transaction by transaction hash.

{% hint style="info" %}
**Note:** The receipt is not available for pending transactions.
{% endhint %}

**Parameters**

`DATA`, 32 Bytes - hash of a transaction.

```javascript
params: [
   '0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238'
]
```

**Returns**

`Object` - A transaction receipt object, or `null` when no receipt was found:

* `transactionHash`: `DATA`, 32 Bytes - hash of the transaction.
* `transactionIndex`: `QUANTITY` - integer of the transactions index position in the block.
* `blockHash`: `DATA`, 32 Bytes - hash of the block where this transaction was in.
* `blockNumber`: `QUANTITY`- block number where this transaction was in.
* `from`: `DATA`, 20 Bytes - address of the sender.
* `to`: `DATA`, 20 Bytes - address of the receiver. null when its a contract creation transaction.
* `cumulativeGasUsed`:`QUANTITY` - The total amount of gas used when this transaction was executed in the block.
* `gasUsed`: `QUANTITY` - The amount of gas used by this specific transaction alone.
* `contractAddress`: `DATA`, 20 Bytes - The contract address created, if the transaction was a contract creation, otherwise `null`.
* `logs`: `Array` - Array of log objects, which this transaction generated.
* `logsBloom`: `DATA`, 256 Bytes - Bloom filter, null
* `status`: `QUANTITY`, either `1` (success) or `0` (failure)

**Sample Request**

```bash
curl -X POST http://127.0.0.1:20339 -H 'Content-Type: application/json' --data '{    "jsonrpc": "2.0",
    "id": 16661,
    "method": "eth_getTransactionReceipt",
    "params": [
        "0xe15e2c2240dc58dff54f7c4561a3f784b4ac91cefd0b7cf4dad014fd8a0ad70b"
    ]'
```

**Sample Response**

```javascript
{
    "jsonrpc": "2.0",
    "id": 16661,
    "result": {
        "blockHash": "0x747d2b4599a08c423d50ec772897c992b01b1ac1510d487be52d0167014bd063",
        "blockNumber": "0x204",
        "contractAddress": "0xddcb212ce4896bb02f79db726f6bb8588df41a5c",
        "cumulativeGasUsed": "0x13eecbeb0",
        "from": "0x96216849c49358b10257cb55b28ea603c874b05e",
        "gasUsed": "0x20a86c",
        "logs": [
            {
                "address": "0xddcb212ce4896bb02f79db726f6bb8588df41a5c",
                "topics": [
                    "0x7ac369dbd14fa5ea3f473ed67cc9d598964a77501540ba6751eb0b3decf5870d"
                ],
                "data": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000055354e90851d79ee31d8f27d94613cf8f5e7f9e8",
                "blockNumber": "0x204",
                "transactionHash": "0xe15e2c2240dc58dff54f7c4561a3f784b4ac91cefd0b7cf4dad014fd8a0ad70b",
                "transactionIndex": "0x0",
                "blockHash": "0x747d2b4599a08c423d50ec772897c992b01b1ac1510d487be52d0167014bd063",
                "logIndex": "0x0",
                "removed": false
            },
            {
                "address": "0xddcb212ce4896bb02f79db726f6bb8588df41a5c",
                "topics": [
                    "0xedffc32e068c7c95dfd4bdfd5c4d939a084d6b11c4199eac8436ed234d72f926"
                ],
                "data": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a5b9c59f24caa24ddd9a7ef3aec61bb4908ad984",
                "blockNumber": "0x204",
                "transactionHash": "0xe15e2c2240dc58dff54f7c4561a3f784b4ac91cefd0b7cf4dad014fd8a0ad70b",
                "transactionIndex": "0x0",
                "blockHash": "0x747d2b4599a08c423d50ec772897c992b01b1ac1510d487be52d0167014bd063",
                "logIndex": "0x1",
                "removed": false
            },
            {
                "address": "0xddcb212ce4896bb02f79db726f6bb8588df41a5c",
                "topics": [
                    "0xd604de94d45953f9138079ec1b82d533cb2160c906d1076d1f7ed54befbca97a"
                ],
                "data": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000056319fd5a22da14daf19394937dd562619ea34ad",
                "blockNumber": "0x204",
                "transactionHash": "0xe15e2c2240dc58dff54f7c4561a3f784b4ac91cefd0b7cf4dad014fd8a0ad70b",
                "transactionIndex": "0x0",
                "blockHash": "0x747d2b4599a08c423d50ec772897c992b01b1ac1510d487be52d0167014bd063",
                "logIndex": "0x2",
                "removed": false
            }
        ],
        "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
        "status": "0x1",
        "to": null,
        "transactionHash": "0xe15e2c2240dc58dff54f7c4561a3f784b4ac91cefd0b7cf4dad014fd8a0ad70b",
        "transactionIndex": "0x0"
    }
}
```

## `eth_pendingTransactions`

Access all pending transactions.

## `eth_pendingTransactionsByHash`

Access all pending transactions by transaction hash.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.ont.io/developer-tools/api/eth-web3-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
