NAV Navigation
Shell Node.js

ONCHAIN.IO API overview v2

Scroll down for code samples, example requests and responses. Select a language for code samples from the tabs above or the mobile navigation menu.

Base URLs:

Authentication

Address API

Get Balance

Code samples

# You can also use wget
curl -X GET https://onchain.io/api/address/balance/{coin}/{address} \
  -H 'Accept: application/json' \
  -H 'X-API-KEY: API_KEY'

const fetch = require('node-fetch');

const headers = {
  'Accept':'application/json',
  'X-API-KEY':'API_KEY'

};

fetch('https://onchain.io/api/address/balance/{coin}/{address}',
{
  method: 'GET',

  headers: headers
})
.then(function(res) {
    return res.json();
}).then(function(body) {
    console.log(body);
});

GET /address/balance/{coin}/{address}

Get Balance

Returns the satoshi balance, usd balance and user viewable balance for an address. For ERC20 tokens you need to pass in the contract ID and the number of decimal places.

Parameters

Name In Type Required Description
coin path coin true The name of the coin i.e. bitcoin
address path string true The public address to lookup
contract_id query string false The contract ID of the ERC20 token.
decimal_places query integer false The number of decimal places for this contract.

Enumerated Values

Parameter Value
coin bitcoin
coin testnet3
coin litecoin
coin ethereum
coin bitcoin_private
coin bitcoin_gold
coin bitcoin_cash
coin dash
coin zcash
coin zclassic

Example responses

200 Response

{
  "usd_balance": 120.34,
  "balance": 27018060,
  "unconfirmed_balance": 27018060,
  "human_balance": 0.2701806,
  "human_unconfirmed_balance": 0.2701806
}

Responses

Status Meaning Description Schema
200 OK Returns the balances balance
default Default If an error occurs error_message

Get Balances

Code samples

# You can also use wget
curl -X GET https://onchain.io/api/address/balances/{coin}/{addresses} \
  -H 'Accept: application/json' \
  -H 'X-API-KEY: API_KEY'

const fetch = require('node-fetch');

const headers = {
  'Accept':'application/json',
  'X-API-KEY':'API_KEY'

};

fetch('https://onchain.io/api/address/balances/{coin}/{addresses}',
{
  method: 'GET',

  headers: headers
})
.then(function(res) {
    return res.json();
}).then(function(body) {
    console.log(body);
});

GET /address/balances/{coin}/{addresses}

Get Balances

Returns the satoshi balance, usd balance and user viewable balance for a set of addresses

Parameters

Name In Type Required Description
coin path coin true The name of the coin i.e. bitcoin
addresses path string true A comma seperated list of public addresses
contract_id query string false The contract ID of the ERC20 token.
decimal_places query integer false The number of decimal places for this contract.

Enumerated Values

Parameter Value
coin bitcoin
coin testnet3
coin litecoin
coin ethereum
coin bitcoin_private
coin bitcoin_gold
coin bitcoin_cash
coin dash
coin zcash
coin zclassic

Example responses

200 Response

{
  "totals": {
    "usd_balance": 120.34,
    "balance": 27018060,
    "unconfirmed_balance": 27018060,
    "human_balance": 0.2701806,
    "human_unconfirmed_balance": 0.2701806
  },
  "addresses": [
    {
      "address": "1KFHE7w8BhaENAswwryaoccDb6qcT6DbYY",
      "usd_balance": 120.34,
      "balance": 27018060,
      "unconfirmed_balance": 27018060,
      "human_balance": 0.2701806,
      "human_unconfirmed_balance": 0.2701806
    }
  ]
}

Responses

Status Meaning Description Schema
200 OK Returns the balances balances
default Default If an error occurs error_message

Get History

Code samples

# You can also use wget
curl -X GET https://onchain.io/api/address/history/{coin}/{addresses} \
  -H 'Accept: application/json' \
  -H 'X-API-KEY: API_KEY'

const fetch = require('node-fetch');

const headers = {
  'Accept':'application/json',
  'X-API-KEY':'API_KEY'

};

fetch('https://onchain.io/api/address/history/{coin}/{addresses}',
{
  method: 'GET',

  headers: headers
})
.then(function(res) {
    return res.json();
}).then(function(body) {
    console.log(body);
});

GET /address/history/{coin}/{addresses}

Get History

Returns the transaction history for an address or addresses.

Parameters

Name In Type Required Description
coin path coin true The name of the coin i.e. bitcoin
addresses path string true A comma seperated list of public addresses
contract_id query string false The contract ID of the ERC20 token.
decimal_places query integer false The number of decimal places for this contract.

Enumerated Values

Parameter Value
coin bitcoin
coin testnet3
coin litecoin
coin ethereum
coin bitcoin_private
coin bitcoin_gold
coin bitcoin_cash
coin dash
coin zcash
coin zclassic

Example responses

200 Response

