External Events
Last updated
Last updated
Guardian will publish a number of events to the NATS server to hook into those events, which extends the function that is suitable to the solution.
To hook into Guardian events, we need to have a client, that is connected to the same NATS instance with Guardian and implement the response function for a specific event.
Below is the sample for .NodeJs and in the case of other languages please refer to for complete documentation.
The events with type=publish
is publish/subscribe pattern so that the same message can be received by multiple clients. If there are multiple clients make sure it is handled by duplicate message processing.
Some event has a type=request
for which we need to subscribe and respond to the event.
For the before/after IPFS event, if the listener responds with an error then the IPFS service will be skipped and upload/respond to the actual content. This same scenario also happens when we do not have a listener to an event. For example, we can use this to encrypt/decrypt IPFS content file
external-events.token_minted
publish
{ tokenId, tokenValue, memo }
Triggered when a token is successfully minted.
external-events.token_mint_complete
publish
{ tokenValue }
Triggered when all tokens have been minted.
external-events.error_logs
publish
{ message, type, attributes }
Triggered when an error is sent to the logger service.is sent to logger service
external-events.block_event
publish
<blockEventData>
Represents a block external event.
external-events.ipfs_before_upload_content
request
{content}
The base64-encoded content (buffer) to be hooked and modified before uploading to IPFS.
external-events.ipfs_after_read_content
request
{content}
The base64-encoded content (buffer) to be modified or processed after reading from IPFS.
external-events.ipfs_loaded_file
subscription
{ taskId, fileContent, error }
Receives an event when a file load is complete.
This example demonstrates the implementation of encryption/decryption of simple IPFS content.
To get more information please click
Please refer to