NAV
cURL

Introduction

#   ^
#  / \    _               _
# / ^ \  |_) |  _   _ |  /     ._  |_   _  ._
#<     > |_) | (_) (_ |< \_ \/ |_) | | (/_ |
# \ v /                     /  |
#  \ /
#   v

Welcome to BlockCypher's Ethereum API documentation! If you're familiar with our Bitcoin endpoints, you'll feel right at home with our Ethereum API. However, there are a few differences, and they stem in part from the fundamental differences between Bitcoin and Ethereum. In the most abstract sense, Bitcoin and Ethereum are cousins; they both have "blocks" of transactions linked together into a chain, they both use Proof of Work to reach consensus (for now, as Ethereum plans to move to Proof of Stake in a future release), they are both about decentralizing trust. But that's where the similarities end. Here are just some of Ethereum's differences:

In a nutshell, Bitcoin is about decentralized, trust-minimizing, sound money. Ethereum is about decentralized, trust-minimizing, sound computation. Much more detail about these differences can be read at the Ethereum Wiki here. You can find more information at the project's webpage as well.

Documentation Structure

man curl | grep -A 3 "DESCRIPTION"

DESCRIPTION
curl is a tool to transfer data from or to a server, using one of the supported protocols (DICT, FILE, FTP, FTPS, GOPHER, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMB, SMBS, SMTP, SMTPS, TELNET and TFTP). The command is designed to work without user interaction.

In these docs you'll find everything you need to start working with Ethereum with BlockCypher. For now, you'll see cURL examples for interacting with the Ethereum blockchain, but we'll add SDK examples as we support them.

Section Summaries

Changelog and Errors

Our documentation is powered by GitHub Pages and Slate, which makes viewing changes as simple as checking the git commit history. If there's an error or you'd like to suggest a change, please consider submitting a pull request to benefit the broader BlockCypher community.

API Versions

All API calls are versioned, and the current BlockCypher API is v1. We will never introduce any breaking changes within v1, but we may add new, non-breaking features from time to time.

RESTful Resources

curl -s https://api.blockcypher.com/v1/eth/main
{
  "name": "ETH.main",
  "height": 1663353,
  "hash": "863dda1124f2b438c607f5b8d00e8511f6f8d206b21aad3b9c460b8c5221e31b",
  "time": "2016-06-08T00:46:34.795856213Z",
  "latest_url": "https://api.blockcypher.com/v1/eth/main/blocks/863dda1124f2b438c607f5b8d00e8511f6f8d206b21aad3b9c460b8c5221e31b",
  "previous_hash": "783aa3ef1b45121ee5bc33acb6c5986d6132d04cf20c85ba256b155b2c196006",
  "previous_url": "https://api.blockcypher.com/v1/eth/main/blocks/783aa3ef1b45121ee5bc33acb6c5986d6132d04cf20c85ba256b155b2c196006",
  "peer_count": 52,
  "unconfirmed_count": 11924,
  "high_gas_price": 40000000000,
  "medium_gas_price": 20000000000,
  "low_gas_price": 5000000000,
  "last_fork_height": 1661588,
  "last_fork_hash": "79075d95aacc6ac50dbdf58da044af396ca97e09cbb31527809579cc96f1c8a7"
}

Almost all resources exist under a given blockchain, and follow this pattern:

https://api.blockcypher.com/$API_VERSION/$COIN/$CHAIN/

Currently, there's only one version of the API (v1). For Ethereum, there are the available blockchains:

Coin Chain Resource
Ethereum Main api.blockcypher.com/v1/eth/main
BlockCypher Test api.blockcypher.com/v1/beth/test

Rate Limits and Tokens

# Adding your token as URL parameter
curl https://api.blockcypher.com/v1/eth/main?token=YOURTOKEN

# Checking your token's limits
curl https://api.blockcypher.com/v1/tokens/YOURTOKEN
{
"token": "YOURTOKEN",
"limits": {
    "api/hour": 10000,
    "api/second": 500,
    "hooks/hour": 5000,
    "confidence/hour": 1000,
    "hooks": 5000,
    "payments": 5000
},
"hits": {
    "api/hour": 280,
    "hooks/hour": 240,
    "confidence/hour": 100
}
}
# These are quite above the default limits, but if you'd like them, reach out at [email protected] ;)

We want everyone to try BlockCypher with as little friction as possible, which is why you don't need a token for any read-only GET calls. Please register for a user token if you want to use POST and DELETE calls. Once you have your token, you can append it to all your requests like any other URL parameter.

We do rate-limit our free tier, with or without a token (though tokens are required for Confidence lookups, WebHooks/Sockets, Payments, and any POST or DELETE calls):

On the accounts page, you'll find paid plans starting at $75 a month (with a 10% discount if you pay with Bitcoin). To request higher limits or SLAs beyond what's offered on the accounts page, please email us.

You can check your current limits and usage via a GET on the following endpoint, outside of our normal coin/chain pattern:

https://api.blockcypher.com/v1/tokens/YOURTOKEN

Batching

# Batching blocks 5, 6, and 7 from Ethereum
curl 'https://api.blockcypher.com/v1/eth/main/blocks/5;6;7'
[{
  "hash": "f37c632d361e0a93f08ba29b1a2c708d9caa3ee19d1ee8d2a02612bffe49f0a9",
  "height": 5,
  "chain": "ETH.main",
  "total": 0,
  "fees": 0,
  "size": 537,
  "ver": 0,
  "time": "2015-07-30T15:28:03Z",
  "received_time": "2015-07-30T15:28:03Z",
  "coinbase_addr": "05a56e2d52c817161883f50c441c3228cfe54d9f",
  "relayed_by": "",
  "nonce": 18134254966252788979,
  "n_tx": 0,
  "prev_block": "23adf5a3be0f5235b36941bcb29b62504278ec5b9cdfa277b992ba4a7a3cd3a2",
  "mrkl_root": "4470f3dc1cc8097394a4ae85302eac3368462b3c1cfa523ffca942c1dd478220",
  "txids": [],
  "depth": 1656648,
  "prev_block_url": "https://api.blockcypher.com/v1/eth/main/blocks/23adf5a3be0f5235b36941bcb29b62504278ec5b9cdfa277b992ba4a7a3cd3a2",
  "tx_url": "https://api.blockcypher.com/v1/eth/main/txs/"
},
{
  "hash": "1f1aed8e3694a067496c248e61879cda99b0709a1dfbacd0b693750df06b326e",
  "height": 6,
  "chain": "ETH.main",
  "total": 0,
  "fees": 0,
  "size": 537,
  "ver": 0,
  "time": "2015-07-30T15:28:27Z",
  "received_time": "2015-07-30T15:28:27Z",
  "coinbase_addr": "0193d941b50d91be6567c7ee1c0fe7af498b4137",
  "relayed_by": "",
  "nonce": 8915216988711600153,
  "n_tx": 0,
  "prev_block": "f37c632d361e0a93f08ba29b1a2c708d9caa3ee19d1ee8d2a02612bffe49f0a9",
  "mrkl_root": "c211464e6957ae62a33c2146cf36371222ea4557c42efe9c618971e09d056aae",
  "txids": [],
  "depth": 1656647,
  "prev_block_url": "https://api.blockcypher.com/v1/eth/main/blocks/f37c632d361e0a93f08ba29b1a2c708d9caa3ee19d1ee8d2a02612bffe49f0a9",
  "tx_url": "https://api.blockcypher.com/v1/eth/main/txs/"
},
{
  "hash": "e0c7c0b46e116b874354dce6f64b8581bd239186b03f30a978e3dc38656f723a",
  "height": 7,
  "chain": "ETH.main",
  "total": 0,
  "fees": 0,
  "size": 1078,
  "ver": 0,
  "time": "2015-07-30T15:28:30Z",
  "received_time": "2015-07-30T15:28:30Z",
  "coinbase_addr": "dd2f1e6e498202e86d8f5442af596580a4f03c2c",
  "relayed_by": "",
  "nonce": 13599487003767981,
  "n_tx": 0,
  "prev_block": "1f1aed8e3694a067496c248e61879cda99b0709a1dfbacd0b693750df06b326e",
  "mrkl_root": "ff8d97d9ca01ee59c793c4da2ba4ce8c31d358b42f216ab2f11af4bb097b6a2b",
  "uncles": [
    "4b8729311c5b59f418c5154fd54d85e6a8b42eabf83a1d3c05c754a8f10354cc"
  ],
  "txids": [],
  "depth": 1656646,
  "prev_block_url": "https://api.blockcypher.com/v1/eth/main/blocks/1f1aed8e3694a067496c248e61879cda99b0709a1dfbacd0b693750df06b326e",
  "tx_url": "https://api.blockcypher.com/v1/eth/main/txs/"
}]

All endpoints that can retrieve a single Object can be batched to return multiple objects. If you're cURLing the API directly, batching simply requires appending each identifier to the previous one using a semicolon (check the code pane for an example). The results are aggregated in a JSON array.

When cURLing BlockCypher, batching also works when the identifiers aren't the last part of the URL; e.g., this URL will return the balances of three separate addresses:

https://api.blockcypher.com/v1/btc/main/addrs/1J38WorKngZLJvA7qMin9g5jqUfTQUBZNE;1JP8FqoXtCMrR1sZc2McLWmHxENox1Y1PV;1ENn7XmqXNnReiQEFHhBGzfiv5gAyBj7r1/balance

Testing

To ease your development process, we offer an Ethereum-compatible internal testnet and faucet. It is identical in form and function to Ethereum mainnet (including the same address/account format and EVM). The chain is private (no data is broadcast, only BlockCypher mines the transactions).

In case you missed the Resources section, the BlockCypher Ethereum Testnet is accessible from this resource:

https://api.blockcypher.com/v1/beth/test

# Note resource change to beth/test instead of eth/main
# Make new address; returns private key/public key/address
curl -sX POST https://api.blockcypher.com/v1/beth/test/addrs?token=$YOURTOKEN
{
  "private": "a98e4f4181805a89322a1cff0da749fe297e3b44d18f17d55a86d4c64c9d5489",
  "public": "04ec8be2b66782caf8ba4158bf7a2027aaebdcd8a2dbcb52bd9f81668748671a0a3a5494bb85b0a10b3f52ac812246c8bc4c0269d92ef7d9e015090233044b40fe",
  "address": "1585a07efe60806132c994eb39b5f33f55a1eff8"
}

# Fund prior address with faucet, in wei
curl -sd '{"address": "1585a07efe60806132c994eb39b5f33f55a1eff8", "amount": 1000000000000000000}' https://api.blockcypher.com/v1/beth/test/faucet?token=$YOURTOKEN
{
  "tx_ref": "a4de50532f1a2b59cd50242ba98f5849aea691ae618c58efc05895cd7786a3d1"
}

Test Faucets

To help facilitate automated testing in your applications, a faucet endpoint is available on BlockCypher's Ethereum Testnet. Calling the faucet endpoint, along with passing a valid address, will automatically create---and propagate---a new transaction funding the address with the amount you provide. You can then use the funded address to publish contracts, engage in other transactions, or to aid in automated testing.

This example shows how to leverage the faucet to programmatically fund addresses.

Objects

# All cURL'd Objects are JSON:

{
  key: value,
  key: value,
}

Before diving into BlockCypher's endpoints, this section details all the Objects exposed and expected by the API. Some of you might be more interested in the endpoints themselves, in which case, feel free to skip to the next section. For each Object there's a description and a link to a germane API endpoint.

Blockchain

curl -s https://api.blockcypher.com/v1/eth/main
{
  "name": "ETH.main",
  "height": 1663099,
  "hash": "72c4b2773c41cc33fb7f708d1d410d4225706292b795e24e3f6f859927c0b932",
  "time": "2016-06-07T23:44:03.834909578Z",
  "latest_url": "https://api.blockcypher.com/v1/eth/main/blocks/72c4b2773c41cc33fb7f708d1d410d4225706292b795e24e3f6f859927c0b932",
  "previous_hash": "1060a6d4870aed200cb84c83c26203331f433d08f34c13b7de10c400866e43b1",
  "previous_url": "https://api.blockcypher.com/v1/eth/main/blocks/1060a6d4870aed200cb84c83c26203331f433d08f34c13b7de10c400866e43b1",
  "peer_count": 83,
  "unconfirmed_count": 11904,
  "high_gas_price": 40000000000,
  "medium_gas_price": 20000000000,
  "low_gas_price": 5000000000,
  "last_fork_height": 1661588,
  "last_fork_hash": "79075d95aacc6ac50dbdf58da044af396ca97e09cbb31527809579cc96f1c8a7"
}

A Blockchain represents the current state of the Ethereum blockchain. Typically returned from the Chain API endpoint.

Attribute Type Description
name string The name of the blockchain represented, in the form of $COIN.$CHAIN.
height integer The current height of the blockchain; i.e., the number of blocks in the blockchain.
hash string The hash of the latest confirmed block in the blockchain; in Ethereum, the hashing function is Keccak/SHA3.
time time The time of the latest update to the blockchain; typically when the latest block was added.
latest_url url The BlockCypher URL to query for more information on the latest confirmed block; returns a Block.
previous_hash string The hash of the second-to-latest confirmed block in the blockchain.
previous_url url The BlockCypher URL to query for more information on the second-to-latest confirmed block; returns a Block.
unconfirmed_count integer Number of unconfirmed transactions in memory pool (likely to be included in next block).
peer_count integer N/A, will be deprecated soon.
high_gas_price integer A rolling average of the gas price (in wei) for transactions to be confirmed within 1 to 2 blocks.
medium_gas_price integer A rolling average of the gas price (in wei) for transactions to be confirmed within 3 to 6 blocks.
low_gas_price integer A rolling average of the gas price (in wei) for transactions to be confirmed in 7 or more blocks.
high_priority_fee integer A rolling average of the priority fee (in wei) for transactions to be confirmed within 1 to 2 blocks.
medium_priority_fee integer A rolling average of the priority fee (in wei) for transactions to be confirmed within 3 to 6 blocks.
low_priority_fee integer A rolling average of the priority fee (in wei) for transactions to be confirmed in 7 or more blocks.
base_fee integer Represents the minimum amount of gas that must be used for a transaction to be included in a block.
last_fork_height integer Optional The current height of the latest fork to the blockchain; when no competing blockchain fork present, not returned with endpoints that return Blockchains.
last_fork_hash string Optional The hash of the latest confirmed block in the latest fork of the blockchain; when no competing blockchain fork present, not returned with endpoints that return Blockchains.

Block

curl -s https://api.blockcypher.com/v1/eth/main/blocks/7
{
  "hash": "e0c7c0b46e116b874354dce6f64b8581bd239186b03f30a978e3dc38656f723a",
  "height": 7,
  "chain": "ETH.main",
  "total": 0,
  "fees": 0,
  "size": 1078,
  "ver": 0,
  "time": "2015-07-30T15:28:30Z",
  "received_time": "2015-07-30T15:28:30Z",
  "coinbase_addr": "dd2f1e6e498202e86d8f5442af596580a4f03c2c",
  "relayed_by": "",
  "nonce": 13599487003767981,
  "n_tx": 0,
  "prev_block": "1f1aed8e3694a067496c248e61879cda99b0709a1dfbacd0b693750df06b326e",
  "mrkl_root": "ff8d97d9ca01ee59c793c4da2ba4ce8c31d358b42f216ab2f11af4bb097b6a2b",
  "uncles": [
    "4b8729311c5b59f418c5154fd54d85e6a8b42eabf83a1d3c05c754a8f10354cc"
  ],
  "txids": [],
  "internal_txids": [],
  "depth": 1656646,
  "prev_block_url": "https://api.blockcypher.com/v1/eth/main/blocks/1f1aed8e3694a067496c248e61879cda99b0709a1dfbacd0b693750df06b326e",
  "tx_url": "https://api.blockcypher.com/v1/eth/main/txs/"
}

