> 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/bitcoin.md).

# Bitcoin

## Create Bitcoin Client

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

```php
use BlockSDK;

$blockSDK = new BlockSDK("YOU_TOKEN");
$btcClient = $blockSDK->createBitcoin();

or

$btcClient = BlockSDK::createBitcoin("YOU_TOKEN");
```

{% endtab %}
{% endtabs %}

## Object

### TX

| Name          | Type                                 | Content                                                      |
| ------------- | ------------------------------------ | ------------------------------------------------------------ |
| txid          | string                               | hash of the transaction.                                     |
| hash          | string                               | hash of the transaction.                                     |
| size          | int                                  | size of the transaction.                                     |
| version       | char                                 | version of the transaction.                                  |
| vin           | array\[[vin](/api/bitcoin.md#vin)]   | List of inputs into transaction                              |
| total\_in     | double                               | Total balance of transaction input                           |
| vout          | array\[[vout](/api/bitcoin.md#vout)] | List of outputs into transaction                             |
| total\_out    | double                               | Total balance of transaction output                          |
| in\_count     | int                                  | Transaction input count                                      |
| out\_count    | int                                  | Transaction output count                                     |
| fee           | double                               | Transaction fee                                              |
| fee\_per\_kb  | double                               | Transaction fee per kb                                       |
| locktime      | int                                  | If not 0, this tells when a transaction output is spendable. |
| block\_hash   | string                               | block hash including the transaction                         |
| block\_height | int                                  | block height including the transaction                       |
| time          | int                                  | The time contained in the block                              |
| confirmations | int                                  | Transaction Confirmation Count                               |

### VIN

| Name      | Type           | Content                                                            |
| --------- | -------------- | ------------------------------------------------------------------ |
| txid      | string         | hash of the transaction                                            |
| vout      | int            | the index of the output being redeemed from the origin transaction |
| scriptSig | object         | signature script                                                   |
| addresses | array\[string] | Bitcoin Address                                                    |
| value     | double         | Amount used                                                        |

### VOUT

| Name         | Type           | Content                                 |
| ------------ | -------------- | --------------------------------------- |
| value        | double         | Amount received                         |
| n            | int            | Output index                            |
| scriptPubKey | object         | the public key script used to pay coins |
| addresses    | array\[string] | Bitcoin Address                         |

## &#x20;GetBlockChain

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

{% tabs %}
{% tab title="200 Cake successfully retrieved." %}

```javascript
{
    "height":591332,
    "bestblockhash":"00000000000000000004a175c14f3bea27ff1714bf9e10bb38b9c9d05a9119fb",
    "prev_hash":"00000000000000000004a175c14f3bea27ff1714bf9e10bb38b9c9d05a9119fb",
    "unconfirmed_count":4198,
    "low_fee_per_kb":0,
    "medium_fee_per_kb":0,
    "high_fee_per_kb":0
}
```

{% endtab %}
{% endtabs %}

### Response

| Name                 | 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\_fee\_per\_kb    | double | Low Priority (7+ blocks)                     |
| medium\_fee\_per\_kb | double | Medium Priority (3-6 blocks)                 |
| high\_fee\_per\_kb   | double | High Priority (1-2 blocks)                   |

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

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

{% endtab %}
{% endtabs %}

## GetBlock

<mark style="color:blue;">`GET`</mark> `https://api.blocksdk.com/v1/btc/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          |

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

```javascript
{
    "hash":"00000000000000000004a175c14f3bea27ff1714bf9e10bb38b9c9d05a9119fb",
    "confirmations":1,
    "height":591332,
    "chain":"main",
    "time":1566537913,
    "tx":[...],
    "tx_count":1944,
    "input_total":666.41239337,
    "input_count":3304,
    "out_total":666.37846362,
    "out_count":4313,
    "fee_per_kb":0.00003941,
    "fee_total":0.03392975,
    "generation":12.5,
    "reward":12.53392975,
    "size":860885,
    "prev_hash":"00000000000000000005658caea146711753c08ad1308e4abf35765eed0c9738",
    "next_hash":""
}
```

{% endtab %}
{% endtabs %}

### Response

| Name          | Type   | Content                                                     |
| ------------- | ------ | ----------------------------------------------------------- |
| hash          | string | hash of the block                                           |
| confirmations | int    | Block Confirmation Count                                    |
| height        | int    | the block number                                            |
| time          | int    | The date and time at which a block is mined.                |
| tx            | array  | Transaction contained in the block                          |
| tx\_count     | int    | The number of transactions contained in the block           |
| input\_total  | double | Total input balance of transactions contained in the block  |
| input\_count  | int    | The number of inputs for all transactions in the block      |
| out\_total    | double | Total output balance of transactions contained in the block |
| out\_count    | int    | The number of outputs for all transactions in the block     |
| fee\_per\_kb  | double | Kb unit fee for all transactions in a block                 |
| fee\_total    | double | Total transaction fee                                       |
| generation    | double | Mining Compensation Including Fees                          |
| reward        | double | Block Mining Reward                                         |
| size          | int    | integer the size of this block in bytes.                    |
| prev\_hash    | string | Previous block hash                                         |
| next\_hash    | string | Next block hash                                             |

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

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

{% endtab %}
{% endtabs %}

## GetAddressInfo

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

#### Path Parameters

| Name    | Type   | Description     |
| ------- | ------ | --------------- |
| address | string | Bitcoin 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":"18cBEMRxXHqzWWCxZNtU91F5sbUNKhL5PX",
"tx":[...],
"tx_count":16835,
"received_count":15015,
"received_total":200909.75773048965,
"received_unconfirmed":0,
"spent_count":13743,
"spent_total":183877.14267344927,
"spent_unconfirmed":0,
"balance":17032.615057040384,
"unconfirmed_count":0,
"unspent_output_count":1272,
"first_time":1465122643,
"last_time":1566536738
}
```

{% endtab %}
{% endtabs %}

### Response

| Name                  | Type   | Content                                                                |
| --------------------- | ------ | ---------------------------------------------------------------------- |
| address               | string | Bitcoin 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\_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 = $btcClient->getAddressInfo([
    "address" => "18cBEMRxXHqzWWCxZNtU91F5sbUNKhL5PX",
    "rawtx" => true,
    "reverse" => true,
    "offset" => 0,
    "limit" => 10
]);
```

{% endtab %}
{% endtabs %}

## GetMemPool

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

#### Query Parameters

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

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

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

{% endtab %}
{% endtabs %}

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

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

{% endtab %}
{% endtabs %}

## GetAddressBalance

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

#### Path Parameters

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

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

```javascript
{
    "address":"14cK6zRk4zdfbrYG5srA69hCngkV7zDzbt",
    "balance":0,
    "unconfirmed_balance":0
}
```

{% endtab %}
{% endtabs %}

### Response

| Name                 | Type   | Content                                                        |
| -------------------- | ------ | -------------------------------------------------------------- |
| address              | string | Bitcoin 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
$balance = $btcClient->getAddressBalance([
    "address" => "14cK6zRk4zdfbrYG5srA69hCngkV7zDzbt"
]);
```

{% endtab %}
{% endtabs %}

## ListWallet&#x20;

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

#### Query Parameters

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

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

```javascript
{
    "items" : [
                {
                "id":31,
                "name":"PLum6KG5bbbLqPovFT5vTCTtPME4Zaaaaaa",
                "created_at":"2019-07-16 08:14:21"
                },
                {
                "id":32,
                "name":"2ypjOjJhbbb3qBiyPhEHpDouyKDt8bbbbb",
                "created_at":"2019-07-16 08:15:56"
                }
    ]
}
```

{% endtab %}
{% endtabs %}

### Response

| Name        | Type     | Content                             |
| ----------- | -------- | ----------------------------------- |
| id          | int      | Unique ID of the wallet             |
| name        | string   | Name specified when creating wallet |
| created\_at | datetime | Date Wallet Was Created             |

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

```php
$listWallet = $btcClient->listWallet([
    "offset" => 0,
    "limit" => 10
])
```

{% endtab %}
{% endtabs %}

## CreateWallet

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

#### Request Body

| Name | Type   | Description |
| ---- | ------ | ----------- |
| name | string | Wallet Name |

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

```javascript
{
    "id": 38,
    "name": "test",
    "seed_wif": "abcdefg"
}
```

{% endtab %}
{% endtabs %}

### Response

| Name      | Type   | Content                                                                   |
| --------- | ------ | ------------------------------------------------------------------------- |
| id        | id     | Unique ID of the wallet                                                   |
| name      | string | Wallet name                                                               |
| seed\_wif | string | Seed private key of wallet(This key is not stored on the blocksdk server) |

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

```php
$wallet = $btcClient->createWallet([
    "name" => "test"
]);
```

{% endtab %}
{% endtabs %}

## LoadWallet

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

Load your wallet.\
The loaded wallet does not require seed\_wif when using CreateAddress,SendToAddress,SendMany\
\
※It is not recommended to use

#### Path Parameters

| Name       | Type   | Description      |
| ---------- | ------ | ---------------- |
| wallet\_id | number | Wallet Unique ID |

#### Request Body

| Name      | Type   | Description                                          |
| --------- | ------ | ---------------------------------------------------- |
| password  | string | Password to use when creating transaction or address |
| seed\_wif | string | Wallet seed private key                              |

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

```
[]
```

{% endtab %}
{% endtabs %}

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

```php
$load = $btcClient->loadWallet([
    "wallet_id" => 999,
    "seed_wif" => "abcdefg",
    "password" => "abcdefg"
]);
```

{% endtab %}
{% endtabs %}

## UnloadWallet

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

#### Path Parameters

| Name       | Type   | Description      |
| ---------- | ------ | ---------------- |
| wallet\_id | number | Wallet Unique ID |

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

```
[]
```

{% endtab %}
{% endtabs %}

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

```php
$unload = $btcClient->unloadWallet([
    "wallet_id" => 999
]);
```

{% endtab %}
{% endtabs %}

## GetWalletBalance

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

#### Path Parameters

| Name       | Type   | Description      |
| ---------- | ------ | ---------------- |
| wallet\_id | number | Wallet Unique ID |

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

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

{% endtab %}
{% endtabs %}

### Response

| Name                 | Type   | Content                                                     |
| -------------------- | ------ | ----------------------------------------------------------- |
| balance              | double | Wallet Balance                                              |
| unconfirmed\_balance | double | Balance of transactions not included in the block of wallet |

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

```php
$walletBalance = $btcClient->getWalletBalance([
    "wallet_id" => 999
]);
```

{% endtab %}
{% endtabs %}

## ListWalletAddress

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

#### Path Parameters

| Name       | Type   | Description      |
| ---------- | ------ | ---------------- |
| wallet\_id | string | Wallet Unique ID |

#### Query Parameters

| Name      | Type   | Description                      |
| --------- | ------ | -------------------------------- |
| offset    | string | Number of Address to import      |
| limit     | string | Number of transactions to import |
| address   | string | Search by this address           |
| hdkeypath | string | Search by this hdkeypath         |

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

```javascript
{
    "items" : [
        {
            "address":"37sYsRooWpm7tpM9oEufWev9NkzZ77HXsx",
            "hdkeypath":"m\/0'\/0'\/0'"
        },
        {
            "address":"3Q8QaUXye8VsPEvAPgFee2941WsKxLiv5Q",
            "hdkeypath":"m\/0'\/0'\/1'"
        }
    ]
}
```

{% endtab %}
{% endtabs %}

### Response

| Name      | Type   | Content                                       |
| --------- | ------ | --------------------------------------------- |
| address   | string | Bitcoin Address                               |
| hdkeypath | string | The HD keypath if the key is HD and available |

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

```php
$listAddress = $btcClient->listWalletAddress([
    "wallet_id" => 999,
    "offset" => 0,
    "limit" => 10
]);
```

{% endtab %}
{% endtabs %}

## CreateWalletAddress

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

#### Path Parameters

| Name       | Type   | Description      |
| ---------- | ------ | ---------------- |
| wallet\_id | string | Wallet Unique ID |

#### Request Body

| Name      | Type   | Description                                                                        |
| --------- | ------ | ---------------------------------------------------------------------------------- |
| password  | string | Only available if the wallet is loaded.                                            |
| seed\_wif | string | Seed private key issued at wallet creation(Not necessary if your wallet is loaded) |

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

```javascript
{
    "address": "3C1XkY6eVTNoTwC78vcckj85HVavgwLSy3",
    "hdkeypath": "m/0'/0'/0'"
}
```

{% endtab %}
{% endtabs %}

### Response

| Name      | Type   | Content                                       |
| --------- | ------ | --------------------------------------------- |
| address   | string | Bitcoin Address                               |
| hdkeypath | string | The HD keypath if the key is HD and available |

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

```php
$address = $btcClient->createWalletAddress([
    "wallet_id" => 999,
    "seed_wif" => "abcdefg"
]);

or

$address = $btcClient->createWalletAddress([
    "wallet_id" => 999,
    "password" => "abcdefg"
]);
```

{% endtab %}
{% endtabs %}

## GetWalletTx

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

#### Path Parameters

| Name       | Type   | Description      |
| ---------- | ------ | ---------------- |
| wallet\_id | string | Wallet Unique ID |

#### Request Body

| Name     | Type   | Description                                           |
| -------- | ------ | ----------------------------------------------------- |
| category | string | Transaction type to import(all,receive,spent,unspent) |
| order    | string | Sort deals to import(desc,asc)                        |
| offset   | number | Number of Address to import                           |
| limit    | number | Address List offset                                   |

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

```javascript
{
   "items" : [
       {
            "txid":"a7b554f194ee00a241c9176e71f872d561ddcfac8c4610230cf0502f085a04b4",
            "category":"receive",
            "address":"3M8QmmzQjGVGQ9B3tdFb5F2eRXABu5z1FJ",
            "amount":0.0001,
            "confirmations":0
        },
        {
            "txid":"a7b554f194ee00a241c9176e71f872d561ddcfac8c4610230cf0502f085a04b4",
            "category":"receive",
            "address":"3BZaHZ7dUch839qpS6iXJygoRJqNuJJGw8",
            "amount":0.0001,
            "confirmations":0
        }
    ]
}
```

{% endtab %}
{% endtabs %}

### Response

| Name          | Type   | Content                                |
| ------------- | ------ | -------------------------------------- |
| txid          | string | Transaction hash                       |
| category      | string | receive or spent                       |
| address       | string | Address where the transaction occurred |
| amount        | double | Transaction balance amount             |
| confirmations | int    | Transaction Confirmation Count         |

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

```php
$walletTx = $btcClient->getWalletTx([
    "wallet_id" => 999,
    "category" => "all",
    "order" => "desc",
    "offset" => 0,
    "limit" => 10
]);
```

{% endtab %}
{% endtabs %}

## SendToAddress

<mark style="color:green;">`POST`</mark> `https://api.blocksdk.com/v1/btc/wallet/{wallet_id}/sendtoaddress`

&#x20;

#### Path Parameters

| Name       | Type   | Description      |
| ---------- | ------ | ---------------- |
| wallet\_id | string | Wallet Unique ID |

#### Request Body

| Name                  | Type    | Description                                                                                                                    |
| --------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------ |
| subtractfeefromamount | boolean | The fee will be deducted from the amount being sent. The recipient will receive less coins than you enter in the amount field. |
| password              | string  | Only available if the wallet is loaded.                                                                                        |
| kbfee                 | number  | Fee per kilobytes to be used for transactions                                                                                  |
| seed\_wif             | string  | Seed private key issued at wallet creation(Not necessary if your wallet is loaded)                                             |
| amount                | number  | balance to be sent                                                                                                             |
| address               | string  | Bitcoin Address to Receive                                                                                                     |

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

```javascript
{
	"txid":"892235a5aa0f52c2240603e9ca55012f0c76fee688623961003eae1f0ede4506",
	"hash":"892235a5aa0f52c2240603e9ca55012f0c76fee688623961003eae1f0ede4506",
	"version":2,
	"size":292,
	"vin":[
		{
			"txid":"4f8d383fc972843209779c0f35f6e3fec244167561660fc85bb2f15657564487",
			"vout":2,
			"scriptSig":{
				"asm":"3045022100fba461d3d8a83afb6d771f67fb1ac066ca3471c390940a7965256199752797ac0220656921deac061b8ec7d44a0c8efe8a74195e858db4d77c1f6c5a74464d8a3b3801 047146f0e0fcb3139947cf0beb870fe251930ca10d4545793d31033e801b5219abf56c11a3cf3406ca590e4c14b0dab749d20862b3adc4709153c280c2a78be10c",
				"hex":"483045022100fba461d3d8a83afb6d771f67fb1ac066ca3471c390940a7965256199752797ac0220656921deac061b8ec7d44a0c8efe8a74195e858db4d77c1f6c5a74464d8a3b380141047146f0e0fcb3139947cf0beb870fe251930ca10d4545793d31033e801b5219abf56c11a3cf3406ca590e4c14b0dab749d20862b3adc4709153c280c2a78be10c"
			},
			"addresses":["17A16QmavnUfCW11DAApiJxp7ARnxN5pGX"],
			"value":6.52039025
		}
	],
	"total_in":6.52039025,
	"vout":[
		{
			"value":1.70478869,
			"n":0,
			"scriptPubKey":{
				"type":"pubkeyhash",
				"asm":"OP_DUP OP_HASH160 82441821d7ab938c03f607b138aed7ea4c0aad30 OP_EQUALVERIFY OP_CHECKSIG",
				"hex":"76a91482441821d7ab938c03f607b138aed7ea4c0aad3088ac"
			},
			"addresses":["1CsnRDDDdS64nJqwF687rncuk3ndQa4dag"]
		},
		{
			"value":2.50850000,
			"n":1,
			"scriptPubKey":{
				"type":"pubkeyhash",
				"asm":"OP_DUP OP_HASH160 76bf865e630ed0ccfa7a0f75447aa533aa02260c OP_EQUALVERIFY OP_CHECKSIG",
				"hex":"76a91476bf865e630ed0ccfa7a0f75447aa533aa02260c88ac"
			},
			"addresses":["1BptB22qiHQcenFyAFAgkmqBprxHx9dxrJ"]
		},
		{
			"value":2.30610156,
			"n":2,
			"scriptPubKey":{
				"type":"pubkeyhash",
				"asm":"OP_DUP OP_HASH160 43849383122ebb8a28268a89700c9f723663b5b8 OP_EQUALVERIFY OP_CHECKSIG",
				"hex":"76a91443849383122ebb8a28268a89700c9f723663b5b888ac"
			},
			"addresses":["17A16QmavnUfCW11DAApiJxp7ARnxN5pGX"]
		}
	],
	"total_out":6.51939025,
	"in_count":1,
	"out_count":3,
	"fee":"0.00100000",
	"fee_per_kb":0.00342466,
	"locktime":0,
	"block_hash":"00000000000000000004238de85af7921db3f2edad78fed165156b33900a33c4",
	"block_height":608168,
	"time":1576378457,
	"confirmations":4
}
```

{% endtab %}
{% endtabs %}

### Response

Return [Tx](/api/bitcoin.md#tx) on Success

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

```php
$tx = $btcClient->sendToAddress([
    "wallet_id" => 999,
    "seed_wif" => "abcdefg",
    "address" => "3DRqFYMG2dFpVb8uTpCu8WoBhRBQ2FCphb",
    "amount" => 0.1,
    "kbfee" => 0.0001
])

or

$tx = $btcClient->sendToAddress([
    "wallet_id" => 999,
    "password" => "abcdefg",
    "address" => "3DRqFYMG2dFpVb8uTpCu8WoBhRBQ2FCphb",
    "amount" => 0.1,
    "kbfee" => 0.0001
])
```

{% endtab %}
{% endtabs %}

## SendMany

<mark style="color:green;">`POST`</mark> `https://api.blocksdk.com/v1/btc/wallet/{wallet_id}/sendmany`

#### Path Parameters

| Name       | Type   | Description      |
| ---------- | ------ | ---------------- |
| wallet\_id | string | Wallet Unique ID |

#### Request Body

| Name                  | Type    | Description                                                                                                                    |
| --------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------ |
| subtractfeefromamount | boolean | The fee will be deducted from the amount being sent. The recipient will receive less coins than you enter in the amount field. |
| password              | string  | Only available if the wallet is loaded.                                                                                        |
| to                    | object  | Receiving Information                                                                                                          |
| kbfee                 | number  | Fee per kilobytes to be used for transactions                                                                                  |
| seed\_wif             | string  | Seed private key issued at wallet creation(Not necessary if your wallet is loaded)                                             |

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

```javascript
{
	"txid":"892235a5aa0f52c2240603e9ca55012f0c76fee688623961003eae1f0ede4506",
	"hash":"892235a5aa0f52c2240603e9ca55012f0c76fee688623961003eae1f0ede4506",
	"version":2,
	"size":292,
	"vin":[
		{
			"txid":"4f8d383fc972843209779c0f35f6e3fec244167561660fc85bb2f15657564487",
			"vout":2,
			"scriptSig":{
				"asm":"3045022100fba461d3d8a83afb6d771f67fb1ac066ca3471c390940a7965256199752797ac0220656921deac061b8ec7d44a0c8efe8a74195e858db4d77c1f6c5a74464d8a3b3801 047146f0e0fcb3139947cf0beb870fe251930ca10d4545793d31033e801b5219abf56c11a3cf3406ca590e4c14b0dab749d20862b3adc4709153c280c2a78be10c",
				"hex":"483045022100fba461d3d8a83afb6d771f67fb1ac066ca3471c390940a7965256199752797ac0220656921deac061b8ec7d44a0c8efe8a74195e858db4d77c1f6c5a74464d8a3b380141047146f0e0fcb3139947cf0beb870fe251930ca10d4545793d31033e801b5219abf56c11a3cf3406ca590e4c14b0dab749d20862b3adc4709153c280c2a78be10c"
			},
			"addresses":["17A16QmavnUfCW11DAApiJxp7ARnxN5pGX"],
			"value":6.52039025
		}
	],
	"total_in":6.52039025,
	"vout":[
		{
			"value":1.70478869,
			"n":0,
			"scriptPubKey":{
				"type":"pubkeyhash",
				"asm":"OP_DUP OP_HASH160 82441821d7ab938c03f607b138aed7ea4c0aad30 OP_EQUALVERIFY OP_CHECKSIG",
				"hex":"76a91482441821d7ab938c03f607b138aed7ea4c0aad3088ac"
			},
			"addresses":["1CsnRDDDdS64nJqwF687rncuk3ndQa4dag"]
		},
		{
			"value":2.50850000,
			"n":1,
			"scriptPubKey":{
				"type":"pubkeyhash",
				"asm":"OP_DUP OP_HASH160 76bf865e630ed0ccfa7a0f75447aa533aa02260c OP_EQUALVERIFY OP_CHECKSIG",
				"hex":"76a91476bf865e630ed0ccfa7a0f75447aa533aa02260c88ac"
			},
			"addresses":["1BptB22qiHQcenFyAFAgkmqBprxHx9dxrJ"]
		},
		{
			"value":2.30610156,
			"n":2,
			"scriptPubKey":{
				"type":"pubkeyhash",
				"asm":"OP_DUP OP_HASH160 43849383122ebb8a28268a89700c9f723663b5b8 OP_EQUALVERIFY OP_CHECKSIG",
				"hex":"76a91443849383122ebb8a28268a89700c9f723663b5b888ac"
			},
			"addresses":["17A16QmavnUfCW11DAApiJxp7ARnxN5pGX"]
		}
	],
	"total_out":6.51939025,
	"in_count":1,
	"out_count":3,
	"fee":0.001,
	"fee_per_kb":0.00342466,
	"locktime":0,
	"block_hash":"00000000000000000004238de85af7921db3f2edad78fed165156b33900a33c4",
	"block_height":608168,
	"time":1576378457,
	"confirmations":4
}
```

{% endtab %}
{% endtabs %}

### Example PostData

```
{
   "to":{
     	"3BZaHZ7dUch839qpS6iXJygoRJqNuJJGw8":0.0001,
		 "3M8QmmzQjGVGQ9B3tdFb5F2eRXABu5z1FJ":0.0001
   },
   "kbfee":0.00001,
   "seed_wif" : "abcdefg"
}
```

### Response

Return [Tx](/api/bitcoin.md#tx) on Success

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

```php
$tx = $btcClient->sendMany([
    "wallet_id" => 999,
    "seed_wif" => "abcdefg",
    "to" => [
        "3BZaHZ7dUch839qpS6iXJygoRJqNuJJGw8" => 0.0001,
        "3M8QmmzQjGVGQ9B3tdFb5F2eRXABu5z1FJ" => 0.0001
    ],
    "kbfee" => 0.0001,
    "seed_wif" => "abcdefg"
]);

or

$tx = $btcClient->sendMany([
    "wallet_id" => 999,
    "password" => "abcdefg",
    "to" => [
        "3BZaHZ7dUch839qpS6iXJygoRJqNuJJGw8" => 0.0001,
        "3M8QmmzQjGVGQ9B3tdFb5F2eRXABu5z1FJ" => 0.0001
    ],
    "kbfee" => 0.0001,
    "seed_wif" => "abcdefg"
]);
```

{% endtab %}
{% endtabs %}

## GetTransaction

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

#### Path Parameters

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

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

```javascript
{
	"txid":"892235a5aa0f52c2240603e9ca55012f0c76fee688623961003eae1f0ede4506",
	"hash":"892235a5aa0f52c2240603e9ca55012f0c76fee688623961003eae1f0ede4506",
	"version":2,
	"size":292,
	"vin":[
		{
			"txid":"4f8d383fc972843209779c0f35f6e3fec244167561660fc85bb2f15657564487",
			"vout":2,
			"scriptSig":{
				"asm":"3045022100fba461d3d8a83afb6d771f67fb1ac066ca3471c390940a7965256199752797ac0220656921deac061b8ec7d44a0c8efe8a74195e858db4d77c1f6c5a74464d8a3b3801 047146f0e0fcb3139947cf0beb870fe251930ca10d4545793d31033e801b5219abf56c11a3cf3406ca590e4c14b0dab749d20862b3adc4709153c280c2a78be10c",
				"hex":"483045022100fba461d3d8a83afb6d771f67fb1ac066ca3471c390940a7965256199752797ac0220656921deac061b8ec7d44a0c8efe8a74195e858db4d77c1f6c5a74464d8a3b380141047146f0e0fcb3139947cf0beb870fe251930ca10d4545793d31033e801b5219abf56c11a3cf3406ca590e4c14b0dab749d20862b3adc4709153c280c2a78be10c"
			},
			"addresses":["17A16QmavnUfCW11DAApiJxp7ARnxN5pGX"],
			"value":6.52039025
		}
	],
	"total_in":6.52039025,
	"vout":[
		{
			"value":1.70478869,
			"n":0,
			"scriptPubKey":{
				"type":"pubkeyhash",
				"asm":"OP_DUP OP_HASH160 82441821d7ab938c03f607b138aed7ea4c0aad30 OP_EQUALVERIFY OP_CHECKSIG",
				"hex":"76a91482441821d7ab938c03f607b138aed7ea4c0aad3088ac"
			},
			"addresses":["1CsnRDDDdS64nJqwF687rncuk3ndQa4dag"]
		},
		{
			"value":2.50850000,
			"n":1,
			"scriptPubKey":{
				"type":"pubkeyhash",
				"asm":"OP_DUP OP_HASH160 76bf865e630ed0ccfa7a0f75447aa533aa02260c OP_EQUALVERIFY OP_CHECKSIG",
				"hex":"76a91476bf865e630ed0ccfa7a0f75447aa533aa02260c88ac"
			},
			"addresses":["1BptB22qiHQcenFyAFAgkmqBprxHx9dxrJ"]
		},
		{
			"value":2.30610156,
			"n":2,
			"scriptPubKey":{
				"type":"pubkeyhash",
				"asm":"OP_DUP OP_HASH160 43849383122ebb8a28268a89700c9f723663b5b8 OP_EQUALVERIFY OP_CHECKSIG",
				"hex":"76a91443849383122ebb8a28268a89700c9f723663b5b888ac"
			},
			"addresses":["17A16QmavnUfCW11DAApiJxp7ARnxN5pGX"]
		}
	],
	"total_out":6.51939025,
	"in_count":1,
	"out_count":3,
	"fee":0.001,
	"fee_per_kb":0.00342466,
	"locktime":0,
	"block_hash":"00000000000000000004238de85af7921db3f2edad78fed165156b33900a33c4",
	"block_height":608168,
	"time":1576378457,
	"confirmations":4
}
```

{% endtab %}
{% endtabs %}

### Response

Return [Tx](/api/bitcoin.md#tx) on Success

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

```php
$tx = $btcClient->getTransaction([
    "hash" => "892235a5aa0f52c2240603e9ca55012f0c76fee688623961003eae1f0ede4506	"
]);
```

{% endtab %}
{% endtabs %}

## TransactionTracking

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

Beta.Track sent and received transactions

#### Path Parameters

| Name | Type   | Description    |
| ---- | ------ | -------------- |
| hash | string | Transaction ID |

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

```
{
    "txid" : "407f7a89c29bbf5f268ea4e78ad40feb380391acc71d4f79f911391dccfbf54a",
    "height" : 610000,
    "input" : {...},
    "output" : {...},
    "time" : 1577447627
}
```

{% endtab %}
{% endtabs %}

### Response

#### TrackingObject

| Name      | Type                   | Content                                                    |
| --------- | ---------------------- | ---------------------------------------------------------- |
| txid      | string                 | Transaction ID                                             |
| height    | int                    | Height of the block containing this transaction            |
| addresses | Object                 | Addresses and amounts used or received in this transaction |
| input     | array\[TrackingObject] | List of inputs used in this transaction                    |
| output    | array\[TrackingObject] | List of outputs that received this transaction             |
| time      | int                    | Time when this transaction was included in the block       |

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

```php
$trackingData = $btcClient->getTransactionTracking([
    "hash" => "407f7a89c29bbf5f268ea4e78ad40feb380391acc71d4f79f911391dccfbf54a"
]);
```

{% endtab %}
{% endtabs %}

## SendTransaction

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

#### Request Body

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

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

```javascript
{
	"txid":"892235a5aa0f52c2240603e9ca55012f0c76fee688623961003eae1f0ede4506",
	"hash":"892235a5aa0f52c2240603e9ca55012f0c76fee688623961003eae1f0ede4506",
	"version":2,
	"size":292,
	"vin":[
		{
			"txid":"4f8d383fc972843209779c0f35f6e3fec244167561660fc85bb2f15657564487",
			"vout":2,
			"scriptSig":{
				"asm":"3045022100fba461d3d8a83afb6d771f67fb1ac066ca3471c390940a7965256199752797ac0220656921deac061b8ec7d44a0c8efe8a74195e858db4d77c1f6c5a74464d8a3b3801 047146f0e0fcb3139947cf0beb870fe251930ca10d4545793d31033e801b5219abf56c11a3cf3406ca590e4c14b0dab749d20862b3adc4709153c280c2a78be10c",
				"hex":"483045022100fba461d3d8a83afb6d771f67fb1ac066ca3471c390940a7965256199752797ac0220656921deac061b8ec7d44a0c8efe8a74195e858db4d77c1f6c5a74464d8a3b380141047146f0e0fcb3139947cf0beb870fe251930ca10d4545793d31033e801b5219abf56c11a3cf3406ca590e4c14b0dab749d20862b3adc4709153c280c2a78be10c"
			},
			"addresses":["17A16QmavnUfCW11DAApiJxp7ARnxN5pGX"],
			"value":6.52039025
		}
	],
	"total_in":6.52039025,
	"vout":[
		{
			"value":1.70478869,
			"n":0,
			"scriptPubKey":{
				"type":"pubkeyhash",
				"asm":"OP_DUP OP_HASH160 82441821d7ab938c03f607b138aed7ea4c0aad30 OP_EQUALVERIFY OP_CHECKSIG",
				"hex":"76a91482441821d7ab938c03f607b138aed7ea4c0aad3088ac"
			},
			"addresses":["1CsnRDDDdS64nJqwF687rncuk3ndQa4dag"]
		},
		{
			"value":2.50850000,
			"n":1,
			"scriptPubKey":{
				"type":"pubkeyhash",
				"asm":"OP_DUP OP_HASH160 76bf865e630ed0ccfa7a0f75447aa533aa02260c OP_EQUALVERIFY OP_CHECKSIG",
				"hex":"76a91476bf865e630ed0ccfa7a0f75447aa533aa02260c88ac"
			},
			"addresses":["1BptB22qiHQcenFyAFAgkmqBprxHx9dxrJ"]
		},
		{
			"value":2.30610156,
			"n":2,
			"scriptPubKey":{
				"type":"pubkeyhash",
				"asm":"OP_DUP OP_HASH160 43849383122ebb8a28268a89700c9f723663b5b8 OP_EQUALVERIFY OP_CHECKSIG",
				"hex":"76a91443849383122ebb8a28268a89700c9f723663b5b888ac"
			},
			"addresses":["17A16QmavnUfCW11DAApiJxp7ARnxN5pGX"]
		}
	],
	"total_out":6.51939025,
	"in_count":1,
	"out_count":3,
	"fee":0.001,
	"fee_per_kb":0.00342466,
	"locktime":0,
	"block_hash":"00000000000000000004238de85af7921db3f2edad78fed165156b33900a33c4",
	"block_height":608168,
	"time":1576378457,
	"confirmations":4
}
```

{% endtab %}
{% endtabs %}

### Response

Return [Tx](/api/bitcoin.md#tx) on Success

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

```php
$tx = $btcClient->sendTransaction([
    "sign_hex" => "abcdefg"
])
```

{% endtab %}
{% endtabs %}
