ETEnterprises1 / ET.ENT

[BMO Master Page(https://dashboard.plaid.com/overview)https://sandbox.plaid.com/balance/get]
https://ETCBI.com
1 stars 1 forks source link

BlockCypher Supported Language SDKs – Blockchain Developer API for Bitcoin, Ethereum, Testnet, Litecoin and More | BlockCypher #125

Open ETEnterprises1 opened 1 month ago

ETEnterprises1 commented 1 month ago

"curl https://api.blockcypher.com/v1/btc/main

{ "name": "BTC.main", "height": 360060, "hash": "000000000000000000bf56ff4a81e399374a68344a64d6681039412de78366b8", "time": "2015-06-08T22:57:08.260165627Z", "latest_url": "https://api.blockcypher.com/v1/btc/main/blocks/000000000000000000bf56ff4a81e399374a68344a64d6681039412de78366b8", "previous_hash": "000000000000000011c9511ae1265d34d3c16fff6e8f94380425833b3d0ae5d8", "previous_url": "https://api.blockcypher.com/v1/btc/main/blocks/000000000000000011c9511ae1265d34d3c16fff6e8f94380425833b3d0ae5d8", "peer_count": 239, "unconfirmed_count": 617, "high_fee_per_kb": 46086, "medium_fee_per_kb": 29422, "low_fee_per_kb": 12045, "last_fork_height": 359865, "last_fork_hash": "00000000000000000aa6462fd9faf94712ce1b5a944dc666f491101c996beab9" }" https://www.blockcypher.com/dev/#:~:text=RESTful%20Resources-,curl%20https%3A//api.blockcypher.com/v1/btc/main%0A%0A%7B%0A%20%20%22name%22,12045%2C%0A%20%20%22last_fork_height%22%3A%20359865%2C%0A%20%20%22last_fork_hash%22%3A%20%2200000000000000000aa6462fd9faf94712ce1b5a944dc666f491101c996beab9%22%0A%7D,-Almost%20all%20resources

ETEnterprises1 commented 1 month ago

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

Currently, there's only one version of the API (v1). Thus, here's an exhaustive list of blockchains and their corresponding resources:

CoinChainResourceBitcoinMainapi.blockcypher.com/v1/btc/mainBitcoinTestnet3api.blockcypher.com/v1/btc/test3DashMainapi.blockcypher.com/v1/dash/mainDogecoinMainapi.blockcypher.com/v1/doge/mainLitecoinMainapi.blockcypher.com/v1/ltc/mainBlockCypherTestapi.blockcypher.com/v1/bcy/test

ETEnterprises1 commented 1 month ago

 Unless otherwise noted, all descriptions of direct HTTP requests will assume one of these base resources prepends it. But you can always see the full call in the cURL code sample. Our API always returns values in satoshis, or the lowest non-divisible unit in non-Bitcoin blockchains. As a friendly reminder, there are 10^8 satoshis in a single bitcoin (100,000,000s = 1BTC), 10^8 base units per litecoin, 10^8 koinus per dogecoin (100,000,000k = 1DOGE) and 10^8 duff per dash.

Rate Limits and Tokens

Adding your token as URL parameter curl https://api.blockcypher.com/v1/btc/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 }, "hits_history": { { "api/hour": 253, "confidence/hour": 50, "time": "2016-06-15T07:00:00-00:00", "hooks": 358, }, { "api/hour": 2, "hooks/hour": 30, "time": "2016-06-15T06:00:00-00:00" "hooks": 358, }, ... } } # These are quite above the default limits, but if you'd like them, reach out at contact@blockcypher.com ;)

ETEnterprises1 commented 1 month ago

NAV 

cURL JavaScript Ruby Python Go PHP

Introduction

Documentation Structure

API Versions

BlockCypher Supported Language SDKs

RESTful Resources

Rate Limits and Tokens

Batching

Testing

Objects

Blockchain API

Address API

Wallet API

Transaction API

Confidence Factor

Metadata API

Asset API

Address Forwarding

Events and Hooks

Updates

Sign Up/Login

Introduction

# |) | | / . | . # |) | () ( |< _ \/ |) | | (/ | # / |

Welcome to BlockCypher's API documentation! BlockCypher is a simple, mostly RESTful JSON API for interacting with blockchains, accessed over HTTP or HTTPS from the api.blockcypher.com domain. Currently, BlockCypher supports Bitcoin, Ethereum, Litecoin, Dash, Dogecoin, Bitcoin Testnet3, and BlockCypher's Test Chain (more about BlockCypher's Test Chain below).

 While our Ethereum API is very similar to the API here, it's different enough to necessitate its own documentation; you can find those docs here: https://www.blockcypher.com/dev/ethereum/.

BlockCypher's API provides a superset of the endpoints you'd find in reference implementations, in addition to some special features that make BlockCypher uniquely powerful, like our unconfirmed transaction Confidence Factor, dependable WebHook or WebSockets-based Events, and Address Forwarding.

Consequently, if you're familiar with a blockchain's reference implementation, you'll feel at home using BlockCypher, but without worrying about scaling or implementation challenges. And if you're not familiar---with the reference implementations or blockchains in general---BlockCypher's API is a great way to dip your toes into blockchain development, without a lengthy setup process. In either case, BlockCypher has 99.99% up-time, and maintains an expressive, logical API that you'll love.

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 leverage BlockCypher for your applications. For all officially supported languages, you'll see code samples, in addition to basic cURL requests/responses for every endpoint. You can switch between cURL/language samples via the selector in the upper right. We're working on supporting more languages, but if you're working on your own language library, definitely let us know: we'd love to add more community supported libraries here.

Section Summaries

Objects: An overview of all the objects in the API, alongside detailed descriptions of every field.

Blockchain API: Endpoints to query general information about a blockchain and its blocks.

Address API: Query information about addresses, generate addresses, and generate multisig addresses from public keys.

Wallet API: Build and modify multiple-address-watching and hierarchical deterministic (HD) wallets, usable throughout the BlockCypher API.

Transaction API: Information about transactions, how to generate/send your own, and how to embed data into the blockchain.

Confidence Factor: Get an accurate measure of the likelihood of a successful double-spend against your unconfirmed transactions.

Metadata API: Store both public and private key-value pairs against addresses, transactions, and blocks.

Asset API: Create and manage your own assets---embedded on a public blockchain---via the Open Assets standard.

Address Forwarding: Create one-time addresses that will automatically forward to an address of your choosing, while optionally adding processing fees.

Events and Hooks: Reliable notifications system for a wide variety of events on blockchains, available through WebHooks or WebSockets.

Updates: List all the updates, bugfixes and new features in reverse chronological order.

In-Browser Code Examples

We know many learn more from code examples than specific reference documentation, which is why we have code samples in our official languages. In addition, we have a number of in-browser code examples for particular use cases, which you can see here:

Browse the Blockchain

Using WebHooks

Sending a Simple Transaction

Create Multisig Transactions

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.

BlockCypher Supported Language SDKs

BlockCypher has client SDKs for the following languages:

Ruby https://github.com/blockcypher/ruby-client

Python https://github.com/blockcypher/blockcypher-python

Go https://github.com/blockcypher/gobcy

If you're using these languages, we strongly encourage you to use an official SDK. Of course, all our API calls are standard HTTP endpoints using JSON formatted responses, so any language (or cURL from the command-line) will work just fine.

Deprecated SDKs

Due to the lack of usage, the following SDKs have been deprecated and as such will not be updated:

Node.js https://github.com/blockcypher/node-client

Java https://github.com/blockcypher/java-client

PHP https://github.com/blockcypher/php-client

You can still use them but beware that there might be some bugs or missing features.

Unofficial Libraries

This client SDK was made by the community, and is not officially supported by BlockCypher. As such, BlockCypher cannot guarantee that it's fully up to date, but we hope it will provide a nice jumping-off point for developers using this language. We'll endeavor to keep this list updated, if any of these prove obsolete. If there's enough support for a particular language, we'll work with the community to turn it into an officially supported SDK.

.NET https://github.com/bscheiman/BlockCypher

Postman Collection

If your favorite language is not listed above or if you prefers using raw queries, be sure to check our Postman Collection documentation.

RESTful Resources

curl https://api.blockcypher.com/v1/btc/main { "name": "BTC.main", "height": 360060, "hash": "000000000000000000bf56ff4a81e399374a68344a64d6681039412de78366b8", "time": "2015-06-08T22:57:08.260165627Z", "latest_url": "https://api.blockcypher.com/v1/btc/main/blocks/000000000000000000bf56ff4a81e399374a68344a64d6681039412de78366b8", "previous_hash": "000000000000000011c9511ae1265d34d3c16fff6e8f94380425833b3d0ae5d8", "previous_url": "https://api.blockcypher.com/v1/btc/main/blocks/000000000000000011c9511ae1265d34d3c16fff6e8f94380425833b3d0ae5d8", "peer_count": 239, "unconfirmed_count": 617, "high_fee_per_kb": 46086, "medium_fee_per_kb": 29422, "low_fee_per_kb": 12045, "last_fork_height": 359865, "last_fork_hash": "00000000000000000aa6462fd9faf94712ce1b5a944dc666f491101c996beab9" }

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). Thus, here's an exhaustive list of blockchains and their corresponding resources:

CoinChainResourceBitcoinMainapi.blockcypher.com/v1/btc/mainBitcoinTestnet3api.blockcypher.com/v1/btc/test3DashMainapi.blockcypher.com/v1/dash/mainDogecoinMainapi.blockcypher.com/v1/doge/mainLitecoinMainapi.blockcypher.com/v1/ltc/mainBlockCypherTestapi.blockcypher.com/v1/bcy/test Unless otherwise noted, all descriptions of direct HTTP requests will assume one of these base resources prepends it. But you can always see the full call in the cURL code sample. Our API always returns values in satoshis, or the lowest non-divisible unit in non-Bitcoin blockchains. As a friendly reminder, there are 10^8 satoshis in a single bitcoin (100,000,000s = 1BTC), 10^8 base units per litecoin, 10^8 koinus per dogecoin (100,000,000k = 1DOGE) and 10^8 duff per dash.

Rate Limits and Tokens

Adding your token as URL parameter curl https://api.blockcypher.com/v1/btc/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 }, "hits_history": { { "api/hour": 253, "confidence/hour": 50, "time": "2016-06-15T07:00:00-00:00", "hooks": 358, }, { "api/hour": 2, "hooks/hour": 30, "time": "2016-06-15T06:00:00-00:00" "hooks": 358, }, ... } } # These are quite above the default limits, but if you'd like them, reach out at contact@blockcypher.com ;)

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 if you're using cURL, or through the appropriate method in the language SDK you're using.

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):

Classic requests, up to 3 requests/sec and 100 requests/hr

WebHooks and WebSockets, up to 100 requests sent to your servers/hr

WebHooks, up to 100 stored on our servers

Confidence lookups, up to 10 requests/hour

The hourly rate limits reset on the top of the hour UTC. For example, if you're under the free tier, and you have used 100 regular requests by 03:58 UTC, you'll hit a rate limit until it resets at 04:00 UTC.

 If you exceed these limits, your requests will return an HTTP Status Code 429!

On the accounts page, you'll find paid plans starting at $119 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

Within that return object, you'll also find hits_history array, which shows your token's last 48 hours of usage, while hits shows the current hour's usage.

You can even see information about your remaining limits by checking the X-Ratelimit-Remaining attribute in the HTTP header in normal API calls. Keep in mind the X-Ratelimit-Remaining attribute corresponds to the hourly rate limit associated with the endpoint you call (e.g., if it's from a WebHook, that corresponds to the Hooks/Hour; if it's a normal call, the number corresponds to the normal Requests/Hour limit).

Batching

Batching blocks 5, 6, and 7 curl 'https://api.blockcypher.com/v1/btc/main/blocks/5;6;7' [{ "hash": "000000003031a0e73735690c5a1ff2a4be82553b2a12b776fbd3a215dc8f778d", "height": 6, "chain": "BTC.main", "total": 0, "fees": 0, "ver": 1, "time": "2009-01-09T03:29:49Z", ..., }, { "hash": "000000009b7262315dbf071787ad3656097b892abffd1f95a1a022f896f533fc", "height": 5, "chain": "BTC.main", "total": 0, "fees": 0, "ver": 1, "time": "2009-01-09T03:23:48Z", ..., }, { "hash": "0000000071966c2b1d065fd446b1e485b2c9d9594acd2007ccbd5441cfc89444", "height": 7, "chain": "BTC.main", "total": 0, "fees": 0, "ver": 1, "time": "2009-01-09T03:39:29Z", ..., }]

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. The other supported client SDKs batch differently, but each idiomatic to their respective language (check the code pane examples in each library).

 The maximum number of elements that can be batched in a single call is 100. As you may have noticed from the examples, batched calls don't necessarily respect ordering, especially for bigger batches. But this shouldn't matter, as the requested identifiers are always present in the returned objects.

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

 With regard to rate limits, each individual batch call counts as a request; for example, if you request 3 addresses in a batch, you're still using 3 API calls of resources on our end. The big advantage to batching is that you avoid 3 separate round-trip calls/reduce latency. Since the default, non-registered rate limit per second is 3, larger batches require a paid API token. To use larger batches please register.

Testing

We offer an automated faucets for BlockCypher's Test Chain. We recommend using BlockCypher's Test Chain for a variety of reasons:

It's nearly identical in characteristics to Bitcoin Main, with a few differences listed below.

The prefix for standard addreses is 'B' or 'C' (0x1B). The prefix for multisig addresses is 'D' (0x1F). This is also known as the "address version byte," which you can read more about here.

The chain is private (no data is broadcasted, only BlockCypher mines the transactions), making it much more predictable than the Bitcoin's testnet (which is frequently under attack).

New blocks get built every minute, confirming the transactions that have been created using our transaction API.

In case you missed the Resources section, the BlockCypher Test Chain is accessible from this resource:

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

 As mentioned above, Bitcoin Testnet3 is frequently under attack, sometimes from core developers stress-testing the protocol, sometimes from malevolent actors attempting new attack vectors. It can be extremely---and inconsistently---unreliable. Unless your testing environment requires Testnet3, we strongly encourage you to use BlockCypher's Test Chain.

Note resource change to bcy/test instead of btc/main # Make new address; returns private key/public key/address curl -X POST https://api.blockcypher.com/v1/bcy/test/addrs?token=$YOURTOKEN { "private": "26415016a2fb49f51aef161cb35bd537be07b75a6ac1e297d3b7a370cc85433b", "public": "02c572d062fefcc8c3e1bf5016450addcedb89cd7e4507d8a323f327b4ad1018e0", "address": "CFqoZmZ3ePwK5wnkhxJjJAQKJ82C7RJdmd" } # Fund prior address with faucet curl -d '{"address": "CFqoZmZ3ePwK5wnkhxJjJAQKJ82C7RJdmd", "amount": 100000}' https://api.blockcypher.com/v1/bcy/test/faucet?token=$YOURTOKEN { "tx_ref": "02dbf5585d438a1cba82a9041dd815635a6b0df684225cb5271e11397a759479" }

Test Faucets

To help facilitate automated testing in your applications, a faucet endpoint is available on BlockCypher's Test Chain. 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.

This example shows how to leverage the faucet to programmatically fund addresses, to test your applications.

 You need a token to use test faucets. On the BlockCypher Test Chain, the faucet will refuse to fund an address with more than 500 billion BlockCypher satoshis and will not fund more than 100 million BlockCypher satoshis at a time. On Bitcoin Testnet3 those numbers are adjusted to 10 million and 500,000 testnet satoshis respectively.

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. But for others, a section dedicated to all of BlockCypher's Objects might prove a useful overview, especially if you're new to Blockchain development in general. And in either case, this section provides a comprehensive reference for Objects in the API. For each Object there's a description and a link to a germane API endpoint.

 Objects sometimes contain attributes that are optional. These are always noted in the description. In these cases, the Object may not be guaranteed to include that attribute in its response.

Blockchain

curl https://api.blockcypher.com/v1/btc/main { "name": "BTC.main", "height": 360060, "hash": "000000000000000000bf56ff4a81e399374a68344a64d6681039412de78366b8", "time": "2015-06-08T22:57:08.260165627Z", "latest_url": "https://api.blockcypher.com/v1/btc/main/blocks/000000000000000000bf56ff4a81e399374a68344a64d6681039412de78366b8", "previous_hash": "000000000000000011c9511ae1265d34d3c16fff6e8f94380425833b3d0ae5d8", "previous_url": "https://api.blockcypher.com/v1/btc/main/blocks/000000000000000011c9511ae1265d34d3c16fff6e8f94380425833b3d0ae5d8", "peer_count": 239, "unconfirmed_count": 617, "high_fee_per_kb": 46086, "medium_fee_per_kb": 29422, "low_fee_per_kb": 12045, "last_fork_height": 359865, "last_fork_hash": "00000000000000000aa6462fd9faf94712ce1b5a944dc666f491101c996beab9" }

A Blockchain represents the current state of a particular blockchain from the Coin/Chain resources that BlockCypher supports. Typically returned from the Chain API endpoint.

AttributeTypeDescriptionnamestringThe name of the blockchain represented, in the form of $COIN.$CHAIN.heightintegerThe current height of the blockchain; i.e., the number of blocks in the blockchain.hashstringThe hash of the latest confirmed block in the blockchain; in Bitcoin, the hashing function is SHA256(SHA256(block)).timetimeThe time of the latest update to the blockchain; typically when the latest block was added.latest_urlurlThe BlockCypher URL to query for more information on the latest confirmed block; returns a Block.previous_hashstringThe hash of the second-to-latest confirmed block in the blockchain.previous_urlurlThe BlockCypher URL to query for more information on the second-to-latest confirmed block; returns a Block.peer_countintegerN/A, will be deprecated soon.high_fee_per_kbintegerA rolling average of the fee (in satoshis) paid per kilobyte for transactions to be confirmed within 1 to 2 blocks.medium_fee_per_kbintegerA rolling average of the fee (in satoshis) paid per kilobyte for transactions to be confirmed within 3 to 6 blocks.low_fee_per_kbintegerA rolling average of the fee (in satoshis) paid per kilobyte for transactions to be confirmed in 7 or more blocks.unconfirmed_countintegerNumber of unconfirmed transactions in memory pool (likely to be included in next block).last_fork_heightintegerOptional 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_hashstringOptional 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 https://api.blockcypher.com/v1/btc/main/blocks/00000000000000000003dc20b868d17121303308f6bba329302e75913f0790db { "hash": "000000000000000000058b0392acad50a141c980a0137fa381eed4bb9da2266b", "height": 670850, "chain": "BTC.main", "total": 2666972965896, "fees": 131055032, "size": 1337178, "vsize": 999378, "ver": 939515904, "time": "2021-02-16T14:30:47Z", "received_time": "2021-02-16T14:30:50.082Z", "coinbase_addr": "", "relayed_by": "100.19.55.173:8333", "bits": 386736569, "nonce": 3721541004, "n_tx": 3238, "prev_block": "00000000000000000007d284fb11be7e6adcc81d05177f05ff5ba6b906f151d2", "mrkl_root": "67ebfe25f76df77fe4c46e9474a4bcdaeb71034da6fc3509fdd2c6d0817b9de8", "txids": [ "67f0821545bbfd815d2fc37dd24b945b76dcebb7b78f7dafbe55c5d09418a63e", "c537f4241a77391e3fb39c9d42157b0c040542ef3f08f5bd1903d5dc87175691", ..., ], "depth": 292, "prev_block_url": "https://api.blockcypher.com/v1/btc/main/blocks/00000000000000000007d284fb11be7e6adcc81d05177f05ff5ba6b906f151d2", "tx_url": "https://api.blockcypher.com/v1/btc/main/txs/", "next_txids": "https://api.blockcypher.com/v1/btc/main/blocks/000000000000000000058b0392acad50a141c980a0137fa381eed4bb9da2266b?txstart=20\u0026limit=20" }

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

AttributeTypeDescriptionhashstringThe hash of the block; in Bitcoin, the hashing function is SHA256(SHA256(block))heightintegerThe height of the block in the blockchain; i.e., there are height earlier blocks in its blockchain.depthintegerThe depth of the block in the blockchain; i.e., there are depth later blocks in its blockchain.chainstringThe name of the blockchain represented, in the form of $COIN.$CHAINtotalintegerThe total number of satoshis transacted in this block.feesintegerThe total number of fees---in satoshis---collected by miners in this block.sizeintegerOptional Raw size of block (including header and all transactions) in bytes. Not returned for bitcoin blocks earlier than height 389104.vsizeintegerOptional Raw size of block (including header and all transactions) in virtual bytes. Not returned for bitcoin blocks earlier than height 670850.verintegerBlock version.timetimeRecorded time at which block was built. Note: Miners rarely post accurate clock times.received_timetimeThe time BlockCypher's servers receive the block. Our servers' clock is continuously adjusted and accurate.relayed_bystringAddress of the peer that sent BlockCypher's servers this block.bitsintegerThe block-encoded difficulty target.nonceintegerThe number used by a miner to generate this block.n_txintegerNumber of transactions in this block.prev_blockstringThe hash of the previous block in the blockchain.prev_block_urlurlThe BlockCypher URL to query for more information on the previous block.tx_urlurlThe 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_rootstringThe Merkle root of this block.txidsarray[string]An array of transaction hashes in this block. By default, only 20 are included.next_txidsurlOptional 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).

TX

curl https://api.blockcypher.com/v1/btc/main/txs/f854aebae95150b379cc1187d848d58225f3c4157fe992bcd166f58bd5063449 { "block_hash": "0000000000000000c504bdea36e531d80...", "block_height": 293000, "hash": "f854aebae95150b379cc1187d848d58225f3c41...", "addresses": [ "13XXaBufpMvqRqLkyDty1AXqueZHVe6iyy", "19YtzZdcfs1V2ZCgyRWo8i2wLT8ND1Tu4L", "1BNiazBzCxJacAKo2yL83Wq1VJ18AYzNHy", "1GbMfYui17L5m6sAy3L3WXAtf1P32bxJXq", "1N2f642sbgCMbNtXFajz9XDACDFnFzdXzV" ], "total": 70320221545, "fees": 0, "size": 636, "vsize": 636, "preference": "low", "relayed_by": "", "confirmed": "2014-03-29T01:29:19Z", "received": "2014-03-29T01:29:19Z", "ver": 1, "lock_time": 0, "double_spend": false, "vin_sz": 4, "vout_sz": 1, "confirmations": 63171, "inputs": [ { "prev_hash": "583910b7bf90ab802e22e5c25a89...", "output_index": 1, "script": "4830450220504b1ccfddf508422bdd8...", "output_value": 16450000, "sequence": 4294967295, "addresses": [ "1GbMfYui17L5m6sAy3L3WXAtf1P32bxJXq" ], "script_type": "pay-to-pubkey-hash" }, ..., ..., ], "outputs": [ { "value": 70320221545, "script": "76a914e6aad9d712c419ea8febf009a...", "spent_by": "35832d6c70b98b54e9a53ab2d5117...", "addresses": [ "1N2f642sbgCMbNtXFajz9XDACDFnFzdXzV" ], "script_type": "pay-to-pubkey-hash" } ] }

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. Typically returned from the Unconfirmed Transactions and Transaction Hash endpoints.

AttributeTypeDescriptionblock_heightintegerHeight of the block that contains this transaction. If this is an unconfirmed transaction, it will equal -1.hashstringThe hash of the transaction. While reasonably unique, using hashes as identifiers may be unsafe.addressesarray[string]Array of bitcoin public addresses involved in the transaction.totalintegerThe total number of satoshis exchanged in this transaction.feesintegerThe total number of fees---in satoshis---collected by miners in this transaction.sizeintegerThe size of the transaction in bytes.vsizeintegerThe virtual size of the transaction in bytes.preferencestringThe likelihood that this transaction will make it to the next block; reflects the preference level miners have to include this transaction. Can be high, medium or low.relayed_bystringAddress of the peer that sent BlockCypher's servers this transaction.receivedtimeTime this transaction was received by BlockCypher's servers.verintegerVersion number, typically 1 for Bitcoin transactions.lock_timeintegerTime when transaction can be valid. Can be interpreted in two ways: if less than 500 million, refers to block height. If more, refers to Unix epoch time.double_spendbooltrue if this is an attempted double spend; false otherwise.vin_szintegerTotal number of inputs in the transaction.vout_szintegerTotal number of outputs in the transaction.confirmationsintegerNumber of subsequent blocks, including the block the transaction is in. Unconfirmed transactions have 0 confirmations.inputsarray[TXInput]TXInput Array, limited to 20 by default.outputsarray[TXOutput]TXOutput Array, limited to 20 by default.opt_in_rbfboolOptional Returns true if this transaction has opted in to Replace-By-Fee (RBF), either true or not present. You can read more about Opt-In RBF here.confidencefloatOptional The percentage chance this transaction will not be double-spent against, if unconfirmed. For more information, check the section on Confidence Factor.confirmedtimeOptional Time at which transaction was included in a block; only present for confirmed transactions.receive_countintegerOptional Number of peers that have sent this transaction to BlockCypher; only present for unconfirmed transactions.change_addressstringOptional Address BlockCypher will use to send back your change, if you constructed this transaction. If not set, defaults to the address from which the coins were originally sent.block_hashstringOptional Hash of the block that contains this transaction; only present for confirmed transactions.block_indexintegerOptional Canonical, zero-indexed location of this transaction in a block; only present for confirmed transactions.double_ofstringOptional If this transaction is a double-spend (i.e. double_spend == true) then this is the hash of the transaction it's double-spending.data_protocolstringOptional Returned if this transaction contains an OP_RETURN associated with a known data protocol. Data protocols currently detected: blockchainid ; openassets ; factom ; colu ; coinspark ; omnihexstringOptional Hex-encoded bytes of the transaction, as sent over the network.next_inputsurlOptional If there are more transaction inptus that couldn't fit into the TXInput array, this is the BlockCypher URL to query the next set of TXInputs (within a TX object).next_outputsurlOptional If there are more transaction outputs that couldn't fit into the TXOutput array, this is the BlockCypher URL to query the next set of TXOutputs(within a TX object).

TXInput

{ "prev_hash": "e5c9be87798b0fa8ad55a22b5d731d6f50d72bffaa6179f9999499e57388cc33", "output_index": 1, "script": "004730440220689409a16c98fa1659cae4c20...", "output_value": 2450698356, "sequence": 4294967295, "addresses": [ "34ch2jrhYXDFsLK1FZQ3SjqgFRnX8mGC5W" ], "script_type": "pay-to-script-hash", "age": 5 }

A TXInput represents an input consumed within a transaction. Typically found within an array in a TX. In most cases, TXInputs are from previous UTXOs, with the most prominent exceptions being attempted double-spend and coinbase inputs.

AttributeTypeDescriptionprev_hashstringThe previous transaction hash where this input was an output. Not present for coinbase transactions.output_indexintegerThe index of the output being spent within the previous transaction. Not present for coinbase transactions.output_valueintegerThe value of the output being spent within the previous transaction. Not present for coinbase transactions.script_typestringThe type of script that encumbers the output corresponding to this input.scriptstringRaw hexadecimal encoding of the script.addressesarray[string]An array of public addresses associated with the output of the previous transaction.sequenceintegerLegacy 4-byte sequence number, not usually relevant unless dealing with locktime encumbrances.ageintegerOptional Number of confirmations of the previous transaction for which this input was an output. Currently, only returned in unconfirmed transactions.wallet_namestringOptional Name of Wallet or HDWallet from which to derive inputs. Only used when constructing transactions via the Creating Transactions process.wallet_tokenstringOptional Token associated with Wallet or HDWallet used to derive inputs. Only used when constructing transactions via the Creating Transactions process.

TXOutput

{ "value": 70320221545, "script": "76a914e6aad9d712c419ea8febf009a3f3bfdd8d222fac88ac", "spent_by": "35832d6c70b98b54e9a53ab2d51176eb19ad11bc4505d6bb1ea6c51a68cb92ee", "addresses": [ "1N2f642sbgCMbNtXFajz9XDACDFnFzdXzV" ], "script_type": "pay-to-pubkey-hash" }

A TXOutput represents an output created by a transaction. Typically found within an array in a TX.

AttributeTypeDescriptionvalueintValue in this transaction output, in satoshis.scriptstringRaw hexadecimal encoding of the encumbrance script for this output.addressesarray[string]Addresses that correspond to this output; typically this will only have a single address, and you can think of this output as having "sent" value to the address contained herein.script_typestringThe type of encumbrance script used for this output.spent_bystringOptional The transaction hash that spent this output. Only returned for outputs that have been spent. The spending transaction may be unconfirmed.data_hexstringOptional A hex-encoded representation of an OP_RETURN data output, without any other script instructions. Only returned for outputs whose script_type is null-data.data_stringstringOptional An ASCII representation of an OP_RETURN data output, without any other script instructions. Only returned for outputs whose script_type is null-data and if its data falls into the visible ASCII range.

TXConfidence

curl https://api.blockcypher.com/v1/btc/main/txs/43fa951e1bea87c282f6725cf8bdc08bb48761396c3af8dd5a41a085ab62acc9/confidence { "age_millis": 12725, "receive_count": 666, "confidence": 0.9901509730004237, "txhash": "43fa951e1bea87c282f6725cf8bdc08bb48761396c3af8dd5a41a085ab62acc9", "txurl": "https://api.blockcypher.com/v1/btc/main/txs/43fa951e1bea87c282f6725cf8bdc08bb48761396c3af8dd5a41a085ab62acc9" }

A TXConfidence represents information about the confidence that an unconfirmed transaction will make it into the next block. Typically used as a return object from the Transaction Confidence Endpoint.

AttributeTypeDescriptionage_millisintegerThe age of the transaction in milliseconds, based on the earliest time BlockCypher saw it relayed in the network.receive_countintegerNumber of peers that have sent this transaction to BlockCypher; only positive for unconfirmed transactions. -1 for confirmed transactions.confidencefloatA number from 0 to 1 representing BlockCypher's confidence that the transaction won't be double-spent against.txhashstringThe hash of the transaction. While reasonably unique, using hashes as identifiers may be unsafe.txurlurlThe BlockCypher URL one can use to query more detailed information about this transaction.

TXRef

{ "tx_hash": "14b1052855bbf6561bc4db8aa501762e7cc1e86994dda9e782a6b73b1ce0dc1e", "block_height": 302013, "tx_input_n": -1, "tx_output_n": 0, "value": 20213, "ref_balance": 4433416, "spent": false, "confirmations": 54405, "confirmed": "2014-05-22T03:46:25Z", "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.

AttributeTypeDescriptionaddressstringOptional The address associated with this transaction input/output. Only returned when querying an address endpoint via a wallet/HD wallet name.block_heightintegerHeight of the block that contains this transaction input/output. If it's unconfirmed, this will equal -1.tx_hashstringThe hash of the transaction containing this input/output. While reasonably unique, using hashes as identifiers may be unsafe.tx_input_nintegerIndex of this input in the enclosing transaction. It's a negative number for an output.tx_output_nintegerIndex of this output in the enclosing transaction. It's a negative number for an input.valueintegerThe value transfered by this input/output in satoshis exchanged in the enclosing transaction.preferencestringThe likelihood that the enclosing transaction will make it to the next block; reflects the preference level miners have to include the enclosing transaction. Can be high, medium or low.spentbooltrue if this is an output and was spent. If it's an input, or an unspent output, it will be false.double_spendbooltrue if this is an attempted double spend; false otherwise.confirmationsintegerNumber of subsequent blocks, including the block the transaction is in. Unconfirmed transactions have 0 confirmations.scriptstringOptional Raw, hex-encoded script of this input/output.ref_balanceintegerOptional The past balance of the parent address the moment this transaction was confirmed. Not present for unconfirmed transactions.confidencefloatOptional The percentage chance this transaction will not be double-spent against, if unconfirmed. For more information, check the section on Confidence Factor.confirmedtimeOptional Time at which transaction was included in a block; only present for confirmed transactions.spent_bystringOptional The transaction hash that spent this output. Only returned for outputs that have been spent. The spending transaction may be unconfirmed.receivedtimeOptional Time this transaction was received by BlockCypher's servers; only present for unconfirmed transactions.receive_countintegerOptional Number of peers that have sent this transaction to BlockCypher; only present for unconfirmed transactions.double_ofstringOptional 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

Note resource change to bcy/test instead of btc/main curl -d '{"inputs":[{"addresses": ["CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9"]}],"outputs":[{"addresses": ["C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn"], "value": 1000000}]}' https://api.blockcypher.com/v1/bcy/test/txs/new { "tx": { "block_height": -1, "block_index": 0, "hash": "4d6e32d71313fb548232642fd...", "addresses": [ "CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9", "C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn" ], "total": 5419600, "fees": 12500, "size": 119, ... }, "tosign": [ "97d81abd54cae1648951f49..." ], "errors": [ { "error": "..." } ], "signatures": [], "pubkeys": [] }

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

AttributeTypeDescriptiontxTXA temporary TX, usually returned fully filled but missing input scripts.tosignarray[string]Array of hex-encoded data for you to sign, one for each input.signaturesarray[string]Array of signatures corresponding to all the data in tosign, typically provided by you.pubkeysarray[string]Array of public keys corresponding to each signature. In general, these are provided by you, and correspond to the signatures you provide.tosign_txarray[string]Optional Array of hex-encoded, work-in-progress transactions; optionally returned to validate the tosign data locally.errorsarray["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.

WitnessToSignTx

curl -d '{"witness_tosign_tx":"01000000d0fe2d3feb5f3a5b6a99c244f21924b0249e2bc65c5745bdb618b1799066a80a3bb13029ce7b1f559ef5e747fcac439f1455a2ec7c5f09b72290795e706650448b3658589c258fb4b44180f158ae73d4dbaaf26d64c43a97a5cd78d9577f786d010000001976a9141b80a938a784abe7cdee8fdaf95f5f7e0b8cd0b988ac40420f0000000000ffffffff5fa4537c4c565583f8d32a36c3510808d38acc0ad18cc7e637be6523ebb39ff30000000001000000"}' https://api.blockcypher.com/v1/bcy/test/txs/decodeWitnessToSign?token=YOURTOKEN { "version": 1, "hash_prevouts": "0aa8669079b118b6bd45575cc62b9e24b02419f244c2996a5b3a5feb3f2dfed0", "hash_sequence": "445066705e799022b7095f7ceca255149f43acfc47e7f59e551f7bce2930b13b", "outpoint": "6d787f57d978cda5973ac4646df2aadbd473ae58f18041b4b48f259c5858368b", "outpoint_index": 1, "script_code": "76a9141b80a938a784abe7cdee8fdaf95f5f7e0b8cd0b988ac", "value": 1000000, "sequence": 4294967295, "hash_outputs": "f39fb3eb2365be37e6c78cd10acc8ad3080851c3362ad3f88355564c7c53a45f", "lock_time": 0, "sighash_type": 1 } }

A WitnessToSignTx is created when creating a transaction which spend a P2WPKH input and includeToSignTx is set to true.

AttributeTypeDescriptionversionintegerVersion of the transaction.hash_prevoutsstringHash of the previous output.hash_sequencestringHash sequence.outpointstringHash of the outpoint.outpoint_indexintegerOutpoint index.script_codestringScript code of the input.valueintegerValue of the output spent by this input.sequenceintegerSequence number of the input.hash_outputsstringHash of the output.lock_timeintegerLock time of the transaction.sighash_typeintegersighash type of the signature.

Address

curl https://api.blockcypher.com/v1/btc/main/addrs/1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD { "address": "1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD", "total_received": 4433416, "total_sent": 0, "balance": 4433416, "unconfirmed_balance": 0, "final_balance": 4433416, "n_tx": 7, "unconfirmed_n_tx": 0, "final_n_tx": 7, "txrefs": [ ... ], "unconfirmed_txrefs": [ ... ] }

An Address represents a public address on a blockchain, and contains information about the state of balances and transactions related to this address. Typically returned from the Address Balance, Address, and Address Full Endpoint.

AttributeTypeDescriptionaddressstringOptional The requested address. Not returned if querying a wallet/HD wallet.walletWalletOptional The requested wallet object. Only returned if querying by wallet name instead of public address.hd_walletHDWalletOptional The requested HD wallet object. Only returned if querying by HD wallet name instead of public address.total_receivedintegerTotal amount of confirmed satoshis received by this address.total_sentintegerTotal amount of confirmed satoshis sent by this address.balanceintegerBalance of confirmed satoshis on this address. This is the difference between outputs and inputs on this address, but only for transactions that have been included into a block (i.e., for transactions whose confirmations > 0).unconfirmed_balanceintegerBalance of unconfirmed satoshis on this address. Can be negative (if unconfirmed transactions are just spending outputs). Only unconfirmed transactions (haven't made it into a block) are included.final_balanceintegerTotal balance of satoshis, including confirmed and unconfirmed transactions, for this address.n_txintegerNumber of confirmed transactions on this address. Only transactions that have made it into a block (confirmations > 0) are counted.unconfirmed_n_txintegerNumber of unconfirmed transactions for this address. Only unconfirmed transactions (confirmations == 0) are counted.final_n_txintegerFinal number of transactions, including confirmed and unconfirmed transactions, for this address.tx_urlurlOptional To retrieve base URL transactions. To get the full URL, concatenate this URL with a transaction's hash.txsarray[TX]Optional Array of full transaction details associated with this address. Usually only returned from the Address Full Endpoint.txrefsarray[TXRef]Optional Array of transaction inputs and outputs for this address. Usually only returned from the standard Address Endpoint.unconfirmed_txrefsarray[TXRef]Optional All unconfirmed transaction inputs and outputs for this address. Usually only returned from the standard Address Endpoint.hasMoreboolOptional 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 -X POST https://api.blockcypher.com/v1/btc/test3/addrs { "private": "86751cb880a9a1addcc3b67979976158dd800afe9d14b68349921299b20c94dd", "public": "03866586fbe3652eb219c5ed99c3fc72d125472248183f966e0673be08a1c543de", "address": "n1ucSDLByN5GLLQuE7BMrtTWHwHtkaVkfA", "wif": "cS64ygfjWjN73S78oUbJQeikDn9uS7KNWS1PL7NqeBUuF4UobnAy" }

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

AttributeTypeDescriptionaddressstringStandard address representation.publicstringHex-encoded Public key.privatestringHex-encoded Private key.wifstringWallet import format, a common encoding for the private key.pubkeysarray[string]Optional Array of public keys to provide to generate a multisig address.script_typestringOptional If generating a multisig address, the type of multisig script; typically "multisig-n-of-m", where n and m are integers.original_addressstringOptional If generating an OAP address, this represents the parent blockchain's underlying address (the typical address listed above).oap_addressstringOptional The OAP address, if generated using the Generate Asset Address Endpoint.

Wallet

curl -d '{"name": "alice","addresses": ["1JcX75oraJEmzXXHpDjRctw3BX6qDmFM8e"]}' https://api.blockcypher.com/v1/btc/main/wallets?token=YOURTOKEN { "token":"YOURTOKEN", "name": "alice", "addresses": ["1JcX75oraJEmzXXHpDjRctw3BX6qDmFM8e"] }

AttributeTypeDescriptiontokenstringUser token associated with this wallet.namestringName of the wallet.addressesarray[string]List of addresses associated with this wallet.

A Wallet contains a list of addresses associated by its name and the user's token. It can be used interchangeably with all the Address API endpoints, and in many places that require addresses, like when Creating Transactions.

The name of a wallet must be 1-25 characters long and cannot start with any characters that start an address for the currency contained in the wallet. For example, bitcoin wallet names cannot start with '1' or '3'.

HDWallet

curl -d '{"name": "bob", "extended_public_key": "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8"}' https://api.blockcypher.com/v1/btc/main/wallets/hd?token=YOURTOKEN {"token": "YOURTOKEN", "name": "bob", "hd": true, "extended_public_key": "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8", "chains": [ {"chain_addresses": [ { "address": "1FHz8bpEE5qUZ9XhfjzAbCCwo5bT1HMNAc", "path": "m/0" }, { "address": "1J8QDN1u7iDMbJktbqXPSrAqruNjkmRFmT", "path": "m/1" }, { "address": "1MWNKnYfE2LVdvAzFUioF3F3JXFpRfDCQb", "path": "m/2" } ]} ]}

An HDWallet contains addresses derived from a single seed. Like normal wallets, it can be used interchangeably with all the Address API endpoints, and in many places that require addresses, like when Creating Transactions.

AttributeTypeDescriptiontokenstringUser token associated with this HD wallet.namestringName of the HD wallet.chainsarray[HDChain]List of HD chains associated with this wallet, each containing HDAddresses. A single chain is returned if the wallet has no subchains.hdbooltrue for HD wallets, not present for normal wallets.extended_public_keystringThe extended public key all addresses in the HD wallet are derived from. It's encoded in BIP32 formatsubchain_indexesarray[integer]optional returned for HD wallets created with subchains.

The name of a wallet must be 1-25 characters long and cannot start with any characters that start an address for the currency contained in the wallet. For example, bitcoin wallet names cannot start with '1' or '3'.

HDChain

curl https://api.blockcypher.com/v1/btc/main/wallet/hd/bob/addresses?token=YOURTOKEN {"chains": [ {"chain_addresses": [ { "address": "1FHz8bpEE5qUZ9XhfjzAbCCwo5bT1HMNAc", "path": "m/0" }, { "address": "1J8QDN1u7iDMbJktbqXPSrAqruNjkmRFmT", "path": "m/1" }, { "address": "1MWNKnYfE2LVdvAzFUioF3F3JXFpRfDCQb", "path": "m/2" }] } ]}

An array of HDChains are included in every HDWallet and returned from the Get Wallet, Get Wallet Addresses and Derive Address in Wallet endpoints.

AttributeTypeDescriptionchain_addressesarray[HDAddress]Array of HDAddresses associated with this subchain.indexintegeroptional Index of the subchain, returned if the wallet has subchains.

HDAddress

AttributeTypeDescriptionaddressstringStandard address representation.pathstringThe BIP32 path of the HD address.publicstringoptional Contains the hex-encoded public key if returned by Derive Address in Wallet endpoint.

An HD Address object contains an address and its BIP32 HD path (location of the address in the HD tree). It also contains the hex-encoded public key when returned from the Derive Address in Wallet endpoint.

OAPIssue

{ "from_private": "0eb369746401c3369517239...", "to_address": "1C3nrGhUDxBbr393u2Wq4PiE8T6oEYjYhrK", "amount": 200, "metadata": "1a2b3c4d5e6f" }

An OAPIssue represents a request for either issuance or transfer of new assets, as detailed in the Asset API.

AttributeTypeDescriptionfrom_privatestringThe private key being used to issue or transfer assets.to_addressstringThe target OAP address assets for issue or transfer.amountintThe amount of assets being issued or transfered.metadatastringOptional Hex-encoded metadata that can optionally be encoded into the issue or transfer transaction.

OAPTX

{ "ver": 1, "assetid": "1Npqwstp55vgThp4pwAC9UhYkvPJ28b2Ui", "hash": "022e05bdfa2e148bc1882cb7a81506b8316fee6957b11625126d075a8cf8791b", "confirmed": "2015-10-25T04:50:06Z", "received": "2015-10-25T04:49:32.37Z", "oap_meta": "1a2b3c4d5e6f", "double_spend": false, "inputs": [ { "prev_hash": "56253cffa1b3508d106391da3646cda2aee0bd080db427321c77ad11739e4239", "output_index": 0, "address": "1ByJUiocpifLPaYVTALpA7JYa9DxpGxXKKP", "output_value": 1000 } ], "outputs": [ { "address": "1C3nrGhUDxBbr393u2Wq4PiE8T6oEYjYhrK", "value": 200, "original_output_index": 1 } ] }

An OAPTX represents an Open Assets Protocol transaction, generated when issuing or transfering assets.

AttributeTypeDescriptionverintVersion of Open Assets Protocol transaction. Typically 1.assetidstringUnique indentifier associated with this asset; can be used to query other transactions associated with this asset.hashstringThis transaction's unique hash; same as the underlying transaction on the asset's parent blockchain.confirmedtimeOptional Time this transaction was confirmed; only returned for confirmed transactions.receivedtimeTime this transaction was received.oap_metastringOptional Associated hex-encoded metadata with this transaction, if it exists.double_spendbooltrue if this is an attempted double spend; false otherwise.inputsarray[...]Array of input data, which can be seen explicitly in the cURL example. Very similar to array of TXInputs, but with values related to assets instead of satoshis.outputsarray[...]Array of output data, which can be seen explicitly in the cURL example. Very similar to array of TXOutputs, but with values related to assets instead of satoshis.

Event

curl https://api.blockcypher.com/v1/btc/main/hooks/399d0923-e920-48ee-8928-2051cbfbc369 { "id": "399d0923-e920-48ee-8928-2051cbfbc369" "event": "unconfirmed-tx", "address": "15qx9ug952GWGTNn7Uiv6vode4RcGrRemh", "token": "YOURTOKEN", "url": "https://my.domain.com/callbacks/new-tx", "callback_errors": 0 }

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

AttributeTypeDescriptionidstringIdentifier of the event; generated when a new request is created.eventstringType of event; can be unconfirmed-tx, new-block, confirmed-tx, tx-confirmation, double-spend-tx, tx-confidence.hashstringoptional Only objects with a matching hash will be sent. The hash can either be for a block or a transaction.wallet_namestringoptional Only transactions associated with the given wallet will be sent; can use a regular or HD wallet name. If used, requires a user token.tokenstringoptional Required if wallet_name is used, though generally we advise users to include it (as they can reach API throttling thresholds rapidly).addressstringoptional Only transactions associated with the given address will be sent. A wallet name can also be used instead of an address, which will then match on any address in the wallet.confirmationsintegeroptional 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.confidencefloatoptional Used in concert with the tx-confidence event type to set the minimum confidence for which you'll receive a notification. You'll receive a TX once this threshold is met. Will accept any float between 0 and 1, exclusive; if not set, defaults to 0.99.scriptstringoptional Only transactions with an output script of the provided type will be sent. The recognized types of scripts are: pay-to-pubkey-hash, pay-to-multi-pubkey-hash, pay-to-pubkey, pay-to-script-hash, null-data (sometimes called OP_RETURN), empty or unknown.urlurloptional Callback URL for this Event's WebHook; not applicable for WebSockets usage.callback_errorsintNumber of errors when attempting to POST to callback URL; not applicable for WebSockets usage.

AddressForward

curl -d '{"destination":"15qx9ug952GWGTNn7Uiv6vode4RcGrRemh","callback_url": "https://my.domain.com/callbacks/new-pay","process_fees_address": "1LWw6FdzNUcX8bnekMMZ7eofcGF7SXmbrL", "process_fees_percent": 0.1,"token":"YOURTOKEN"}' https://api.blockcypher.com/v1/btc/main/forwards { "input_address": "16uKw7GsQSzfMaVTcT7tpFQkd7Rh9qcXWX", "destination": "15qx9ug952GWGTNn7Uiv6vode4RcGrRemh", "callback_url": "https://my.domain.com/callbacks/new-pay" "process_fees_address": "1LWw6FdzNUcX8bnekMMZ7eofcGF7SXmbrL", "process_fees_percent": 0.1, "token": "YOURTOKEN" }

A AddressForward object represents a request set up through the Address Forwarding service.

AttributeTypeDescriptionidstringIdentifier of the orwarding request; generated when a new request is created.tokenstringThe mandatory user token.destinationstringThe required destination address to forward to.input_addressstringThe address which will automatically forward to destination; generated when a new request is created.process_fees_addressstringOptional Address to forward processing fees, if specified. Allows you to receive a fee for your own services.process_fees_satoshisintOptional Fixed processing fee amount to be sent to the fee address. A fixed satoshi amount or a percentage is required if a process_fees_address has been specified.process_fees_percentfloatOptional Percentage of the transaction to be sent to the fee address. A fixed satoshi amount or a percentage is required if a process_fees_address has been specified.callback_urlurlOptional The URL to call anytime a new transaction is forwarded.enable_confirmationsboolOptional Whether to also call the callback_url with subsequent confirmations of the forwarding transactions. Automatically sets up a WebHook.mining_fees_satoshisintOptional Mining fee amount to include in the forwarding transaction, in satoshis. If not set, defaults to 10,000.txsarray[string]Optional History of forwarding transaction hashes for this forward; not present if this request has yet to forward any transactions.

AddressForwardCallback

{ "value": 100000000, "input_address": "16uKw7GsQSzfMaVTcT7tpFQkd7Rh9qcXWX", "destination": "15qx9ug952GWGTNn7Uiv6vode4RcGrRemh", "input_transaction_hash": "39bed5d...", "transaction_hash": "1aa6103..." }

A AddressForwardCallback object represents the payload delivered to the optional callback_url in a AddressForward request.

AttributeTypeDescriptionvalueintAmount sent to the destination address, in satoshis.input_addressstringThe intermediate address to which the transaction was originally sent.destinationstringThe final destination address to which the forward will eventually be sent.input_transaction_hashstringThe transaction hash representing the initial transaction to the input_address.transaction_hashstringThe transaction hash of the generated transaction that forwards from the input_address to the destination.

Blockchain API

The first component---and highest level---of the BlockCypher API allows you to query general information about blockchain and blocks based on the coin/chain resource you've selected for your endpoints.

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.

Chain Endpoint

curl https://api.blockcypher.com/v1/btc/main { "name": "BTC.main", "height": 360060, "hash": "000000000000000000bf56ff4a81e399374a68344a64d6681039412de78366b8", "time": "2015-06-08T22:57:08.260165627Z", "latest_url": "https://api.blockcypher.com/v1/btc/main/blocks/000000000000000000bf56ff4a81e399374a68344a64d6681039412de78366b8", "previous_hash": "000000000000000011c9511ae1265d34d3c16fff6e8f94380425833b3d0ae5d8", "previous_url": "https://api.blockcypher.com/v1/btc/main/blocks/000000000000000011c9511ae1265d34d3c16fff6e8f94380425833b3d0ae5d8", "peer_count": 239, "unconfirmed_count": 617, "high_fee_per_kb": 46086, "medium_fee_per_kb": 29422, "low_fee_per_kb": 12045, "last_fork_height": 359865, "last_fork_hash": "00000000000000000aa6462fd9faf94712ce1b5a944dc666f491101c996beab9" }

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

ResourceMethodReturn Object/GETBlockchain

The returned object contains a litany of information about the blockchain, including its height, the time/hash of the latest block, and more.

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

Block Hash Endpoint

curl https://api.blockcypher.com/v1/btc/main/blocks/00000000000000000003dc20b868d17121303308f6bba329302e75913f0790db { "hash": "00000000000000000003dc20b868d17121303308f6bba329302e75913f0790db", "height": 671142, "chain": "BTC.main", "total": 2928942845838, "fees": 135268918, "size": 1448143, "vsize": 998941, "ver": 1073725440, "time": "2021-02-18T16:01:12Z", "received_time": "2021-02-18T16:02:17.341Z", "coinbase_addr": "", "relayed_by": "68.168.176.51:8333", "bits": 386736569, "nonce": 3270005482, "n_tx": 2025, "prev_block": "00000000000000000001245ac74971793689be7924cd0b031302661e806deb0d", "mrkl_root": "5283c26fb8d64d2284ffda76af6cd584292b76f265932cd121ac16fb475d7a8a", "txids": [ "39dec39382157569b809446037c6d5658d490e38907060112c16d8de49aeab0b", "ce0a8256a459ba14feb48931a2344ff7af3af4f9aa2b5acb795a1b0b9fd8806e", ..., ], "depth": 5, "prev_block_url": "https://api.blockcypher.com/v1/btc/main/blocks/00000000000000000001245ac74971793689be7924cd0b031302661e806deb0d", "tx_url": "https://api.blockcypher.com/v1/btc/main/txs/", "next_txids": "https://api.blockcypher.com/v1/btc/main/blocks/00000000000000000003dc20b868d17121303308f6bba329302e75913f0790db?txstart=20\u0026limit=20" }

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

ResourceMethodReturn Object/blocks/$BLOCK_HASHGETBlockFlagTypeEffecttxstartintegerFilters response to only include transaction hashes after txstart in the block.limitintegerFilters 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 satoshis 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 'https://api.blockcypher.com/v1/btc/main/blocks/671142?txstart=1&limit=1' { "hash": "00000000000000000003dc20b868d17121303308f6bba329302e75913f0790db", "height": 671142, "chain": "BTC.main", "total": 2928942845838, "fees": 135268918, "size": 1448143, "vsize": 998941, "ver": 1073725440, "time": "2021-02-18T16:01:12Z", "received_time": "2021-02-18T16:02:17.341Z", "coinbase_addr": "", "relayed_by": "68.168.176.51:8333", "bits": 386736569, "nonce": 3270005482, "n_tx": 2025, "prev_block": "00000000000000000001245ac74971793689be7924cd0b031302661e806deb0d", "mrkl_root": "5283c26fb8d64d2284ffda76af6cd584292b76f265932cd121ac16fb475d7a8a", "txids": [ "39dec39382157569b809446037c6d5658d490e38907060112c16d8de49aeab0b" ], "depth": 5, "prev_block_url": "https://api.blockcypher.com/v1/btc/main/blocks/00000000000000000001245ac74971793689be7924cd0b031302661e806deb0d", "tx_url": "https://api.blockcypher.com/v1/btc/main/txs/", "next_txids": "https://api.blockcypher.com/v1/btc/main/blocks/00000000000000000003dc20b868d17121303308f6bba329302e75913f0790db?txstart=20\u0026limit=20" }

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

ResourceMethodReturn Object/blocks/$BLOCK_HEIGHTGETBlockFlagTypeEffecttxstartintegerFilters response to only include transaction hashes after txstart in the block.limitintegerFilters 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:

294322

As above, the returned object contains information about the block, including its hash, the total amount of satoshis 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.

 With recent blocks, $BLOCK_HEIGHT is not always a unique identifier, due to the possibility of soft forks and the nature of the consensus model with blockchains. If you're querying blocks with depth above 10 (i.e., there are more than 10 blocks ahead of your target) the height should be a safe identifier.

Feature Endpoint

curl https://api.blockcypher.com/v1/btc/main/feature/bip65?token=YOURTOKEN { "name": "bip65", "state": "EXCLUSIVE", "last_transition_height": 388380, "last_transition_hash": "000000000000000009f886db2c7c12a497603e86378bace3ead93d350be3f38c" }

ResourceMethod/feature/$NAMEGET

If you're curious about the adoption of upgrade features on a blockchain, you can use this endpoint to get some information about its state on the network. For example, for bip65 on bitcoin, you could check its state via this URL: https://api.blockcypher.com/v1/btc/main/feature/bip65?token=YOURTOKEN. Generally speaking, for bitcoin, this will follow the form of tracking bipXX (where XX = a number), but the list of features we're tracking is always changing.

Address API

BlockCypher's Address API allows you to look up information about public addresses on the blockchain, generate single-use, low-value key pairs with corresponding addresses, help generate multisig addresses, and collect multiple addresses into a single shortcut for address viewing, all based on the coin/chain resource you've selected for your endpoints.

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:

Anyone can generate a public address themselves (through ECDSA in Bitcoin). No single authority is needed to generate new addresses; it's just public-private key cryptography.

Public addresses are significantly more lightweight. Consequently, and unlike traditional bank accounts, you can (and should!) generate new addresses for every transaction.

Addresses can also leverage pay-to-script-hash, which means they can represent exotic things beyond a single private-public key pair; the most prominent example being multi-signature addresses that require n-of-m signatures to spend.

Address Balance Endpoint

curl https://api.blockcypher.com/v1/btc/main/addrs/1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD/balance { "address": "1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD", "total_received": 4433416, "total_sent": 0, "balance": 4433416, "unconfirmed_balance": 0, "final_balance": 4433416, "n_tx": 7, "unconfirmed_n_tx": 0, "final_n_tx": 7 }

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

ResourceMethodReturn Object/addrs/$ADDRESS/balanceGETAddressFlagTypeEffectomitWalletAddressesboolIf 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:

1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD

The returned object contains information about the address, including its balance in satoshis 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 https://api.blockcypher.com/v1/btc/main/addrs/1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD { "address": "1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD", "total_received": 4433416, "total_sent": 0, "balance": 4433416, "unconfirmed_balance": 0, "final_balance": 4433416, "n_tx": 7, "unconfirmed_n_tx": 0, "final_n_tx": 7, "txrefs": [ { "tx_hash": "14b1052855bbf6561bc4db8aa501762e7cc1e86994dda9e782a6b73b1ce0dc1e", "block_height": 302013, "tx_input_n": -1, "tx_output_n": 0, "value": 20213, "ref_balance": 4433416, "spent": false, "confirmations": 63066, "confirmed": "2014-05-22T03:46:25Z", "double_spend": false }, { "tx_hash": "4cff011ec53022f2ae47197d1a2fd4a6ac2a80139f4d0131c1fed625ed5dc869", "block_height": 302002, "tx_input_n": -1, "tx_output_n": 0, "value": 40596, "ref_balance": 4413203, "spent": false, "confirmations": 63077, "confirmed": "2014-05-22T02:56:08Z", "double_spend": false }, ... ], "tx_url": "https://api.blockcypher.com/v1/btc/main/txs/" }

The default Address Endpoint strikes a balance between speed of response and data on Addresses. It returns more information about an address' transactions than the Address Balance Endpoint but doesn't return full transaction information (like the Address Full Endpoint).

ResourceMethodReturn Object/addrs/$ADDRESSGETAddressFlagTypeEffectunspentOnlyboolIf unspentOnly is true, filters response to only include unspent transaction outputs (UTXOs).includeScriptboolIf includeScript is true, includes raw script of input or output within returned TXRefs.includeConfidenceboolIf true, includes the confidence attribute (useful for unconfirmed transactions) within returned TXRefs. For more info about this figure, check the Confidence Factor documentation.beforeintegerFilters response to only include transactions below before height in the blockchain.afterintegerFilters response to only include transactions above after height in the blockchain.limitintegerlimit 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.confirmationsintegerIf set, only returns the balance and TXRefs that have at least this number of confirmations.confidenceintegerFilters response to only include TXRefs above confidence in percent; e.g., if this is set to 99, will only return TXRefs with 99% confidence or above (including all confirmed TXRefs). For more detail on confidence, check the Confidence Factor documentation.omitWalletAddressesboolIf 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:

1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD

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

Address Full Endpoint

curl https://api.blockcypher.com/v1/btc/main/addrs/1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD/full?before=300000 { "address": "1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD", "total_received": 4433416, "total_sent": 0, "balance": 4433416, "unconfirmed_balance": 0, "final_balance": 4433416, "n_tx": 7, "unconfirmed_n_tx": 0, "final_n_tx": 7, "txs": [ { "block_hash": "0000000000000000af64802c79...", "block_height": 292586, "hash": "b4735a0690dab16b8789fceaf81c511f...", "addresses": [ "18KXZzuC3xvz6upUMQpsZzXrBwNPWZjdSa", "1AAuRETEcHDqL4VM3R97aZHP8DSUHxpkFV", "1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD", "1VxsEDjo6ZLMT99dpcLu4RQonMDVEQQTG" ], "total": 3537488, "fees": 20000, "size": 438, "preference": "medium", "relayed_by": "", "confirmed": "2014-03-26T17:08:04Z", "received": "2014-03-26T17:08:04Z", "ver": 1, "lock_time": 0, "double_spend": false, "vin_sz": 2, "vout_sz": 2, "confirmations": 64492, "confidence": 1, "inputs": [ { "prev_hash": "729f6469b59fea5da7...", "output_index": 0, "script": "483045022100d06cdad1a...", "output_value": 3500000, "sequence": 4294967295, "addresses": [ "1VxsEDjo6ZLMT99dpcLu4RQonMDVEQQTG" ], "script_type": "pay-to-pubkey-hash" }, ... ], "outputs": [ { "value": 3500000, "script": "76a9148629647bd642a237...", "addresses": [ "1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD" ], "script_type": "pay-to-pubkey-hash" }, { "value": 37488, "script": "76a9145049e2ad94ed9c68...", "spent_by": "3ebe4bb294beaed58aca83...", "addresses": [ "18KXZzuC3xvz6upUMQpsZzXrBwNPWZjdSa" ], "script_type": "pay-to-pubkey-hash" } ] }, ..., ] }

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.

ResourceMethodReturn Object/addrs/$ADDRESS/fullGETAddressFlagTypeEffectbeforeintegerFilters response to only include transactions below before height in the blockchain.afterintegerFilters response to only include transactions above after height in the blockchain.limitintegerlimit 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.txlimitintegerThis filters the TXInputs/TXOutputs within the returned TXs to include a maximum of txlimit items.confirmationsintegerIf set, only returns the balance and TXs that have at least this number of confirmations.confidenceintegerFilters 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.legacyaddrsboolLitecoin Only. Replaces P2SH prefix with legacy 3 instead of M. Disabled by default.includeHexboolIf true, includes hex-encoded raw transaction for each TX; false by default.includeConfidenceboolIf true, includes the confidence attribute (useful for unconfirmed transactions) within returned TXs. For more info about this figure, check the Confidence Factor documentation.omitWalletAddressesboolIf 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:

1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD

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).

 If your returned Address object includes the hasMore attribute, there are more transactions associated with the address than transfered through this endpoint. If this happens, note the block height of the last transaction in the array, and then you can use the before flag to page through results.

Generate Address Endpoint

curl -X POST https://api.blockcypher.com/v1/btc/test3/addrs { "private": "81ee75559d37cbe4b7cbbfb9931ab1ba32172c5cdfc3ac2d020259b4c1104198", "public": "0231ff9ec76820cb36b69061f6ffb125db3793b4aced468a1261b0680e1ef4883a", "address": "mvpW7fMSi1nbZhJJDySNS2PUau8ppnu4kY", "wif": "cRwGhRjCuuNtPgLcoYd1CuAqjFXCV5YNCQ1LB8RsFCvu61VfSsgR" }

generate bech32 p2wpkh curl -X POST https://api.blockcypher.com/v1/btc/test3/addrs?bech32=true { "private": "516c110f271f2b26ad8ed2d72c469d2dde0db5030241926b6b0388c602cf572c", "public": "023766804d9c34ead560be1d1f819127cb2636305ac9ba2f76c176efd2b3913a25", "address": "tb1q2u0dzlwf805qy62w099p06f8z5nxz5kk34a456", "wif": "cQJyYH6rjkV2W9jR9PjnJftBmGt93Yi4gpn494oEAiWvoUJoEpCs" }

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.

 The private key returned is immediately discarded by our servers, but we advise that these keys should not be used for any high-value---or long-term storage---addresses. Always use HTTPS for Address Generation requests. Otherwise, your generated private keys will be sent over insecure channels and could be MITM'd.ResourceMethodRequest ObjectReturn Object/addrsPOSTnilAddressKeychainFlagTypeEffectbech32boolWhether or not to generate a p2wpkh bech32 address. Default is false.

The returned object contains a private key in hex-encoded and wif-encoded format, a public key, and a public address.

Generate Multisig Address Endpoint

curl -d '{"pubkeys": ["02c716d071a76cbf0d29c29cacfec76e0ef8116b37389fb7a3e76d6d32cf59f4d3", "033ef4d5165637d99b673bcdbb7ead359cee6afd7aaf78d3da9d2392ee4102c8ea", "022b8934cc41e76cb4286b9f3ed57e2d27798395b04dd23711981a77dc216df8ca"], "script_type": "multisig-2-of-3"}' https://api.blockcypher.com/v1/btc/main/addrs { "private": "", "public": "", "address": "3BF1M1PnTge94QewuWh3B8mRVw8U4SVnb4", "wif": "", "pubkeys": [ "02c716d071a76cbf0d29c29cacfec76e0ef8116b37389fb7a3e76d6d32cf59f4d3", "033ef4d5165637d99b673bcdbb7ead359cee6afd7aaf78d3da9d2392ee4102c8ea", "022b8934cc41e76cb4286b9f3ed57e2d27798395b04dd23711981a77dc216df8ca" ], "script_type": "multisig-2-of-3" }

The Generate Multisig Address Endpoint is a convenience method to help you generate multisig addresses from multiple public keys. After supplying a partially filled-out AddressKeychain object (including only an array of hex-encoded public keys and the script type), the returned object includes the computed public address.

 This endpoint is the same resource as the Generate Address Endpoint, but with data in the request body.ResourceMethodRequest ObjectReturn Object/addrsPOSTAddressKeychainAddressKeychain

Wallet API

The Wallet API allows you to group multiple addresses under a single name. It only holds public address information and never requires any private keys.

 Don't be confused: this Wallet API has nothing to do with private key management. The best way to think of the Wallet API is a "Set of Public Addresses to Query Together" API, but that name refused to fit into any of our marketing materials.

A normal Wallet can be created, deleted, and have addresses added and removed. The Wallet itself can have any custom name as long as it does not start with the standard address prefix (1, 3 or bc1 for Bitcoin Mainnet).

Hierarchical Deterministic (HD) Wallets

We also offer support for HD Wallets, which make it easy to manage multiple addresses under a single name. All HD wallet addresses are derived from a single seed. Please see BIP32 for more background on HD wallets.

HD Wallets can be created, deleted, and have new addresses generated. However, unlike normal Wallets, addresses cannot be removed.

When creating a wallet, one can optionally include one or more "subchain" indexes. These subchains can later be referenced when generating new addresses or sending txs. If none are provided in wallet creation, the wallet will derive & use addresses straight from the given extended pubkey. If no index is given when using the wallet with other APIs, it defaults to using the wallet's first (sub) chain.

In BIP32 notation, the wallet layout is m/0, m/1, ... and m/i/0, m/i/1, ... for each subchain i if the wallet has subchains. For example, the path of the fourth address generated is m/3 for a non-subchain wallet. The path of the fourth address at subchain index two is m/2/3. Note that this is different from the default BIP32 wallet layout.

If you want to use BIP32 default wallet layout you can submit the extended public key of m/0' (which can only be derived from your master private key) with subchain indexes = [0, 1]. Subchain index 0 represents the external chain (of account 0) and will discover all k keypairs that look like: m/0'/0/k. Subchain index 1 represents the internal chain (of account 0) and will discover all k keypairs in m/0'/1/k.

If you want to use BIP 44 layout (for BTC), you can submit the extended public key of m/44'/0'/0'. (which can only be derived from your master private key) with subchain indexes = [0, 1]. Subchain index 0 represents the external chain (of account 0) and will discover all k keypairs in m/44'/0'/0'/0/k. Subchain index 1 represents the internal chain (of account 0) and will discover all k keypairs in m/44'/0'/0'/1/k.

If you want to use BIP 84 layout (for BTC), you can submit the extended public key of m/84'/0'/0'. (which can only be derived from your master private key) with subchain indexes = [0, 1]. Subchain index 0 represents the external chain (of account 0) and will discover all k keypairs in m/84'/0'/0'/0/k. Subchain index 1 represents the internal chain (of account 0) and will discover all k keypairs in m/84'/0'/0'/1/k.

If an address ahead of current addresses listed in an HD Wallet receives a transaction, it will be added, along with any addresses between the new address and the last used one. We limit looking ahead to 20 addresses; if more than 20 addresses are skipped for the next payment to an HD Wallet, it won't be detected/added to the HD Wallet.

 When creating a BIP84 HD wallet, be sure to submit the extended public key with the correct prefix. For example zpub for Bitcoin Mainnet, vpub for Bitcoin Testnet, vpub for BlockCypher Testnet...

Using Wallets

Both HD Wallets and normal Wallets can be leveraged by the Address API, just by using their $NAME instead of $ADDRESS. They can also be used with Events and with the Transaction API. In general, using a wallet instead of an address in an API will have the effect of batching the set of addresses contained in the wallet.

 You are required to authenticate with your user token when using a Wallet or HD Wallet in any API endpoint. You can register for a token here.

The following code examples should be considered serially; that is to say, the results will appear as if each API call were done sequentially. Also, $NAME is a string representing the name of your wallet, for example:

alice

As you'll see in the examples, if you're using HD Wallets, take care to use the appropriate resource (e.g. /wallets/hd instead of /wallets ).

 HD Wallets and Wallets share the same namespace under a particular coin/chain. For example, under a single token, you cannot have both an HD Wallet and normal Wallet named "alice" on Bitcoin Main.

Create Wallet Endpoint

normal wallet curl -d '{"name": "alice","addresses": ["1JcX75oraJEmzXXHpDjRctw3BX6qDmFM8e"]}' https://api.blockcypher.com/v1/btc/main/wallets?token=YOURTOKEN {"token": "YOURTOKEN", "name": "alice", "addresses": [ "1JcX75oraJEmzXXHpDjRctw3BX6qDmFM8e" ]} # hd wallet curl -d '{"name": "bob", "extended_public_key": "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8"}' https://api.blockcypher.com/v1/btc/main/wallets/hd?token=YOURTOKEN {"token": "YOURTOKEN", "name": "bob", "hd": true, "extended_public_key": "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8", "chains": [ {"chain_addresses": [ { "address": "1FHz8bpEE5qUZ9XhfjzAbCCwo5bT1HMNAc", "path": "m/0" }, { "address": "1J8QDN1u7iDMbJktbqXPSrAqruNjkmRFmT", "path": "m/1" }, { "address": "1MWNKnYfE2LVdvAzFUioF3F3JXFpRfDCQb", "path": "m/2" } ]} ]} # hd wallet BIP84 curl -d '{"name": "charlie", "extended_public_key": "vpub5bJX9NkmSDP33H5PxJXmehqyV7aDaVWxudzDW3kP4c5Z5KFEaUNtJ9CLebEiEssZJyZa7AE9zR5Q7nqPAmk6xgRpRvXRMKj6WPfBGBi3fR"}' https://api.blockcypher.com/v1/btc/test3/wallets/hd?token=YOURTOKEN {"token": "YOURTOKEN", "name": "charlie", "hd": true, "extended_public_key": "vpub5bJX9NkmSDP33H5PxJXmehqyV7aDaVWxudvzDW3kP4c5Z5KFEaUNtJ9CLebEiEssZJyZa7AE9zR5Q7nqPAmk6xgRpRvXRMKj6WPfBGBi3fR", "chains": [ {"chain_addresses": [ { "address": "tb1q4a9vav7vq4gp7ca9emddr66dvk099vdhh5srhp", "path": "m/0" } ]} ]} # hd wallet with subchains curl -d '{"name": "catheryne", "extended_public_key": "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8", "subchain_indexes": [1, 3]}' https://api.blockcypher.com/v1/btc/main/wallets/hd?token=YOURTOKEN {"token": "YOURTOKEN", "name": "catheryne", "hd": true, "extended_public_key": "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8", "subchain_indexes": [ 1, 3 ], "chains": [ { "index": 1, "chain_addresses": [] }, { "index": 3, "chain_addresses": [] } ]}

ResourceMethodRequest ObjectReturn Object/walletsPOSTWalletWallet/wallets/hdPOSTHDWalletHDWallet

This endpoint allows you to create a new wallet, by POSTing a partially filled out Wallet or HDWallet object, depending on the endpoint.

For normal wallets, at minimum, you must include the name attribute and at least one public address in the addresses array.

For HD wallets, at minimum, you must include the name and the extended_public_key attributes. The encoding of the key is documented here. You can optionally include subchain_indexes to initialize the wallet with one or more subchains. If not given, the wallet will derive address straight from the given extended pubkey. See BIP32 for more info.

If successful, it will return the same Wallet or HDWallet object you requested, appended with your user token.

 If the named wallet already exists under your token, attempting to create a new wallet will return an error. As mentioned above, Wallets and HDWallets share the same namespace, so an error will be returned if you attempt to create a named HD Wallet that shares a name with a normal Wallet under your token.

List Wallets Endpoint

curl https://api.blockcypher.com/v1/btc/main/wallets?token=YOURTOKEN { "wallet_names": [ "alice", "bob", "catheryne" ] }

ResourceMethodReturn Object/walletsGET{"wallet_names":$NAMEARRAY}

This endpoint returns a string array ($NAMEARRAY) of active wallet names (both normal and HD) under the token you queried. You can then query detailed information on individual wallets (via their names) by leveraging the Get Wallet Endpoint.

 If you're building a client-side application where your users might have access to your token, and your security model requires maintaining wallet name privacy, we can blacklist this endpoint for you. Just reach out to support@blockcypher.com to let us know.

Get Wallet Endpoint

normal wallet curl https://api.blockcypher.com/v1/btc/main/wallets/alice?token=YOURTOKEN {"token":"YOURTOKEN", "name":"alice", "addresses": [ "1JcX75oraJEmzXXHpDjRctw3BX6qDmFM8e"]} # hd wallet curl https://api.blockcypher.com/v1/btc/main/wallets/hd/bob?token=YOURTOKEN {"token": "YOURTOKEN", "name": "bob", "hd": true, "extended_public_key": "xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8", "chains": [{ "chain_addresses": [ { "address": "1FHz8bpEE5qUZ9XhfjzAbCCwo5bT1HMNAc", "path": "m/0" }, { "address": "1J8QDN1u7iDMbJktbqXPSrAqruNjkmRFmT", "path": "m/1" }, { "address": "1MWNKnYfE2LVdvAzFUioF3F3JXFpRfDCQb", "path": "m/2" } ]} ]}

ResourceMethodReturn Object/wallets/$NAMEGETWallet/wallets/hd/$NAMEGETHDWallet

This endpoint returns a Wallet or HDWallet based on its $NAME.

Add Addresses to Wallet Endpoint

curl -d '{"addresses": ["13cj1QtfW61kQHoqXm3khVRYPJrgQiRM6j"]}' https://api.blockcypher.com/v1/btc/main/wallets/alice/addresses?token=YOURTOKEN {"token": "YOURTOKEN", "name": "alice", "addresses": [ "1JcX75oraJEmzXXHpDjRctw3BX6qDmFM8e", "13cj1QtfW61kQHoqXm3khVRYPJrgQiRM6j" ]}

ResourceMethodRequest ObjectReturn Object/wallets/$NAME/addressesPOSTWalletWalletFlagTypeEffectomitWalletAddressesboolIf omitWalletAddresses is true, the response will omit address information (useful to speed up the API call for larger wallets).

This endpoint allows you to add public addresses to the $NAME wallet, by POSTing a partially filled out Wallet object. You only need to include the additional addresses in a new addresses array in the object. If successful, it will return the newly modified Wallet, including an up-to-date, complete listing of addresses.

 You cannot add custom addresses to HD Wallets, since they are all derived from your extended public key. You can always generate new addresses client-side, or using the Generate Address in Wallet Endpoint below.

Get Wallet Addresses Endpoint

normal wallet curl https://api.blockcypher.com/v1/btc/main/wallets/alice/addresses?token=YOURTOKEN {"addresses": [ "13cj1QtfW61kQHoqXm3khVRYPJrgQiRM6j", "1JcX75oraJEmzXXHpDjRctw3BX6qDmFM8e" ]} #hd wallet curl https://api.blockcypher.com/v1/btc/main/wallets/hd/bob/addresses?token=YOURTOKEN {"chains": [ {"chain_addresses": [ { "address": "1FHz8bpEE5qUZ9XhfjzAbCCwo5bT1HMNAc", "path": "m/0" }, { "address": "1J8QDN1u7iDMbJktbqXPSrAqruNjkmRFmT", "path": "m/1" }, { "address": "1MWNKnYfE2LVdvAzFUioF3F3JXFpRfDCQb", "path": "m/2" }] } ]}

ResourceMethodReturn Object/wallets/$NAME/addressesGETWallet/wallets/hd/$NAME/addressesGETHDChainFlagTypeEffectusedboolReturns only used addresses if set to true and only unused if false. Only valid on HD wallets.zerobalanceboolReturns only addresses with zero balance if set to true and only addresses with non-zero balance if false. Only valid on HD wallets.

This endpoint returns a list of the addresses associated with the $NAME wallet. It returns the addresses in a partially filled out Wallet which you'll find under the addresses attribute. For HD wallets it returns an HDChain object.

Remove Addresses from Wallet Endpoint

pipe to grep to check status code $ curl -X DELETE -Is https://api.blockcypher.com/v1/btc/main/wallets/alice/addresses?token=USERTOKEN&address=1JcX75oraJEmzXXHpDjRctw3BX6qDmFM8e | grep "HTTP/1.1" HTTP/1.1 204 OK

ResourceMethodReturn Object/wallets/$NAME/addresses?address=$ADDRESSDELETEnil

This endpoint allows you to delete an $ADDRESS associated with the $NAME wallet. As a reminder, you can batch multiple addresses by appending them with semicolons within the $ADDRESS URL parameter. If successful, it will return an HTTP 204 status code with no return object.

 You cannot remove addresses from HD Wallets.

Generate Address in Wallet Endpoint

curl -X POST https://api.blockcypher.com/v1/btc/main/wallets/alice/addresses/generate?token=YOURTOKEN {"token": "YOURTOKEN", "name": "alice", "addresses": [ "13cj1QtfW61kQHoqXm3khVRYPJrgQiRM6j", "14LcPtRSGjYb1s8kfxsVDbXvA7VYCmoFho" ], "private": "6238efeb679d75ec3b1a43e76cc0ed33abdf56e30bb5bb95e4793134a7958609", "public": "03e4f273521a30373a639f60da836f2308a5d53853ec18f903dd235c73e6e26e4a", "address": "14LcPtRSGjYb1s8kfxsVDbXvA7VYCmoFho", "wif": "KzWeDL7sysRay7pZUm6hQQLaDVjmN1jUZzeZuq6ru5FtN1RhPrLX"}

ResourceMethodRequest ObjectReturn Object/wallets/$NAME/addresses/generatePOSTnilWallet + AddressKeychainFlagTypeEffectbech32boolWhether or not to generate a p2wpkh bech32 address. Default is false.

This endpoint allows you to generate a new address associated with the $NAME wallet, similar to the Generate Address Endpoint. If successful, it will returned the newly modified Wallet composed with an AddressKeychain.

Only works for regular Wallets; for HD Wallets, use the Derive Address endpoint specified below.

Derive Address in Wallet Endpoint

curl -X POST https://api.blockcypher.com/v1/btc/main/wallets/hd/bob/addresses/derive?token=YOURTOKEN { "chains": [ {"chain_addresses": [ { "address": "19urzZsoBNsomSfj68PUUGLXDz261tK5Jo", "public": "02c85080e00080aa933f93a2718bba9f01fd6fdc8e4712a155849f5ba588666471", "path": "m/3" } ]} ]} #with subchain_index curl -X POST 'https://api.blockcypher.com/v1/btc/main/wallets/hd/catheryne/addresses/derive?token=YOURTOKEN&subchain_index=1' { "chains": [ {"index":1, "chain_addresses": [ { "address": "1NwEtFZ6Td7cpKaJtYoeryS6avP2TUkSMh", "public": "029b393153a1ec68c7af3a98e88aecede3a409f27e698c090540098611c79e05b0", "path": "m/1/0" } ]} ]}

ResourceMethodRequest ObjectReturn Object/wallets/hd/$NAME/addresses/derivePOSTnilPartial HDWalletFlagTypeEffectcountintegerNumber of addresses to derive. If not set, default is one address.subchain_indexintegerDerives address(es) on this specific subchain. If not set, address will be generated on the first chain in the HD wallet.lookaheadbooleanDefault to true. If set to false will not try to check the balance of the subsequent addresses. Set to false if this endpoint is too slow.

This endpoint allows you to derive a new address (or multiple addresses) associated with the $NAME HD Wallet. If successful, it will return an HDWallet but only with the newly derived address(es) represented in its chains field to limit the data transmitted; for the full address list after derivation, you can follow up this API call with the Get Wallet Addresses Endpoint.

Only works for HD Wallets; for regular wallets, use the Generate Address in Wallet endpoint specified above.

Delete Wallet Endpoint

normal wallet, pipe to grep to check status code curl -X DELETE -Is https://api.blockcypher.com/v1/btc/main/wallets/alice?token=YOURTOKEN | grep "HTTP/1.1" HTTP/1.1 204 OK # hd wallet curl -X DELETE -Is https://api.blockcypher.com/v1/btc/main/wallets/hd/bob?token=YOURTOKEN | grep "HTTP/1.1" HTTP/1.1 204 OK

ResourceMethodReturn Object/wallets/$NAMEDELETEnil/wallets/hd/$NAMEDELETEnil

This endpoint deletes the Wallet or HD Wallet with $NAME. If successful, it will return an HTTP 204 status code with no return object.

Transaction API

BlockCypher's Transaction API allows you to look up information about unconfirmed transactions, query transactions based on hash, create and propagate your own transactions, including multisignature transactions, and embed data on the blockchain---all based on the coin/chain resource you've selected for your endpoints.

If you're new to blockchains, the idea of transactions is relatively self-explanatory. Here's what's going on underneath the hood: a transaction takes previous "unspent transaction outputs" (also known as UTXOs) as "transaction inputs" and creates new "locking scripts" on those inputs such that they are "sent" to new addresses (to become new UTXOs). While most of these public addresses are reference points for single private keys that can "unlock" the newly created UTXOs, occasionally they are sent to more exotic addresses through pay-to-script-hash, typically multisignature addresses.

Generally speaking, UTXOs are generated from previous transactions (except for Coinbase inputs).

 Even if you don't use the API to assist in creating transactions, we highly recommend using BlockCypher to push your raw transactions. BlockCypher maintains connections to 20% of all nodes on all blockchains it supports, which means we can propagate transactions faster than almost anyone else. Given our speed and reliability, this is especially powerful when used in concert with our Confidence Factor.

Transaction Hash Endpoint

curl https://api.blockcypher.com/v1/btc/main/txs/f854aebae95150b379cc1187d848d58225f3c4157fe992bcd166f58bd5063449 { "block_hash": "0000000000000000c504bdea36e5...", "block_height": 293000, "hash": "f854aebae95150b379cc1187d848d58225f...", "addresses": [ "13XXaBufpMvqRqLkyDty1AXqueZHVe6iyy", "19YtzZdcfs1V2ZCgyRWo8i2wLT8ND1Tu4L", "1BNiazBzCxJacAKo2yL83Wq1VJ18AYzNHy", "1GbMfYui17L5m6sAy3L3WXAtf1P32bxJXq", "1N2f642sbgCMbNtXFajz9XDACDFnFzdXzV" ], "total": 70320221545, "fees": 0, "size": 636, "vsize": 636, "preference": "low", "relayed_by": "", "confirmed": "2014-03-29T01:29:19Z", "received": "2014-03-29T01:29:19Z", "ver": 1, "lock_time": 0, "double_spend": false, "vin_sz": 4, "vout_sz": 1, "confirmations": 64373, "inputs": [ { "prev_hash": "583910b7bf90ab802e22e5c25a89b59...", "output_index": 1, "script": "4830450220504b1ccfddf508422bdd8b0f...", "output_value": 16450000, "sequence": 4294967295, "addresses": [ "1GbMfYui17L5m6sAy3L3WXAtf1P32bxJXq" ], "script_type": "pay-to-pubkey-hash" }, ... ], "outputs": [ { "value": 70320221545, "script": "76a914e6aad9d712c419ea8febf009a3f3...", "spent_by": "35832d6c70b98b54e9a53ab2d51176eb...", "addresses": [ "1N2f642sbgCMbNtXFajz9XDACDFnFzdXzV" ], "script_type": "pay-to-pubkey-hash" } ] }

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

ResourceMethodReturn Object/txs/$TXHASHGETTXFlagTypeEffectlimitintegerFilters TXInputs/TXOutputs, if unset, default is 20.instartintegerFilters TX to only include TXInputs from this input index and above.outstartintegerFilters TX to only include TXOutputs from this output index and above.legacyaddrsboolLitecoin Only. Replaces P2SH prefix with legacy 3 instead of M. Disabled by default.includeHexboolIf true, includes hex-encoded raw transaction; false by default.includeConfidenceboolIf true, includes the confidence attribute (useful for unconfirmed transactions). For more info about this figure, check the Confidence Factor documentation.

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

f854aebae95150b379cc1187d848d58225f3c4157fe992bcd166f58bd5063449

The returned object contains detailed information about the transaction, including the value transfered, date received, and a full listing of inputs and outputs.

Unconfirmed Transactions Endpoint

curl https://api.blockcypher.com/v1/btc/main/txs [ { "block_height": -1, "hash": "7f3af38d988e479f651520b13b85...", "addresses": [ "19ZZonTmBD3VBhgFSWrtNis6Wo4aNRyjAV", "1GD2Gnt3Vk51FpUhZWrFpSa24KE2ZGPaWG", "1HEJiW8jxvUvVQ5cuButRmFj6ZzKzM9Fp6" ], "total": 46977000, "fees": 10000, "size": 225, "vsize": 225, "preference": "medium", "relayed_by": "54.209.56.58:8333", ... }, { "block_height": -1, "hash": "7e2d8b4e95c8246e81f297539409...", "addresses": [ "12u8EFJR6QJpNYbuQcYt2iMsAtPdnCFwQb", "1MUbYoqSadRSEipwcmKnH37NaKakDCmgwW" ], "total": 1070000, "fees": 10000, "size": 225, "vsize": 225, "preference": "medium", "relayed_by": "52.1.229.213:8333", "received": "2015-05-21T05:44:13.878Z", ... }, ... ]

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

ResourceMethodReturn Object/txsGETArray[TX]FlagTypeEffectlimitintegerMaximum number of transactions returned, if unset, default is 10. Maximum is 100.minValueintegerFilter transactions that transfer a total above the minimal value provided (in satoshis).

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).

 Due to transaction malleability it can be difficult to deal with transaction hashes before they've been confirmed in blocks. Use caution, and consider applying our Confidence Factor to mitigate potential issues.

Creating Transactions

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

Use a third party library to create your transactions and push raw transactions

Use our two-endpoint process outlined below, wherein we generate a TXSkeleton based on your input address, output address, and value to transfer.

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

 Always use HTTPS for creating and pushing transactions.

New Transaction Endpoint

Note resource change to bcy/test instead of btc/main, makes sharing private keys easier :) curl -d '{"inputs":[{"addresses": ["CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9"]}],"outputs":[{"addresses": ["C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn"], "value": 1000000}]}' https://api.blockcypher.com/v1/bcy/test/txs/new { "tx": { "block_height": -1, "hash": "c2b350b273b3bf04791d8e59fc9c021fd91fa423c50c29473dc079150f5a778a", "addresses": [ "CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9", "C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn" ], "total": 4988000, "fees": 12000, "size": 119, "vsize": 119, "preference": "high", ..., "confirmations": 0, "inputs": [ { "prev_hash": "c8ea8b221580ebb2f1cabc8b40797bffec742b97c82a329df96d93121db43519", "output_value": 5000000, "addresses": ["CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9"], "script": "", "script_type": "", ... } ], "outputs": [ { "value": 1000000, "script": "76a9145fb1af31edd2aa5a2bbaa24f6043d6ec31f7e63288ac", "addresses": ["C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn"], "script_type": "pay-to-pubkey-hash" }, { "value": 3988000, "script": "76a914efec6de6c253e657a9d5506a78ee48d89762fb3188ac", "addresses": ["CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9"], "script_type": "pay-to-pubkey-hash" } ] }, "tosign": ["32b5ea64c253b6b466366647458cfd60de9cd29d7dc542293aa0b8b7300cd827"] }

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

ResourceMethodRequest ObjectReturn Object/txs/newPOSTTXTXSkeletonFlagTypeEffectincludeToSignTxboolIf true, includes tosign_tx array in TXSkeleton, useful for validating data to sign; false by default.

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.

If you'd like, you can even use a Wallet instead of addresses as your input. You just need to use two non-standard fields (your wallet_name and wallet_token) within the inputs array in your transaction, instead of addresses:

{inputs:[{"wallet_name":"alice", "wallet_token":"YOURTOKEN"}], value: 5000000}

While this particular usage will differ between client libraries, the result is the same: the addresses within your wallet will be used as the inputs, as if all of them had been placed within the addresses array.

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.

 The TXSkeleton returned by this endpoint may contain some data that's temporary or incomplete, like the hash, size, and the inputs' script fields. This is by design, as the final TX can only be computed once signed data has been added. Do not rely on these fields until they are returned and sent to the network via the Send Transaction Endpoint outlined below.

Validating the Data to Sign

For the extra cautious, you can protect yourself from a potential malicious attack on BlockCypher by validating the data we're asking you to sign. Unfortunately, it's impossible to do so directly, as pre-signed signature data is hashed twice using SHA256. To get around this, set the includeToSignTx URL flag to true. The optional tosign_tx array will be returned within the TXSkeleton, which you can use in the following way:

Hashing the hex-encoded string twice using SHA256 should give you back the corresponding tosign data.

Decoding the hex-encoded string using our /txs/decode endpoint (or an independent, client-side source) should give you the output addresses and amounts that match your work-in-progress transaction.

 If you want to automatically empty your input address(es) without knowing their exact value, your TX request object's value can be set to -1 to sweep all value from your input address(es) to your output address. Please be advised that this only works with a single output address. If you are using a bech32 address (starting with bc1) be sure to add 01 (SIGHASH_ALL) at the end of the signature.

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 # $PRIVATEKEY here is a hex-encoded private key corresponding to the input from address CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9 ./signer 32b5ea64c253b6b466366647458cfd60de9cd29d7dc542293aa0b8b7300cd827 $PRIVATEKEY 3045022100921fc36b911094280f07d8504a80fbab9b823a25f102e2bc69b14bcd369dfc7902200d07067d47f040e724b556e5bc3061af132d5a47bd96e901429d53c41e0f8cca

Locally Sign Your Transaction

With your TXSkeleton returned from the New Transaction Endpoint, you now need to use your private key(s) 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. We are working on integrating client-side signing solutions into our libraries to make this process easier. You can read more about signing here. In the mean time, if you want to experiment with client-side signing, consider using our signer tool.

 One of the most common errors in the signing process is a data format mismatch. We always return and expect hex-encoded data, but oftentimes, standard signing libraries require byte arrays. Remember to convert your data, and always send hex-encoded signatures to BlockCypher.

the request body is truncated because it's huge, but it's the same as the returned object from above plus the signatures and public keys # remember, still using bcy/test instead of btc/main curl -d '{"tx": {...}, "tosign": [ "32b5ea64c253b6b466366647458cfd60de9cd29d7dc542293aa0b8b7300cd827" ], "signatures": [ "3045022100921fc36b911094280f07d8504a80fbab9b823a25f102e2bc69b14bcd369dfc7902200d07067d47f040e724b556e5bc3061af132d5a47bd96e901429d53c41e0f8cca" ], "pubkeys": [ "02152e2bb5b273561ece7bbe8b1df51a4c44f5ab0bc940c105045e2cc77e618044" ] }' https://api.blockcypher.com/v1/bcy/test/txs/send?token=YOURTOKEN { "tx": { "block_height": -1, "hash": "4e6dfb1415b4fba5bd257c129847c70fbd4e45e41828079c4a282680528f3a50", "addresses": [ "CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9", "C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn" ], "total": 4988000, "fees": 12000, "size": 226, "vsize": 226, "preference": "high", ..., "confirmations": 0, "inputs": [ { "prev_hash": "c8ea8b221580ebb2f1cabc8b40797bffec742b97c82a329df96d93121db43519", "output_value": 5000000, "addresses": ["CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9"], "script": "483045022100921fc36b911094280f...", "script_type": "pay-to-pubkey-hash", ... } ], "outputs": [ { "value": 1000000, "script": "76a9145fb1af31edd2aa5a2bbaa24f6043d6ec31f7e63288ac", "addresses": ["C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn"], "script_type": "pay-to-pubkey-hash" }, { "value": 3988000, "script": "76a914efec6de6c253e657a9d5506a78ee48d89762fb3188ac", "addresses": ["CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9"], "script_type": "pay-to-pubkey-hash" } ] }, "tosign": [ "" ] }

Send Transaction Endpoint

Once you've finished signing the tosign array locally, put that (hex-encoded) data into the signatures array of the TXSkeleton. You also need to include the corresponding (hex-encoded) public key(s) in the pubkeys array, in the order of the addresses/inputs provided. Signature and public key order matters, so make sure they are returned in the same order as the inputs you provided.

ResourceMethodRequest ObjectReturn Object/txs/sendPOSTTXSkeletonTXSkeleton

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.

Dealing with Errors

Signing and creating transactions can be one of the trickiest parts of using blockchains in your applications. Consequently, when an error is encountered when Creating Transactions, we send back an HTTP Status Code 400 alongside a descriptive array of errors within the TXSkeleton.

 One of the most common errors we see are users who use uncompressed public keys when compressed public keys were used to generate the address; remember to be careful to use the right keys!

Customizing Transaction Requests

here are some example request objects for /txs/new # simplest posssible case, with input address, output address and value '{ "inputs": [{"addresses": ["CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9"]}], "outputs": [{"addresses": ["C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn"], "value": 1000000}] }' # let's add confirmation field to only allow UTXOs, and set fee preference to medium '{ "inputs": [{"addresses": ["CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9"]}], "outputs": [{"addresses": ["C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn"], "value": 1000000}], "confirmations": 1, "preference": "medium" }' # instead of providing an address, let's specify a particular UTXO via prev_hash and output_index, and add a different change_address '{ "inputs": [{"prev_hash":"a238c817bea2d54dad4cdde38a1cfeb2aa5592313bc49514f3cd0d9db71c69c8", "output_index":0}], "outputs": [{"addresses": ["C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn"], "value": 1000000}], "confirmations": 1, "preference": "medium", "change_address": "CFr99841LyMkyX5ZTGepY58rjXJhyNGXHf" }'

While we demonstrated the simplest use of our two-endpoint process to create transactions, you can have finer-grain control by modifying the TX request object before sending to /txs/new.

By default, we allow unconfirmed UTXOs as inputs when creating transactions. If you only want to allow confirmed UTXOs, set the confirmations value in your TX request object to 1.

Instead of providing addresses, you can use prev_hash and output_index within the inputs array of your request object, in which case, we'll use the inputs as provided and not attempt to generate them from a list of addresses. We will compute change and fees the same way.

BlockCypher will set the change address to the first transaction input/address listed in the transaction. To redirect this default behavior, you can set an optional change_address field within the TX request object.

Fees in cryptocurrencies can be complex. We provide 2 different ways for you to control the fees included in your transactions:

Set the preference property in your TX request object to "high", "medium", or "low". This will calculate and include appropriate fees for your transaction to be included in the next 1-2 blocks, 3-6 blocks or 7 or more blocks respectively. You can see the explicit estimates per kilobyte for these high, medium, and low ranges by calling your base resource through the Chain Endpoint. The default fee calculation is based on a "high" preference. A preference set to "zero" will set no fee.

Manually set the fee to a desired amount by setting the fees property in your TX request object. Note that a fee too low may result in an error for some transactions that would require it.

To learn more about fees, bitcoinfees.com is a good resource.

For even more control, you can also change the script_type in the outputs of your partially filled TX. You'll notice this used to powerful effect in the section on Multisig Transactions. These are the possible script types:

pay-to-pubkey-hash (most common transaction transferring to a public key hash, and the default behavior if no out)

pay-to-multi-pubkey-hash (multi-signatures transaction, now actually less used than pay-to-script-hash for this purpose)

pay-to-pubkey (used for mining transactions)

pay-to-script-hash (used for transactions relying on arbitrary scripts, now used primarily for multi-sig transactions)

multisig-m-of-n (not present in blockchain, but used by BlockCypher to construct P2SH multisig transactions; see Multisig Transactions for more info)

null-data (sometimes called op-return; used to embed small chunks of data in the blockchain)

empty (no script present, mostly used for mining transaction inputs)

unknown (non-standard script)

 Due to safety checks within the API's transaction creation process, the user-set value field of an output may never be 0, except when using a null-data script-type, where it must be 0.

Push Raw Transaction Endpoint

Note resource change to bcy/test instead of btc/main curl -d '{"tx":"01000000011935b41d12936df99d322ac8972b74ecff7b79408bbccaf1b2eb8015228beac8000000006b483045022100921fc36b911094280f07d8504a80fbab9b823a25f102e2bc69b14bcd369dfc7902200d07067d47f040e724b556e5bc3061af132d5a47bd96e901429d53c41e0f8cca012102152e2bb5b273561ece7bbe8b1df51a4c44f5ab0bc940c105045e2cc77e618044ffffffff0240420f00000000001976a9145fb1af31edd2aa5a2bbaa24f6043d6ec31f7e63288ac20da3c00000000001976a914efec6de6c253e657a9d5506a78ee48d89762fb3188ac00000000"}' https://api.blockcypher.com/v1/bcy/test/txs/push?token=YOURTOKEN { "block_height": -1, "hash": "4e6dfb1415b4fba5bd257c129847c70fbd4e45e41828079c4a282680528f3a50", "addresses": [ "CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9", "C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn" ], "total": 4988000, "fees": 12000, "size": 226, "vsize": 226, "preference": "high", "relayed_by": "73.162.198.68", "received": "2015-05-22T05:10:00.305308666Z", "ver": 1, "lock_time": 0, "double_spend": false, "vin_sz": 1, "vout_sz": 2, "confirmations": 0, "inputs": [ { "prev_hash": "c8ea8b221580ebb2f1cabc8b40797bffec742b97c82a329df96d93121db43519", "output_index": 0, "script": "483045022100921fc36b911094280f07d8504a80fbab9b823a25f102e2bc69b14bcd369dfc7902200d07067d47f040e724b556e5bc3061af132d5a47bd96e901429d53c41e0f8cca012102152e2bb5b273561ece7bbe8b1df51a4c44f5ab0bc940c105045e2cc77e618044", "output_value": 5000000, "sequence": 4294967295, "addresses": [ "CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9" ], "script_type": "pay-to-pubkey-hash", "age": 576 } ], "outputs": [ { "value": 1000000, "script": "76a9145fb1af31edd2aa5a2bbaa24f6043d6ec31f7e63288ac", "addresses": [ "C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn" ], "script_type": "pay-to-pubkey-hash" }, { "value": 3988000, "script": "76a914efec6de6c253e657a9d5506a78ee48d89762fb3188ac", "addresses": [ "CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9" ], "script_type": "pay-to-pubkey-hash" } ] }

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 huge network of nodes to propagate your transaction faster than anywhere else.

ResourceMethodRequest ObjectReturn Object/txs/pushPOST{"tx":$TXHEX}TX

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

01000000011935b41d12936df99d322ac8972b74ecff7b79408bbccaf1b2eb8015228beac8000000006b483045022100921fc36b911094280f07d8504a80fbab9b823a25f102e2bc69b14bcd369dfc7902200d07067d47f040e724b556e5bc3061af132d5a47bd96e901429d53c41e0f8cca012102152e2bb5b273561ece7bbe8b1df51a4c44f5ab0bc940c105045e2cc77e618044ffffffff0240420f00000000001976a9145fb1af31edd2aa5a2bbaa24f6043d6ec31f7e63288ac20da3c00000000001976a914efec6de6c253e657a9d5506a78ee48d89762fb3188ac00000000

If it succeeds, you'll receive a decoded TX object and an HTTP Status Code 201. If you'd like, you can use the decoded transaction hash alongside an Event to track its progress in the network.

Decode Raw Transaction Endpoint

Note resource change to bcy/test instead of btc/main curl -d '{"tx":"01000000011935b41d12936df99d322ac8972b74ecff7b79408bbccaf1b2eb8015228beac8000000006b483045022100921fc36b911094280f07d8504a80fbab9b823a25f102e2bc69b14bcd369dfc7902200d07067d47f040e724b556e5bc3061af132d5a47bd96e901429d53c41e0f8cca012102152e2bb5b273561ece7bbe8b1df51a4c44f5ab0bc940c105045e2cc77e618044ffffffff0240420f00000000001976a9145fb1af31edd2aa5a2bbaa24f6043d6ec31f7e63288ac20da3c00000000001976a914efec6de6c253e657a9d5506a78ee48d89762fb3188ac00000000"}' https://api.blockcypher.com/v1/bcy/test/txs/decode?token=YOURTOKEN { "block_height": -1, "hash": "4e6dfb1415b4fba5bd257c129847c70fbd4e45e41828079c4a282680528f3a50", "addresses": [ "CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9", "C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn" ], "total": 4988000, "fees": 12000, "size": 226, "vsize": 226, "preference": "high", "relayed_by": "73.162.198.68", "received": "2015-05-22T05:10:00.305308666Z", "ver": 1, "lock_time": 0, "double_spend": false, "vin_sz": 1, "vout_sz": 2, "confirmations": 0, "inputs": [ { "prev_hash": "c8ea8b221580ebb2f1cabc8b40797bffec742b97c82a329df96d93121db43519", "output_index": 0, "script": "483045022100921fc36b911094280f07d8504a80fbab9b823a25f102e2bc69b14bcd369dfc7902200d07067d47f040e724b556e5bc3061af132d5a47bd96e901429d53c41e0f8cca012102152e2bb5b273561ece7bbe8b1df51a4c44f5ab0bc940c105045e2cc77e618044", "output_value": 5000000, "sequence": 4294967295, "addresses": [ "CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9" ], "script_type": "pay-to-pubkey-hash", "age": 576 } ], "outputs": [ { "value": 1000000, "script": "76a9145fb1af31edd2aa5a2bbaa24f6043d6ec31f7e63288ac", "addresses": [ "C1rGdt7QEPGiwPMFhNKNhHmyoWpa5X92pn" ], "script_type": "pay-to-pubkey-hash" }, { "value": 3988000, "script": "76a914efec6de6c253e657a9d5506a78ee48d89762fb3188ac", "addresses": [ "CEztKBAYNoUEEaPYbkyFeXC5v8Jz9RoZH9" ], "script_type": "pay-to-pubkey-hash" } ] }

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.

ResourceMethodRequest ObjectReturn Object/txs/decodePOST{"tx":$TXHEX}TX

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

01000000011935b41d12936df99d322ac8972b74ecff7b79408bbccaf1b2eb8015228beac8000000006b483045022100921fc36b911094280f07d8504a80fbab9b823a25f102e2bc69b14bcd369dfc7902200d07067d47f040e724b556e5bc3061af132d5a47bd96e901429d53c41e0f8cca012102152e2bb5b273561ece7bbe8b1df51a4c44f5ab0bc940c105045e2cc77e618044ffffffff0240420f00000000001976a9145fb1af31edd2aa5a2bbaa24f6043d6ec31f7e63288ac20da3c00000000001976a914efec6de6c253e657a9d5506a78ee48d89762fb3188ac00000000

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

Decode Transaction Witness To Sign Endpoint

curl -d '{"witness_tosign_tx":"01000000d0fe2d3feb5f3a5b6a99c244f21924b0249e2bc65c5745bdb618b1799066a80a3bb13029ce7b1f559ef5e747fcac439f1455a2ec7c5f09b72290795e706650448b3658589c258fb4b44180f158ae73d4dbaaf26d64c43a97a5cd78d9577f786d010000001976a9141b80a938a784abe7cdee8fdaf95f5f7e0b8cd0b988ac40420f0000000000ffffffff5fa4537c4c565583f8d32a36c3510808d38acc0ad18cc7e637be6523ebb39ff30000000001000000"}' https://api.blockcypher.com/v1/bcy/test/txs/decodeWitnessToSign?token=YOURTOKEN { "version": 1, "hash_prevouts": "0aa8669079b118b6bd45575cc62b9e24b02419f244c2996a5b3a5feb3f2dfed0", "hash_sequence": "445066705e799022b7095f7ceca255149f43acfc47e7f59e551f7bce2930b13b", "outpoint": "6d787f57d978cda5973ac4646df2aadbd473ae58f18041b4b48f259c5858368b", "outpoint_index": 1, "script_code": "76a9141b80a938a784abe7cdee8fdaf95f5f7e0b8cd0b988ac", "value": 1000000, "sequence": 4294967295, "hash_outputs": "f39fb3eb2365be37e6c78cd10acc8ad3080851c3362ad3f88355564c7c53a45f", "lock_time": 0, "sighash_type": 1 }

This endpoint allows you to decode the tosign_tx only in the case of the spending of a native segwit input (P2WPKH). This allows you to double check the which input you are spending and the value transfered.

ResourceMethodRequest ObjectReturn Object/txs/decodeWitnessToSignPOST{"witness_tosign_tx":$WITNESSTOSIGNTXHEX}WitnessToSignTx

$WITNESSTOSIGNTXHEX is a hex-encoded raw given by the #creating-transactions when includeToSignTx is to true, for example:

01000000d0fe2d3feb5f3a5b6a99c244f21924b0249e2bc65c5745bdb618b1799066a80a3bb13029ce7b1f559ef5e747fcac439f1455a2ec7c5f09b72290795e706650448b3658589c258fb4b44180f158ae73d4dbaaf26d64c43a97a5cd78d9577f786d010000001976a9141b80a938a784abe7cdee8fdaf95f5f7e0b8cd0b988ac40420f0000000000ffffffff5fa4537c4c565583f8d32a36c3510808d38acc0ad18cc7e637be6523ebb39ff30000000001000000

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

Multisig Transactions

{ "inputs": [{"addresses": [sourceAddr]}], "outputs": [{ "addresses" : [pubkey1, pubkey2, pubkey3], "script_type" : "multisig-2-of-3", "value" : 250000 }] }

Multisignature transactions are made simple by the method described in the Creating Transactions section, but they deserve special mention. In order to use them, you first need to fund a multisignature address. You use the /txs/new endpoint as before, but instead of the outputs addresses array containing public addresses, it instead contains the public keys associated with the new address. In addition, you must select a script_type of mutlisig-n-of-m, where n and m are numbers (e.g., multisig-2-of-3). The code example demonstrates how the partially filled TX request object would appear.

After you've set up your request object, you send to /txs/new and receive a partially filled TXSkeleton as before, but with data to sign from the source address. Sign this data and include the public key(s) of the source address---as demonstrated in the Creating Transactions---then send along to the /txs/send endpoint. If it returns with an HTTP Status Code 201, then your multisignature address (via a pay-to-script-hash address) is funded.

 If you only need a pay-to-script-hash address corresponding to N-of-M multisig and don't want---or need---to fund it immediately, you should use the comparatively easier Generate Multisig Address Endpoint.

Spending Multisig Funds

{ "inputs": [{ "addresses" : [pubkey1, pubkey2, pubkey3], "script_type" : "multisig-2-of-3" }], "outputs": [{ "addresses" : [destAddr], "value" : 150000 }] }

Once funded, you might want to programmatically spend the money in the address at some point. Here the process is similar, but with the inputs and outputs reversed. As you can see in the code sample, you need to provide the public keys within the inputs addresses array, and the corresponding script_type of multisig-n-of-m (e.g., multisig-2-of-3). Then you follow the same process of sending to /txs/new and getting an array of data to be signed.

Each party can send their signed data individually to /txs/send and we can correlate the signatures to the public keys; once we have enough signatures we'll propagate the transaction. Or you can send all needed signatures alongside ordered public keys with a single call to /txs/send.

If you send all signatures in a single call, and you're spending inputs locked by a multisig-n-of-m script_type, remember that you'll need n signatures for every element in the TXSkeleton's tosign array. For example, let's say /txs/new returns two elements in the tosign array, corresponding to two multisig-2-of-3 inputs locked by pubkey1, pubkey2, and pubkey3:

{...,"tosign":[data1,data2],...}

Then you'd need to return each piece of data signed twice, preserving order between signatures and pubkeys, resulting in four elements for the signatures and pubkeys arrays:

{...,"tosign":[data1,data2], "signatures":[data1sig1,data1sig2,data2sig1,data2sig2], "pubkeys":[pubkey1,pubkey2,pubkey1,pubkey2],...}

Transaction Propagation Endpoint

curl https://api.blockcypher.com/v1/btc/main/txs/5cad31bd8baf5d10ecdc275193f878226bb51f549c2357658f3dd0d7c5402a7b/propagation?token=YOURTOKEN { "transaction": "5cad31bd8baf5d10ecdc275193f878226bb51f549c2357658f3dd0d7c5402a7b", "first_location": { "latitude": 43.171, "longitude": -71.8229 }, "first_city": "Henniker", "first_country": "United States", "aggregated_origin": { "latitude": 44.283110947350366, "longitude": -69.82911485365968 }, "aggregated_origin_radius": 1023192, "first_received": "2016-08-30T21:25:37.427Z" }

By operating a well-connected node, we collect a lot of information about how transactions propagate; for example, our Confidence Factor relies on this connectivity. With this endpoint, you can leverage our connectivity to get an approximation of a transaction's location of origin.

ResourceMethodReturn Object/txs/$TXHASH/propagationGETDescribed Below

TXHASH is a string representing the hex-encoded transaction hash you're interested in querying for propagation information. The return object is described below:

AttributeTypeDescriptiontransactionstringThe hash of the transaction you queried.first_locationObjectAn object containing latitude and longitude floats representing the first location to broadcast this transaction to BlockCypher.first_citystringOptional The name of the city closest to the first_location. If no nearby city can be found, this is not returned.first_countrystringThe name of the country containing the first_location.aggregated_originObjectAn object containing latitude and longitude floats representing BlockCypher's best guess of likely origin of this transaction, based on the radius of the smallest circle containing the first peer from which we detect this transaction, the average of the first five peers, and the average of the first ten peers.aggregated_origin_radiusintegerThe radius (in meters) of the smallest circle containing the first peer from which we detect this transaction, the average of the first five peers, and the average of the first ten peers. In a general sense, this represents an approximate confidence interval in our calculated aggregated_origin; the smaller the radius, the more confidence in our aggregated_origin assessment.first_receivedtimeThe timestamp when BlockCypher first received this transaction. Want more information about transaction propagation? (e.g., IP addresses) Reach out to us to discuss custom endpoints.

Transaction Propagation WebSocket

You can get a live view of unconfirmed transaction propagation analysis on Bitcoin by connecting to our Transaction Propagation WebSocket, at the following address:

wss://socket.blockcypher.com/v1/btc/main?token=$TOKEN/txs/propagation

As soon as an unconfirmed transaction hits 10 peers, we send the object described above through this WebSocket. For more WebSocket implementation details, check Using WebSockets.

Confidence Factor

One of the things that makes BlockCypher's API uniquely powerful is our ability to accurately predict the likelihood of an attempted double-spend succeeding against a transaction; this percentage probability is optionally included within the confidence attribute on any unconfirmed transaction returned by the Transaction Hash Endpoint when using the includeConfidence flag, in addition to the explicit Transaction Confidence Endpoint detailed below.

So what does that confidence attribute actually mean? In simpler terms, if an unconfirmed transaction returns a confidence factor of 99.9%, then our data says there's a 0.1% chance that an attempted double-spend will succeed. By design, we're conservative. Even when we return 90% confidence, the likelihood of a successful double-spend is significantly lower than 10%.

As you may have gathered from the frequency of links to this feature in these docs, we're exceptionally proud of the work we've done to build this feature and provide it to our users. And that pride extends to our own confidence in our confidence product. We've leveraged this product internally on a major feature: our live block explorer visually shows confidence intervals on unconfirmed transactions directly. Check out a live view of bitcoin and click on one of the most recent unconfirmed transactions. Make sure you pick a very recent transaction: our confidence interval rapidly approaches 99% so quickly that you might miss it!

How does it work?

There are a host of factors that go into our confidence calculation, but you can broadly organize them into two categories. The shape of transactions refers to aspects of transactions that don't vary with time (time-invariant) in our model. The behavior of transactions refers to aspects of transactions that do vary with time (time-variant) in our model.

On the shape side of our model, we ask a number of questions about a transaction: How is it structured? What are its inputs and outputs? What's its signature type? Broadly speaking, without knowing anything about the network, does it look like this transaction will be confirmed soon?

The behavior part of our model primarily focuses on how a transaction propagates through the network. In order to model this correctly, you need both a great connection to the network and a lot of past data, which we have. As BlockCypher pools resources for many users, we're always connected to a statistically significant number of nodes on the network---we target anywhere between 10 to 20% of the active nodes on any given blockchain---and offer connections in return. By monitoring transaction propagation, the number of nodes that have received it, and how quickly they received it, we can calculate its probability to be the "winning" transaction at any given point in time, if a double-spend was attempted. (As an aside, you can always see if a double spend was attempted by checking the double_spend and double_spend_tx attributes on an unconfirmed transaction)

The result is a robust and reliable metric for judging unconfirmed transaction confidence, especially when used in concert with webhooks and websockets. Our work here is based on several public research results in addition to our own in-depth follow-up research, which you can read about here. We are constantly improving our confidence model, and we always publish our findings when we do.

 While we stand by our work behind our confidence research, please note that these measures are ultimately mitigation strategies if you need fast transaction confirmations. There's always an appreciable risk when accepting unconfirmed transactions, and there's no truly bulletproof way to secure unconfirmed transactions. Double spending attacks, while extremely unlikely, can still occur. Blockchain confirmations ultimately provide the highest level of security, especially when dealing with higher value addresses.

Transaction Confidence Endpoint

curl https://api.blockcypher.com/v1/btc/main/txs/43fa951e1bea87c282f6725cf8bdc08bb48761396c3af8dd5a41a085ab62acc9/confidence { "age_millis": 12725, "receive_count": 666, "confidence": 0.9901509730004237, "txhash": "43fa951e1bea87c282f6725cf8bdc08bb48761396c3af8dd5a41a085ab62acc9", "txurl": "https://api.blockcypher.com/v1/btc/main/txs/43fa951e1bea87c282f6725cf8bdc08bb48761396c3af8dd5a41a085ab62acc9" }

ResourceMethodReturn Object/txs/$TXHASH/confidenceGETTXConfidence

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

43fa951e1bea87c282f6725cf8bdc08bb48761396c3af8dd5a41a085ab62acc9

The returned TXConfidence object contains the all-important confidence percentage, receive count and more.

You can find an unconfirmed transaction hash from our block explorer here.

Metadata API

Cryptocurrency addresses, transactions, and blocks are extremely powerful, but the labels they employ can be...cryptic. That's why we have a Metadata API, allowing both public and private key-value storage against addresses, transactions, and blocks.

Private vs Public Metadata

The Metadata API supports both public and private key-value storage. In both cases, setting metadata requires use of a token (if you haven't already, you can register for one here). Public metadata is immutable; once set, it cannot be modified or deleted. If you accidentally set public metadata and need it deleted, contact us. Also, as implied by the name, it's openly accessible to the whole world---regardless of whether they have a token or not. Consequently, private metadata is associated and only accessible with your user token. The methods for interacting with metadata are outlined below.

Get Metadata Endpoint

Get Public Metadata (set by you or anyone else) curl https://api.blockcypher.com/v1/btc/main/addrs/1rundZJCMJhUiWQNFS5uT3BvisBuLxkAp/meta?token=YOURTOKEN {"name":"silkroad","owner":"dpr"} # Get Private Metadata (none set yet, returns empty) curl https://api.blockcypher.com/v1/btc/main/addrs/1rundZJCMJhUiWQNFS5uT3BvisBuLxkAp/meta?token=YOURTOKEN&private=true {}

ResourceMethodReturn Object/addrs/$ADDRESS/metaGET{"$KEY":"$VALUE",...}/txs/$TXHASH/metaGET{"$KEY":"$VALUE",...}/blocks/$BLOCKHASH/metaGET{"$KEY":"$VALUE",...}FlagTypeEffectprivateboolIf private is true, it will return privately stored metadata under your token. Otherwise, returns public metadata. If not set, it defaults to false, returning public data.

This endpoint retrieves metadata associated with a given $ADDRESS, $TXHASH, or $BLOCKHASH.

 Remember to set the private flag if you're querying private metadata underneath your token.

Put Metadata Endpoint

Put Private Metadata, piping to grep to check 204 status code curl -X PUT -d '{"satoshi":"nakamoto", "alice":"bob"}' -is 'https://api.blockcypher.com/v1/btc/main/addrs/1rundZJCMJhUiWQNFS5uT3BvisBuLxkAp/meta?token=YOURTOKEN&private=true' | grep "HTTP/1.1" HTTP/1.1 204 No Content # Get Metadata Again curl https://api.blockcypher.com/v1/btc/main/addrs/1rundZJCMJhUiWQNFS5uT3BvisBuLxkAp/meta?token=YOURTOKEN&private=true {"satoshi":"nakamoto", "alice":"bob"} # Modify/Add Private Metadata curl -X PUT -d '{"satoshi":"moto", "charlie":"tango"}' -is 'https://api.blockcypher.com/v1/btc/main/addrs/1rundZJCMJhUiWQNFS5uT3BvisBuLxkAp/meta?token=YOURTOKEN&private=true' | grep "HTTP/1.1" HTTP/1.1 204 No Content # Get Metadata Again curl https://api.blockcypher.com/v1/btc/main/addrs/1rundZJCMJhUiWQNFS5uT3BvisBuLxkAp/meta?token=YOURTOKEN&private=true {"satoshi":"moto", "alice":"bob", "charlie":"tango"}

ResourceMethodRequest ObjectReturn Object/addrs/$ADDRESS/metaPUT{"$KEY":"$VALUE",...}nil/txs/$TXHASH/metaPUT{"$KEY":"$VALUE",...}nil/blocks/$BLOCKHASH/metaPUT{"$KEY":"$VALUE",...}nilFlagTypeEffectprivateboolIf private is true, it will set/update privately stored metadata under your token. Otherwise, sets public metadata. If not set, it defaults to false, setting public metadata.

This endpoint sets or updates metadata (of the form {"$KEY1:$VALUE1,$KEY2:$VALUE2,...}") associated with a given $ADDRESS, $TXHASH, or $BLOCKHASH. If another key with the same name already exists under your private metadata store, supplying a new value will replace it. New key-value pairs will be added without replacing prexisting key-value pairs. If successful, it will return an HTTP Status Code 204 with no return object.

 If you set public metadata, you cannot modify or delete it. It's set there forever, and viewable to the world. If you accidentally set public metadata and need it deleted, contact us.

Delete Metadata Endpoint

Delete Private Metadata, pipes to grep to check for 204 status code curl -X DELETE -Is https://api.blockcypher.com/v1/btc/main/addrs/1rundZJCMJhUiWQNFS5uT3BvisBuLxkAp/meta?token=YOURTOKEN | grep "HTTP/1.1" HTTP/1.1 204 No Content # Get Private Metadata Again to Confirm Deletion curl https://api.blockcypher.com/v1/btc/main/addrs/1rundZJCMJhUiWQNFS5uT3BvisBuLxkAp/meta?token=YOURTOKEN&private=true {}

ResourceMethodReturn Object/addrs/$ADDRESS/metaDELETEnil/txs/$TXHASH/metaDELETEnil/blocks/$BLOCKHASH/metaDELETEnil

This endpoint deletes all private metadata associated with a given $ADDRESS, $TXHASH, or $BLOCKHASH and your token.

 As a last friendly reminder, if you set public metadata, you cannot delete it. It's set there forever, and viewable to the world. This endpoint will only delete your private metadata. If you accidentally set public metadata and need it deleted, contact us.

Asset API

Blockchains are about transferring value and ownership, so why can't that value extend beyond a blockchain's native token? Thanks to the possibility of embedding arbitrary data through null-data outputs, a blockchain can!

However, the act of creating these alternate forms of value---and choosing a format that was universally readable---can be fraught with difficulty. We built our Asset API to simplify that process. Now instead of spelunking through a blockchain's native transactions and interpreting them yourself, you can utilize this set of APIs to easily issue, check, and transfer assets. This set of endpoints currently leverages the Open Assets Protocol, a simple, robust method of embedding assets across any blockchain that supports null-data outputs.

The endpoints (and code examples) are ordered below to demonstrate how to create asset addresses, issue assets, transfer them, then query the assets/asset addresses you initially created.

 The Asset API only works with confirmed transactions; the API will return an error if asset transfer or issuance is attempted using unconfirmed transaction outputs. It also requires the use of user tokens, you can register for one here.

Generate Asset Address Endpoint

generate on bitcoin mainnet curl -X POST https://api.blockcypher.com/v1/btc/main/oap/addrs?token=YOURTOKEN { "private": "c0e09905fddb1b4a42d297cae1a5f20ca4cbe813e92a7dc4035ffc54561c05de", "public": "02e9431a3ba8d756a26c03c07ffda2a7e28a17b62051f77ea3944c21dc090ba45b", "oap_address": "akFjrBkcu9QQoJeBkwWeH54jnymaGVSUBAs", "original_address": "15mxwaoZfvX7SQ2PttY6RCqDeAQ6UqVjuM", "wif": "L3ge2aRsGReaBtYVYg9Lau2LxDkRW4Cak1dQsuttShEnRXcA1Vfy" } # generate on blockcypher testnet curl -X POST https://api.blockcypher.com/v1/bcy/test/oap/addrs?token=YOURTOKEN { "private": "0eb369746401c3369517239314a6bc0f2bda6124a4dda15643887f86dc0590cf", "public": "026b9f2786b96f7f1aae011a08f5aaccc70f2249606fac4c400d6aa35f50bf7373", "oap_address": "1ByJUiocpifLPaYVTALpA7JYa9DxpGxXKKP", "original_address": "ByJUiocpifLPaYVTALpA7JYa9DxpLQwte4", "wif": "BopcB66fRGgKkwiT2fKyxcawQBJ57DgNyvFq65XuVQdTboxsBkRm" } # generate another oap_address to use in examples below curl -X POST https://api.blockcypher.com/v1/bcy/test/oap/addrs?token=YOURTOKEN { "private": "442abd64783a6411d9e6eb0ed9575c6676bb51824aa3ad4b53577e3d344910c6", "public": "03121e17e0996513813c504c63016cea9a7cf9689025e33f9157bccea67ba60846", "oap_address": "1C3nrGhUDxBbr393u2Wq4PiE8T6oEYjYhrK", "original_address": "C3nrGhUDxBbr393u2Wq4PiE8T6oEYU9At1", "wif": "BqcYBWUvXszsRi1A5cD6t21CT7sbBoJQEkRSnFuoznJDn4hw5aGg" }

ResourceMethodRequest ObjectReturn Object/oap/addrsPOSTnilAddressKeychain

The Generate Asset Address Endpoint returns a private/public keypair and the associated oap_address (the asset address) and original_address (native address on parent blockchain). Asset addresses are just like regular bitcoin addresses, and are generated from a private-public keypair. They only differ by a prefix (ex: 'a' for instead of '1') to distinguish them.

 On Bitcoin's blockchain, oap_address will have an "a" prefix, while the original_address will have a "1" prefix. Note that on BlockCypher's testnet, oap_address will have a "1" prefix, while original_address will have a "B" or "C" prefix. This can be confusing, but unfortunately can't be prevented due to the way oap_address is generated.

Issue Asset Endpoint

Since this is a new address, I need to fund underlying bcy original_address # to enable issuance transaction (otherwise no money available for mining fees) # Going to use a faucet thanks to testnet curl -d '{"address": "ByJUiocpifLPaYVTALpA7JYa9DxpLQwte4", "amount": 1000000}' https://api.blockcypher.com/v1/bcy/test/faucet?token=YOURTOKEN {"tx_ref": "e7ca58724100f20b81e82ac24cb83cc112627be9cbfd2d09b96a87fbafe9e636"} # using same underlying (now-funded address) to issue 1000 assets # also could have used a different, funded bcy address to issue assets to a new oap_address curl -d '{"from_private": "0eb369746401c3369517239314a6bc0f2bda6124a4dda15643887f86dc0590cf", "to_address": "1ByJUiocpifLPaYVTALpA7JYa9DxpGxXKKP", "amount": 1000, "metadata": "1a2b3c4d5e6f"}' https://api.blockcypher.com/v1/bcy/test/oap/issue?token=YOURTOKEN { "ver": 1, "assetid": "1Npqwstp55vgThp4pwAC9UhYkvPJ28b2Ui", "hash": "56253cffa1b3508d106391da3646cda2aee0bd080db427321c77ad11739e4239", "received": "2015-10-25T05:41:45.092075094Z", "double_spend": false, "oap_meta": "1a2b3c4d5e6f", "inputs": [], "outputs": [ { "address": "1ByJUiocpifLPaYVTALpA7JYa9DxpGxXKKP", "value": 1000, "original_output_index": 0 } ] }

ResourceMethodRequest ObjectReturn Object/oap/issuePOSTOAPIssueOAPTX

The Issue Asset Endpoint issues new assets onto an OAP to_address, using your private key. Notice that an issuance returns an OAPTX with no inputs, since it is the original issue.

 If you use the same private key to issue multiple times, it's the same asset. To issue different assets, a different issuing key and address are needed each time. For both issuing and transferring assets, the underlying original_address derived from the private key must have enough funds (in the parent blockchain's native token) to pay mining fees for transactions. These fees are adaptively calculated by our API; for Bitcoin, they are usually between 2 to 10 cents per issuance/transfer.

Transfer Asset Endpoint

using assetid in endpoint as issued above # from private key curl -d '{"from_private": "0eb369746401c3369517239314a6bc0f2bda6124a4dda15643887f86dc0590cf", "to_address": "1C3nrGhUDxBbr393u2Wq4PiE8T6oEYjYhrK", "amount": 200, "metadata": "1a2b3c4d5e6f"}' https://api.blockcypher.com/v1/bcy/test/oap/1Npqwstp55vgThp4pwAC9UhYkvPJ28b2Ui/transfer?token=YOURTOKEN { "ver": 1, "assetid": "1Npqwstp55vgThp4pwAC9UhYkvPJ28b2Ui", "hash": "022e05bdfa2e148bc1882cb7a81506b8316fee6957b11625126d075a8cf8791b", "received": "2015-10-25T05:48:13.417949402Z", "oap_meta": "1a2b3c4d5e6f", "double_spend": false, "inputs": [ { "prev_hash": "56253cffa1b3508d106391da3646cda2aee0bd080db427321c77ad11739e4239", "output_index": 0, "address": "1ByJUiocpifLPaYVTALpA7JYa9DxpGxXKKP", "output_value": 1000 } ], "outputs": [ { "address": "1C3nrGhUDxBbr393u2Wq4PiE8T6oEYjYhrK", "value": 200, "original_output_index": 1 } ] }

ResourceMethodRequest ObjectReturn Object/oap/$ASSETID/transferPOSTOAPIssueOAPTX

The Transfer Asset Endpoint transfers already issued assets (represented by ASSETID) onto a different OAP to_address, using your private key.

 For both issuing and transferring assets, the underlying original_address derived from the private key must have enough funds (in the parent blockchain's native token) to pay mining fees for transactions. These fees are adaptively calculated by our API; for Bitcoin, they are usually between 2 to 10 cents per issuance/transfer.

List Asset TXs Endpoint

using asset id as generated above curl https://api.blockcypher.com/v1/bcy/test/oap/1Npqwstp55vgThp4pwAC9UhYkvPJ28b2Ui/txs?token=YOURTOKEN [ "5f13d5c56ed5b7fe673832e2b5b21feceecebfd08aef03f3208ee855d25f050c", "022e05bdfa2e148bc1882cb7a81506b8316fee6957b11625126d075a8cf8791b", "7216fd3fb2908f87255f9514c98f40cf1299ea6b9182fa4825f5c5bfacf8b038", "56253cffa1b3508d106391da3646cda2aee0bd080db427321c77ad11739e4239", "dff06ef62b8d67ce6eb0750ed0a414932c1b13b825870d8711cd81219418f6d4" ]

ResourceMethodReturn Object/oap/$ASSETID/txsGETArray[String]

The List Asset TXs Endpoint returns an array of strings representing transaction hashes associated with this ASSETID.

Get Asset TX Endpoint

using asset id as generated above, and first txhash from list asset txs endpoint curl https://api.blockcypher.com/v1/bcy/test/oap/1Npqwstp55vgThp4pwAC9UhYkvPJ28b2Ui/txs/5f13d5c56ed5b7fe673832e2b5b21feceecebfd08aef03f3208ee855d25f050c?token=YOURTOKEN { "ver": 1, "assetid": "1Npqwstp55vgThp4pwAC9UhYkvPJ28b2Ui", "hash": "5f13d5c56ed5b7fe673832e2b5b21feceecebfd08aef03f3208ee855d25f050c", "block_height": 506539, "confirmed": "2015-10-25T04:50:06Z", "received": "2015-10-25T04:49:32.37Z", "double_spend": false, "oap_meta": "1a2b3c4d5e6f", "inputs": [], "outputs": [ { "address": "1ByJUiocpifLPaYVTALpA7JYa9DxpGxXKKP", "value": 1000, "original_output_index": 0 } ] }

ResourceMethodReturn Object/oap/$ASSETID/txs/$TXHASHGETOAPTX

The Get Asset TX Endpoint returns an OAPTX by TXHASH and ASSETID.

Get Asset Address Endpoint

using the transfer address from above curl https://api.blockcypher.com/v1/bcy/test/oap/1Npqwstp55vgThp4pwAC9UhYkvPJ28b2Ui/addrs/1C3nrGhUDxBbr393u2Wq4PiE8T6oEYjYhrK?token=YOURTOKEN { "address": "1C3nrGhUDxBbr393u2Wq4PiE8T6oEYjYhrK", "total_received": 200, "total_sent": 0, "balance": 200, "unconfirmed_balance": 0, "final_balance": 200, "n_tx": 1, "unconfirmed_n_tx": 0, "final_n_tx": 1, "txrefs": [ { "tx_hash": "022e05bdfa2e148bc1882cb7a81506b8316fee6957b11625126d075a8cf8791b", "block_height": 506598, "tx_input_n": -1, "tx_output_n": 1, "value": 200, "ref_balance": 200, "spent": false, "confirmations": 26, "confirmed": "2015-10-25T05:49:07Z", "double_spend": false } ], "tx_url": "https://api.blockcypher.com/v1/bcy/test/oap/1Npqwstp55vgThp4pwAC9UhYkvPJ28b2Ui/txs/" }

ResourceMethodReturn Object/oap/$ASSETID/addrs/$OAPADDRGETAddress

The Get Asset Address Endpoint returns an Address representing information about a particular OAPADDR underneath a given ASSETID. Note that while it returns an Address object, anything that would have represented "satoshis" now represents "amount of asset." (e.g., balance, value, etc.)

Address 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 Address 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 two we hear most about are:

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.

A method to easily fund a multisignature address from any wallet by providing a classic address that will automatically transfer to the multisignature/pay-to-script-hash address.

We do not take a fee on address forwarding, other than the required miner fee which depends on network conditions; forwards are free. However, as part of your own services, you can include a fee (either fixed or a percentage) that will also be automatically transfered to your own address in the same transaction. Fee-based business models are thus easily achieved, and moreover, easily auditable via the blockchain.

 Address forwarding is only available for paid plans with an active token, you can't create a address forwarding request without one. You can register for a token and pay for a plan here. Note that mining fees are deducted from any user-set processing fees. This can often lead to lower processing fees than expected. By default, all forwards will be debited with a mining fee that depends on current network fee levels. The amount of the fee is configurable, and if a processing fee is set, it will be deducted from that fee. But for very small forwards, if the amount sent is even lower than the mining and user-set processing fees (or if the processing fees cannot cover the mining fee), the forward will fail.

Create Forward Endpoint

curl -d '{"destination":"15qx9ug952GWGTNn7Uiv6vode4RcGrRemh","callback_url": "https://my.domain.com/callbacks/new-pay"}' https://api.blockcypher.com/v1/btc/main/forwards?token=YOURTOKEN { "input_address": "16uKw7GsQSzfMaVTcT7tpFQkd7Rh9qcXWX", "destination": "15qx9ug952GWGTNn7Uiv6vode4RcGrRemh", "callback_url": "https://my.domain.com/callbacks/forwards", "id": "399d0923-e920-48ee-8928-2051cbfbc369", "token": "YOURTOKEN" }

First, to create an address forwarding address, you need to POST a partially filled AddressForward 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, processing fees (either percent or fixed) and a process_fee_address, and a few other options. You can see more details about these options in the AddressForward object details.

ResourceMethodRequest ObjectReturn Object/forwardsPOSTAddressForwardaddressForward

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

 If you decide to have a callback_url, you'll receive a payload at that url whenever a payment is made to the input_address. The payload will come in the form of a AddressForwardCallback object.

List Payments Endpoint

curl https://api.blockcypher.com/v1/btc/main/forwards?token=YOURTOKEN [ { "input_address": "16uKw7GsQSzfMaVTcT7tpFQkd7Rh9qcXWX", "destination": "15qx9ug952GWGTNn7Uiv6vode4RcGrRemh", "callback_url": "https://my.domain.com/callbacks/forwards", "id": "399d0923-e920-48ee-8928-2051cbfbc369", "token": "YOURTOKEN" } ]

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

ResourceMethodReturn Object/forwardsGETArray[AddressForward]FlagTypeEffectstartintegerReturns list of address forwards starting at the start index; useful for paging beyond the limit of 200 address forwards.

This returns the full array of your currently active address forwarding addresses, based on your token. By default, this endpoint only returns the first 200 address 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/btc/main/forwards/399d0923-e920-48ee-8928-2051cbfbc369?token=YOURTOKEN | grep "HTTP/1.1" HTTP/1.1 204 No Content

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

ResourceMethodReturn Object/forwards/$PAYIDDELETEnil

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

399d0923-e920-48ee-8928-2051cbfbc369

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

Events and Hooks

Blockchains are highly transactional systems. Many usage patterns require knowing when an event occurs: i.e., when a transaction is included into a block, or when an unconfirmed transaction is relayed through the network. Instead of requiring you to continuously poll resources, we provide push APIs to facilitate those use cases, and support both WebSockets and WebHooks.

Which Should I Use?

WebSockets are typically used in client applications when a server is not already running: e.g., a web page displaying the most recent transactions or a wallet app updating its UI when a transaction has been confirmed. Websockets are less reliable in longer interactions (> 1 hour) because they require a connection to stay open.

WebHooks are the most reliable way to get event notifications but requires running a server to receive the callbacks. We automatically retry HTTP requests 5 times.

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.

EventDescriptionunconfirmed-txTriggered 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-blockTriggered for every new block added to the blockchain you've selected as your base resource. The payload is a Block.confirmed-txTriggered 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 in the new Block. The payload is a confirmed TX.tx-confirmationSimplifies 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-txTriggered 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.tx-confidenceTriggered any time an address has an unconfirmed transaction above the confidence property specified in the Event, based on our Confidence Factor. The payload is the TX that triggered the event. If confidence is not set, defaults to 0.99. To ensure transactions are not missed, even if your confidence threshold is not reached, a transaction is still sent after a minute timeout; please remember to double-check the confidence attribute in the TX payload. Events like unconfirmed-tx can produce a lot of requests. To avoid rate-limiting, please register for a token.

Using WebSockets

no websockets via cURL, check the Javascript example

Opening a WebSocket to listen to our feeds is easy, like so in Javascript:

new WebSocket("wss://socket.blockcypher.com/v1/btc/main?token=$TOKEN");

The code may differ if you're not programming in Javascript (check relevant code examples for our standard libraries) but the URL will be identical. Once the socket is opened, the JSON document representing the Event of interest should be sent.

In addition to standard events, WebSockets accept a "ping" event. If you send the following, you will receive the same message back with "ping" replaced by "pong":

{ "event": "ping" }

A regular ping (i.e. every 20 seconds) allows the WebSocket to stay connected for a longer period of time.

Using WebHooks

WebHooks leverage similar objects and interactions but with two key differences:

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.

 To prevent eavesdropping, we recommend securing your callback url by using SSL and providing a secret parameter appended to the Event request. We POST the payload to the unaltered url, which allows you to check on your server that the parameter was not modified. For more advanced setups see the Webhook Signing section. Testing WebHooks can be tricky; we recommend using requestb.in to set up a temporary server to test your events.

Create WebHook Endpoint

curl -d '{"event": "unconfirmed-tx", "address": "15qx9ug952GWGTNn7Uiv6vode4RcGrRemh", "url": "https://my.domain.com/callbacks/new-tx"}' https://api.blockcypher.com/v1/btc/main/hooks?token=YOURTOKEN { "id": "399d0923-e920-48ee-8928-2051cbfbc369" "event": "unconfirmed-tx", "address": "15qx9ug952GWGTNn7Uiv6vode4RcGrRemh", "token": "YOURTOKEN", "url": "https://my.domain.com/callbacks/new-tx", "callback_errors": 0 }

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 options available for your events.

ResourceMethodRequest ObjectReturn Object/hooksPOSTEventEvent

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

List WebHooks Endpoint

curl https://api.blockcypher.com/v1/btc/main/hooks?token=YOURTOKEN [ { "id": "399d0923-e920-48ee-8928-2051cbfbc369" "event": "unconfirmed-tx", "address": "15qx9ug952GWGTNn7Uiv6vode4RcGrRemh", "token": "YOURTOKEN", "url": "https://my.domain.com/callbacks/new-tx", "callback_errors": 0 } ]

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

ResourceMethodReturn Object/hooks?token=$YOURTOKENGETArray[Event]

WebHook ID Endpoint

curl https://api.blockcypher.com/v1/btc/main/hooks/399d0923-e920-48ee-8928-2051cbfbc369 { "id": "399d0923-e920-48ee-8928-2051cbfbc369" "event": "unconfirmed-tx", "address": "15qx9ug952GWGTNn7Uiv6vode4RcGrRemh", "token": "YOURTOKEN", "url": "https://my.domain.com/callbacks/new-tx", "callback_errors": 0 }

This resource returns an Event based on its generated id.

ResourceMethodReturn Object/hooks/$WEBHOOKIDGETEvent

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

399d0923-e920-48ee-8928-2051cbfbc369

Delete WebHook Endpoint

Piping into grep to get status code curl -X DELETE -Is https://api.blockcypher.com/v1/btc/main/hooks/399d0923-e920-48ee-8928-2051cbfbc369?token=YOURTOKEN | grep "HTTP/1.1" HTTP/1.1 204 OK

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

ResourceMethodReturn Object/hooks/$WEBHOOKIDDELETEnil

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

399d0923-e920-48ee-8928-2051cbfbc369

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

WebHook Signing

To guarantee the origin and integrity of the webhook data, webhooks can optionally be signed by our servers. An optional JSON attribute called "signkey" can be provided with the webhook when created to either:

A PEM-encoded ECDSA private key that you created.

The string "preset", in which case the BlockCypher signing key will be used. The associated x509 PKIX encoded public key for our webhook signing key is MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEflgGqpIAC9k65JicOPBgXZUExen4rWLq05KwYmZHphTU/fmi3Oe/ckyxo2w3Ayo/SCO/rU2NB90jtCJfz9i1ow==

Once the "signkey" attribute is set on a webhook, all webhook requests will be signed following the sha256-ecdsa scheme of the HTTP signatures specification.

Updates

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

28/10/21 - Partial Taproot Support

We are happy to announce that BlockCypher now support P2TR (Taproot). Please not that it is not possible to create a transaction that spend a P2TR but you can send to P2TR. We support the new bech32m address format for v1 witness.

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.

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

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

11/06/21 - Data Endpoint Terminated

The data endpoint no longer exists as it was uneconomical and thus non functional since a long time.

19/02/21 - Node-Client Archived

BlockCypher Node.js SDK is now archived. We recommend that javascript users use HTTP libraries such as Axios. The POSTMAN documentation contains all the examples that you need.

18/02/21 - Virtual Size for Blocks

Virtual size (vsize) for blocks.

12/02/21 - Virtual Size for Segwit Transaction

We've added the virtual size (vsize) for segwit transaction. For regular (non-segwit) transaction the vsize is the same as the size. This is how you can see how much fees you are saving by using segwit. Enjoy!

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 :).

03/02/21 - Additional DNS Seeds for Doge

Following last week Dogecoin chain lag due to unhealthy network conditions, we've added new DNS seeds thanks to Denarius.

02/02/21 - Additional Support for Litecoin Maddrs

Following previous updates to enhance the support of "Maddrs" on Litecoin, we've added several bugfixes:

Correctly display "Maddrs" webhooks with standard wallet.

Correctly display wallet webhooks with "Maddrs".

Fix an error where a webhook will not be delivered if created with a standard wallet and a "Maddr". If you encounter this issue please recreate your wallet.

In standard wallet, listing all addresses will correctly convert "3addrs" to "Maddrs".

In standard wallet, getting a wallet will always show "Maddrs".

27/11/20 - New DASH DNS Seeds

We've updated our DASH DNS seeds in order to provide a more reliable service.

23/11/20 - Payment Forward for Litecoin MAddrs

We've added the ability to create payment forward to Litecoin address with the M prefix.

17/11/20 - OP_RETURN Simplification

We've added the ability to create OP_RETURN output as easily as including null-data as script-type. See the TXOutput object for more details.