A Block represents the current state of a particular block from a Blockchain. Typically returned from the Block Hash and Block Height endpoints.

Attribute Type Description
hash string The hash of the block; in Ethereum, the hashing function is Keccak/SHA3
height integer The height of the block in the blockchain; i.e., there are height earlier blocks in its blockchain.
depth integer The depth of the block in the blockchain; i.e., there are depth later blocks in its blockchain.
chain string The name of the blockchain represented, in the form of $COIN.$CHAIN
total integer The total number of wei transacted in this block.
fees integer The total number of fees---in wei---collected by miners in this block.
size integer Raw size of block (including header and all transactions) in bytes.
ver integer Block version.
time time Recorded time at which block was built.
received_time time The time BlockCypher's servers receive the block.
coinbase_addr string The Ethereum address of the miner that received the coinbase and fee reward.
relayed_by string Address of the peer that sent BlockCypher's servers this block.
nonce integer The number used by a miner to generate this block.
n_tx integer Number of transactions in this block.
prev_block string The hash of the previous block in the blockchain.
prev_block_url url The BlockCypher URL to query for more information on the previous block.
tx_url url The base BlockCypher URL to receive transaction details. To get more details about specific transactions, you must concatenate this URL with the desired transaction hash(es).
mrkl_root string The Merkle root of this block.
txids array[string] An array of transaction hashes in this block (initiated by externally controlled accounts). By default, only 20 are included.
internal_txids array[string] An array of internal transaction hashes (initiated by internal contracts) in this block. By default, only 20 are included.
next_txids url Optional If there are more transactions that couldn't fit in the txids array, this is the BlockCypher URL to query the next set of transactions (within a Block object).
next_internal_txids url Optional If there are more internal transactions that couldn't fit in the internal_txids array, this is the BlockCypher URL to query the next set of transactions (within a Block object).
uncles array[string] List of uncle blocks by hash included by the miner of this block. You can read more about uncles here.

TX

curl -s https://api.blockcypher.com/v1/eth/main/txs/8f39fb4940c084460da00a876a521ef2ba84ad6ea8d2f5628c9f1f8aeb395342
{
  "block_hash": "b35265965f6f14c5d692b2030922fce53067fc0e9d8c8490c31d4ecd3e46500c",
  "block_height": 1564040,
  "block_index": 0,
  "hash": "8f39fb4940c084460da00a876a521ef2ba84ad6ea8d2f5628c9f1f8aeb395342",
  "addresses": [
    "738d145faabb1e00cf5a017588a9c0f998318012",
    "4e9d8b4f18d984f6f0c88d07e4b39201e825cd17"
  ],
  "total": 10153153359437326,
  "fees": 1595580000000000,
  "size": 116,
  "gas_used": 79779,
  "gas_price": 20000000000,
  "relayed_by": "",
  "confirmed": "2016-05-22T12:43:00Z",
  "received": "2016-05-22T12:43:00Z",
  "ver": 0,
  "double_spend": false,
  "vin_sz": 1,
  "vout_sz": 1,
  "confirmations": 99100,
  "confidence": 1,
  "inputs": [
    {
      "sequence": 273,
      "addresses": [
        "738d145faabb1e00cf5a017588a9c0f998318012"
      ]
    }
  ],
  "outputs": [
    {
      "value": 10153153359437326,
      "script": "4e71d92d",
      "addresses": [
        "4e9d8b4f18d984f6f0c88d07e4b39201e825cd17"
      ]
    }
  ]
}

A TX represents the current state of a particular transaction from either a Block within a Blockchain, or an unconfirmed transaction that has yet to be included in a Block.

Attribute Type Description
block_height integer Height of the block that contains this transaction. If this is an unconfirmed transaction, it will equal -1.
hash string The hash of the transaction.
addresses array[string] Array of Ethereum addresses involved in the transaction.
total integer The total number of wei exchanged in this transaction.
fees integer The total number of fees---in wei---collected by miners in this transaction. Equal to gas_price * gas_used.
size integer The size of the transaction in bytes.
gas_used integer The amount of gas used by this transaction.
gas_price integer The price of gas---in wei---in this transaction.
relayed_by string Address of the peer that sent BlockCypher's servers this transaction. May be empty.
received time Time this transaction was received by BlockCypher's servers.
ver integer Version number of this transaction.
double_spend bool true if this is an attempted double spend; false otherwise.
vin_sz integer Total number of inputs in the transaction.
vout_sz integer Total number of outputs in the transaction.
confirmations integer Number of subsequent blocks, including the block the transaction is in. Unconfirmed transactions have 0 confirmations.
inputs Object An array object containing a single input with a sequence number (used as a nonce for account balances) and an Ethereum account address. Only contains one input in the array; we still use an array to maintain parity with the Bitcoin API.
outputs Object An array object containing a single output with value (in wei), script, and an Ethereum account address. Only contains one output in the array; we still use an array to maintain parity with the Bitcoin API.
internal_txids array[string] Optional If this transaction executed a contract which propagated its own subsequent transactions, then this array will be present, containing the hashes of those subsequent internal transactions.
parent_tx string Optional If this transaction was initiated by a contract, this field will be present, conveying the hash of the parent transaction that executed the contract resulting in this transaction (the inverse of an internal_txids hash).
confirmed time Optional Time at which transaction was included in a block; only present for confirmed transactions.
gas_limit integer Optional If creating a transaction, can optionally set a higher default gas limit (useful if your recepient is a contract). If not set, default is 21000 gas for external accounts and 80000 for contract accounts.
contract_creation bool Optional If true, this transaction was used to create a contract and contract account. Note that the contract address (in the outputs field) will be blank until the transaction is confirmed.
receive_count integer Optional Number of peers that have sent this transaction to BlockCypher; only present for unconfirmed transactions.
block_hash string Optional Hash of the block that contains this transaction; only present for confirmed transactions.
block_index integer Optional Canonical, zero-indexed location of this transaction in a block; only present for confirmed transactions.
double_of string Optional If this transaction is a double-spend (i.e. double_spend == true) then this is the hash of the transaction it's double-spending.
execution_error string Optional If this transaction has an execution error, then this field will be included (e.g. "out of gas").

TXRef

{
  "tx_hash": "ba44f568dc77d33893261c041994eeaef17d108a1845ccb9e376afea2acdd0e9",
  "block_height": 1648312,
  "tx_input_n": 0,
  "tx_output_n": -1,
  "value": 50420000000000000,
  "ref_balance": 2845236193385545395,
  "confirmations": 8342,
  "confirmed": "2016-06-05T12:47:08Z",
  "double_spend": false
}

A TXRef object represents summarized data about a transaction input or output. Typically found in an array within an Address object, which is usually returned from the standard Address Endpoint.

Attribute Type Description
block_height integer Height of the block that contains this transaction input/output. If it's unconfirmed, this will equal -1.
tx_hash string The hash of the transaction containing this input/output.
tx_input_n integer Index of this input in the enclosing transaction. 0 if it's an input, -1 if it's an output.
tx_output_n integer Index of this output in the enclosing transaction. -1 if it's an input, 0 if it's an output.
value integer The value transfered by this input/output in wei exchanged in the enclosing transaction.
double_spend bool true if this is an attempted double spend; false otherwise.
confirmations integer Number of subsequent blocks, including the block the transaction is in. Unconfirmed transactions have 0 confirmations.
ref_balance integer Optional The past balance of the parent address the moment this transaction was confirmed. Not present for unconfirmed transactions.
confirmed time Optional Time at which transaction was included in a block; only present for confirmed transactions.
double_of string Optional If this transaction is a double-spend (i.e. double_spend == true) then this is the hash of the transaction it's double-spending.

TXSkeleton

curl -sd '{"inputs":[{"addresses": ["1cc60c94254c0f0f0b957fb7c3dfed2d00e49a4c"]}],"outputs":[{"addresses": ["add42af7dd58b27e1e6ca5c4fdc01214b52d382f"], "value": 4200000000000000}]}' https://api.blockcypher.com/v1/eth/main/txs/new?token=YOURTOKEN
{
  "tx": {
    "block_height": -1,
    "block_index": 0,
    "hash": "5f32efeee4c1132df5aea5ac42735e0e21df995dd1cb0a4196eff4afc81ccb77",
    "addresses": [
      "1cc60c94254c0f0f0b957fb7c3dfed2d00e49a4c",
      "add42af7dd58b27e1e6ca5c4fdc01214b52d382f"
    ],
    "total": 4200000000000000,
    "fees": 861000000000000,
    "size": 44,
    "relayed_by": "",
    "received": "2016-06-07T06:41:25.396799578Z",
    "ver": 0,
    "double_spend": false,
    "vin_sz": 1,
    "vout_sz": 1,
    "inputs": [
      {
        "sequence": 2,
        "addresses": [
          "1cc60c94254c0f0f0b957fb7c3dfed2d00e49a4c"
        ]
      }
    ],
    "outputs": [
      {
        "value": 4200000000000000,
        "addresses": [
          "add42af7dd58b27e1e6ca5c4fdc01214b52d382f"
        ]
      }
    ]
  },
  "tosign": [
    "dd3c2cc1cf735ce5a3bbb5de7fb8f3ac2d9b6e6ec211ec6d8c03f098403e7736"
  ],
  "signatures": [],
  "errors": []
}

A TXSkeleton is a convenience/wrapper Object that's used primarily when Creating Transactions through the New and Send endpoints.

Attribute Type Description
tx TX A temporary TX, usually returned fully filled.
tosign array[string] Array of hex-encoded data for you to sign, containing one element for you to sign. Still an array to maintain parity with the Bitcoin API.
signatures array[string] Array of signatures corresponding to all the data in tosign, typically provided by you. Only one signature is required.
errors array["error":string] Optional Array of errors in the form "error":"description-of-error". This is only returned if there was an error in any stage of transaction generation, and is usually accompanied by a HTTP 400 code.

Address

curl -s https://api.blockcypher.com/v1/eth/main/addrs/738d145faabb1e00cf5a017588a9c0f998318012
{
  "address": "738d145faabb1e00cf5a017588a9c0f998318012",
  "total_received": 9762206505909057760,
  "total_sent": 9742951942909057760,
  "balance": 19254563000000000,
  "unconfirmed_balance": 0,
  "final_balance": 19254563000000000,
  "n_tx": 704,
  "unconfirmed_n_tx": 0,
  "final_n_tx": 704,
  "nonce": 414,
  "pool_nonce": 414,
  "txrefs": [
    {
      "tx_hash": "ba44f568dc77d33893261c041994eeaef17d108a1845ccb9e376afea2acdd0e9",
      "block_height": 1648312,
      "tx_input_n": 0,
      "tx_output_n": -1,
      "value": 50420000000000000,
      "ref_balance": 2845236193385545395,
      "confirmations": 8342,
      "confirmed": "2016-06-05T12:47:08Z",
      "double_spend": false
    },
    {
      "tx_hash": "99ec589ab8cb9498093c4d0c534bdcfd8bd04bfead1d869e3a79165a4f98af0d",
      "block_height": 1628712,
      "tx_input_n": 0,
      "tx_output_n": -1,
      "value": 10623553359437326,
      "ref_balance": 2895656193385545395,
      "confirmations": 27942,
      "confirmed": "2016-06-02T06:53:55Z",
      "double_spend": false
    },
    {
      "tx_hash": "20551685c6c311738da9f42019eb66fccd2cec4cc48e00d98967365d6ad77164",
      "block_height": 1628222,
      "tx_input_n": 0,
      "tx_output_n": -1,
      "value": 10623553359437326,
      "ref_balance": 2906279746744982721,
      "confirmations": 28432,
      "confirmed": "2016-06-02T05:02:50Z",
      "double_spend": false
    },
    ...
  ],
  "hasMore": true,
  "tx_url": "https://api.blockcypher.com/v1/eth/main/txs/"
}

An Address represents the state of an Ethereum address/account, containing information about the state of balances and transactions related to this address. Typically returned from the Address Balance and Address endpoints.