{
  "total_txs": 37000,
  "txs": [
    {
      "confirmations": 3,
      "time": 1524579200,
      "is_deposit": true,
      "address": "1KFHE7w8BhaENAswwryaoccDb6qcT6DbYY",
      "amount": 27018060,
      "human_amount": 0.2701806
    }
  ]
}

Responses

Status Meaning Description Schema
200 OK Returns the transaction history for an address or addresses history
default Default If an error occurs error_message

Get Unspent

Code samples

# You can also use wget
curl -X GET https://onchain.io/api/address/utxos/{coin}/{addresses} \
  -H 'Accept: application/json' \
  -H 'X-API-KEY: API_KEY'

const fetch = require('node-fetch');

const headers = {
  'Accept':'application/json',
  'X-API-KEY':'API_KEY'

};

fetch('https://onchain.io/api/address/utxos/{coin}/{addresses}',
{
  method: 'GET',

  headers: headers
})
.then(function(res) {
    return res.json();
}).then(function(body) {
    console.log(body);
});

GET /address/utxos/{coin}/{addresses}

Get Unspent Outs

Returns the unspent outputs for an address or addresses.

Parameters

Name In Type Required Description
coin path coin true The name of the coin i.e. bitcoin
addresses path string true A comma seperated list of public addresses

Enumerated Values

Parameter Value
coin bitcoin
coin testnet3
coin litecoin
coin ethereum
coin bitcoin_private
coin bitcoin_gold
coin bitcoin_cash
coin dash
coin zcash
coin zclassic

Example responses

200 Response

{
  "utxos": [
    {
      "amount": 395260,
      "vout": 1,
      "txid": "9bd89c6555d42a2e0922f32f9227440def71ffc4e03ac6eda4c79ebbc0ceed1f",
      "script_pub_key": "76a91404d075b3f501deeef5565143282b6cfe8fad5e9488ac"
    }
  ]
}

Responses

Status Meaning Description Schema
200 OK Returns the unspent outputs for an address or addresses utxos
default Default If an error occurs error_message

To Network Addresses

Code samples

# You can also use wget
curl -X POST https://onchain.io/api/address/to_network_addresses \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'X-API-KEY: API_KEY'

const fetch = require('node-fetch');
const inputBody = '{
  "number_of_required_signatures": 2,
  "master_keys": [
    {
      "xpub": "xpub6CUGRUonZSQ4TWtTMmzXdrXDtypWKiKrhko4egpiMZbpiaQL2jkwSB1icqYh2cfDfVxdx4df189oLKnC5fSwqPfgyP3hooxujYzAu3fDVmz",
      "path": "m/0'/2"
    }
  ]
}';
const headers = {
  'Content-Type':'application/json',
  'Accept':'application/json',
  'X-API-KEY':'API_KEY'

};

fetch('https://onchain.io/api/address/to_network_addresses',
{
  method: 'POST',
  body: inputBody,
  headers: headers
})
.then(function(res) {
    return res.json();
}).then(function(body) {
    console.log(body);
});

POST /address/to_network_addresses

To Network Address

Convert xpub single and multisig paths to network addresses. If the number of requires signatures is non zero then we will generate multi signature addresses.

Body parameter

{
  "number_of_required_signatures": 2,
  "master_keys": [
    {
      "xpub": "xpub6CUGRUonZSQ4TWtTMmzXdrXDtypWKiKrhko4egpiMZbpiaQL2jkwSB1icqYh2cfDfVxdx4df189oLKnC5fSwqPfgyP3hooxujYzAu3fDVmz",
      "path": "m/0'/2"
    }
  ]
}

Parameters

Name In Type Required Description
body body extended_keys true none

Example responses

200 Response

[
  {
    "addresses": [
      {
        "network_address": "string",
        "coin": "string"
      }
    ],
    "public_keys": [
      "0250863AD64A87AE8A2FE83C1AF1A8403CB53F53E486D8511DAD8A04887E5B2352"
    ]
  }
]

Responses

Status Meaning Description Schema
200 OK Returns the unspent outputs for an address or addresses Inline
default Default If an error occurs error_message

Response Schema

Status Code 200

Name Type Required Restrictions Description
anonymous [network_addresses] false none none
» addresses [network_address] false none none
»» network_address string false none none
»» coin string false none none
» public_keys [string] false none none

Transaction API

Create

Code samples

# You can also use wget
curl -X POST https://onchain.io/api/transaction/create/{coin}?to=2MttUxQo4jjyVtb5Br49WUEy3LZoZuwtba5&from=036f3972643ab052f9f77cbaf67f0e517180ac488453bde8cb27e9e3e1d6847d49&amount=80000 \
  -H 'Accept: application/json' \
  -H 'X-API-KEY: API_KEY'

const fetch = require('node-fetch');

const headers = {
  'Accept':'application/json',
  'X-API-KEY':'API_KEY'

};

