Beats
Last updated
Was this helpful?
Last updated
Was this helpful?
Beats are messages that are sent on each new block, containing tiny bits of data that can be used to detect changes happening on the blockchain. Beats provide as little data as possible to remove the need to load full block and receipt data every time.
The connection is managed using WebSockets, which connect directly to a VeChain node.
A simple connection can be established with this snippet:
This will receive a new block as soon as it is added to the blockchain, in the form of JSON-encoded strings with a bloom filter which can be used to check if the block contains an account.
To resume listening from a specific block position, the options can include a blockID
to continue from where a previous listener may have disconnected.
For additional details on the options, refer to the documentation of .
The blocks are received as JSON-encoded strings. These strings must be parsed into usable objects.
An example result is:
It enables the verification of interactions involving a specific address, potentially eliminating the need for further transaction or block lookups if the block lacks information related to that address.
The bloomUtils
offer a straightforward test function to determine whether an address has had interactions within a block:
The bloom filter is used for testing and includes:
The Gas Payer of a transaction
The emitters of all events within transactions
The topics of all events in transactions that include an address or shorter than an address
The sender and receiver of transfers
The origin of the transaction
The signer of the block
The beneficiary of the block
Another example can be found on GitHub using a React Hook that listens and provides state updates when information is found in a new block. For example, transaction IDs or addresses:
For more details on the implementation, you can view the .