Attribute Type Description
address string The requested address.
total_received integer Total amount of confirmed wei received by this address.
total_sent integer Total amount of confirmed wei sent by this address.
balance integer Balance of confirmed wei on this address. (i.e., for transactions whose confirmations > 0).
unconfirmed_balance integer Balance of unconfirmed wei on this address. Can be negative (if unconfirmed transactions are just spending part of an address balance). Only unconfirmed transactions (haven't made it into a block) are included in this calculation.
final_balance integer Total balance of wei, including confirmed and unconfirmed transactions, for this address.
n_tx integer Number of confirmed transactions on this address. Only transactions that have made it into a block (confirmations > 0) are counted.
unconfirmed_n_tx integer Number of unconfirmed transactions for this address. Only unconfirmed transactions (confirmations == 0) are counted.
final_n_tx integer Final number of transactions, including confirmed and unconfirmed transactions, for this address.
nonce integer Current nonce for this address.
pool_nonce integer Pool nonce for this address.
tx_url url Optional To retrieve base URL transactions. To get the full URL, concatenate this URL with a transaction's hash.
txrefs array[TXRef] Optional Array of transaction summaries for this address. Usually only returned from the standard Address Endpoint.
unconfirmed_txrefs array[TXRef] Optional All unconfirmed transaction summaries for this address. Usually only returned from the standard Address Endpoint.
hasMore bool Optional If true, then the Address object contains more transactions than shown. Useful for determining whether to poll the API for more transaction information.

AddressKeychain

curl -sX POST https://api.blockcypher.com/v1/eth/main/addrs
{
  "private": "32605f9fbe224ebe621f88c33ae27099d4ce803e3b1cb5a1a3169790fd71beee",
  "public": "04d3e1b49ef16dcde23be535b621d15c83ff75ef097ae43f2ef7a98bcddbb402034ddb6a5ca781d7333ef988bb9a5cd98c1f407d8acf77a1a8a17a26899fa66be5",
  "address": "d543125acfc1e4d22f7f62aa5fbb2bb9a42bdb6d"
}

An AddressKeychain represents an associated collection of public and private keys alongside their respective Ethereum address. Generally returned and used with the Generate Address Endpoint.

Attribute Type Description
address string Standard address representation.
public string Hex-encoded Public key.
private string Hex-encoded Private key.

Contract

{
"solidity": "contract mortal {\n  /* Define variable owner of the type address*/\n    address owner;\n    /* this function is executed at initialization and sets the owner of the contract */\n    function mortal() { owner = msg.sender; }\n    /* Function to recover the funds on the contract */\n    function kill() { if (msg.sender == owner) suicide(owner); }\n}\n\ncontract greeter is mortal {\n    /* define variable greeting of the type string */\n    string greeting;\n    /* this runs when the contract is executed */\n    function greeter(string _greeting) public {\n        greeting = _greeting;\n    }\n    /* main function */\n    function greet() constant returns (string) {\n        return greeting;\n    }\n}",
"params": ["Hello BlockCypher Test"],
"publish": ["greeter"],
"private": "3ca40...",
"gas_limit": 500000
}

{
"name": "greeter",
"solidity": "contract mortal {\n  /* Define variable owner of the type address*/\n    address owner;\n    /* this function is executed at initialization and sets the owner of the contract */\n    function mortal() { owner = msg.sender; }\n    /* Function to recover the funds on the contract */\n    function kill() { if (msg.sender == owner) suicide(owner); }\n}\n\ncontract greeter is mortal {\n    /* define variable greeting of the type string */\n    string greeting;\n    /* this runs when the contract is executed */\n    function greeter(string _greeting) public {\n        greeting = _greeting;\n    }\n    /* main function */\n    function greet() constant returns (string) {\n        return greeting;\n    }\n}",
"bin": "606060405260405161023e38038061023e8339810160405280510160008054600160a060020a031916331790558060016000509080519060200190828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10609f57805160ff19168380011785555b50608e9291505b8082111560cc57600081558301607d565b50505061016e806100d06000396000f35b828001600101855582156076579182015b82811115607657825182600050559160200191906001019060b0565b509056606060405260e060020a600035046341c0e1b58114610026578063cfae321714610068575b005b6100246000543373ffffffffffffffffffffffffffffffffffffffff908116911614156101375760005473ffffffffffffffffffffffffffffffffffffffff16ff5b6100c9600060609081526001805460a06020601f6002600019610100868816150201909416939093049283018190040281016040526080828152929190828280156101645780601f1061013957610100808354040283529160200191610164565b60405180806020018281038252838181518152602001915080519060200190808383829060006004602084601f0104600f02600301f150905090810190601f1680156101295780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b565b820191906000526020600020905b81548152906001019060200180831161014757829003601f168201915b505050505090509056",
"abi": [...],
"gas_limit": 500000,
"creation_tx_hash": "61474003e56d67aba6bf148c5ec361e3a3c1ceea37fe3ace7d87759b399292f9",
"address": "0eb688e79698d645df015cf2e9db5a6fe16357f1",
"params": [
  "Hello BlockCypher Test"
]
}

A Contract represents an embedded contract on the Ethereum blockchain, and is used with both creating and executing contracts in our Contract API. All the fields below are generally optional, but may be required depending on the particular contract endpoint you're using.

Attribute Type Description
solidity string Solidity code of this contract; required when creating a contract. In responses, only returned with contracts initially compiled by BlockCypher.
params Array[string] Parameters for either contract creation or method execution.
publish Array[string] Named contract(s) to publish; necessary to specify when first creating a contract.
private string Private key associated with a funded Ethereum external account used to publish a contract or execute a method.
gas_limit int Maximum amount of gas to use in contract creation or method execution.
gas_price int Gas price in wei.
value int Amount (in wei) to transfer; can be used when creating a contract or calling a method.
name string Name of contract as published.
bin string Hex-encoded binary compilation of this contract.
abi ABI JSON-encoded ABI. Only returned with contracts initially compiled by BlockCypher.
address string Hex-encoded address of this contract.
created time Timestamp when this contract was confirmed in the Ethereum blockchain.
creation_tx_hash string Hex-encoded transaction hash that created this contract.
results Array[string] If this is a response from a calling a contract method, this array of results may appear if the method returns any.

Event

curl -s https://api.blockcypher.com/v1/eth/main/hooks/ce83d08f-7b86-4a6a-9b41-85507648f9c7?token=YOURTOKEN
{
  "id": "ce83d08f-7b86-4a6a-9b41-85507648f9c7",
  "token": "YOURTOKEN",
  "url": "https://my.domain.com/callbacks/new-tx",
  "callback_errors": 0,
  "address": "c5beef03aaa9548210b5550a62f7756efaa08ba3",
  "event": "unconfirmed-tx",
  "filter": "addr=c5beef03aaa9548210b5550a62f7756efaa08ba3\u0026event=unconfirmed-tx"
}

An Event represents a WebHooks or WebSockets-based notification request, as detailed in the Events & Hooks section of the documentation.

Attribute Type Description
id string Identifier of the event; generated when a new request is created.
event string Type of event; can be unconfirmed-tx, new-block, confirmed-tx, tx-confirmation, double-spend-tx.
hash string optional Only objects with a matching hash will be sent. The hash can either be for a block or a transaction.
address string optional Only transactions associated with the given address will be sent.
confirmations integer optional Used in concert with the tx-confirmation event type to set the number of confirmations desired for which to receive an update. You'll receive an updated TX for every confirmation up to this amount. The maximum allowed is 10; if not set, it will default to 6.
url url optional Callback URL for this Event's WebHook; not applicable for WebSockets usage.
callback_errors int Number of errors when attempting to POST to callback URL; not applicable for WebSockets usage.

PaymentForward

curl -d '{"destination":"0xda4b58eff2f3fd6c9845f82268cac1115b9b446b","callback_url": "https://my.domain.com/callbacks/new-pay", "gas_price_gwei": 50,"token":"YOURTOKEN"}' https://api.blockcypher.com/v1/eth/main/payments

{
  "id": "82f0af68-da11-477f-8b42-79edbf3e6481",
  "token": "YOURTOKEN",
  "destination": "da4b58eff2f3fd6c9845f82268cac1115b9b446b",
  "input_address": "718d2ab6160cf79cab1815dcc87d6b76fc20a0ba",
  "callback_url": "https://my.domain.com/callbacks/new-pay"
}

A PaymentForward object represents a request set up through the Payment Forwarding service.

Attribute Type Description
id string Identifier of the payment forwarding request; generated when a new request is created.
token string The mandatory user token.
destination string The required destination address for payment forwarding.
input_address string The address which will automatically forward to destination; generated when a new request is created.
callback_url url Optional The URL to call anytime a new payment is forwarded.
enable_confirmations bool Optional Whether to also call the callback_url with subsequent confirmations of the forwarding transactions. Automatically sets up a WebHook.
gas_price_gwei int Optional Gas price for the forwarding transaction, in gwei. If not set, defaults to 80 gwei.
txs array[string] Optional History of forwarding transaction hashes for this payment forward; not present if this request has yet to forward any transactions.

PaymentForwardCallback

{
  "value": 935404733882568,
  "input_address": "c46d6b42d7df500d6fe83fb5e86969b51e775bad",
  "destination": "2139b240756b7522702b742ec01271b0e2d6e245",
  "transaction_hash": "db08bc6ae92405f8346ae80def1c436dff9ca47e4ae718b46ac68e93da41395d"
}

A PaymentForwardCallback object represents the payload delivered to the optional callback_url in a PaymentForward request.

Attribute Type Description
value int Amount sent to the destination address, in wei.
input_address string The intermediate address to which the payment was originally sent.
destination string The final destination address to which the payment will eventually be sent.
transaction_hash string The transaction hash of the generated transaction that forwards the payment from the input_address to the destination.

Blockchain API

The first component---and highest level---of the BlockCypher Ethereum API allows you to query general information about Ethereum's blockchain and blocks.

If you're new to blockchains, you can think of the blockchain itself as an immutable, distributed ledger. Each block in the blockchain is like a "page" in the ledger containing information about transactions between parties. A great place to start understanding the mechanics behind blockchains is the original Bitcoin whitepaper. To get a handle on how Ethereum differs from Bitcoin, you can check the Ethereum project whitepaper.

Chain Endpoint

curl -s https://api.blockcypher.com/v1/eth/main
{
  "name": "ETH.main",
  "height": 1663350,
  "hash": "2dc3d6b080fbc78e576c8a0a7ccb52ca2af25b60c0df30ff82279fa41454729c",
  "time": "2016-06-08T00:46:10.101109766Z",
  "latest_url": "https://api.blockcypher.com/v1/eth/main/blocks/2dc3d6b080fbc78e576c8a0a7ccb52ca2af25b60c0df30ff82279fa41454729c",
  "previous_hash": "00709ed44e1ee2f2e5416c1e48bfd1a820e30aa14348b97d802d463f4ec940a6",
  "previous_url": "https://api.blockcypher.com/v1/eth/main/blocks/00709ed44e1ee2f2e5416c1e48bfd1a820e30aa14348b97d802d463f4ec940a6",
  "peer_count": 55,
  "unconfirmed_count": 11924,
  "high_gas_price": 40000000000,
  "medium_gas_price": 20000000000,
  "low_gas_price": 5000000000,
  "last_fork_height": 1661588,
  "last_fork_hash": "79075d95aacc6ac50dbdf58da044af396ca97e09cbb31527809579cc96f1c8a7"
}

General information about the Ethereum blockchain is available by GET-ing the base resource.

Resource Method Return Object
/ GET Blockchain

The returned object contains a litany of information, including its height, the time/hash of the latest block, and more. For Ethereum, the object includes information on gas_price, denoted in wei. Unlike Bitcoin, fees are determined by the computational execution cost of the transaction via gas; in order to prevent runaway contract execution, each operation in Ethereum's Virtual Machine requires a fixed/known amount of gas. While the amount of gas is fixed for a given EVM operation, the price of gas fluctuates based on market demand on the Ethereum blockchain (similar to Bitcoin fees). For more detail, check this very helpful Stack Exchange explanation.

For more detailed information about the data returned, check the Blockchain object.

Block Hash Endpoint

curl -s https://api.blockcypher.com/v1/eth/main/blocks/b35265965f6f14c5d692b2030922fce53067fc0e9d8c8490c31d4ecd3e46500c
{
  "hash": "b35265965f6f14c5d692b2030922fce53067fc0e9d8c8490c31d4ecd3e46500c",
  "height": 1564040,
  "chain": "ETH.main",
  "total": 20306306718874652,
  "fees": 1595580000000000,
  "size": 661,
  "ver": 0,
  "time": "2016-05-22T12:43:00Z",
  "received_time": "2016-05-22T12:43:00Z",
  "coinbase_addr": "4bb96091ee9d802ed039c4d1a5f6216f90f81b01",
  "relayed_by": "",
  "nonce": 2464233431647216841,
  "n_tx": 1,
  "prev_block": "e52d8cd9bf52374fd47e9d9ed81d2702f9e6352455f0ac07000bd3682b70cde7",
  "mrkl_root": "23f82aa013765c42fbee7f4e57c22befd7aece689834d0d2d6e25208713efb6a",
  "txids": [
    "8f39fb4940c084460da00a876a521ef2ba84ad6ea8d2f5628c9f1f8aeb395342"
  ],
  "internal_txids": [
    "dd107c8488867fd53c0aa3bf1d8a478a077ec67af75842d24f1a64eb44e4d902",
    "9a98678d209910f70bded624f2c5c18ed17d417752072d41c5d61b42c277348c",
    "ad959961f46663f785e1e0a0b2656960b5d27061097c5092c4e68964bfaf0041",
    "5a23d74a484ec58b211264888846be6d7428c33be93223396eff3626e036a7f4",
    "73906b2f1a1d7fd17c77684e5e811ae8710e4a032501090da264712db7a48e7a",
    "53ce88e1cf98b37fb64c16121b4641dde65290838ce0bde6cb1c319df3ef8ff9",
    "29bc4e7fa2db28b0a2ef9e7a5e073cc7532e609f752b2eb0b5731b0c6b926a2c",
    "4a9afc5a680917955e781b890688143f56badc76785af98753d5267270d7d809"
  ],
  "depth": 92613,
  "prev_block_url": "https://api.blockcypher.com/v1/eth/main/blocks/e52d8cd9bf52374fd47e9d9ed81d2702f9e6352455f0ac07000bd3682b70cde7",
  "tx_url": "https://api.blockcypher.com/v1/eth/main/txs/"
}

If you want more data on a particular block, you can use the Block Hash endpoint.

Resource Method Return Object
/blocks/$BLOCK_HASH GET Block
Flag Type Effect
txstart integer Filters response to only include transaction hashes after txstart in the block.
limit integer Filters response to only include a maximum of limit transactions hashes in the block. Maximum value allowed is 500.

$BLOCK_HASH is a string representing the hash of the block you're interested in querying, for example:

0000000000000000189bba3564a63772107b5673c940c16f12662b3e8546b412

The returned object contains information about the block, including its height, the total amount of wei transacted within it, the number of transactions in it, transaction hashes listed in the canonical order in which they appear in the block, and more. For more detail on the data returned, check the Block object.

Block Height Endpoint

curl -s https://api.blockcypher.com/v1/eth/main/blocks/7
{
  "hash": "e0c7c0b46e116b874354dce6f64b8581bd239186b03f30a978e3dc38656f723a",
  "height": 7,
  "chain": "ETH.main",
  "total": 0,
  "fees": 0,
  "size": 1078,
  "ver": 0,
  "time": "2015-07-30T15:28:30Z",
  "received_time": "2015-07-30T15:28:30Z",
  "coinbase_addr": "dd2f1e6e498202e86d8f5442af596580a4f03c2c",
  "relayed_by": "",
  "nonce": 13599487003767981,
  "n_tx": 0,
  "prev_block": "1f1aed8e3694a067496c248e61879cda99b0709a1dfbacd0b693750df06b326e",
  "mrkl_root": "ff8d97d9ca01ee59c793c4da2ba4ce8c31d358b42f216ab2f11af4bb097b6a2b",
  "uncles": [
    "4b8729311c5b59f418c5154fd54d85e6a8b42eabf83a1d3c05c754a8f10354cc"
  ],
  "txids": [],
  "depth": 1656646,
  "prev_block_url": "https://api.blockcypher.com/v1/eth/main/blocks/1f1aed8e3694a067496c248e61879cda99b0709a1dfbacd0b693750df06b326e",
  "tx_url": "https://api.blockcypher.com/v1/eth/main/txs/"
}

You can also query for information on a block using its height, using the same resource but with a different variable type.

Resource Method Return Object
/blocks/$BLOCK_HEIGHT GET Block
Flag Type Effect
txstart integer Filters response to only include transaction hashes after txstart in the block.
limit integer Filters response to only include a maximum of limit transactions hashes in the block. Maximum value allowed is 500.

BLOCK_HEIGHT is an integer representing the height of the block you're interested in querying, for example:

1500000

As above, the returned object contains information about the block, including its hash, the total amount of wei transacted within it, the number of transactions in it, transaction hashes listed in the canonical order in which they appear in the block, and more. For more detail on the data returned, check the Block object.

Address API

BlockCypher's Ethereum Address API allows you to look up information about public Ethereum addresses/accounts and generate your own low-value Ethereum addresses/public-private key pairs.

If you're new to blockchains, you can think of public addresses as similar to bank account numbers in a traditional ledger. The biggest differences:

Address Balance Endpoint

curl -s https://api.blockcypher.com/v1/eth/main/addrs/738d145faabb1e00cf5a017588a9c0f998318012/balance
{
  "address": "738d145faabb1e00cf5a017588a9c0f998318012",
  "total_received": 9762206505909057760,
  "total_sent": 6916970312523512365,
  "balance": 2845236193385545395,
  "unconfirmed_balance": 0,
  "final_balance": 2845236193385545395,
  "n_tx": 702,
  "unconfirmed_n_tx": 0,
  "final_n_tx": 702
}

The Address Balance Endpoint is the simplest---and fastest---method to get a subset of information on a public address.

Resource Method Return Object
/addrs/$ADDRESS/balance GET Address

ADDRESS is a string representing the public address you're interested in querying, for example:

738d145faabb1e00cf5a017588a9c0f998318012

The returned object contains information about the address, including its balance in wei and the number of transactions associated with it. The endpoint omits any detailed transaction information, but if that isn't required by your application, then it's the fastest and preferred way to get public address information.

Address Endpoint

curl -s https://api.blockcypher.com/v1/eth/main/addrs/738d145faabb1e00cf5a017588a9c0f998318012
{
  "address": "738d145faabb1e00cf5a017588a9c0f998318012",
  "total_received": 9762206505909057760,
  "total_sent": 6916970312523512365,
  "balance": 2845236193385545395,
  "unconfirmed_balance": 0,
  "final_balance": 2845236193385545395,
  "n_tx": 702,
  "unconfirmed_n_tx": 0,
  "final_n_tx": 702,
  "txrefs": [
    {
      "tx_hash": "ba44f568dc77d33893261c041994eeaef17d108a1845ccb9e376afea2acdd0e9",
      "block_height": 1648312,
      "tx_input_n": 0,
      "tx_output_n": -1,
      "value": 50420000000000000,
      "ref_balance": 2845236193385545395,
      "confirmations": 8342,
      "confirmed": "2016-06-05T12:47:08Z",
      "double_spend": false
    },
    {
      "tx_hash": "99ec589ab8cb9498093c4d0c534bdcfd8bd04bfead1d869e3a79165a4f98af0d",
      "block_height": 1628712,
      "tx_input_n": 0,
      "tx_output_n": -1,
      "value": 10623553359437326,
      "ref_balance": 2895656193385545395,
      "confirmations": 27942,
      "confirmed": "2016-06-02T06:53:55Z",
      "double_spend": false
    },
    {
      "tx_hash": "20551685c6c311738da9f42019eb66fccd2cec4cc48e00d98967365d6ad77164",
      "block_height": 1628222,
      "tx_input_n": 0,
      "tx_output_n": -1,
      "value": 10623553359437326,
      "ref_balance": 2906279746744982721,
      "confirmations": 28432,
      "confirmed": "2016-06-02T05:02:50Z",
      "double_spend": false
    },
    ...
  ],
  "hasMore": true,
  "tx_url": "https://api.blockcypher.com/v1/eth/main/txs/"
}

The Address Endpoint returns more information about an address' transactions than the Address Balance Endpoint, but sacrifices some response speed in the process.

Resource Method Return Object
/addrs/$ADDRESS GET Address
Flag Type Effect
before integer Filters response to only include transactions below before height in the blockchain.
after integer Filters response to only include transactions above after height in the blockchain.
limit integer limit sets the minimum number of returned TXRefs; there can be less if there are less than limit TXRefs associated with this address, but there can be more in the rare case of more TXRefs in the block at the bottom of your call. This ensures paging by block height never misses TXRefs. Defaults to 200, maximum is 2000.
confirmations integer If set, only returns the balance and TXRefs that have at least this number of confirmations.

ADDRESS is a string representing the public address (or wallet/HD wallet name) you're interested in querying, for example:

738d145faabb1e00cf5a017588a9c0f998318012

The returned object contains information about the address, including its balance in wei, the number of transactions associated with it, and transaction summaries in descending order by block height.

Address Full Endpoint

curl -s https://api.blockcypher.com/v1/eth/main/addrs/0x7CEcBd7a618146Cb251735b524e98f62d548177b/full
{
  "address": "0x7CEcBd7a618146Cb251735b524e98f62d548177b",
  "total_received": 613136037139846027,
  "total_sent": 609820639361600898,
  "balance": 3315397778245129,
  "unconfirmed_balance": 0,
  "final_balance": 3315397778245129,
  "n_tx": 58,
  "unconfirmed_n_tx": 0,
  "final_n_tx": 58,
  "nonce": 36,
  "pool_nonce": 36,
  "hasMore": true,
  "txs": [
    {
      "block_hash": "eec1dd4d7271a53ada4cf3145577d0610e8648aefa42a9420a7ab1d3ae9a787b",
      "block_height": 13113955,
      "block_index": 550,
      "hash": "5b199d5a3b3a3f9b2ffe37878bb3b428affbec117e7888202ba22503b3967a79",
      "addresses": [
        "7cecbd7a618146cb251735b524e98f62d548177b",
        "f9209e6809e0a08ae18b1366c437cb3cad2b6182"
      ],
      "total": 1550897349206251,
      "fees": 735000000000000,
      "size": 109,
      "gas_limit": 21000,
      "gas_used": 21000,
      "gas_price": 35000000000,
      "gas_tip_cap": 35000000000,
      "gas_fee_cap": 35000000000,
      "confirmed": "2021-08-28T12:41:39Z",
      "received": "2021-08-28T12:01:08.52Z",
      "ver": 0,
      "double_spend": false,
      "vin_sz": 1,
      "vout_sz": 1,
      "confirmations": 111695,
      "confidence": 1,
      "inputs": [
        {
          "sequence": 35,
          "addresses": [
            "7cecbd7a618146cb251735b524e98f62d548177b"
          ]
        }
      ],
      "outputs": [
        {
          "value": 1550897349206251,
          "addresses": [
            "f9209e6809e0a08ae18b1366c437cb3cad2b6182"
          ]
        }
      ]
    },
  ...,
]
}

The Address Full Endpoint returns all information available about a particular address, including an array of complete transactions instead of just transaction inputs and outputs. Unfortunately, because of the amount of data returned, it is the slowest of the address endpoints, but it returns the most detailed data record.

Resource Method Return Object
/addrs/$ADDRESS/full GET Address
Flag Type Effect
before integer Filters response to only include transactions below before height in the blockchain.
after integer Filters response to only include transactions above after height in the blockchain.
limit integer limit sets the minimum number of returned TXs; there can be less if there are less than limit TXs associated with this address, but there can also be more in the rare case of more TXs in the block at the bottom of your call. This ensures paging by block height never misses TXs. Defaults to 10, maximum is 50.
txlimit integer This filters the TXInputs/TXOutputs within the returned TXs to include a maximum of txlimit items.
confirmations integer If set, only returns the balance and TXs that have at least this number of confirmations.
confidence integer Filters response to only include TXs above confidence in percent; e.g., if this is set to 99, will only return TXs with 99% confidence or above (including all confirmed TXs). For more detail on confidence, check the Confidence Factor documentation.
includeHex bool If true, includes hex-encoded raw transaction for each TX; false by default.
includeConfidence bool If true, includes the confidence attribute (useful for unconfirmed transactions) within returned TXs. For more info about this figure, check the Confidence Factor documentation.
omitWalletAddresses bool If omitWalletAddresses is true and you're querying a Wallet or HDWallet, the response will omit address information (useful to speed up the API call for larger wallets).

ADDRESS is a string representing the public address (or wallet/HD wallet name) you're interested in querying, for example:

0x7CEcBd7a618146Cb251735b524e98f62d548177b

The returned object contains information about the address, including its balance in satoshis, the number of transactions associated with it, and the corresponding full transaction records in descending order by block height---and if multiple transactions associated with this address exist within the same block, by descending block index (position in block).

Generate Address Endpoint

curl -sX POST https://api.blockcypher.com/v1/eth/main/addrs?token=YOURTOKEN
{
  "private": "44c984a089184a9a659e10210af360049f366a34f7f3cb253ac5cbfcb33f3d7c",
  "public": "04b7de9b47fc1fb278648266316dffe47cc7f5280b69b05b5770ad1624ee3da7647c98ade5e4c35b99e606535eaca54db0f913c8aa1fa7226f15b9996325d0989d",
  "address": "e3f7e628fff7589218d88ae1d6bcdac52fef2168"
}

The Generate Address endpoint allows you to generate private-public key-pairs along with an associated public address. No information is required with this POST request.

Resource Method Request Object Return Object
/addrs POST nil AddressKeychain

The returned object contains a private key, a public key, and a public address, all hex-encoded.

Transaction API

BlockCypher's Ethereum Transaction API allows you to look up information about unconfirmed transactions, query transactions based on hash, and create and propagate your own transactions.

Unlike Bitcoin, Ethereum has no concept of UTXOs. Instead, addresses have a running balance, and use an ever-increasing sequence/nonce for every transaction to maintain proper address state. You can read more about this design decision here. Transaction signing and generation are also different in Ethereum, but for basic transactions, the process is very similar to our Bitcoin API.

Transaction Hash Endpoint

curl -s https://api.blockcypher.com/v1/eth/main/txs/8f39fb4940c084460da00a876a521ef2ba84ad6ea8d2f5628c9f1f8aeb395342
{
  "block_hash": "b35265965f6f14c5d692b2030922fce53067fc0e9d8c8490c31d4ecd3e46500c",
  "block_height": 1564040,
  "block_index": 0,
  "hash": "8f39fb4940c084460da00a876a521ef2ba84ad6ea8d2f5628c9f1f8aeb395342",
  "addresses": [
    "738d145faabb1e00cf5a017588a9c0f998318012",
    "4e9d8b4f18d984f6f0c88d07e4b39201e825cd17"
  ],
  "total": 10153153359437326,
  "fees": 1595580000000000,
  "size": 116,
  "relayed_by": "",
  "confirmed": "2016-05-22T12:43:00Z",
  "received": "2016-05-22T12:43:00Z",
  "ver": 0,
  "double_spend": false,
  "vin_sz": 1,
  "vout_sz": 1,
  "confirmations": 94919,
  "confidence": 1,
  "inputs": [
    {
      "sequence": 273,
      "addresses": [
        "738d145faabb1e00cf5a017588a9c0f998318012"
      ]
    }
  ],
  "outputs": [
    {
      "value": 10153153359437326,
      "script": "4e71d92d",
      "addresses": [
        "4e9d8b4f18d984f6f0c88d07e4b39201e825cd17"
      ]
    }
  ]
}

The Transaction Hash Endpoint returns detailed information about a given transaction based on its hash.

Resource Method Return Object
/txs/$TXHASH GET TX

TXHASH is a string representing the hex-encoded transaction hash you're interested in querying, for example:

8f39fb4940c084460da00a876a521ef2ba84ad6ea8d2f5628c9f1f8aeb395342

The returned object contains detailed information about the transaction, including the value transfered, fees collected, date received, any scripts associated with an output, and more.

Unconfirmed Transactions Endpoint

curl -s https://api.blockcypher.com/v1/eth/main/txs
[
  {
    "block_height": -1,
    "block_index": 0,
    "hash": "1f5bd529e72f6aa5724b6a3971781909e5156dc60058ccdfea15419bef25f5dd",
    "addresses": [
      "70d84f9b00556bb41c04aa0205506345f43ba746",
      "f7b0b916b2849255a61127fc4a42b9dfeaddf7d6"
    ],
    "total": 972909140000000000,
    "fees": 1260000000000000,
    "size": 110,
    "relayed_by": "",
    "received": "2016-06-07T07:47:40.14486539Z",
    "ver": 0,
    "double_spend": false,
    "vin_sz": 1,
    "vout_sz": 1,
    "confirmations": 0,
    "inputs": [
      {
        "sequence": 19,
        "addresses": [
          "70d84f9b00556bb41c04aa0205506345f43ba746"
        ]
      }
    ],
    "outputs": [
      {
        "value": 972909140000000000,
        "addresses": [
          "f7b0b916b2849255a61127fc4a42b9dfeaddf7d6"
        ]
      }
    ]
  },
  {
    "block_height": -1,
    "block_index": 0,
    "hash": "1bd833698337fce44a7feedf6bbe78c90ada088389ebafcad0b56901def3c989",
    "addresses": [
      "a1b5f95be71ffa2f86adefcaa0028c46fe825161",
      "b7443c8bdff977234ed9394169f181f9e9851422"
    ],
    "total": 1000000000000000000,
    "fees": 2420000000000000,
    "size": 111,
    "relayed_by": "",
    "received": "2016-06-07T07:47:38.710195289Z",
    "ver": 0,
    "double_spend": false,
    "vin_sz": 1,
    "vout_sz": 1,
    "confirmations": 0,
    "inputs": [
      {
        "sequence": 68,
        "addresses": [
          "a1b5f95be71ffa2f86adefcaa0028c46fe825161"
        ]
      }
    ],
    "outputs": [
      {
        "value": 1000000000000000000,
        "addresses": [
          "b7443c8bdff977234ed9394169f181f9e9851422"
        ]
      }
    ]
  },
    ...
]

The Unconfirmed Transactions Endpoint returns an array of the latest transactions that haven't been included in any blocks.

Resource Method Return Object
/txs GET Array[TX]
Flag Type Effect
limit integer Maximum number of transactions returned, if unset, default is 10. Maximum is 100.
minValue integer Filter transactions that transfer a total above the minimal value provided (in wei).

The returned object is an array of transactions that haven't been included in blocks, arranged in reverse chronological order (latest is first, then older transactions follow).

Creating Transactions

Using BlockCypher's API, you can push transactions to Ethereum in one of two ways:

In either case, for security reasons, we never take possession of your private keys.

curl -sd '{"inputs":[{"addresses": ["add42af7dd58b27e1e6ca5c4fdc01214b52d382f"]}],"outputs":[{"addresses": ["884bae20ee442a1d53a1d44b1067af42f896e541"], "value": 4200000000000000}]}' https://api.blockcypher.com/v1/eth/main/txs/new?token=YOURTOKEN

{
  "tx": {
    "block_height": -1,
    "block_index": 0,
    "hash": "9403244c6bcfe4063e7fb33138b02881d7a72ccdbd9c04d9abdff2b432d67ada",
    "addresses": [
      "add42af7dd58b27e1e6ca5c4fdc01214b52d382f",
      "884bae20ee442a1d53a1d44b1067af42f896e541"
    ],
    "total": 4200000000000000,
    "fees": 861000000000000,
    "size": 44,
    "gas_used": 0,
    "gas_price": 41000000000,
    "relayed_by": "",
    "received": "2016-06-08T01:32:35.573921633Z",
    "ver": 0,
    "double_spend": false,
    "vin_sz": 1,
    "vout_sz": 1,
    "inputs": [
      {
        "sequence": 0,
        "addresses": [
          "add42af7dd58b27e1e6ca5c4fdc01214b52d382f"
        ]
      }
    ],
    "outputs": [
      {
        "value": 4200000000000000,
        "addresses": [
          "884bae20ee442a1d53a1d44b1067af42f896e541"
        ]
      }
    ]
  },
  "tosign": [
    "a83f5bea598e0d217a03a2646d6c49edb2e99daf4537b2c09b008df76b77acec"
  ]
}

New Transaction Endpoint

To use BlockCypher's two-endpoint transaction creation tool, first you need to provide the input address, output address, and value to transfer (in wei). Provide this in a partially-filled out TX request object.

Resource Method Request Object Return Object
/txs/new POST TX TXSkeleton

As you can see from the code example, you only need to provide a single public address within the addresses array of both the input and output of your TX request object. You also need to fill in the value with the amount you'd like to transfer from one address to another. Note that we only accept a single input and output address per Ethereum's transaction model, and tosign only returns a single element in its array; we use arrays for parity with our Bitcoin API.

As a return object, you'll receive a TXSkeleton containing a slightly-more complete TX alongside data you need to sign in the tosign array. You'll need this object for the next steps of the transaction creation process.

# next, you sign the data returned in the tosign array locally
# here we're using our signer tool (https://github.com/blockcypher/btcutils/tree/master/signer), but any ECDSA secp256k1 signing tool should work (Ethereum uses the same ECDSA curve as Bitcoin for transaction signatures)
# $PRIVATEKEY here is a hex-encoded private key corresponding to the input from address add42af7dd58b27e1e6ca5c4fdc01214b52d382f

./signer a83f5bea598e0d217a03a2646d6c49edb2e99daf4537b2c09b008df76b77acec $PRIVATEKEY 
3045022100bc04ce017622f9830f955dbd8fafb65c5a72306a674711e507200f5f198954c90220581bc05e2658c258a985d914a158f89f44144a2e082837955b218d12a43a6a38

Locally Sign Your Transaction

With your TXSkeleton returned from the New Transaction Endpoint, you now need to use your private key to sign the data provided in the tosign array.

Digital signing can be a difficult process, and is where the majority of issues arise when dealing with cryptocurrency transactions. Ethereum uses the same elliptic curve as Bitcoin (secp256k1), so any Bitcoin signing library that fits with your workflow should suffice. If you want to experiment with client-side signing, consider using our signer tool.

# the request body is truncated because it's huge, but it's the same as the returned object from above plus the signature
curl -sd '{"tx": {...}, "tosign": [ "a83f5bea598e0d217a03a2646d6c49edb2e99daf4537b2c09b008df76b77acec" ], "signatures": [ "3045022100bc04ce017622f9830f955dbd8fafb65c5a72306a674711e507200f5f198954c90220581bc05e2658c258a985d914a158f89f44144a2e082837955b218d12a43a6a38" ]}' https://api.blockcypher.com/v1/eth/main/txs/send?token=YOURTOKEN

{
  "tx": {
    "block_height": -1,
    "block_index": 0,
    "hash": "85725e97d83ec7ce3888ca74d68b7820640f80d6380b9e1c565f61f5409acf50",
    "addresses": [
      "add42af7dd58b27e1e6ca5c4fdc01214b52d382f",
      "884bae20ee442a1d53a1d44b1067af42f896e541"
    ],
    "total": 4200000000000000,
    "fees": 861000000000000,
    "size": 109,
    "gas_used": 0,
    "gas_price": 41000000000,
    "relayed_by": "",
    "received": "2016-06-08T02:38:59.691331763Z",
    "ver": 0,
    "double_spend": false,
    "vin_sz": 1,
    "vout_sz": 1,
    "inputs": [
      {
        "sequence": 0,
        "addresses": [
          "add42af7dd58b27e1e6ca5c4fdc01214b52d382f"
        ]
      }
    ],
    "outputs": [
      {
        "value": 4200000000000000,
        "addresses": [
          "884bae20ee442a1d53a1d44b1067af42f896e541"
        ]
      }
    ]
  }
}

Send Transaction Endpoint

Once you've finished signing the tosign data locally, put that (hex-encoded) data into the signatures array of the TXSkeleton. Unlike Bitcoin, you don't need to include the signing accounts public key, as on Ethereum this is derived using the tosign data and signature data. But you must include the tosign data in addition to the signatures array for that derivation to work.

Resource Method Request Object Return Object
/txs/send POST TXSkeleton TXSkeleton

If the transaction was successful, you'll receive a TXSkeleton with the completed TX (which contains its final hash) and an HTTP Status Code 201.

Decode Raw Transaction Endpoint

curl -sd '{"tx":"f86b808504e3b2920082520894add42af7dd58b27e1e6ca5c4fdc01214b52d382f870bdccd84e7b000801ba0b86360f1c2d2b38421a80e71bf4cf54371bc9aa62f81c925484c6557b44b13f1a07b5690150c10a3947225fb612162c90ccfaefde99f7d363a8013e3eead0e55dd"}' https://api.blockcypher.com/v1/eth/main/txs/decode?token=YOURTOKEN
{
  "block_height": -1,
  "block_index": 0,
  "hash": "a88cca4dd97e028d7199028888156c4dad9936a2cbdfe8262fb12a252e16d4f1",
  "addresses": [
    "7ea7eb1c8b0fba77964c561f9b7494a87534aa15",
    "add42af7dd58b27e1e6ca5c4fdc01214b52d382f"
  ],
  "total": 3339000000000000,
  "fees": 441000000000000,
  "size": 109,
  "gas_used": 0,
  "gas_price": 21000000000,
  "relayed_by": "54.213.170.147",
  "received": "2016-06-08T06:18:08.181893896Z",
  "ver": 0,
  "double_spend": false,
  "vin_sz": 1,
  "vout_sz": 1,
  "confirmations": 0,
  "inputs": [
    {
      "sequence": 0,
      "addresses": [
        "7ea7eb1c8b0fba77964c561f9b7494a87534aa15"
      ]
    }
  ],
  "outputs": [
    {
      "value": 3339000000000000,
      "addresses": [
        "add42af7dd58b27e1e6ca5c4fdc01214b52d382f"
      ]
    }
  ]
}

We also offer the ability to decode raw transactions without sending propagating them to the network; perhaps you want to double-check another client library or confirm that another service is sending proper transactions.

Resource Method Request Object Return Object
/txs/decode POST {"tx":$TXHEX} TX

$TXHEX is a hex-encoded raw representation of your transaction, for example:

f86b808504e3b2920082520894add42af7dd58b27e1e6ca5c4fdc01214b52d382f870bdccd84e7b000801ba0b86360f1c2d2b38421a80e71bf4cf54371bc9aa62f81c925484c6557b44b13f1a07b5690150c10a3947225fb612162c90ccfaefde99f7d363a8013e3eead0e55dd

If it succeeds, you'll receive your decoded TX object.

Push Raw Transaction Endpoint

curl -sd '{"tx":"f86b808504e3b2920082520894add42af7dd58b27e1e6ca5c4fdc01214b52d382f870bdccd84e7b000801ba0b86360f1c2d2b38421a80e71bf4cf54371bc9aa62f81c925484c6557b44b13f1a07b5690150c10a3947225fb612162c90ccfaefde99f7d363a8013e3eead0e55dd"}' https://api.blockcypher.com/v1/eth/main/txs/push?token=YOURTOKEN
{
  "block_height": -1,
  "block_index": 0,
  "hash": "a88cca4dd97e028d7199028888156c4dad9936a2cbdfe8262fb12a252e16d4f1",
  "addresses": [
    "7ea7eb1c8b0fba77964c561f9b7494a87534aa15",
    "add42af7dd58b27e1e6ca5c4fdc01214b52d382f"
  ],
  "total": 3339000000000000,
  "fees": 441000000000000,
  "size": 109,
  "gas_used": 0,
  "gas_price": 21000000000,
  "relayed_by": "54.213.170.147",
  "received": "2016-06-08T06:18:08.181893896Z",
  "ver": 0,
  "double_spend": false,
  "vin_sz": 1,
  "vout_sz": 1,
  "confirmations": 0,
  "inputs": [
    {
      "sequence": 0,
      "addresses": [
        "7ea7eb1c8b0fba77964c561f9b7494a87534aa15"
      ]
    }
  ],
  "outputs": [
    {
      "value": 3339000000000000,
      "addresses": [
        "add42af7dd58b27e1e6ca5c4fdc01214b52d382f"
      ]
    }
  ]
}

If you'd prefer to use your own transaction library instead of the recommended path of our two-endpoint transaction generation we're still happy to help you propagate your raw transactions. Simply send your raw hex-encoded transaction to this endpoint and we'll leverage our well-connected network to propagate your transaction faster than anywhere else.

Resource Method Request Object Return Object
/txs/push POST {"tx":$TXHEX} TX

$TXHEX is a hex-encoded raw, RLP-encoded, representation of your transaction, for example:

f86b808504e3b2920082520894add42af7dd58b27e1e6ca5c4fdc01214b52d382f870bdccd84e7b000801ba0b86360f1c2d2b38421a80e71bf4cf54371bc9aa62f81c925484c6557b44b13f1a07b5690150c10a3947225fb612162c90ccfaefde99f7d363a8013e3eead0e55dd

If it succeeds, you'll receive a decoded TX object and an HTTP Status Code 201. You can then use the hash to track its progress on the network.

Transaction Cancellation and Replacement

curl -sd '{"gas_price": 150000000000, "inputs":[ "sequence": 1 ,{"addresses": ["add42af7dd58b27e1e6ca5c4fdc01214b52d382f"]}],"outputs":[{"addresses": ["884bae20ee442a1d53a1d44b1067af42f896e541"], "value": 4200000000000000}]}' https://api.blockcypher.com/v1/eth/main/txs/new?token=YOURTOKEN

{
  "tx": {
    "block_height": -1,
    "block_index": 0,
    "hash": "9403244c6bcfe4063e7fb33138b02881d7a72ccdbd9c04d9abdff2b432d67ada",
    "addresses": [
      "add42af7dd58b27e1e6ca5c4fdc01214b52d382f",
      "884bae20ee442a1d53a1d44b1067af42f896e541"
    ],
    "total": 7350000000000000,
    "fees": 3150000000000000,
    "size": 37,
    "gas_limit": 21000,
    "gas_price": 150000000000,
    "relayed_by": "",
    "received": "2016-06-08T01:32:35.573921633Z",
    "ver": 0,
    "double_spend": false,
    "vin_sz": 1,
    "vout_sz": 1,
    "inputs": [
      {
        "sequence": 1,
        "addresses": [
          "add42af7dd58b27e1e6ca5c4fdc01214b52d382f"
        ]
      }
    ],
    "outputs": [
      {
        "value": 4200000000000000,
        "addresses": [
          "884bae20ee442a1d53a1d44b1067af42f896e541"
        ]
      }
    ]
  },
  "tosign": [
    "a83f5bea598e0d217a03a2646d6c49edb2e99daf4537b2c09b008df76b77acec"
  ]
}

It is possible to "cancel" or "replace" a stuck transaction with Ethereum. This is particularly useful in times when gas prices are fluctuating a lot: you may want to increase the gas price of your transaction, to make sure it will be confirmed quickly.

To "cancel" or "replace" a transaction, create a transaction with the same nonce as the one stuck in the mempool.

Be sure to use the same nonce. To do so, you have to add the sequences params with the txs/new endpoint.

Contract API

Compared to other blockchains, contracts lie at the heart of Ethereum's unique value proposition. Contracts can be expressively programmed in languages like Solidity; if you're not familiar with Ethereum's contract language you should definitely start there.

We offer a number of API endpoints that significantly simplify contract creation and method calling. Via the methods below, you can embed new contracts into the Ethereum blockchain, check their code and ABI, and initiate contract methods and execution. Essentially, we provide a JSON/HTTP binding for your Ethereum contracts.

With great power comes great responsibility; in other words, it's easier to shoot yourself in the foot with Ethereum. Don't The DAO it. Follow best security and safety practices when coding your smart contracts.

Create Contract Endpoint

# Check solidity compilation via non-published test
# Using "greeter" contract solidity example, the "hello world" of Ethereum
cat testGreeter.json
{
  "solidity": "contract mortal { \n /* Define variable owner of the type address*/ \n address owner; \n /* this function is executed at initialization and sets the owner of the contract */ \n constructor() {  \n owner = msg.sender; // 'msg.sender' is sender of current call, contract deployer for a constructor \n } \n /* Function to recover the funds on the contract */ \n function kill() public {  \n require(msg.sender == owner, \"Caller is not owner\"); \n selfdestruct(payable(owner)); \n } \n } \n  \n contract greeter is mortal { \n /* define variable greeting of the type string */ \n string greeting; \n /* this runs when the contract is executed */ \n constructor(string memory _greeting) { \n greeting = _greeting; \n } \n function greet() public view \n returns (string memory) \n { \n return greeting; \n }}",
  "params": ["Hello BlockCypher Test"]
}
curl -sd @testGreeter.json https://api.blockcypher.com/v1/eth/main/contracts?token=YOURTOKEN
[
  {
    "name": "greeter",
    "solidity": "contract mortal { \n /* Define variable owner of the type address*/ \n address owner; \n /* this function is executed at initialization and sets the owner of the contract */ \n constructor() {  \n owner = msg.sender; // 'msg.sender' is sender of current call, contract deployer for a constructor \n } \n /* Function to recover the funds on the contract */ \n function kill() public {  \n require(msg.sender == owner, \"Caller is not owner\"); \n selfdestruct(payable(owner)); \n } \n } \n  \n contract greeter is mortal { \n /* define variable greeting of the type string */ \n string greeting; \n /* this runs when the contract is executed */ \n constructor(string memory _greeting) { \n greeting = _greeting; \n } \n function greet() public view \n returns (string memory) \n { \n return greeting; \n }}",
    "bin": "608060405234801561001057600080fd5b5060405161043838038061043883398101604081905261002f916100f4565b600080546001600160a01b03191633179055805161005490600190602084019061005b565b505061020e565b828054610067906101bd565b90600052602060002090601f01602090048101928261008957600085556100cf565b82601f106100a257805160ff19168380011785556100cf565b828001600101855582156100cf579182015b828111156100cf5782518255916020019190600101906100b4565b506100db9291506100df565b5090565b5b808211156100db57600081556001016100e0565b60006020808385031215610106578182fd5b82516001600160401b038082111561011c578384fd5b818501915085601f83011261012f578384fd5b815181811115610141576101416101f8565b604051601f8201601f19908116603f01168101908382118183101715610169576101696101f8565b816040528281528886848701011115610180578687fd5b8693505b828410156101a15784840186015181850187015292850192610184565b828411156101b157868684830101525b98975050505050505050565b600181811c908216806101d157607f821691505b602082108114156101f257634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052604160045260246000fd5b61021b8061021d6000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c806341c0e1b51461003b578063cfae321714610045575b600080fd5b610043610063565b005b61004d6100c5565b60405161005a9190610157565b60405180910390f35b6000546001600160a01b031633146100b75760405162461bcd60e51b815260206004820152601360248201527221b0b63632b91034b9903737ba1037bbb732b960691b604482015260640160405180910390fd5b6000546001600160a01b0316ff5b6060600180546100d4906101aa565b80601f0160208091040260200160405190810160405280929190818152602001828054610100906101aa565b801561014d5780601f106101225761010080835404028352916020019161014d565b820191906000526020600020905b81548152906001019060200180831161013057829003601f168201915b5050505050905090565b6000602080835283518082850152825b8181101561018357858101830151858201604001528201610167565b818111156101945783604083870101525b50601f01601f1916929092016040019392505050565b600181811c908216806101be57607f821691505b602082108114156101df57634e487b7160e01b600052602260045260246000fd5b5091905056fea26469706673582212209e12fa52086396058ad5dfc326b67b76a390adea81009f8f36b36ebe126e46d564736f6c63430008030033",
    "abi": [
      {
        "inputs": [
          {
            "internalType": "string",
            "name": "_greeting",
            "type": "string"
          }
        ],
        "stateMutability": "nonpayable",
        "type": "constructor"
      },
      {
        "inputs": [],
        "name": "greet",
        "outputs": [
          {
            "internalType": "string",
            "name": "",
            "type": "string"
          }
        ],
        "stateMutability": "view",
        "type": "function"
      },
      {
        "inputs": [],
        "name": "kill",
        "outputs": [],
        "stateMutability": "nonpayable",
        "type": "function"
      }
    ],
    "params": [
      "Hello BlockCypher Test"
    ]
  },
  {
    "name": "mortal",
    "solidity": "contract mortal { \n /* Define variable owner of the type address*/ \n address owner; \n /* this function is executed at initialization and sets the owner of the contract */ \n constructor() {  \n owner = msg.sender; // 'msg.sender' is sender of current call, contract deployer for a constructor \n } \n /* Function to recover the funds on the contract */ \n function kill() public {  \n require(msg.sender == owner, \"Caller is not owner\"); \n selfdestruct(payable(owner)); \n } \n } \n  \n contract greeter is mortal { \n /* define variable greeting of the type string */ \n string greeting; \n /* this runs when the contract is executed */ \n constructor(string memory _greeting) { \n greeting = _greeting; \n } \n function greet() public view \n returns (string memory) \n { \n return greeting; \n }}",
    "bin": "608060405234801561001057600080fd5b50600080546001600160a01b0319163317905560cc806100316000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c806341c0e1b514602d575b600080fd5b60336035565b005b6000546001600160a01b0316331460885760405162461bcd60e51b815260206004820152601360248201527221b0b63632b91034b9903737ba1037bbb732b960691b604482015260640160405180910390fd5b6000546001600160a01b0316fffea2646970667358221220420a57eb2167f9e9f39ce5c996fb4bb09909dba814de08f90a34171b9e3bf61c64736f6c63430008030033",
    "abi": [
      {
        "inputs": [],
        "stateMutability": "nonpayable",
        "type": "constructor"
      },
      {
        "inputs": [],
        "name": "kill",
        "outputs": [],
        "stateMutability": "nonpayable",
        "type": "function"
      }
    ],
    "params": [
      "Hello BlockCypher Test"
    ]
  }
]

# Now publish the greeter contract
cat publishGreeter.json
{
  "solidity": "contract mortal { \n /* Define variable owner of the type address*/ \n address owner; \n /* this function is executed at initialization and sets the owner of the contract */ \n constructor() {  \n owner = msg.sender; // 'msg.sender' is sender of current call, contract deployer for a constructor \n } \n /* Function to recover the funds on the contract */ \n function kill() public {  \n require(msg.sender == owner, \"Caller is not owner\"); \n selfdestruct(payable(owner)); \n } \n } \n  \n contract greeter is mortal { \n /* define variable greeting of the type string */ \n string greeting; \n /* this runs when the contract is executed */ \n constructor(string memory _greeting) { \n greeting = _greeting; \n } \n function greet() public view \n returns (string memory) \n { \n return greeting; \n }}",
  "params": ["Hello BlockCypher Test"],
  "publish": ["greeter"],
  "private": "3ca40...",
  "gas_limit": 500000
}
curl -d @publishGreeter.json https://api.blockcypher.com/v1/eth/main/contracts?token=YOURTOKEN
[
  {
    "name": "\u003cstdin\u003e:greeter",
    "solidity": "contract mortal { \n /* Define variable owner of the type address*/ \n address owner; \n /* this function is executed at initialization and sets the owner of the contract */ \n constructor() {  \n owner = msg.sender; // 'msg.sender' is sender of current call, contract deployer for a constructor \n } \n /* Function to recover the funds on the contract */ \n function kill() public {  \n require(msg.sender == owner, \"Caller is not owner\"); \n selfdestruct(payable(owner)); \n } \n } \n  \n contract greeter is mortal { \n /* define variable greeting of the type string */ \n string greeting; \n /* this runs when the contract is executed */ \n constructor(string memory _greeting) { \n greeting = _greeting; \n } \n function greet() public view \n returns (string memory) \n { \n return greeting; \n }}",
    "bin": "608060405234801561001057600080fd5b5060405161043838038061043883398101604081905261002f916100f4565b600080546001600160a01b03191633179055805161005490600190602084019061005b565b505061020e565b828054610067906101bd565b90600052602060002090601f01602090048101928261008957600085556100cf565b82601f106100a257805160ff19168380011785556100cf565b828001600101855582156100cf579182015b828111156100cf5782518255916020019190600101906100b4565b506100db9291506100df565b5090565b5b808211156100db57600081556001016100e0565b60006020808385031215610106578182fd5b82516001600160401b038082111561011c578384fd5b818501915085601f83011261012f578384fd5b815181811115610141576101416101f8565b604051601f8201601f19908116603f01168101908382118183101715610169576101696101f8565b816040528281528886848701011115610180578687fd5b8693505b828410156101a15784840186015181850187015292850192610184565b828411156101b157868684830101525b98975050505050505050565b600181811c908216806101d157607f821691505b602082108114156101f257634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052604160045260246000fd5b61021b8061021d6000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c806341c0e1b51461003b578063cfae321714610045575b600080fd5b610043610063565b005b61004d6100c5565b60405161005a9190610157565b60405180910390f35b6000546001600160a01b031633146100b75760405162461bcd60e51b815260206004820152601360248201527221b0b63632b91034b9903737ba1037bbb732b960691b604482015260640160405180910390fd5b6000546001600160a01b0316ff5b6060600180546100d4906101aa565b80601f0160208091040260200160405190810160405280929190818152602001828054610100906101aa565b801561014d5780601f106101225761010080835404028352916020019161014d565b820191906000526020600020905b81548152906001019060200180831161013057829003601f168201915b5050505050905090565b6000602080835283518082850152825b8181101561018357858101830151858201604001528201610167565b818111156101945783604083870101525b50601f01601f1916929092016040019392505050565b600181811c908216806101be57607f821691505b602082108114156101df57634e487b7160e01b600052602260045260246000fd5b5091905056fea26469706673582212209e12fa52086396058ad5dfc326b67b76a390adea81009f8f36b36ebe126e46d564736f6c63430008030033",
    "abi": [
      {
        "inputs": [
          {
            "internalType": "string",
            "name": "_greeting",
            "type": "string"
          }
        ],
        "stateMutability": "nonpayable",
        "type": "constructor"
      },
      {
        "inputs": [],
        "name": "greet",
        "outputs": [
          {
            "internalType": "string",
            "name": "",
            "type": "string"
          }
        ],
        "stateMutability": "view",
        "type": "function"
      },
      {
        "inputs": [],
        "name": "kill",
        "outputs": [],
        "stateMutability": "nonpayable",
        "type": "function"
      }
    ],
    "gas_limit": 500000,
    "creation_tx_hash": "61474003e56d67aba6bf148c5ec361e3a3c1ceea37fe3ace7d87759b399292f9",
    "address": "0eb688e79698d645df015cf2e9db5a6fe16357f1",
    "params": [
      "Hello BlockCypher Test"
    ]
  },
  {
    "name": "\u003cstdin\u003e:mortal",
    "solidity": "contract mortal { \n /* Define variable owner of the type address*/ \n address owner; \n /* this function is executed at initialization and sets the owner of the contract */ \n constructor() {  \n owner = msg.sender; // 'msg.sender' is sender of current call, contract deployer for a constructor \n } \n /* Function to recover the funds on the contract */ \n function kill() public {  \n require(msg.sender == owner, \"Caller is not owner\"); \n selfdestruct(payable(owner)); \n } \n } \n  \n contract greeter is mortal { \n /* define variable greeting of the type string */ \n string greeting; \n /* this runs when the contract is executed */ \n constructor(string memory _greeting) { \n greeting = _greeting; \n } \n function greet() public view \n returns (string memory) \n { \n return greeting; \n }}",
    "bin": "608060405234801561001057600080fd5b50600080546001600160a01b0319163317905560cc806100316000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c806341c0e1b514602d575b600080fd5b60336035565b005b6000546001600160a01b0316331460885760405162461bcd60e51b815260206004820152601360248201527221b0b63632b91034b9903737ba1037bbb732b960691b604482015260640160405180910390fd5b6000546001600160a01b0316fffea2646970667358221220420a57eb2167f9e9f39ce5c996fb4bb09909dba814de08f90a34171b9e3bf61c64736f6c63430008030033",
    "abi": [
      {
        "inputs": [],
        "stateMutability": "nonpayable",
        "type": "constructor"
      },
      {
        "inputs": [],
        "name": "kill",
        "outputs": [],
        "stateMutability": "nonpayable",
        "type": "function"
      }
    ],
    "params": [
      "Hello BlockCypher Test"
    ]
  }
]

# you can check the creation_tx_hash to see that the contract was published
curl -s https://api.blockcypher.com/v1/eth/main/txs/61474003e56d67aba6bf148c5ec361e3a3c1ceea37fe3ace7d87759b399292f9
{
  "block_hash": "fcd88715c95e6082612ab673ae3053d8bbfc51ca0b00aa82974ea4d139010015",
  "block_height": 1917071,
  "block_index": 0,
  "hash": "61474003e56d67aba6bf148c5ec361e3a3c1ceea37fe3ace7d87759b399292f9",
  "addresses": [
    "e2d7871ca37379ea18d259cdf3592fe032183d94"
  ],
  "total": 0,
  "fees": 8448706000000000,
  "size": 756,
  "gas_used": 206066,
  "gas_price": 41000000000,
  "contract_creation": true,
  "relayed_by": "",
  "confirmed": "2016-07-20T01:54:50Z",
  "received": "2016-07-20T01:54:50Z",
  "ver": 0,
  "double_spend": false,
  "vin_sz": 1,
  "vout_sz": 1,
  "confirmations": 5,
  "confidence": 1,
  "inputs": [
    {
      "sequence": 7,
      "addresses": [
        "e2d7871ca37379ea18d259cdf3592fe032183d94"
      ]
    }
  ],
  "outputs": [
    {
      "value": 0,
      "script": "606060405260405161023e38038061023e8339810160405280510160008054600160a060020a031916331790558060016000509080519060200190828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10609f57805160ff19168380011785555b50608e9291505b8082111560cc57600081558301607d565b50505061016e806100d06000396000f35b828001600101855582156076579182015b82811115607657825182600050559160200191906001019060b0565b509056606060405260e060020a600035046341c0e1b58114610026578063cfae321714610068575b005b6100246000543373ffffffffffffffffffffffffffffffffffffffff908116911614156101375760005473ffffffffffffffffffffffffffffffffffffffff16ff5b6100c9600060609081526001805460a06020601f6002600019610100868816150201909416939093049283018190040281016040526080828152929190828280156101645780601f1061013957610100808354040283529160200191610164565b60405180806020018281038252838181518152602001915080519060200190808383829060006004602084601f0104600f02600301f150905090810190601f1680156101295780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b565b820191906000526020600020905b81548152906001019060200180831161014757829003601f168201915b5050505050905090560000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001648656c6c6f20426c6f636b437970686572205465737400000000000000000000",
      "addresses": [
        "0eb688e79698d645df015cf2e9db5a6fe16357f1"
      ]
    }
  ]
}

The Create Contract Endpoint allows you to submit your solidity code and params to check raw serialized binary compilation and ABI. It's an easy to validate your contract compiles before pushing it to the Ethereum blockchain.

If you include a private key (associated with a funded Ethereum external account), gas_limit, and contract(s) to publish, BlockCypher will embed the contract into the blockchain and return the transaction hash that created the contract and the contract address. Find both of those properties under the returned contract object as address and creation_tx_hash.

The params property lets you provide arguments to the contract constructor. If your contract has no constructor or the constructor takes no arguments, this property can be omitted.

You can optionally include value in wei to transfer to the contract on creation.

Resource Method Request Object Return Object
/contracts POST Contract Array[Contract]

Get Contract Address Endpoint


# and/or, check the contract address. if it was created by blockcypher, we'll return the code and ABI as well.
curl -s https://api.blockcypher.com/v1/eth/main/contracts/0eb688e79698d645df015cf2e9db5a6fe16357f1?token=YOURTOKEN
{
  "solidity": "contract mortal {\n  /* Define variable owner of the type address*/\n    address owner;\n    /* this function is executed at initialization and sets the owner of the contract */\n    function mortal() { owner = msg.sender; }\n    /* Function to recover the funds on the contract */\n    function kill() { if (msg.sender == owner) suicide(owner); }\n}\n\ncontract greeter is mortal {\n    /* define variable greeting of the type string */\n    string greeting;\n    /* this runs when the contract is executed */\n    function greeter(string _greeting) public {\n        greeting = _greeting;\n    }\n    /* main function */\n    function greet() constant returns (string) {\n        return greeting;\n    }\n}",
  "bin": "606060405260405161023e38038061023e8339810160405280510160008054600160a060020a031916331790558060016000509080519060200190828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10609f57805160ff19168380011785555b50608e9291505b8082111560cc57600081558301607d565b50505061016e806100d06000396000f35b828001600101855582156076579182015b82811115607657825182600050559160200191906001019060b0565b509056606060405260e060020a600035046341c0e1b58114610026578063cfae321714610068575b005b6100246000543373ffffffffffffffffffffffffffffffffffffffff908116911614156101375760005473ffffffffffffffffffffffffffffffffffffffff16ff5b6100c9600060609081526001805460a06020601f6002600019610100868816150201909416939093049283018190040281016040526080828152929190828280156101645780601f1061013957610100808354040283529160200191610164565b60405180806020018281038252838181518152602001915080519060200190808383829060006004602084601f0104600f02600301f150905090810190601f1680156101295780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b565b820191906000526020600020905b81548152906001019060200180831161014757829003601f168201915b5050505050905090560000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001648656c6c6f20426c6f636b437970686572205465737400000000000000000000",
  "abi": "[{\"constant\":false,\"inputs\":[],\"name\":\"kill\",\"outputs\":[],\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"greet\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"type\":\"function\"},{\"inputs\":[{\"name\":\"_greeting\",\"type\":\"string\"}],\"type\":\"constructor\"}]",
  "creation_tx_hash": "61474003e56d67aba6bf148c5ec361e3a3c1ceea37fe3ace7d87759b399292f9",
  "created": "2016-07-20T01:54:50Z",
  "address": "0eb688e79698d645df015cf2e9db5a6fe16357f1"
}
Resource Method Return Object
/contract/$ADDRESS GET Contract

ADDRESS is a string representing the contract address you're interested in querying, for example:

0eb688e79698d645df015cf2e9db5a6fe16357f1

The returned object contains information about the contract; if you deployed the contract with BlockCypher, it will return solidity and abi as well.

Call Contract Method Endpoint

# call the greet method, using your own private key and gas amount to fund
cat call.json
{
  "private": "3ca40...",
  "gas_limit": 20000
}
curl -d @call.json -s https://api.blockcypher.com/v1/eth/main/contracts/0eb688e79698d645df015cf2e9db5a6fe16357f1/greet?token=YOURTOKEN
{
  "gas_limit": 20000,
  "address": "0eb688e79698d645df015cf2e9db5a6fe16357f1",
  "results": [
    "Hello BlockCypher Test"
  ]
}

# use the same private key/gas amount to call the "kill" method, which causes the contract to create an internal_tx to refund the initial private key
curl -d @call.json -s https://api.blockcypher.com/v1/eth/main/contracts/0eb688e79698d645df015cf2e9db5a6fe16357f1/kill?token=YOURTOKEN
{"error": "Error calling contract: Gas value too low, intrinsic gas required is 53272.."}

# whoops! let's try upping the gas
cat call.json
{
  "private": "3ca40...",
  "gas_limit": 100000
}
curl -d @call.json -s https://api.blockcypher.com/v1/eth/main/contracts/0eb688e79698d645df015cf2e9db5a6fe16357f1/kill?token=YOURTOKEN
{
  "gas_limit": 100000,
  "call_tx_hash": "42dc5862aeedf1001db37c404c8dc922918167589aba1e0b19c6a9372eedb294",
  "address": "0eb688e79698d645df015cf2e9db5a6fe16357f1"
}

The Call Contract Method endpoint makes every method in your contracts callable simply via an HTTP request. It's a binding that translates a published contract into a set of endpoints (one for each method) and a provided JSON array into a set of arguments to invoke a given method.

To call a method on a given contract, you must include a private key associated with a funded external account and a specified gas_limit in your request object. params are optionally accepted if the contract method allows them. Make sure the JSON types your provide match your contract signature (string, number, etc.). You can optionally include value in wei to transfer to this contract method.

The Call Contract endpoint will check the contract ABI to determine whether the method has been declared "constant". If so, no transaction will be created and no gas will be consumed. The method is just called locally on our servers and won't be registered on the blockchain. Otherwise, we will build the call transaction to invoke the method on the Ethereum blockchain and propagate it on the network. Keep in mind that in that case, you will need to wait for the call transaction to be included in a block to see its effects.

Resource Method Request Object Return Object
/contracts/$ADDRESS/$METHOD POST Contract Contract

ADDRESS is a string representing the contract address you're interested in querying, for example:

0eb688e79698d645df015cf2e9db5a6fe16357f1

METHOD is a string representing a declared method from the above contract; in the above example, the options are:

greet

or

kill

Events and Hooks

Ethereum is a highly transactional system. Many usage patterns require knowing when an event occurs: i.e., when a transaction is included into a block, when an address is updated, etc. Instead of requiring you to continuously poll resources, we provide push APIs to facilitate those use cases, and support WebHooks for that express purpose.

Types of Events

We support a number of different event types, and you can filter your notification requests depending on how you structure your Event request object.

Event Description
unconfirmed-tx Triggered for every new transaction BlockCypher receives before it's confirmed in a block; basically, for every unconfirmed transaction. The payload is an unconfirmed TX.
new-block Triggered for every new block. The payload is a Block.
confirmed-tx Triggered for every new transaction making it into a new block; in other words, for every first transaction confirmation. This is equivalent to listening to the new-block event and fetching each transaction (or filtered transaction) in the new Block. The payload is a confirmed TX.
tx-confirmation Simplifies listening to confirmations on all transactions for a given address up to a provided threshold. Sends first the unconfirmed transaction and then the transaction for each confirmation. Use the confirmations property within the Event to manually specify the number of confirmations desired (maximum 10, defaults to 6). The payload is a TX.
double-spend-tx Triggered any time a double spend is detected by BlockCypher. The payload is the TX that triggered the event; the hash of the transaction that it's trying to double spend is included in its double_spend_tx property.

Using WebHooks

For WebHooks, the JSON Event should be sent using a POST request to the "create webhook endpoint" and include a url property to denote where payloads should be delivered. The TX or Block associated with the Event will be POSTed to the provided url. The POSTed payload will also include X-EventType and X-EventId metadata in the HTTP header specifying the event type and id of the WebHook which triggered the payload.

We retry individual payloads to your url five times; if one fails, we wait exponentially between retries: 1 second, 2s, 4s, 8s, 16s. In order to protect against stale callback urls, your Event will be deleted if it reaches 50 aggregate callback_errors from failed payloads.

Create WebHook Endpoint

curl -sd '{"event": "unconfirmed-tx", "address": "c5beef03aaa9548210b5550a62f7756efaa08ba3", "url": "https://my.domain.com/callbacks/new-tx"}' https://api.blockcypher.com/v1/eth/main/hooks?token=YOURTOKEN
{
  "id": "ce83d08f-7b86-4a6a-9b41-85507648f9c7",
  "token": "YOURTOKEN",
  "url": "https://my.domain.com/callbacks/new-tx",
  "callback_errors": 0,
  "address": "c5beef03aaa9548210b5550a62f7756efaa08ba3",
  "event": "unconfirmed-tx",
  "filter": "addr=c5beef03aaa9548210b5550a62f7756efaa08ba3\u0026event=unconfirmed-tx"
}

Using a partially filled out Event, you can create a WebHook using this resource. Check the Event object description and types of events to understand the available options.

Resource Method Request Object Return Object
/hooks POST Event Event

If successful, it will return the Event with a newly generated id.

List WebHooks Endpoint

curl -s https://api.blockcypher.com/v1/eth/main/hooks?token=YOURTOKEN
[
  {
    "id": "ce83d08f-7b86-4a6a-9b41-85507648f9c7",
    "token": "YOURTOKEN",
    "url": "https://my.domain.com/callbacks/new-tx",
    "callback_errors": 0,
    "address": "c5beef03aaa9548210b5550a62f7756efaa08ba3",
    "event": "unconfirmed-tx",
    "filter": "addr=c5beef03aaa9548210b5550a62f7756efaa08ba3\u0026event=unconfirmed-tx"
  }
]

This resource lists your currently active events, according to the base resource and $YOURTOKEN.

Resource Method Return Object
/hooks?token=$YOURTOKEN GET Array[Event]

WebHook ID Endpoint

curl -s https://api.blockcypher.com/v1/eth/main/hooks/ce83d08f-7b86-4a6a-9b41-85507648f9c7?token=YOURTOKEN
{
  "id": "ce83d08f-7b86-4a6a-9b41-85507648f9c7",
  "token": "YOURTOKEN",
  "url": "https://my.domain.com/callbacks/new-tx",
  "callback_errors": 0,
  "address": "c5beef03aaa9548210b5550a62f7756efaa08ba3",
  "event": "unconfirmed-tx",
  "filter": "addr=c5beef03aaa9548210b5550a62f7756efaa08ba3\u0026event=unconfirmed-tx"
}

This resource returns an Event based on its generated id.

Resource Method Return Object
/hooks/$WEBHOOKID GET Event

WEBHOOKID is a string representing the event's generated id, for example:

ce83d08f-7b86-4a6a-9b41-85507648f9c7

Delete WebHook Endpoint

# Piping into grep to get status code
curl -X DELETE -Is https://api.blockcypher.com/v1/eth/main/hooks/ce83d08f-7b86-4a6a-9b41-85507648f9c7?token=YOURTOKEN | grep "HTTP/1.1"
HTTP/1.1 204 No Content

This resource deletes an active Event based on its id. Remember to include your token, or the request will fail.

Resource Method Return Object
/hooks/$WEBHOOKID DELETE nil

WEBHOOKID is a string representing the event's generated id, for example:

ce83d08f-7b86-4a6a-9b41-85507648f9c7

If successful, it won't return any objects, but will respond with an HTTP Status Code 204.

Payment Forwarding

One of the well-known benefits of cryptocurrency is the ability to allow users to partake in online commerce without necessarily requiring extensive setup barriers, like registering new accounts. In that spirit, our Payment Forwarding API is the easiest way to accept---and consolidate---payments securely without forcing your users to create accounts and jump through unnecessary loops. It's also a generic way to automatically transfer value from one address to another. While there are many possible use cases, the main one is a way to generate payment-specific addresses for which funds will automatically transfer to a main merchant address. Great for automatic merchandise (whether physical or virtual) processing.

We do not take a fee on payment forwarding, other than the required 1,680,000 wei miner fee (default 80 gwei gas price with 21000 gas limit); which can be changed with the gas_price_gwei parameter.

Create Payment Endpoint

curl -d '{"destination":"0xda4b58eff2f3fd6c9845f82268cac1115b9b446b","callback_url": "https://my.domain.com/callbacks/new-pay"}' https://api.blockcypher.com/v1/eth/main/payments?token=YOURTOKEN

{
  "id": "82f0af68-da11-477f-8b42-79edbf3e6481",
  "token": "YOURTOKEN",
  "destination": "da4b58eff2f3fd6c9845f82268cac1115b9b446b",
  "input_address": "718d2ab6160cf79cab1815dcc87d6b76fc20a0ba",
  "callback_url": "https://my.domain.com/callbacks/new-pay"
}

First, to create an payment forwarding address, you need to POST a partially filled PaymentForward object to the payment creation endpoint. You need to include at least a destination address and your token; optionally, you can add a callback_url, a gas_price_gwei and a few other options. You can see more details about these options in the PaymentForward object details.

Resource Method Request Object Return Object
/payments POST PaymentForward PaymentForward

In return, you'll get a more complete PaymentForward object, including an input_address and id.

List Payments Endpoint

curl https://api.blockcypher.com/v1/eth/main/payments?token=YOURTOKEN

[
  {
    "id": "82f0af68-da11-477f-8b42-79edbf3e6481",
    "token": "YOURTOKEN",
    "destination": "da4b58eff2f3fd6c9845f82268cac1115b9b446b",
    "input_address": "718d2ab6160cf79cab1815dcc87d6b76fc20a0ba",
    "callback_url": "https://my.domain.com/callbacks/new-pay"
  },
]

To list your currently active payment forwarding addresses, you can use this endpoint.

Resource Method Return Object
/payments GET Array[PaymentForward]
Flag Type Effect
start integer Returns list of payment forwards starting at the start index; useful for paging beyond the limit of 200 payment forwards.

This returns the full array of your currently active payment forwarding addresses, based on your token. By default, this endpoint only returns the first 200 payment forwards. If you have more, you can page through them using the optional start parameter.

Delete Payment Endpoint

# Piping to grep to just show status code
curl -X DELETE -Is https://api.blockcypher.com/v1/eth/main/payments/82f0af68-da11-477f-8b42-79edbf3e6481?token=YOURTOKEN | grep "HTTP/1.1"

HTTP/1.1 204 No Content

When you're done with a payment forwarding address, you can delete it via its id.

Resource Method Return Object
/payments/$PAYID DELETE nil

PAYID is a string representing the payment forwarding request you want to delete, for example:

82f0af68-da11-477f-8b42-79edbf3e6481

This will return no object, but will return an HTTP Status Code 204 if the request was successfully deleted.

Examples

This section contains various examples about how to leverage BlockCypher's Ethereum API.

ERC-20 Tokens

ERC-20 is the Ethereum token standard which is used for Ethereum smart contracts. Developed in 2015, ERC-20 defines a common list of rules that an Ethereum token has to implement. Giving developers the ability to program how new tokens will function within the Ethereum ecosystem.

The ERC-20 Token Standard is defined in EIP 20.

In this category, we will take the example of Tether (USDT), an ERC-20 token, to show you how you can use BlockCypher's API to easily interact with the Ethereum Blockchain.

This contract is deployed at dac17f958d2ee523a2206206994597c13d831ec7.

We can use the contract endpoint to learn more about it.

curl -s https://api.blockcypher.com/v1/eth/main/contracts/dac17f958d2ee523a2206206994597c13d831ec7?token=$TOKEN
{
  "bin": "606060405260008060146101000a81548160ff0219169083151502179055506000600355600060045534156200003457600080fd5b60405162002d7c38038062002d7c83398101604052808051906020019091908051820191906020018051820191906020018051906020019091905050336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550836001819055508260079080519060200190620000cf9291906200017a565b508160089080519060200190620000e89291906200017a565b508060098190555083600260008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506000600a60146101000a81548160ff0219169083151502179055505050505062000229565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10620001bd57805160ff1916838001178555620001ee565b82800160010185558215620001ee579182015b82811115620001ed578251825591602001919060010190620001d0565b5b509050620001fd919062000201565b5090565b6200022691905b808211156200022257600081600090555060010162000208565b5090565b90565b612b4380620002396000396000f300606060405260043610610196576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde031461019b5780630753c30c14610229578063095ea7b3146102625780630e136b19146102a45780630ecb93c0146102d157806318160ddd1461030a57806323b872dd1461033357806326976e3f1461039457806327e235e3146103e9578063313ce56714610436578063353907141461045f5780633eaaf86b146104885780633f4ba83a146104b157806359bf1abe146104c65780635c658165146105175780635c975abb1461058357806370a08231146105b05780638456cb59146105fd578063893d20e8146106125780638da5cb5b1461066757806395d89b41146106bc578063a9059cbb1461074a578063c0324c771461078c578063cc872b66146107b8578063db006a75146107db578063dd62ed3e146107fe578063dd644f721461086a578063e47d606014610893578063e4997dc5146108e4578063e5b5019a1461091d578063f2fde38b14610946578063f3bdc2281461097f575b600080fd5b34156101a657600080fd5b6101ae6109b8565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101ee5780820151818401526020810190506101d3565b50505050905090810190601f16801561021b5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561023457600080fd5b610260600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610a56565b005b341561026d57600080fd5b6102a2600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610b73565b005b34156102af57600080fd5b6102b7610cc1565b604051808215151515815260200191505060405180910390f35b34156102dc57600080fd5b610308600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610cd4565b005b341561031557600080fd5b61031d610ded565b6040518082815260200191505060405180910390f35b341561033e57600080fd5b610392600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091908035906020019091905050610ebd565b005b341561039f57600080fd5b6103a761109d565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156103f457600080fd5b610420600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506110c3565b6040518082815260200191505060405180910390f35b341561044157600080fd5b6104496110db565b6040518082815260200191505060405180910390f35b341561046a57600080fd5b6104726110e1565b6040518082815260200191505060405180910390f35b341561049357600080fd5b61049b6110e7565b6040518082815260200191505060405180910390f35b34156104bc57600080fd5b6104c46110ed565b005b34156104d157600080fd5b6104fd600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919050506111ab565b604051808215151515815260200191505060405180910390f35b341561052257600080fd5b61056d600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050611201565b6040518082815260200191505060405180910390f35b341561058e57600080fd5b610596611226565b604051808215151515815260200191505060405180910390f35b34156105bb57600080fd5b6105e7600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050611239565b6040518082815260200191505060405180910390f35b341561060857600080fd5b610610611348565b005b341561061d57600080fd5b610625611408565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561067257600080fd5b61067a611431565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34156106c757600080fd5b6106cf611456565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561070f5780820151818401526020810190506106f4565b50505050905090810190601f16801561073c5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561075557600080fd5b61078a600480803573ffffffffffffffffffffffffffffffffffffffff169060200190919080359060200190919050506114f4565b005b341561079757600080fd5b6107b6600480803590602001909190803590602001909190505061169e565b005b34156107c357600080fd5b6107d96004808035906020019091905050611783565b005b34156107e657600080fd5b6107fc600480803590602001909190505061197a565b005b341561080957600080fd5b610854600480803573ffffffffffffffffffffffffffffffffffffffff1690602001909190803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050611b0d565b6040518082815260200191505060405180910390f35b341561087557600080fd5b61087d611c52565b6040518082815260200191505060405180910390f35b341561089e57600080fd5b6108ca600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050611c58565b604051808215151515815260200191505060405180910390f35b34156108ef57600080fd5b61091b600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050611c78565b005b341561092857600080fd5b610930611d91565b6040518082815260200191505060405180910390f35b341561095157600080fd5b61097d600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050611db5565b005b341561098a57600080fd5b6109b6600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050611e8a565b005b60078054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610a4e5780601f10610a2357610100808354040283529160200191610a4e565b820191906000526020600020905b815481529060010190602001808311610a3157829003601f168201915b505050505081565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610ab157600080fd5b6001600a60146101000a81548160ff02191690831515021790555080600a60006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055507fcc358699805e9a8b7f77b522628c7cb9abd07d9efb86b6fb616af1609036a99e81604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a150565b604060048101600036905010151515610b8b57600080fd5b600a60149054906101000a900460ff1615610cb157600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663aee92d333385856040518463ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050600060405180830381600087803b1515610c9857600080fd5b6102c65a03f11515610ca957600080fd5b505050610cbc565b610cbb838361200e565b5b505050565b600a60149054906101000a900460ff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515610d2f57600080fd5b6001600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055507f42e160154868087d6bfdc0ca23d96a1c1cfa32f1b72ba9ba27b69b98a0d819dc81604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a150565b6000600a60149054906101000a900460ff1615610eb457600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166318160ddd6000604051602001526040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b1515610e9257600080fd5b6102c65a03f11515610ea357600080fd5b505050604051805190509050610eba565b60015490505b90565b600060149054906101000a900460ff16151515610ed957600080fd5b600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16151515610f3257600080fd5b600a60149054906101000a900460ff161561108c57600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16638b477adb338585856040518563ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828152602001945050505050600060405180830381600087803b151561107357600080fd5b6102c65a03f1151561108457600080fd5b505050611098565b6110978383836121ab565b5b505050565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60026020528060005260406000206000915090505481565b60095481565b60045481565b60015481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561114857600080fd5b600060149054906101000a900460ff16151561116357600080fd5b60008060146101000a81548160ff0219169083151502179055507f7805862f689e2f13df9f062ff482ad3ad112aca9e0847911ed832e158c525b3360405160405180910390a1565b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff169050919050565b6005602052816000526040600020602052806000526040600020600091509150505481565b600060149054906101000a900460ff1681565b6000600a60149054906101000a900460ff161561133757600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166370a08231836000604051602001526040518263ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001915050602060405180830381600087803b151561131557600080fd5b6102c65a03f1151561132657600080fd5b505050604051805190509050611343565b61134082612652565b90505b919050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156113a357600080fd5b600060149054906101000a900460ff161515156113bf57600080fd5b6001600060146101000a81548160ff0219169083151502179055507f6985a02210a168e66602d3235cb6db0e70f92b3ba4d376a33c0f3d9434bff62560405160405180910390a1565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60088054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156114ec5780601f106114c1576101008083540402835291602001916114ec565b820191906000526020600020905b8154815290600101906020018083116114cf57829003601f168201915b505050505081565b600060149054906101000a900460ff1615151561151057600080fd5b600660003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615151561156957600080fd5b600a60149054906101000a900460ff161561168f57600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16636e18980a3384846040518463ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050600060405180830381600087803b151561167657600080fd5b6102c65a03f1151561168757600080fd5b50505061169a565b611699828261269b565b5b5050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156116f957600080fd5b60148210151561170857600080fd5b60328110151561171757600080fd5b81600381905550611736600954600a0a82612a0390919063ffffffff16565b6004819055507fb044a1e409eac5c48e5af22d4af52670dd1a99059537a78b31b48c6500a6354e600354600454604051808381526020018281526020019250505060405180910390a15050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156117de57600080fd5b60015481600154011115156117f257600080fd5b600260008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205481600260008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054011115156118c257600080fd5b80600260008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550806001600082825401925050819055507fcb8241adb0c3fdb35b70c24ce35c5eb0c17af7431c99f827d44a445ca624176a816040518082815260200191505060405180910390a150565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415156119d557600080fd5b80600154101515156119e657600080fd5b80600260008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410151515611a5557600080fd5b8060016000828254039250508190555080600260008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055507f702d5967f45f6513a38ffc42d6ba9bf230bd40e8f53b16363c7eb4fd2deb9a44816040518082815260200191505060405180910390a150565b6000600a60149054906101000a900460ff1615611c3f57600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663dd62ed3e84846000604051602001526040518363ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200192505050602060405180830381600087803b1515611c1d57600080fd5b6102c65a03f11515611c2e57600080fd5b505050604051805190509050611c4c565b611c498383612a3e565b90505b92915050565b60035481565b60066020528060005260406000206000915054906101000a900460ff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515611cd357600080fd5b6000600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055507fd7e9ec6e6ecd65492dce6bf513cd6867560d49544421d0783ddf06e76c24470c81604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a150565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515611e1057600080fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141515611e8757806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b50565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141515611ee757600080fd5b600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161515611f3f57600080fd5b611f4882611239565b90506000600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550806001600082825403925050819055507f61e6e66b0d6339b2980aecc6ccc0039736791f0ccde9ed512e789a7fbdd698c68282604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a15050565b60406004810160003690501015151561202657600080fd5b600082141580156120b457506000600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205414155b1515156120c057600080fd5b81600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508273ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040518082815260200191505060405180910390a3505050565b60008060006060600481016000369050101515156121c857600080fd5b600560008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054935061227061271061226260035488612a0390919063ffffffff16565b612ac590919063ffffffff16565b92506004548311156122825760045492505b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff84101561233e576122bd8585612ae090919063ffffffff16565b600560008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b6123518386612ae090919063ffffffff16565b91506123a585600260008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612ae090919063ffffffff16565b600260008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555061243a82600260008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612af990919063ffffffff16565b600260008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555060008311156125e4576124f983600260008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612af990919063ffffffff16565b600260008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a35b8573ffffffffffffffffffffffffffffffffffffffff168773ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a350505050505050565b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b6000806040600481016000369050101515156126b657600080fd5b6126df6127106126d160035487612a0390919063ffffffff16565b612ac590919063ffffffff16565b92506004548311156126f15760045492505b6127048385612ae090919063ffffffff16565b915061275884600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612ae090919063ffffffff16565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506127ed82600260008873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612af990919063ffffffff16565b600260008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506000831115612997576128ac83600260008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054612af990919063ffffffff16565b600260008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef856040518082815260200191505060405180910390a35b8473ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef846040518082815260200191505060405180910390a35050505050565b6000806000841415612a185760009150612a37565b8284029050828482811515612a2957fe5b04141515612a3357fe5b8091505b5092915050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b6000808284811515612ad357fe5b0490508091505092915050565b6000828211151515612aee57fe5b818303905092915050565b6000808284019050838110151515612b0d57fe5b80915050929150505600a165627a7a72305820645ee12d73db47fd78ba77fa1f824c3c8f9184061b3b10386beb4dc9236abb280029000000000000000000000000000000000000000000000000000000174876e800000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a546574686572205553440000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000045553445400000000000000000000000000000000000000000000000000000000",
  "abi": "[{\"constant\":true,\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_spender\",\"type\":\"address\"},{\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_from\",\"type\":\"address\"},{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"name\":\"\",\"type\":\"uint8\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_owner\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"name\":\"balance\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_owner\",\"type\":\"address\"},{\"name\":\"_spender\",\"type\":\"address\"}],\"name\":\"allowance\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"fallback\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"spender\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"}]",
  "creation_tx_hash": "2f1c5c2b44f771e942a8506148e256f94f1a464babc938ae0690c6e34cd79190",
  "created": "2017-11-28T00:41:21Z",
  "address": "dac17f958d2ee523a2206206994597c13d831ec7"
}