fetch('https://onchain.io/api/transaction/create/{coin}?to=2MttUxQo4jjyVtb5Br49WUEy3LZoZuwtba5&from=036f3972643ab052f9f77cbaf67f0e517180ac488453bde8cb27e9e3e1d6847d49&amount=80000',
{
  method: 'POST',

  headers: headers
})
.then(function(res) {
    return res.json();
}).then(function(body) {
    console.log(body);
});

POST /transaction/create/{coin}

Create Unsigned Transaction

Create an unsigned transaction. OnChain returns the transaction for the specified coin in hex format along with a list of hashes that need to be signed.

Parameters

Name In Type Required Description
coin path coin true The name of the coin i.e. bitcoin
to query string true The address to send coins to.
from query string true The addresses we are sending coins from. OnChain will fetch unspent outs from each address in order until the amount to send is met. We use the public hex key of the address not the hash.
amount query integer true The amount we wish to send.
fee_address query string false An address to send fees to.
fee_amount query integer false The amount of fees to send.
miners_fee query integer false The amount to send to the miners.

Enumerated Values

Parameter Value
coin bitcoin
coin testnet3
coin litecoin
coin ethereum
coin bitcoin_private
coin bitcoin_gold
coin bitcoin_cash
coin dash
coin zcash
coin zclassic

Example responses

200 Response

{
  "tx": "02000000011cd5d7621e2a7c9403e54e089cb0b5430b83ed13f1b897d3e319b100ba1b059b01000000db00483045022100d7534c80bc0a42addc3d955f74e31610aa78bf15d79ec4df4c36dc98e802f5200220369cab1bccb2dbca0921444ce3fafb15129fa0494d041998be104df39b8895ec01483045022100fe48c4c1d46e163acaff6b0d2e702812d20",
  "total_input_value": 500000,
  "hashes": [
    {
      "input_index": 0,
      "public_key": "036f3972643ab052f9f77cbaf67f0e517180ac488453bde8cb27e9e3e1d6847d49",
      "hash_to_sign": "004cfaf7cff86e7f171db23d67acd6c986273e578d7466e43e2b78913e1ce7c7"
    }
  ]
}

Responses

Status Meaning Description Schema
200 OK The unsigned transaction in hex format and a list of hashes that need signatures. hashes_to_sign
default Default If an error occurs error_message

Sign and send

Code samples

# You can also use wget
curl -X POST https://onchain.io/api/transaction/sign_and_send/{coin} \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'X-API-KEY: API_KEY'

const fetch = require('node-fetch');
const inputBody = '{
  "tx": "string",
  "signatures": [
    {
      "hash_to_sign": "7a77eb8e0e9e56ca925473cbfaa215822b1bc73de40dc9098d66b2eb785af9db",
      "signature": "304402202915d9763c944918712155522ed99d1f01d7998c349316b5ba2d75ac41bb3dae022033b4d5800d2c5f461abf42a967625f77f4e16933bf9fa81aa753c423687eee02",
      "public_key": "036f3972643ab052f9f77cbaf67f0e517180ac488453bde8cb27e9e3e1d6847d49",
      "input_index": 0
    }
  ]
}';
const headers = {
  'Content-Type':'application/json',
  'Accept':'application/json',
  'X-API-KEY':'API_KEY'

};

fetch('https://onchain.io/api/transaction/sign_and_send/{coin}',
{
  method: 'POST',
  body: inputBody,
  headers: headers
})
.then(function(res) {
    return res.json();
}).then(function(body) {
    console.log(body);
});

POST /transaction/sign_and_send/{coin}

Sign and Send a Transaction

Sign and send transaction onto the network.

Body parameter

{
  "tx": "string",
  "signatures": [
    {
      "hash_to_sign": "7a77eb8e0e9e56ca925473cbfaa215822b1bc73de40dc9098d66b2eb785af9db",
      "signature": "304402202915d9763c944918712155522ed99d1f01d7998c349316b5ba2d75ac41bb3dae022033b4d5800d2c5f461abf42a967625f77f4e16933bf9fa81aa753c423687eee02",
      "public_key": "036f3972643ab052f9f77cbaf67f0e517180ac488453bde8cb27e9e3e1d6847d49",
      "input_index": 0
    }
  ]
}

Parameters

Name In Type Required Description
coin path coin true The name of the coin i.e. bitcoin
body body signatures true none

Enumerated Values

Parameter Value
coin bitcoin
coin testnet3
coin litecoin
coin ethereum
coin bitcoin_private
coin bitcoin_gold
coin bitcoin_cash
coin dash
coin zcash
coin zclassic

Example responses

200 Response

{
  "status_code": 200,
  "message": "3bcf74e3421148db08daf6f5787a698534046bff54b2af1b8252b9166f8f4749"
}

Responses

Status Meaning Description Schema
200 OK Send a transaction onto the network. send_status
default Default If an error occurs error_message

Send Raw

Code samples

# You can also use wget
curl -X POST https://onchain.io/api/transaction/send_raw/{coin}?rawtx=string \
  -H 'Accept: application/json' \
  -H 'X-API-KEY: API_KEY'

