Access blockchain events & logs using a simple URL

favo
vechain.energy
Published in
2 min readSep 7, 2022

--

Today another API launched to comfort developers and continue building bridges between VeChain and regular web-applications.

Available at https://event.api.vechain.energy/ it is now possible to load plain event data from contracts. It enables access to contract logs like a browsable database.

event.api.vechain.energy

There are two types of data related to a contract required to be read from the outside. Data stored in the contract and events logged on the Blockchain. Here is a rough overview:

Data Storage

Information that is stored within a contract. For example a users balance for given token. The data is also available from the contracts perspective. Access is either possible by accessing public variables or using public functions.

Read more about the anatomy of a contract at ethereum.org.

Events & Logs

The second relevant data type is events. Events are not stored in the contract. Events are like short bursts of information logged by the Blockchain. From the contracts perspective they are emitted but can not be read. These logs are immutable and can be filtered & paginated like a database.

The new Event-API provides simple access to this kind of data allowing every web-application or legacy environment to use its data too.

Read more about Events and Logging in the Chainlink Blog.

How to accessing event logs

Using the Event-Signature from the contracts source code or the ABI definition, data is available with a single request:

For example the list of all VTHO Transfers on the MainNet is available by calling:

https://event.api.vechain.energy/main/0x0000000000000000000000000000456E65726779/Transfer%20(address%20indexed%20_from,%20address%20indexed%20_to,%20uint256%20_value)

Listing only the last 10 transfers can be accomplished by applying pagination:

https://event.api.vechain.energy/main/0x0000000000000000000000000000456E65726779/Transfer%20(address%20indexed%20_from,%20address%20indexed%20_to,%20uint256%20_value)?order=desc&limit=10

Multiple events can be queried with a POST-Request.
See the short documentation with examples to learn more:
https://event.api.vechain.energy

An example Sandbox browsing thru VTHO Transfers is available here: https://codesandbox.io/s/demonstration-of-event-api-1k2wqs?file=/src/Transfers.js

Notes

The combination of the newly added APIs allow developers to start easier and work faster with Blockchain data. It allows every developer used to REST-APIs to:

  1. Execute Functions on the Blockchain
  2. Read Storage-Values from any Contract
  3. Access event logs like a Database from any Contract

It enables the implementation of the Blockchain as a public backend in everyones application.

As Developer do you have suggestions or require something that slows you down? Join us on Discord and let us know — we’ll try to remove hurdles or build solutions.

--

--