Methods

ERC-20 Tokens have a list of common methods defined in EIP 20 and also available when querying the contract endpoint. For example, name return the name of the token, symbol returns the symbol of the token, etc...

Getting Total Supply

Even if you do not need gas for constant methods, you MUST always provide your private key. You can use a dummy key when you don't need gas.

If you want to get the total supply, simply query the totalSupply function with your gas limit and address. For Tether, we get the value 5618111721549909 which is the total supply of tokens.

curl -d '{"private": "$PRIVATE","gas_limit": 20000}' https://api.blockcypher.com/v1/eth/main/contracts/dac17f958d2ee523a2206206994597c13d831ec7/totalSupply?token=$TOKEN
{
  "gas_limit": 20000,
  "address": "dac17f958d2ee523a2206206994597c13d831ec7",
  "results": [
    5618111721549909
  ]
}

Getting Balance

Now, what if we want to query the balance of an account? It's very easy to do with BlockCypher API. Simply query the contract endpoint with the balanceOf function and provide in the parameters the address that you want to fetch. In this example, we query the Tether balance of the Ethereum address 3f5ce5fbfe3e9af3971dd833d26ba9b5c936f0be.

curl -d '{ "private": "$PRIVATE", "gas_limit": 20000, "params": ["3f5ce5fbfe3e9af3971dd833d26ba9b5c936f0be"] }' https://api.blockcypher.com/v1/eth/main/contracts/dac17f958d2ee523a2206206994597c13d831ec7/balanceOf?token=$TOKEN
{
  "gas_limit": 20000,
  "address": "dac17f958d2ee523a2206206994597c13d831ec7",
  "params": [
    "3f5ce5fbfe3e9af3971dd833d26ba9b5c936f0be"
  ],
  "results": [
    27574376981160
  ]
}

