ChainRelay Events API
Smart Contract APIs for Hackers
ChainRelay’s belief is that you shouldn’t have to be a blockchain expert in order to get started building apps that leverage Ethereum. ChainRelay has an ambitious vision of being a global platform for building Ethereum blockchain enabled apps. Today we take the first step in achieving that vision with the alpha release of the ChainRelay web service: RESTful APIs for Ethereum smart contract events. The ChainRelay roadmap includes more web services for contract events including webhooks for seamless integrations and websocket subscriptions, so stay tuned!
ChainRelay Smart Contract Events API
With the ChainRelay Smart Contracts Events API, you can now build websites, apps, and tools that rely on smart contract events via simple HTTPS requests. Spend your valuable time building amazing apps with the knowledge that your Ethereum events backend will just work.
All Ethereum contracts can emit events, allowing external services and apps to react to changes in a smart contract. Smart contract events are often used to signal that a function call has completed successfully, or that some change in contract state has occurred — like a token “Transfer” event. Events are also used as a cheap form of storage by smart contract developers. Since contract events exist within the public domain you are free to build apps that monitor or respond to events on any Ethereum contract. Don’t ask anyone for permission to access a contract’s event data — just do it!
Lead by example
It’s easy to query for events using the ChainRelay API, just create an API token and try it out. Here’s an example of requesting events data for the CryptoKitties token on the command line:
The response includes events specific to the CryptoKitties contract, like the “Pregnant” event:
You’ll notice there are only two required query string parameters, token and fromBlock. The URL path has two additional parameters: the network ID and the contract address that you’d like events for. You can read our docs for more info about these parameters.
A Note on ABIs
Since events on Ethereum are “hashed” (i.e., encoded by a certain hashing algorithm), we need some information about the smart contract in order to translate events into a human-readable format. The information we need about a contract is called an “ABI”, which is a JSON document that describes the contract’s methods and events.
ChainRelay has pre-loaded several of the most popular contract ABIs so you can easily get started making API requests for contract events. If you’d like to use a contract that we don’t have listed, you can either upload a contract ABI using our API (see here for more details), or send us an email and we’ll do it for you. We are constantly pre-loading more contracts to make your life easier. You can still request events for a smart contract that we don’t know the ABI for, the response will just include hashed data that you’ll have to translate yourself.
While ChainRelay is in alpha, feel free to use the API at no cost. You can generate a free API token by reading the API docs.
— ChainRelay team