const fetch = require('node-fetch');

const headers = {
  'Accept':'application/json',
  'X-API-KEY':'API_KEY'

};

fetch('https://onchain.io/api/transaction/send_raw/{coin}?rawtx=string',
{
  method: 'POST',

  headers: headers
})
.then(function(res) {
    return res.json();
}).then(function(body) {
    console.log(body);
});

POST /transaction/send_raw/{coin}

Send Raw Transaction

Send a transaction onto the network.

Parameters

Name In Type Required Description
coin path coin true The name of the coin i.e. bitcoin
rawtx query string true The raw signed transaction as a hex string

Enumerated Values

Parameter Value
coin bitcoin
coin testnet3
coin litecoin
coin ethereum
coin bitcoin_private
coin bitcoin_gold
coin bitcoin_cash
coin dash
coin zcash
coin zclassic

Example responses

200 Response

{
  "status_code": 200,
  "message": "3bcf74e3421148db08daf6f5787a698534046bff54b2af1b8252b9166f8f4749"
}

Responses

Status Meaning Description Schema
200 OK Send a transaction onto the network. send_status
default Default If an error occurs error_message

Multisig

Create

Code samples

# You can also use wget
curl -X POST https://onchain.io/api/multi_sig/create/{coin} \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'X-API-KEY: API_KEY'

const fetch = require('node-fetch');
const inputBody = '{
  "number_of_required_signatures": 1,
  "amount": 100000,
  "to": "1F1tAaz5x1HUXrCNLbtMDqcw6o5GNn4xqX",
  "fee_amount": 100000,
  "fee_address": "1F1tAaz5x1HUXrCNLbtMDqcw6o5GNn4xqX",
  "miners_fee": 40000,
  "redeem_scripts": [
    {
      "public_keys": [
        "036f3972643ab052f9f77cbaf67f0e517180ac488453bde8cb27e9e3e1d6847d49"
      ]
    }
  ]
}';
const headers = {
  'Content-Type':'application/json',
  'Accept':'application/json',
  'X-API-KEY':'API_KEY'

};

fetch('https://onchain.io/api/multi_sig/create/{coin}',
{
  method: 'POST',
  body: inputBody,
  headers: headers
})
.then(function(res) {
    return res.json();
}).then(function(body) {
    console.log(body);
});

POST /multi_sig/create/{coin}

Create Unsigned Transaction

Create an unsigned transaction. OnChain returns the transaction for the specified coin in hex format along with a list of hashes that need to be signed.

Body parameter

{
  "number_of_required_signatures": 1,
  "amount": 100000,
  "to": "1F1tAaz5x1HUXrCNLbtMDqcw6o5GNn4xqX",
  "fee_amount": 100000,
  "fee_address": "1F1tAaz5x1HUXrCNLbtMDqcw6o5GNn4xqX",
  "miners_fee": 40000,
  "redeem_scripts": [
    {
      "public_keys": [
        "036f3972643ab052f9f77cbaf67f0e517180ac488453bde8cb27e9e3e1d6847d49"
      ]
    }
  ]
}

Parameters

Name In Type Required Description
coin path coin true none
body body multi_sig_payment true none

Enumerated Values

Parameter Value
coin bitcoin
coin testnet3
coin litecoin
coin ethereum
coin bitcoin_private
coin bitcoin_gold
coin bitcoin_cash
coin dash
coin zcash
coin zclassic

Example responses

200 Response

{
  "tx": "02000000011cd5d7621e2a7c9403e54e089cb0b5430b83ed13f1b897d3e319b100ba1b059b01000000db00483045022100d7534c80bc0a42addc3d955f74e31610aa78bf15d79ec4df4c36dc98e802f5200220369cab1bccb2dbca0921444ce3fafb15129fa0494d041998be104df39b8895ec01483045022100fe48c4c1d46e163acaff6b0d2e702812d20",
  "total_input_value": 500000,
  "hashes": [
    {
      "input_index": 0,
      "public_key": "036f3972643ab052f9f77cbaf67f0e517180ac488453bde8cb27e9e3e1d6847d49",
      "hash_to_sign": "004cfaf7cff86e7f171db23d67acd6c986273e578d7466e43e2b78913e1ce7c7"
    }
  ]
}

Responses

Status Meaning Description Schema
200 OK The unsigned transaction in hex format and a list of hashes that need signatures. hashes_to_sign
default Default If an error occurs error_message

Sign and send

Code samples

# You can also use wget
curl -X POST https://onchain.io/api/multi_sig/sign_and_send/{coin} \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'X-API-KEY: API_KEY'

