Ethereum Block & Transaction Info via Aggregated Views(API by Block 16)
When working with web applications that interface with Ethereum nodes, I’ve always foundthat I need more information than is provided by singular JSON-RPC calls. For instance, youcan get the information about the block —but then have to run another call to get informationabout a transaction and yet another call for the transaction receipt. If you are gathering andorganizing this information at scale, it oftentimes requires over 500 HTTP requests and cantake a lot of time (not to mention a burden on Infura). At Block 16 we have created internal APIs to present this information quickly along with different “views” or organizations of blockchain information. Today we are making some of these public.
Get All Block Information by Number.
Get all block information, uncles, transactions andreceipts by block number. The datastructure is much like what’s returned from normal
eth_getBlockByNumber
RPC but includes a list of
uncles
,
transactions,
and
receipts
achievedfrom
eth_getUncleByBlockNumberAndIndex
,
eth_getTransactionByHash
and
et h_getTransactionR eceipt
calls respectively. More information can be found here, by invokingthe following command in terminal or clicking the link within the command:
curl -X GET https://api.block16.io/v1/block/5000000 \ -H 'Accept: application/json'
Get All Current Block Information.
Get all block information, uncles, transactions andreceipts for the current block. Internally we track all transactions on the network and performvarious operations
—
so we tend to run about 1–10 seconds behind the current block.
curl -X GET https://api.block16.io/v1/block/current \ -H 'Accept: application/json'
Subscribe to Current Block via Websocket.
Same as the endpoint described above but thewebsocket pushes the current block information upon connection and receives updates asblocks are processed. A sample application can be viewed here with source code availablehere.
Get Last 100 TXs by Address.
We have an interesting data format for this endpoint that isinformed by availability and database space:
1/2
{ "address": "0000000000000000000000000000000000000008", "transactionDate": 1528012206000, "value": "1000000000000000000", "toAddress": "0000000000000000000000000000000000000008", "fromAddress": "dfa5d32e82ce9d131ca77f5e260c3d0d68deb61b", "ethereumContract": "3543638ed4a9006e4840b105944271bcea15605d", "transactionHash": "945ab5e688660478b0bb813cc6c2f4c8a17bb1d8bed810634ec203a26e7a74d8", "blockNumber": 5724039, "transactionType": "token_transaction", "fee": "16440820000000000"}
Notice that all hex prefixes are removed and that there is a “toAddress”, “fromAddress” and an“address” field. Incoming transactions are found by matching “address” with the “toAddress”and outgoing by matching “address” with “fromAddress”. The “value” property is the base 10raw value of the transaction in wei if it was not a token transaction. If it was a tokentransaction, the “value” property is the raw token amount without decimals. The “fee” is in base10 wei. For more information about the structure of the data visit the documentation. Curlinvocation:
curl -X GET https://api.block16.io/v1/address/0x0000000000000000000000000000000000000001/transactions -H 'Accept: application/json'
Get All Token Contracts Associated with an Address.
This endpoint lists all token contractaddresses that an Ethereum address has ever been associated with. As with the previousendpoint, the “0x” hexadecimal prefix is removed in order to save space in the database.
curl -X GET https://api.block16.io/v1/address/0x0000000000000000000000000000000000000001/assets -H 'Accept: application/json'
The formal slate documentation can be found at https://docs.block16.io/ . All of the endpointshave crossorigin headers included so you’ll be able to use them in a webapp, though there is a30 request per minute limit implemented per IP. If these endpoints become popular we’llconsider increasing the request per minute limit and scaling/sharding our public databases.Our goal is to help the ecosystem create more responsive and informative webapps. Anyfeedback is greatly appreciated