World all
- Imports:
- interface
hermes:binary/api - interface
hermes:hash/api - interface
hermes:cbor/api - interface
hermes:cardano/api
- interface
- Exports:
- interface
hermes:cardano/event-on-block - interface
hermes:cardano/event-on-immutable-roll-forward
- interface
Import interface hermes:binary/api
Binary Data API
Binary Data types and functions.
Permissions
This API is ALWAYS available. cspell: words Binary API Interface - Imports ONLY
Types
type bstr
Binary String (bstr) is a list of bytes. This type is used to indicate the data is an arbitrary array of bytes.
tuple b128
128 bit value
Tuple Fields
tuple b256
256 bit value
Tuple Fields
tuple b512
512 bit value
Tuple Fields
Import interface hermes:hash/api
Data Hash API
Hashing Data types and functions.
Permissions
This API is ALWAYS available. Hashing API Interface - Imports ONLY
Types
type bstr
#### `type b256` [`b256`](#b256)
#### `type blake2b256` [`b256`](#b256)
A 256-bit (32-byte) cryptographic hash value produced by the BLAKE2b hash function.
enum errno
Errors that can occur during hashing.
Enum Cases
-
The key exceeds the supported size of the hash function.
-
The hash size requested is larger than supported by the hash function.
-
The salt exceeds the supported size of the hash function.
-
The personal exceeds the supported size of the hash function.
Functions
blake2s: func
BLAKE2s Hash Function
Hash a binary buffer with BLAKE2s.
Parameters
buf: The binary data buffer to hash.outlen: Optional. The size of the digest. If the outlen is not defined, it defaults to 32.
Returns
- Either a buffer the size requested, with the hash.
- Or an error:
hash_too_bigifoutlenis specified and is > 32 bytes.invalid_digest_byte_lengthifoutlenis specified and is = 0.
Params
buf:bstroutlen: option<u8>
Return values
blake2smac: func
BLAKE2sMac Hash Function
Hash a binary buffer with BLAKE2s with MAC (Message Authentication Code) mode.
Parameters
buf: The binary data buffer to hash.outlen: Optional. The size of the digest. If the outlen is not defined, it defaults to 32.key: The key to use with the hash. With MAC mode, key is needed to be defined Should not be > 32 bytes.salt: Optional. Salt uses to increase the randomness and uniqueness of the hash output Should not be > 8 bytes. If not defined, salt is not used.personal: Optional. Personal allows to add customization to the hash function behavior. Should not be > 8 bytes. If not defined, personal is not used.
Returns
- Either a buffer the size requested, with the hash.
- Or an error:
key_too_bigifkeyis > 32 bytes.hash_too_bigifoutlenis specified and is > 32 bytes.salt_too_bigifsaltis specified and is > 8 bytes.personal_too_bigifpersonalis specified and is > 8 bytes.
Note:
key length is checked before outlen so if both sizes are invalid, only
key_too_big will be returned.
If salt length exceeds 8 bytes, salt_too_big will be returned.
if personal length exceeds 8 bytes, personal_too_big will be returned.
Params
Return values
blake2b: func
BLAKE2b Hash Function
Hash a binary buffer with BLAKE2b.
Parameters
buf: The binary data buffer to hash.outlen: Optional. The size of the digest. If the outlen is not defined, it defaults to 64.
Returns
- Either a buffer the size requested, with the hash.
- Or an error:
hash_too_bigifoutlenis specified and is > 64 bytes.invalid_digest_byte_lengthifoutlenis specified and is = 0.
Params
buf:bstroutlen: option<u8>
Return values
blake2bmac: func
BLAKE2bMac Hash Function
Hash a binary buffer with BLAKE2b with MAC (Message Authentication Code) mode.
Parameters
buf: The binary data buffer to hash.outlen: Optional. The size of the digest. If the outlen is not defined, it defaults to 64.key: The key to use with the hash. With MAC mode, key is needed to be defined Should not be > 64 bytes.salt: Optional. Salt uses to increase the randomness and uniqueness of the hash output Should not be > 16 bytes. If not defined, salt is not used.personal: Optional. Personal allows to add customization to the hash function behavior. Should not be > 16 bytes. If not defined, personal is not used.
Returns
- Either a buffer the size requested, with the hash.
- Or an error:
key_too_bigifkeyis specified and is > 64 bytes.hash_too_bigifoutlenis specified and is > 64 bytes.salt_too_bigifsaltis specified and is > 16 bytes.personal_too_bigifpersonalis specified and is > 16 bytes.
Note:
key length is checked before outlen so if both sizes are invalid, only
key_too_big will be returned.
If salt length exceeds 16 bytes, salt_too_big will be returned.
if personal length exceeds 16 bytes, personal_too_big will be returned.
Params
Return values
blake3: func
BLAKE3 Hash Function
Hash a binary buffer with BLAKE3.
Parameters
buf: The binary data buffer to hash.outlen: Optional. The size of the digest. If the outlen is not defined, it defaults to 32.key: Optional. The key to use with the hash. If not defined, the hash is not keyed. Should not be > 32 bytes.
Returns
- Either a buffer the size requested, with the hash.
- Or an error:
key_too_bigifkeyis specified and is > 32 bytes.hash_too_bigifoutlenis specified and is > 32 bytes.
Note:
key length is checked before outlen so if both sizes are invalid, only
key_too_big will be returned.
Params
Return values
Import interface hermes:cbor/api
CBOR API
CBOR Data types and functions.
Permissions
This API is ALWAYS available. cspell: words CBOR API Interface - Imports ONLY
Types
type bstr
#### `type cbor` [`bstr`](#bstr)
CBOR is a binary cbor data type. This type is used to indicate the binary array MUST be CBOR data.
Import interface hermes:cardano/api
Cardano Blockchain API
Cardano Blockchain API functionality exposed to the Hermes WASM Modules.
Permissions
This API is ALWAYS available.
Types
type blake2b256
#### `type cbor` [`cbor`](#cbor)
Slot on the Cardano blockchain.
type txn-idx
u16
Cardano transaction index.
type txn-hash
Cardano transaction hash.
variant cardano-network
Cardano blockchain network.
Variant Cases
-
Cardano Mainnet Network :- "NetworkId": 1, "NetworkMagic": 764824073
-
Cardano Preprod Network :- "NetworkId": 0, "NetworkMagic": 1
-
Cardano Preview Network :- "NetworkId": 0, "NetworkMagic": 2
-
Custom Test Network :- "NetworkId": 0, "NetworkMagic": u64
variant sync-slot
A sync slot variation.
Variant Cases
-
Genesis (first block) of the blockchain.
-
specific:slotA specific slot in the blockchain.
-
The live tip of the blockchain, following the upstream node.
-
The immutable tip of the blockchain e.g., The last block which has reached the absolute finality and can never roll back.
enum subscribe-error
Errors that can happen for subscribing to blocks
Enum Cases
enum create-network-error
Errors that can happen when initialize network.
Enum Cases
enum block-error
Errors that can happen for block.
Enum Cases
enum transaction-error
Errors that can happen for transaction.
Enum Cases
resource network
Cardano network
resource block
Cardano block
resource transaction
Cardano transaction
resource subscription-id
Functions
[static]network.new: func
Create a new Cardano network instance.
Parameters
network: The Cardano network to connect to (e.g., Mainnet, Preprod, Preview).
Returns
ok(network): A resource network, if successfully create network resource.error(create-network-error): If creating network resource failed.
Params
Return values
- result<own<
network>,create-network-error>
[method]network.subscribe-block: func
Subscribe to blockchain block events, start from a specified starting point.
This sets up a subscription to receive new block and block rollback updates starting from the
given start.
Parameters
start: The slot to begin following from.
Returns
ok(u32): A unsigned integer representing the underlying 32-bit subscription resource ID. This is used to distinguish events from different subscribers and provides control over subscription management.The ID must be unique across all active subscriptions.error(subscribe-error): If subscription failed.
Params
Return values
- result<
u32,subscribe-error>
[method]network.subscribe-immutable-roll-forward: func
Subscribe to blockchain immutable rolls forward.
This sets up a subscription to receive event when the immutable part of the blockchain roll forwards.
Parameters
start: The slot to begin following from.
Returns
ok(u32): A unsigned integer representing the underlying 32-bit subscription resource ID. This is used to distinguish events from different subscribers and provides control over subscription management.The ID must be unique across all active subscriptions.error(subscribe-error): If subscription failed.
Params
Return values
- result<
u32,subscribe-error>
[method]network.get-block: func
Get a block relative to start by step.
Parameters
start: Slot to begin retrieval from, current tip ifNone.step-0: the block atstart, will returnNoneif there is no block exactly at thisstartslot. -+n: then‑th block after the givenstartslot. –‑n: then‑th block before the givenstartslot.
Note: For both +n and -n, the start does not need to be a true block.
They will return the block which appears at this block offset, given the arbitrary start point.
If the start block does exist, it will never be returned with a positive or negative step, as it is step 0.
Example, Given three consecutive blocks at slots 100, 200 and 300 the following will be returned:
start = 100, step = 0-> 100 (Exact match)start = 100, step = 2-> 300 (Skips 200)start = 150, step = 1-> 200 (Rounds up from 150)start = 200, step = 1-> 300 (Forward iteration)start = 300, step = -2-> 100 (Skips 200)start = 250, step = -2-> 100 (Rounds down to 200 first)
Returns
- Returns a
blockresource,Noneif block cannot be retrieved.
Params
Return values
- option<own<
block>>
[method]network.get-tips: func
Retrieve the current tips of the blockchain.
Returns
- A tuple of two slots:
- The immutable tip.
- The mutable tip.
Noneif the tips cannot be retrieved.
Params
self: borrow<network>
Return values
[method]block.is-immutable: func
Returns whether the block is part of the immutable section of the chain.
Returns
trueif the block is in the immutable part.falseif the block is in the mutable part.
Params
self: borrow<block>
Return values
[method]block.is-rollback: func
Returns whether the block is the first block of a rollback.
Returns
ok(bool)True if the block is the first block of a rollback, otherwise, False.error(block-error): If block cannot be retrieved.
Params
self: borrow<block>
Return values
- result<
bool,block-error>
[method]block.get-txn: func
Retrieves a transaction at the specified index within the block.
Parameters
index: The index of the transaction to retrieve.
Returns
ok(transaction): Atransactionresource at the given indexerror(transaction-error): If a transaction data does not exist in the block at the given index.
Params
Return values
- result<own<
transaction>,transaction-error>
[method]block.get-slot: func
Retrieves the slot number that this block belongs to.
Returns
slot: The slot number of the block.
Params
self: borrow<block>
Return values
[method]block.raw: func
Returns the raw CBOR representation of the block.
Returns
cbor: The CBOR format of the block.
Params
self: borrow<block>
Return values
[method]block.get-fork: func
Fork count is a counter that is incremented every time there is a roll-back in live-chain. It is used to help followers determine how far to roll-back to resynchronize without storing full block history. The fork count starts at 1 for live blocks and increments if the live chain tip is purged due to a detected fork, but it does not track the exact number of forks reported by peers.
- 0 - for all immutable data
- 1 - for any data read from the blockchain during a backfill on initial sync
- 2+ - for each subsequent rollback detected while reading live blocks.
** Returns **
u64: The fork count.
Params
self: borrow<block>
Return values
[method]transaction.get-metadata: func
Returns the transaction auxiliary metadata in CBOR format.
Parameters
label: A metadata label used as a key to get the associated metadata.
Returns
option<cbor>: The CBOR format of the metadata,Noneif the label requested is not present.
Params
self: borrow<transaction>label:u64
Return values
- option<
cbor>
[method]transaction.get-txn-hash: func
Returns the transaction hash.
Returns
option<txn-hash>: Cardano transaction hash - Blake2b-256,Noneif cannot retrieve the transaction hash.
Params
self: borrow<transaction>
Return values
- option<
txn-hash>
[method]transaction.raw: func
Returns the raw CBOR representation of the transaction.
Returns
option<cbor>: The CBOR format of the transaction,Noneif cannot retrieve the raw transaction.
Params
self: borrow<transaction>
Return values
- option<
cbor>
[method]subscription-id.get-network: func
Returns the network that this subscription is in.
Returns
cardano-network: The Cardano network that this subscription is in.
Params
self: borrow<subscription-id>
Return values
[method]subscription-id.unsubscribe: func
Unsubscribing block event of this subscription-id instance.
Once this function is called, the subscription instance, subscription-id will be removed.
Params
self: borrow<subscription-id>
Export interface hermes:cardano/event-on-block
Types
type block
#### `type subscription-id` [`subscription-id`](#subscription_id)
#### `type cbor` [`cbor`](#cbor)
----
Functions
on-cardano-block: func
Trigger when a Cardano block event is fired.
Parameters
subscription-id: A unique identifier of the block subscription.block: A block resource where information of the block can be retrieve.
Params
subscription-id: borrow<subscription-id>block: borrow<block>
Export interface hermes:cardano/event-on-immutable-roll-forward
Types
type block
#### `type subscription-id` [`subscription-id`](#subscription_id)
----
Functions
on-cardano-immutable-roll-forward: func
Trigger when a Cardano immutable roll-forward event is fired.
Parameters
subscription-id: A unique identifier of the block subscription.block: A block resource where information of the block can be retrieve.
Notes
Roll-forward events are guaranteed to be fully processed before the next
block event is delivered. The block event delivered immediately after a
roll-forward will correspond to the block at the roll-forward target slot.
This means that roll-forward processing does not need to reset or re-subscribe the blockchain follower.
Params
subscription-id: borrow<subscription-id>block: borrow<block>