Transferring ERC-20 Token

Transferring and ERC-20 Token is also very easy with BlockCypher API. When we look at the contract, we can see the transfer function. Be careful that the public key associated with the private key provided in the call MUST contains both Ethereum (to pay for Gas) and the ERC-20 token you want to send.

In this example, you can see that we want to send 1 USDT (1000000) from X (associated with the private key you cannot see here) to dac17f958d2ee523a2206206994597c13d831ec7. Notice that the gas_limit is set at 200,000.

And success! We get a call_tx_hash, which we can use to see the transaction using the Transaction endpoint: 42b26937543905e4633c90dbd222bf04ff67e74d63f8e6f6f1a56879f19e1bc0

curl -d '{ "private": $PRIVATE, "gas_limit": 200000, "params": [ "285e456950190f531cdf06c33bbd74F370727254", 1000000]}' http://api.blockcypher.com/v1/eth/main/contracts/dac17f958d2ee523a2206206994597c13d831ec7/transfer?token=$TOKEN
{
  "gas_limit": 200000,
  "call_tx_hash": "42b26937543905e4633c90dbd222bf04ff67e74d63f8e6f6f1a56879f19e1bc0",
  "address": "dac17f958d2ee523a2206206994597c13d831ec7",
  "params": [
    "285e456950190f531cdf06c33bbd74F370727254",
    1000000
  ]
}

