> For the complete documentation index, see [llms.txt](https://blockchen.gitbook.io/api/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://blockchen.gitbook.io/api/ethereum.md).

# Ethereum

## Create Ethereum Client

{% tabs %}
{% tab title="PHP" %}

```php
use BlockSDK;

$blockSDK = new BlockSDK("YOU_TOKEN");
$ethClient = $blockSDK->createEthereum();

or

$ethClient = BlockSDK::createEthereum("YOU_TOKEN");
```

{% endtab %}
{% endtabs %}

## Object

### Tx

| Name               |  Type  |                                  Content                                 |
| ------------------ | :----: | :----------------------------------------------------------------------: |
| hash               | string |                         hash of the transaction.                         |
| from               | string |                          address of the sender.                          |
| to                 | string |                         address of the receiver.                         |
| contract\_address  | string |          If it is a contract, the contract address is displayed.         |
| value              | double |                         value transferred in Wei.                        |
| erc20\_value       | double | In case of erc20 token transaction, the transaction amount is displayed. |
| gas\_used          |   int  |         The exact units of gas that was used for the transaction.        |
| gas\_limit         |   int  |            Maximum amount of gas provided for the transaction.           |
| gas\_price         | double |                 gas price provided by the sender in Wei.                 |
| fee\_total         | double |                              Transaction fee                             |
| nonce              |   int  |     the number of transactions made by the sender prior to this one.     |
| transaction\_index |   int  |         integer of the transaction's index position in the block         |
| input              | string |                 the data send along with the transaction.                |
| block\_hash        | string |                 block hash where this transaction was in.                |
| block\_height      |   int  |                block number where this transaction was in.               |
| confirmations      |   int  |                      Transaction Confirmation Count                      |
| time               |   int  |                      The time contained in the block                     |
| status             | string |                      The status of the transaction.                      |

## GetBlockChain

<mark style="color:blue;">`GET`</mark> `https://api.blocksdk.com/v1/eth/block`

{% tabs %}
{% tab title="200 " %}

```javascript
{
			"height" : 9098547,
			"bestblockhash" => "0x235145654e2034d0852a9e8cd9bc6e3eea8a7179aec0723cd12db7d18e5f06b4",
			"prev_hash" => "0xb4cbec945d9dcf8a870d4ae5b156758f6b7824ed6da9a69130431cad7200a92e",
			"unconfirmed_count" : 1234,
			"low_gwei" : 1,
			"medium_gwei" : 2,
			"high_gwei" : 3
}
```

{% endtab %}
{% endtabs %}

## Response

| Nmae               | Type   | Content                                      |
| ------------------ | ------ | -------------------------------------------- |
| height             | int    | number of most recent block.                 |
| bestblockhash      | string | hash of most recent block.                   |
| prev\_hash         | string | Previous block hash of the most recent block |
| unconfirmed\_count | int    | Unconfirmed Transaction Count                |
| low\_gwei          | char   | Low Priority (7+ blocks)                     |
| medium\_gwei       | char   | Medium Priority (3-6 blocks)                 |
| high\_gwei         | char   | High Priority (1-2 blocks)                   |

{% tabs %}
{% tab title="PHP" %}

```php
$blockChain = $ethClient->getBlockChain();
```

{% endtab %}
{% endtabs %}

## GetBlock

<mark style="color:blue;">`GET`</mark> `https://api.blocksdk.com/v1/eth/block/{block}`

#### Path Parameters

| Name  | Type   | Description          |
| ----- | ------ | -------------------- |
| block | string | Block number or hash |

#### Query Parameters

| Name   | Type    | Description                      |
| ------ | ------- | -------------------------------- |
| rawtx  | boolean | Get transaction details          |
| limit  | number  | Number of transactions to import |
| offset | number  | Transaction List Offset          |

#### Request Body

| Name | Type   | Description |
| ---- | ------ | ----------- |
|      | string |             |

{% tabs %}
{% tab title="200 " %}

```javascript
{
    "hash" : "0x46b8c1571d9b8511c85f185c6e3fef04431c4b891a294c1a0dfc5056dc5604eb",
    "height" : 900000,
    "extra_data" : "0xd783010303844765746887676f312e342e32856c696e7578",
    "gas_limit" : 3141592,
		"gas_used" : 0,
		"miner" : "0x52bc44d5378309ee2abf1539bf71de1b7d7be3b5",
		"tx" : [],
		"tx_count" : 0,
		"total_value" : 0,
		"fee_total" : 0,
		"reward" : 5,
		"size" : 541,
		"nonce" : "0xe387a98b08a28430",
		"confirmations" : 0,
		"time" : 0,
		"sha3_uncles" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
		"prev_hash" : "0x9b8df528faae645e0b5b2cf6d6aa65f2e45a74fc61f4768a52c051a3d3436f85",
		"next_hash" : "0x93163b2501158b2161fac65799da8e68ce656fcd1f528db4ceaed5ba91866f9a"
}
```

{% endtab %}
{% endtabs %}

## Response

| Name          | Type   | Content                                                               |
| ------------- | ------ | --------------------------------------------------------------------- |
| hash          | string | hash of the block                                                     |
| height        | int    | the block number                                                      |
| extra\_data   | string | the "extra data" field of this block                                  |
| gas\_limit    | int    | the maximum gas allowed in this block                                 |
| gas\_used     | int    | the total used gas by all transactions in this block                  |
| miner         | string | the address of the beneficiary to whom the mining rewards were given. |
| tx            | array  | Transaction contained in the block                                    |
| tx\_count     | int    | The number of transactions contained in the block                     |
| total\_value  | double | Total transaction amount included in the block                        |
| fee\_total    | double | Total transaction fee                                                 |
| reward        | int    | Block Mining Reward                                                   |
| size          | int    | integer the size of this block in bytes.                              |
| nonce         | int    | hash of the generated proof-of-work.                                  |
| confirmations | int    | Block Confirmation Count                                              |
| time          | int    | The date and time at which a block is mined.                          |
| prev\_hash    | string | Previous block hash                                                   |
| next\_hash    | string | Next block hash                                                       |

{% tabs %}
{% tab title="PHP" %}

```php
$block = $ethClient->getBlock([
    "block" => 8913145,
    "offset" => 0,
    "limit" => 10,
    "rawtx" => true
]);
```

{% endtab %}
{% endtabs %}

## GetMemPool

<mark style="color:blue;">`GET`</mark> `https://api.blocksdk.com/v1/eth/mempool`

#### Query Parameters

| Name   | Type    | Description                      |
| ------ | ------- | -------------------------------- |
| rawtx  | boolean | Get transaction details          |
| offset | number  | Transaction List Offset          |
| limit  | number  | Number of transactions to import |

{% tabs %}
{% tab title="200 " %}

```
{
    "unconfirmed_count" : 10,
    "tx" : {...}
}
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="PHP" %}

```php
$pool = $ethClient->getMemPool([
    "rawtx" => true,
    "offset" => 0,
    "limit" => 10
]);
```

{% endtab %}
{% endtabs %}

## ListAddress

<mark style="color:blue;">`GET`</mark> `https://api.blocksdk.com/v1/eth/address`

#### Query Parameters

| Name   | Type   | Description                 |
| ------ | ------ | --------------------------- |
| limit  | string | Number of Address to import |
| offset | string | Address List offset         |

{% tabs %}
{% tab title="200 " %}

```javascript
{
    "items" : [
        {
            "id" : 1,
            "name" : "test address1",
            "created_at" : "2019-03-01 01:23:11"
        },
        {
            "id" : 2,
            "name" : "test address2",
            "created_at" : "2019-03-01 01:23:11"
        }
    ]    
}
```

{% endtab %}
{% endtabs %}

## Response

| Name | type  | Content                   |
| ---- | ----- | ------------------------- |
|      | array | List of created addresses |

{% tabs %}
{% tab title="PHP" %}

```php
$listAddress = $ethClient->listAddress([
    "offset" => 0,
    "limit" => 10
]);
```

{% endtab %}
{% endtabs %}

## CraeteAddress

<mark style="color:green;">`POST`</mark> `https://api.blocksdk.com/v1/eth/address`

#### Request Body

| Name | Type   | Description  |
| ---- | ------ | ------------ |
| name | string | Address name |

{% tabs %}
{% tab title="200 Private keys are not stored in BlockSDK." %}

```javascript
{
    "id" : 1,
    "address" : "0x1234567890",
    "private_key" : "abcdefg"
}
```

{% endtab %}
{% endtabs %}

## Response

| Name         | Type   | Content                                                                |
| ------------ | ------ | ---------------------------------------------------------------------- |
| id           | int    | Generated unique id                                                    |
| address      | string | Generated address                                                      |
| private\_key | string | Private key of generated address(BlockSDK is not stored on the server) |

{% tabs %}
{% tab title="PHP" %}

```php
$address = $ethClient->createAddress([
    "name" => "test address"
]);
```

{% endtab %}
{% endtabs %}

## GetAddressInfo

<mark style="color:blue;">`GET`</mark> `https://api.blocksdk.com/v1/eth/address/{address}`

#### Path Parameters

| Name    | Type   | Description      |
| ------- | ------ | ---------------- |
| address | string | Ethereum Address |

#### Query Parameters

| Name    | Type    | Description                     |
| ------- | ------- | ------------------------------- |
| reverse | boolean | Reverse transaction information |
| rawtx   | boolean | Get transaction details         |
| offset  | number  | Transaction List Offset         |
| limit   | number  | Number of Transaction to import |

{% tabs %}
{% tab title="200 " %}

```javascript
{
    "address" : "0x12345678",
    "nonce" : 0,
    "tx" : [],
    "tx_count" : 0,
    "received_count" : 0,
    "received_total" : 0,
    "received_unconfirmed" : 0,
    "spent_count" : 0,
    "spent_total" : 0,
    "spent_unconfirmed" : 0,
    "balance" : 0,
    "unconfirmed_balance" : 0,
    "unconfirmed_count" : 0,
    "first_time" : 0,
    "last_time" : 0
} 
```

{% endtab %}
{% endtabs %}

## Response

| Name                  | Type   | Content                                                                |
| --------------------- | ------ | ---------------------------------------------------------------------- |
| address               | string | Ethereum Address                                                       |
| nonce                 | int    | number of transactions sent from an address.                           |
| tx                    | array  | Transaction originated from address                                    |
| tx\_count             | int    | The number of transactions that occurred at the address                |
| received\_count       | int    | The number of transactions received from the address                   |
| received\_total       | double | Transaction amount received from the address                           |
| received\_unconfirmed | double | Transaction amount not included in the block received from the address |
| spent\_count          | int    | The number of transactions spent from the address                      |
| spent\_total          | double | Transaction amount spent from the address                              |
| spent\_unconfirmed    | double | Transaction amount not included in the block spent from the address    |
| balance               | double | Remaining balance                                                      |
| unconfirmed\_balance  | double | Transaction balance not included in block at address                   |
| unconfirmed\_count    | int    | Transaction count not included in address block                        |
| first\_time           | int    | First Deal Creation Time at Address                                    |
| last\_time            | int    | Last transaction creation time from address                            |

{% tabs %}
{% tab title="PHP" %}

```php
$addressInfo = $ethClient->getAddressInfo([
    "reverse" => true,
    "rawtx" => false,
    "offset" => 0,
    "limit" => 10
]);
```

{% endtab %}
{% endtabs %}

## GetAddressBalance

<mark style="color:blue;">`GET`</mark> `https://api.blocksdk.com/v1/eth/address/{address}/balance`

#### Path Parameters

| Name    | Type   | Description      |
| ------- | ------ | ---------------- |
| address | string | Ethereum Address |

{% tabs %}
{% tab title="200 " %}

```javascript
{
    "address" : "0x12345678",
    "balance" : 0,
    "unconfirmed_balance" : 0
}
```

{% endtab %}
{% endtabs %}

## Response

| Name                 | Type   | Content                                                        |
| -------------------- | ------ | -------------------------------------------------------------- |
| address              | string | Ethereum Address                                               |
| balance              | double | Balance of the address                                         |
| unconfirmed\_balance | double | Balance of transactions not included in the block of addresses |

{% tabs %}
{% tab title="PHP" %}

```php
$addressBalance = $ethClient->getAddressBalance([
    "address" => "0x12345678"
]);
```

{% endtab %}
{% endtabs %}

## SendToAddress

<mark style="color:green;">`POST`</mark> `https://api.blocksdk.com/v1/eth/address/{from}/sendtoaddress`

#### Path Parameters

| Name | Type   | Description      |
| ---- | ------ | ---------------- |
| from | string | Ethereum Address |

#### Request Body

| Name         | Type   | Description                                                                                                       |
| ------------ | ------ | ----------------------------------------------------------------------------------------------------------------- |
| password     | string | If it is a loaded Ethereum address, this value is required and you can enter the password used to load it.        |
| gas\_limit   | number | Maximum amount of gas provided for the transaction(default 90000)                                                 |
| address      | string | Address to receive Ethereum                                                                                       |
| amount       | string | Amount of Ethereum to send                                                                                        |
| private\_key | string | Ethereum address that has not been loaded requires this value and is issued when generating the Ethereum address. |
| gwei         | string | fee to be used for transactions                                                                                   |

{% tabs %}
{% tab title="200 " %}

```javascript
{
    "hash" : "0x123456",
    "from" : "0x123456",
    "to" : "0x123456",
    "value" : 0,
    "gas_used" : 0,
    "gas_limit" : 0,
    "gas_price" : 0,
    "fee_total" : 0,
    "nonce" : 0,
    "transaction_index" : 0,
    "input" : "0x",
    "block_hash" : "0x123456",
    "block_height" : 0,
    "confirmations" : 0,
    "time" : 0,
    "status" : "success"
} 
```

{% endtab %}
{% endtabs %}

## Response

Return Tx on Success

{% tabs %}
{% tab title="PHP" %}

```php
$tx = $ethClient->sendToAddress([
    "from" => "0x12345678",
    "to" => "0x12345678",
    "amount" => 0.1,
    "private_key" => "abcdefg",
    "gwei" => 5
]);
```

{% endtab %}
{% endtabs %}

## SendTransaction

<mark style="color:green;">`POST`</mark> `https://api.blocksdk.com/v1/eth/transaction`

#### Request Body

| Name      | Type   | Description            |
| --------- | ------ | ---------------------- |
| sign\_hex | string | signed transaction hex |

{% tabs %}
{% tab title="201 " %}

```javascript
{
    "hash" : "0x123456",
    "from" : "0x123456",
    "to" : "0x123456",
    "value" : 0,
    "gas_used" : 0,
    "gas_limit" : 0,
    "gas_price" : 0,
    "fee_total" : 0,
    "nonce" : 0,
    "transaction_index" : 0,
    "input" : "0x",
    "block_hash" : "0x123456",
    "block_height" : 0,
    "confirmations" : 0,
    "time" : 0,
    "status" : "success"
} 
```

{% endtab %}
{% endtabs %}

## Response

Return Tx on Success

{% tabs %}
{% tab title="PHP" %}

```php
$tx = $ethClient->sendTransaction([
    "sign_hex" => "0x1234567890abcdefg"
])
```

{% endtab %}
{% endtabs %}

## GetTransaction

<mark style="color:blue;">`GET`</mark> `https://api.blocksdk.com/v1/eth/transaction/{hash}`

#### Path Parameters

| Name | Type   | Description      |
| ---- | ------ | ---------------- |
| hash | string | transaction hash |

{% tabs %}
{% tab title="200 " %}

```javascript
{
    "hash" : "0x123456",
    "from" : "0x123456",
    "to" : "0x123456",
    "value" : 0,
    "gas_used" : 0,
    "gas_limit" : 0,
    "gas_price" : 0,
    "fee_total" : 0,
    "nonce" : 0,
    "transaction_index" : 0,
    "input" : "0x",
    "block_hash" : "0x123456",
    "block_height" : 0,
    "confirmations" : 0,
    "time" : 0,
    "status" : "success"
} 
```

{% endtab %}
{% endtabs %}

## Response

Return Tx on Success

{% tabs %}
{% tab title="PHP" %}

```php
$tx = $ethClient->getTransaction([
    "hash" => "0x123456789"
])
```

{% endtab %}
{% endtabs %}

## LoadAddress

<mark style="color:green;">`POST`</mark> `https://api.blocksdk.com/v1/eth/address/{address}/load`

Load your address.\
The loaded address does not require private\_key when using SendToAddress

#### Path Parameters

| Name    | Type   | Description      |
| ------- | ------ | ---------------- |
| address | number | Ethereum Address |

#### Request Body

| Name         | Type   | Description         |
| ------------ | ------ | ------------------- |
| password     | string | Used when trading   |
| private\_key | string | Address private key |

{% tabs %}
{% tab title="201 " %}

```
[]
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="PHP" %}

```php
$load = $ethClient->loadAddress([
    "address" => "0x1b2d1d126af619a0fa5211bd2db79d83a29c4991",
    "private_key" => "abcdefg",
    "password" => "abcdefg"
]);
```

{% endtab %}
{% endtabs %}

## UnloadAddress

<mark style="color:green;">`POST`</mark> `https://api.blocksdk.com/v1/eth/address/{address}/unload`

#### Path Parameters

| Name    | Type   | Description      |
| ------- | ------ | ---------------- |
| address | number | Ethereum Address |

{% tabs %}
{% tab title="201 " %}

```
[]
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="PHP" %}

```php
$unload = $ethClient->unloadAddress([
    "address" => "0x1b2d1d126af619a0fa5211bd2db79d83a29c4991"
]);
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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://blockchen.gitbook.io/api/ethereum.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.