const fetch = require('node-fetch');
const inputBody = '{
  "tx": "string",
  "signatures": [
    {
      "hash_to_sign": "7a77eb8e0e9e56ca925473cbfaa215822b1bc73de40dc9098d66b2eb785af9db",
      "signature": "304402202915d9763c944918712155522ed99d1f01d7998c349316b5ba2d75ac41bb3dae022033b4d5800d2c5f461abf42a967625f77f4e16933bf9fa81aa753c423687eee02",
      "public_key": "036f3972643ab052f9f77cbaf67f0e517180ac488453bde8cb27e9e3e1d6847d49",
      "input_index": 0
    }
  ]
}';
const headers = {
  'Content-Type':'application/json',
  'Accept':'application/json',
  'X-API-KEY':'API_KEY'

};

fetch('https://onchain.io/api/multi_sig/sign_and_send/{coin}',
{
  method: 'POST',
  body: inputBody,
  headers: headers
})
.then(function(res) {
    return res.json();
}).then(function(body) {
    console.log(body);
});

POST /multi_sig/sign_and_send/{coin}

Sign and Send a Transaction

Sign and send transaction onto the network.

Body parameter

{
  "tx": "string",
  "signatures": [
    {
      "hash_to_sign": "7a77eb8e0e9e56ca925473cbfaa215822b1bc73de40dc9098d66b2eb785af9db",
      "signature": "304402202915d9763c944918712155522ed99d1f01d7998c349316b5ba2d75ac41bb3dae022033b4d5800d2c5f461abf42a967625f77f4e16933bf9fa81aa753c423687eee02",
      "public_key": "036f3972643ab052f9f77cbaf67f0e517180ac488453bde8cb27e9e3e1d6847d49",
      "input_index": 0
    }
  ]
}

Parameters

Name In Type Required Description
coin path coin true The name of the coin i.e. bitcoin
body body signatures true none

Enumerated Values

Parameter Value
coin bitcoin
coin testnet3
coin litecoin
coin ethereum
coin bitcoin_private
coin bitcoin_gold
coin bitcoin_cash
coin dash
coin zcash
coin zclassic

Example responses

200 Response

{
  "status_code": 200,
  "message": "3bcf74e3421148db08daf6f5787a698534046bff54b2af1b8252b9166f8f4749"
}

Responses

Status Meaning Description Schema
200 OK Send a transaction onto the network. send_status
default Default If an error occurs error_message

Ethereum API

Create

Code samples

# You can also use wget
curl -X POST https://onchain.io/api/ethereum/create/?to=2.5329069089123447e%2B76&from=2.5329069089123447e%2B76&amount=80000 \
  -H 'Accept: application/json' \
  -H 'X-API-KEY: API_KEY'

const fetch = require('node-fetch');

const headers = {
  'Accept':'application/json',
  'X-API-KEY':'API_KEY'

};

fetch('https://onchain.io/api/ethereum/create/?to=2.5329069089123447e%2B76&from=2.5329069089123447e%2B76&amount=80000',
{
  method: 'POST',

  headers: headers
})
.then(function(res) {
    return res.json();
}).then(function(body) {
    console.log(body);
});

POST /ethereum/create/

Create Unsigned Transaction

Create an unsigned transaction. OnChain returns the ethereum transaction in hex format along with a hash that would need to be signed.

Parameters

Name In Type Required Description
to query string true The address to send Ether to.
from query string true The addresses we are sending ether from.
amount query integer true The amount we wish to send in GWEI.
gas_price query integer false The gas price to pay.
gas_limit query integer false The gas limit to use.

Example responses

200 Response

{
  "tx": "02000000011cd5d7621e2a7c9403e54e089cb0b5430b83ed13f1b897d3e319b100ba1b059b01000000db00483045022100d7534c80bc0a42addc3d955f74e31610aa78bf15d79ec4df4c36dc98e802f5200220369cab1bccb2dbca0921444ce3fafb15129fa0494d041998be104df39b8895ec01483045022100fe48c4c1d46e163acaff6b0d2e702812d20",
  "hash_to_sign": "955f74e31610aa78bf15d79ec4df4c36dc98e802f52002"
}

Responses

Status Meaning Description Schema
200 OK The unsigned transaction in hex format and the hash to sign. ethereum_to_sign
default Default If an error occurs error_message

Sign and send

Code samples

# You can also use wget
curl -X POST https://onchain.io/api/ethereum/sign_and_send/?to=2.5329069089123447e%2B76&from=2.5329069089123447e%2B76&amount=80000&r=37ffbebc90cd580b516d99cc53050e93a6cd5f&s=37ffbebc90cd580b516d99cc53050e93a6cd5f&v=52 \
  -H 'Accept: application/json' \
  -H 'X-API-KEY: API_KEY'

const fetch = require('node-fetch');

const headers = {
  'Accept':'application/json',
  'X-API-KEY':'API_KEY'

};

fetch('https://onchain.io/api/ethereum/sign_and_send/?to=2.5329069089123447e%2B76&from=2.5329069089123447e%2B76&amount=80000&r=37ffbebc90cd580b516d99cc53050e93a6cd5f&s=37ffbebc90cd580b516d99cc53050e93a6cd5f&v=52',
{
  method: 'POST',

  headers: headers
})
.then(function(res) {
    return res.json();
}).then(function(body) {
    console.log(body);
});