Deploying an ERC-20 Token

You can deploy an ERC-20 on our BETH Testnet and interact with it. Here is an example that will create a token called ERC20Basic with the symbol BSC. In this example, the creator of the contract will be awarded 1000 tokens. You can send call the contract using the address provided in the response.

curl -d '{
  "solidity": "// SPDX-License-Identifier: MIT \n pragma solidity ^0.8.3; \n contract ERC20Basic { \n string public constant name = \"ERC20Basic\"; \n string public constant symbol = \"BSC\"; \n uint8 public constant decimals = 18; \n event Approval(address indexed tokenOwner, address indexed spender, uint tokens); \n event Transfer(address indexed from, address indexed to, uint tokens); \n mapping(address => uint256) balances; \n mapping(address => mapping (address => uint256)) allowed; \n uint256 totalSupply_; \n using SafeMath for uint256; \n constructor(uint256 total) public { \n totalSupply_ = total; \n balances[msg.sender] = totalSupply_;} \n function totalSupply() public view returns (uint256) { \n return totalSupply_;} \n function balanceOf(address tokenOwner) public view returns (uint) { \n return balances[tokenOwner];} \n function transfer(address receiver, uint numTokens) public returns (bool) { \n require(numTokens <= balances[msg.sender]); \n balances[msg.sender] = balances[msg.sender].sub(numTokens); \n balances[receiver] = balances[receiver].add(numTokens); \n emit Transfer(msg.sender, receiver, numTokens); \n return true;} \n function approve(address delegate, uint numTokens) public returns (bool) { \n allowed[msg.sender][delegate] = numTokens; \n Approval(msg.sender, delegate, numTokens); \n return true;} \n function allowance(address owner, address delegate) public view returns (uint) { \n return allowed[owner][delegate];} \n function transferFrom(address owner, address buyer, uint numTokens) public returns (bool) { \n require(numTokens <= balances[owner]); \n require(numTokens <= allowed[owner][msg.sender]); \n balances[owner] = balances[owner].sub(numTokens); \n allowed[owner][msg.sender] = allowed[owner][msg.sender].sub(numTokens); \n balances[buyer] = balances[buyer].add(numTokens); \n Transfer(owner, buyer, numTokens); \n return true;}} \n library SafeMath {  \n function sub(uint256 a, uint256 b) internal pure returns (uint256) { \n assert(b <= a); \n return a - b;} \n function add(uint256 a, uint256 b) internal pure returns (uint256) { \n uint256 c = a + b; \n assert(c >= a); \n return c;}}",
  "params": [1000],
  "publish": ["ERC20Basic"],
  "private": "$PRIVATE",
  "gas_limit": 500000
}' https://api.blockcypher.com/v1/beth/test/contracts?token=$TOKEN
[
    {
        "name": "ERC20Basic",
         ...
        "gas_limit": 500000,
        "creation_tx_hash": "a578b6cf1d253b1e22a5690deb46dca3097c297355fb7f90ce4e271c14272ae3",
        "address": "6699c5d99527a520fc82cd35cc5c6ccf07893382",
        "params": [
            1000
        ]
    },
]

