Ethereum

Create Ethereum Client

use BlockSDK;

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

or

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

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

GET https://api.blocksdk.com/v1/eth/block

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

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)

$blockChain = $ethClient->getBlockChain();

GetBlock

GET 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

{
    "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"
}

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

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

GetMemPool

GET 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

{
    "unconfirmed_count" : 10,
    "tx" : {...}
}
$pool = $ethClient->getMemPool([
    "rawtx" => true,
    "offset" => 0,
    "limit" => 10
]);

ListAddress

GET https://api.blocksdk.com/v1/eth/address

Query Parameters

Name
Type
Description

limit

string

Number of Address to import

offset

string

Address List offset

{
    "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"
        }
    ]    
}

Response

Name

type

Content

array

List of created addresses

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

CraeteAddress

POST https://api.blocksdk.com/v1/eth/address

Request Body

Name
Type
Description

name

string

Address name

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

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)

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

GetAddressInfo

GET 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

{
    "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
} 

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

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

GetAddressBalance

GET https://api.blocksdk.com/v1/eth/address/{address}/balance

Path Parameters

Name
Type
Description

address

string

Ethereum Address

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

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

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

SendToAddress

POST 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

{
    "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"
} 

Response

Return Tx on Success

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

SendTransaction

POST https://api.blocksdk.com/v1/eth/transaction

Request Body

Name
Type
Description

sign_hex

string

signed transaction hex

{
    "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"
} 

Response

Return Tx on Success

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

GetTransaction

GET https://api.blocksdk.com/v1/eth/transaction/{hash}

Path Parameters

Name
Type
Description

hash

string

transaction hash

{
    "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"
} 

Response

Return Tx on Success

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

LoadAddress

POST 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

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

UnloadAddress

POST https://api.blocksdk.com/v1/eth/address/{address}/unload

Path Parameters

Name
Type
Description

address

number

Ethereum Address

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

Last updated

Was this helpful?