Events
Overview: What are chain events?
Events are objects containing decoded values (data) provided by the chain in the result of any transaction triggered using the submitTxBlocking
function. At least one of these two ExtrinsicSuccessEvent
or ExtrinsicFailedEvent
events is provided for any transaction depending on its success or failure. While submitTxBlocking
provides the SDK handlers main events list of BlockchainEvents available, we also allow you to filter this list to get the ones you need. An example to filter only the events list of a balance transfer transaction:
const balanceTransfertEvents = BlockchainEvents.findEvents(
BalancesTransferEvent
);
note: BlockchainEvents is the result of submitTxBlocking
function. It can be stored in a constant for example.
To better understand Events, we already jumped a bit deeper than the first and easiest option to get the extrinsics events list. In case you do not need to manually sign or send your transaction, each of the Ternoa extrinsics features comes with two functions to execute a transaction and an easy one to directly get the required events list. See the example below :
When the balancesTransferTx
function creates an unsigned unsubmitted transaction hash, the balancesTransfer
function signs and submits the transaction to provide the events list.
About the Event Design Format:
To make the returned events data useful, we provide both the native format and a more friendly, ready-to-use format:
- a string as an AccountId32 corresponds to a classic user-valid address.
- a string as u128 is a BN value as a string natively used under the hood by the chain.
- rounded data (ex: amoutRounded) is the "human" version of data, (usually a BN) that can be directly used.
- some events from the utility pallet do not return any data.
The events below are the Events handled in the Ternoa SDK sorted by categories
Balances
BalancesWithdrawEvent
- Summary: Some amount was withdrawn from the account
- Data returned:
- who: string as AccountId32
- amount: string as u128
- amountRounded: number
BalancesDepositEvent
- Summary: Some amount was deposited.
- Data returned:
- who: string as AccountId32
- amount: string as u128
- amountRounded: number
BalancesTransferEvent
- Summary: Transfer succeeded.
- Data returned:
- from: string as AccountId32
- to: string as AccountId32
- amount: string as u128
- amountRounded: number
BalancesEndowedEvent
- Summary: An account was created with some free balance
- Data returned:
- account: string as AccountId32
- to: string as AccountId32
- freeBalance: string as u128
- freeBalanceRounded: number
Treasury
TreasuryDepositEvent
- Summary: Some funds have been deposited.
- Data returned:
- account: string as AccountId32
- to: string as AccountId32
- value: string as u128
- valueRounded: number
NFT
NFTCreatedEvent
- Summary: An NFT has been created.
- Data returned:
- event : event
- nftId: number
- owner: string as AccountId32
- offchainData: string
- royalty: number
- collectionId: number or null
- isSoulbound: boolean
- mintFee: string as u128
- mintFeeRounded: number
NFTBurnedEvent
- Summary: An NFT has been burned.
- Data returned:
- nftId: number
NFTDelegatedEvent
- Summary: An NFT has been delegated.
- Data returned:
- nftId: number
- recipient: string as AccountId32 or null
NFTRoyaltySetEvent
- Summary: The NFT's royalty has been set.
- Data returned:
- nftId: number
- royalty: number
NFTTransferredEvent
- Summary: An NFT has been transferred.
- Data returned:
- nftId: number
- sender: string as AccountId32
- recipient: string
NFTAddedToCollection
- Summary: An NFT has been added to a collection.
- Data returned:
- nftId: number
- collectionId: number
Collection
CollectionCreatedEvent
- Summary: A Collection has been created.
- Data returned:
- collectionId: number
- owner: string as AccountId32
- offchainData: string
- limit: number or null
CollectionLimitedEvent
- Summary: The collection's limit has been set.
- Data returned:
- collectionId: number
- limit: number
CollectionClosedEvent
- Summary: A collection has been closed.
- Data returned:
- collectionId: number
CollectionBurnedEvent
- Summary: A collection has been burned.
- Data returned:
- collectionId: number
Marketplace
MarketplaceCreatedEvent
- Summary: A marketplace has been created.
- Data returned:
- marketplaceId: number
- owner: string as AccountId32
- kind: the marketplace kind : Public or Private
MarketplaceOwnerSetEvent
- Summary: The marketplace owner has been set.
- Data returned:
- marketplaceId: number
- owner: string as AccountId32
MarketplaceKindSetEvent
- Summary: The marketplace kind has been set.
- Data returned:
- marketplaceId: number
- kind: the marketplace kind : Public or Private
MarketplaceConfigSetEvent
- Summary: The marketplace configuration has been updated. Parameters can be unchanged (Noop), Removed, or Set
- Data returned:
- marketplaceId: number
- commissionFeeType: optional string: Remove or Set
- commissionFee: optional string
- commissionFeeRounded: optional Number
- listingFeeType: optional string: Remove or Set
- listingFee: optional string
- listingFeeRounded: optional Number
- accountList: optional Array of strings as AccountId32
- offchainData: optional string
MarketplaceMintFeeSetEvent
- Summary: The marketplace mint fee has been set.
- Data returned:
- fee: string
- feeRounded: number
NFTListedEvent
- Summary: An NFT has been listed for sale on a marketplace.
- Data returned:
- nftId: number
- marketplaceId: number
- price: string
- priceRounded: number
- commissionFeeType: optional string: Percentage or Flat value
- commissionFee: optional string
- commissionFeeRounded: optional number
NFTUnlistedEvent
- Summary: An NFT has been unlisted from a marketplace.
- Data returned:
- nftId: number
NFTSoldEvent
- Summary: An NFT has sold.
- Data returned:
- nftId: number
- marketplaceId: number
- buyer: string
- listedPrice: string
- listedPriceRounded: number
- marketplaceCut: string
- marketplaceCutRounded: number
- royaltyCut: string
- royaltyCutRounded: number
Utility
ItemCompletedEvent
- Summary: A single item within a Batch of dispatches has been completed with no error.
- Data returned:
- This is an empty event: it does not return any specific event.
BatchInterruptedEvent
- Summary: Batch of dispatches did not complete fully. Index of first failing dispatch given, as well as the error.
- Data returned:
- index: number
- error: object
- module: object
- index: number
- error: string
- module: object
- errorType: optional string
- details: optional string
BatchCompletedEvent
- Summary: Batch of dispatches completed fully with no error.
- Data returned:
- This is an empty event: it does not return any specific event.
System
ExtrinsicFailedEvent
- Summary: An extrinsic failed.
- Data returned:
- dispatchError: object
- module: object
- index: number
- error: string
- module: object
- errorType: optional string
- details: optional string
- dispatchInfo: object
- weigth: string
- class: string
- paysFee: string
- dispatchError: object
ExtrinsicSuccessEvent
- Summary: An extrinsic was completed successfully.
- Data returned:
- dispatchInfo: object
- weigth: string
- class: string
- paysFee: string
- dispatchInfo: object
NewAccountEvent
- Summary: A new account was created.
- Data returned:
- account: string as AccountId32