Updates

This section list all the updates in reverse chronological order. All dates are in the DD/MM/YY format.

24/01/22 - Add ERC-20 Deployement on BETH Example

We have added an example showing you how to deploy an ERC-20 on our Ethereum testnet: BETH.

29/10/21 - Add Priority Fee Estimation

We are now estimating the priority fee. Soon, transactions created with the API will be only EIP-1559 transactions.

18/10/21 - Fix Unconfirmed Transactions on Address Full Endpoint

Previously, when using the address full endpoint with confirmations>0, you'd still get unconfirmed transactions. This is fixed.

14/10/21 - Fix Websocket Origin Check

We fixed an error where using blockcypher websocket would returns a 403.

12/10/21 - Allow Multiple Transaction Replacement

Previously, a hard limit of 2 two transactions with the same nonce was in place. We have removed this limitation.

14/09/21 - Documentation for Address Full Endpoint

We've added some documentation for the Address Full Endpoint and fixed some hyperlinks.

06/08/21 - New Filters for Uncofirmed Transactions Endpoint

We've added new filters possibilities to the Unconfirmed Transactions Endpoint.

04/02/21 - Creation of the "Updates" Section

We've created this new "Updates" section to let you know about the new feature and bugfixes we deployed :).

04/02/21 - Ethereum Transaction Cancellation/Replacement and Bugfixes

You can now cancel and replace Ethereum with our Transaction API. See the Creating Transactions part for more information. Alongside, when creating a new Ethereum transaction, the available balance is now the pool balance and not the confirmed balance.

27/11/20 - Support for OpenZeppelin ERC20 Token

Introduce limited support to contract with fallback. For now, we only allow calls on the USDC contract. Send us a message if you need another token to be included.

04/11/20 - Dynamic Fee for Payment Forwards

Payment Forwards now use our dynamic fees. This should ensure that your forwards are delivered as soon as possible.

15/10/20 - Ethereum Payment Forwards

Finally! Ethereum payment forward are now deployed. We are working hard to add this feature to ERC20 tokens as well.