POST /ethereum/sign_and_send/

Sign and send transaction.

Sign and send transaction onto the Ethereum network.

Parameters

Name In Type Required Description
to query string true The address to send Ether to.
from query string true The addresses we are sending ether from.
amount query integer true The amount we wish to send in GWEI.
r query string true The signed r value.
s query string true The signed r value.
v query string true The signed r value.
gas_price query integer false The gas price to pay.
gas_limit query integer false The gas limit to use.

Example responses

200 Response

{
  "status_code": 200,
  "message": "3bcf74e3421148db08daf6f5787a698534046bff54b2af1b8252b9166f8f4749"
}

Responses

Status Meaning Description Schema
200 OK Send a transaction onto the network. send_status
default Default If an error occurs error_message

ERC20

Create

Code samples

# You can also use wget
curl -X POST https://onchain.io/api/erc20/create/?to=2.5329069089123447e%2B76&from=2.5329069089123447e%2B76&amount=80000&contract_id=6.058968844090876e%2B47&decimal_places=18 \
  -H 'Accept: application/json' \
  -H 'X-API-KEY: API_KEY'

const fetch = require('node-fetch');

const headers = {
  'Accept':'application/json',
  'X-API-KEY':'API_KEY'

};

fetch('https://onchain.io/api/erc20/create/?to=2.5329069089123447e%2B76&from=2.5329069089123447e%2B76&amount=80000&contract_id=6.058968844090876e%2B47&decimal_places=18',
{
  method: 'POST',

  headers: headers
})
.then(function(res) {
    return res.json();
}).then(function(body) {
    console.log(body);
});

POST /erc20/create/

Create Unsigned Transaction

Create an unsigned transaction. OnChain returns the ethereum transaction in hex format along with a hash that would need to be signed.

Parameters

Name In Type Required Description
to query string true The address to send Ether to.
from query string true The addresses we are sending ether from.
amount query integer true The amount we wish to send in GWEI.
contract_id query string true The contract ID of the ERC20 token.
decimal_places query integer true The number of decimal places for this contract.
gas_price query integer false The gas price to pay.
gas_limit query integer false The gas limit to use.

Example responses

200 Response

{
  "tx": "02000000011cd5d7621e2a7c9403e54e089cb0b5430b83ed13f1b897d3e319b100ba1b059b01000000db00483045022100d7534c80bc0a42addc3d955f74e31610aa78bf15d79ec4df4c36dc98e802f5200220369cab1bccb2dbca0921444ce3fafb15129fa0494d041998be104df39b8895ec01483045022100fe48c4c1d46e163acaff6b0d2e702812d20",
  "hash_to_sign": "955f74e31610aa78bf15d79ec4df4c36dc98e802f52002"
}

Responses

Status Meaning Description Schema
200 OK The unsigned transaction in hex format and the hash to sign. ethereum_to_sign
default Default If an error occurs error_message

Sign and send

Code samples

# You can also use wget
curl -X POST https://onchain.io/api/erc20/sign_and_send/?to=2.5329069089123447e%2B76&from=2.5329069089123447e%2B76&amount=80000&contract_id=6.058968844090876e%2B47&decimal_places=18&r=37ffbebc90cd580b516d99cc53050e93a6cd5f&s=37ffbebc90cd580b516d99cc53050e93a6cd5f&v=52 \
  -H 'Accept: application/json' \
  -H 'X-API-KEY: API_KEY'

const fetch = require('node-fetch');

const headers = {
  'Accept':'application/json',
  'X-API-KEY':'API_KEY'

};

fetch('https://onchain.io/api/erc20/sign_and_send/?to=2.5329069089123447e%2B76&from=2.5329069089123447e%2B76&amount=80000&contract_id=6.058968844090876e%2B47&decimal_places=18&r=37ffbebc90cd580b516d99cc53050e93a6cd5f&s=37ffbebc90cd580b516d99cc53050e93a6cd5f&v=52',
{
  method: 'POST',

  headers: headers
})
.then(function(res) {
    return res.json();
}).then(function(body) {
    console.log(body);
});

POST /erc20/sign_and_send/

Sign and send transaction.

Sign and send transaction onto the Ethereum network.

Parameters

Name In Type Required Description
to query string true The address to send Ether to.
from query string true The addresses we are sending ether from.
amount query integer true The amount we wish to send in GWEI.
contract_id query string true The contract ID of the ERC20 token.
decimal_places query integer true The number of decimal places for this contract.
r query string true The signed r value.
s query string true The signed r value.
v query string true The signed r value.
gas_price query integer false The gas price to pay.
gas_limit query integer false The gas limit to use.

Example responses

200 Response

{
  "status_code": 200,
  "message": "3bcf74e3421148db08daf6f5787a698534046bff54b2af1b8252b9166f8f4749"
}

Responses

Status Meaning Description Schema
200 OK Send a transaction onto the network. send_status
default Default If an error occurs error_message

Schemas

coin

"bitcoin"

Properties

None

extended_key

{
  "xpub": "xpub6CUGRUonZSQ4TWtTMmzXdrXDtypWKiKrhko4egpiMZbpiaQL2jkwSB1icqYh2cfDfVxdx4df189oLKnC5fSwqPfgyP3hooxujYzAu3fDVmz",
  "path": "m/0'/2"
}

Properties

Name Type Required Restrictions Description
xpub string false none none
path string false none none

extended_keys

{
  "number_of_required_signatures": 2,
  "master_keys": [
    {
      "xpub": "xpub6CUGRUonZSQ4TWtTMmzXdrXDtypWKiKrhko4egpiMZbpiaQL2jkwSB1icqYh2cfDfVxdx4df189oLKnC5fSwqPfgyP3hooxujYzAu3fDVmz",
      "path": "m/0'/2"
    }
  ]
}

Properties

Name Type Required Restrictions Description
number_of_required_signatures integer false none none
master_keys [extended_key] false none none

network_address

{
  "network_address": "string",
  "coin": "string"
}

Properties

Name Type Required Restrictions Description
network_address string false none none
coin string false none none

network_addresses

{
  "addresses": [
    {
      "network_address": "string",
      "coin": "string"
    }
  ],
  "public_keys": [
    "0250863AD64A87AE8A2FE83C1AF1A8403CB53F53E486D8511DAD8A04887E5B2352"
  ]
}

Properties

Name Type Required Restrictions Description
addresses [network_address] false none none
public_keys [string] false none none

balance

{
  "usd_balance": 120.34,
  "balance": 27018060,
  "unconfirmed_balance": 27018060,
  "human_balance": 0.2701806,
  "human_unconfirmed_balance": 0.2701806
}

Properties

Name Type Required Restrictions Description
usd_balance number false none none
balance integer false none none
unconfirmed_balance integer false none none
human_balance number false none none
human_unconfirmed_balance number false none none

addr_balance

{
  "address": "1KFHE7w8BhaENAswwryaoccDb6qcT6DbYY",
  "usd_balance": 120.34,
  "balance": 27018060,
  "unconfirmed_balance": 27018060,
  "human_balance": 0.2701806,
  "human_unconfirmed_balance": 0.2701806
}

Properties

Name Type Required Restrictions Description
address string false none none
usd_balance number false none none
balance integer false none none
unconfirmed_balance integer false none none
human_balance number false none none
human_unconfirmed_balance number false none none

balances

{
  "totals": {
    "usd_balance": 120.34,
    "balance": 27018060,
    "unconfirmed_balance": 27018060,
    "human_balance": 0.2701806,
    "human_unconfirmed_balance": 0.2701806
  },
  "addresses": [
    {
      "address": "1KFHE7w8BhaENAswwryaoccDb6qcT6DbYY",
      "usd_balance": 120.34,
      "balance": 27018060,
      "unconfirmed_balance": 27018060,
      "human_balance": 0.2701806,
      "human_unconfirmed_balance": 0.2701806
    }
  ]
}

Properties

Name Type Required Restrictions Description
totals balance false none none
addresses [addr_balance] false none none

tx

{
  "confirmations": 3,
  "time": 1524579200,
  "is_deposit": true,
  "address": "1KFHE7w8BhaENAswwryaoccDb6qcT6DbYY",
  "amount": 27018060,
  "human_amount": 0.2701806
}

Properties

Name Type Required Restrictions Description
confirmations integer false none none
time integer false none none
is_deposit boolean false none none
address string false none none
amount integer false none none
human_amount number false none none

utxo

{
  "amount": 395260,
  "vout": 1,
  "txid": "9bd89c6555d42a2e0922f32f9227440def71ffc4e03ac6eda4c79ebbc0ceed1f",
  "script_pub_key": "76a91404d075b3f501deeef5565143282b6cfe8fad5e9488ac"
}

Properties

Name Type Required Restrictions Description
amount integer false none none
vout integer false none none
txid string false none none
script_pub_key string false none none

utxos

{
  "utxos": [
    {
      "amount": 395260,
      "vout": 1,
      "txid": "9bd89c6555d42a2e0922f32f9227440def71ffc4e03ac6eda4c79ebbc0ceed1f",
      "script_pub_key": "76a91404d075b3f501deeef5565143282b6cfe8fad5e9488ac"
    }
  ]
}

Properties

Name Type Required Restrictions Description
utxos [utxo] false none none

history

{
  "total_txs": 37000,
  "txs": [
    {
      "confirmations": 3,
      "time": 1524579200,
      "is_deposit": true,
      "address": "1KFHE7w8BhaENAswwryaoccDb6qcT6DbYY",
      "amount": 27018060,
      "human_amount": 0.2701806
    }
  ]
}

Properties

Name Type Required Restrictions Description
total_txs integer false none none
txs [tx] false none none

hashes_to_sign

{
  "tx": "02000000011cd5d7621e2a7c9403e54e089cb0b5430b83ed13f1b897d3e319b100ba1b059b01000000db00483045022100d7534c80bc0a42addc3d955f74e31610aa78bf15d79ec4df4c36dc98e802f5200220369cab1bccb2dbca0921444ce3fafb15129fa0494d041998be104df39b8895ec01483045022100fe48c4c1d46e163acaff6b0d2e702812d20",
  "total_input_value": 500000,
  "hashes": [
    {
      "input_index": 0,
      "public_key": "036f3972643ab052f9f77cbaf67f0e517180ac488453bde8cb27e9e3e1d6847d49",
      "hash_to_sign": "004cfaf7cff86e7f171db23d67acd6c986273e578d7466e43e2b78913e1ce7c7"
    }
  ]
}

Properties

Name Type Required Restrictions Description
tx string false none none
total_input_value integer false none none
hashes [hash_to_sign] false none none

ethereum_to_sign

{
  "tx": "02000000011cd5d7621e2a7c9403e54e089cb0b5430b83ed13f1b897d3e319b100ba1b059b01000000db00483045022100d7534c80bc0a42addc3d955f74e31610aa78bf15d79ec4df4c36dc98e802f5200220369cab1bccb2dbca0921444ce3fafb15129fa0494d041998be104df39b8895ec01483045022100fe48c4c1d46e163acaff6b0d2e702812d20",
  "hash_to_sign": "955f74e31610aa78bf15d79ec4df4c36dc98e802f52002"
}

Properties

Name Type Required Restrictions Description
tx string false none none
hash_to_sign string false none none

hash_to_sign

{
  "input_index": 0,
  "public_key": "036f3972643ab052f9f77cbaf67f0e517180ac488453bde8cb27e9e3e1d6847d49",
  "hash_to_sign": "004cfaf7cff86e7f171db23d67acd6c986273e578d7466e43e2b78913e1ce7c7"
}

Properties

Name Type Required Restrictions Description
input_index integer false none none
public_key string false none none
hash_to_sign string false none none

signatures

{
  "tx": "string",
  "signatures": [
    {
      "hash_to_sign": "7a77eb8e0e9e56ca925473cbfaa215822b1bc73de40dc9098d66b2eb785af9db",
      "signature": "304402202915d9763c944918712155522ed99d1f01d7998c349316b5ba2d75ac41bb3dae022033b4d5800d2c5f461abf42a967625f77f4e16933bf9fa81aa753c423687eee02",
      "public_key": "036f3972643ab052f9f77cbaf67f0e517180ac488453bde8cb27e9e3e1d6847d49",
      "input_index": 0
    }
  ]
}

Properties

Name Type Required Restrictions Description
tx string false none none
signatures [signature] false none none

signature

{
  "hash_to_sign": "7a77eb8e0e9e56ca925473cbfaa215822b1bc73de40dc9098d66b2eb785af9db",
  "signature": "304402202915d9763c944918712155522ed99d1f01d7998c349316b5ba2d75ac41bb3dae022033b4d5800d2c5f461abf42a967625f77f4e16933bf9fa81aa753c423687eee02",
  "public_key": "036f3972643ab052f9f77cbaf67f0e517180ac488453bde8cb27e9e3e1d6847d49",
  "input_index": 0
}

Properties

Name Type Required Restrictions Description
hash_to_sign string false none none
signature string false none none
public_key string false none none
input_index integer false none none

redeem_script

{
  "public_keys": [
    "036f3972643ab052f9f77cbaf67f0e517180ac488453bde8cb27e9e3e1d6847d49"
  ]
}

Properties

Name Type Required Restrictions Description
public_keys [string] false none none

multi_sig_payment

{
  "number_of_required_signatures": 1,
  "amount": 100000,
  "to": "1F1tAaz5x1HUXrCNLbtMDqcw6o5GNn4xqX",
  "fee_amount": 100000,
  "fee_address": "1F1tAaz5x1HUXrCNLbtMDqcw6o5GNn4xqX",
  "miners_fee": 40000,
  "redeem_scripts": [
    {
      "public_keys": [
        "036f3972643ab052f9f77cbaf67f0e517180ac488453bde8cb27e9e3e1d6847d49"
      ]
    }
  ]
}

Properties

Name Type Required Restrictions Description
number_of_required_signatures integer false none none
amount integer false none none
to string false none none
fee_amount integer false none none
fee_address string false none none
miners_fee integer false none none
redeem_scripts [redeem_script] false none none

send_status

{
  "status_code": 200,
  "message": "3bcf74e3421148db08daf6f5787a698534046bff54b2af1b8252b9166f8f4749"
}

Properties

Name Type Required Restrictions Description
status_code integer false none none
message string false none none

error_message

{
  "message": "Something went wrong."
}

Properties

Name Type Required Restrictions Description
message string false none none