-
Notifications
You must be signed in to change notification settings - Fork 11
4 Events
Events are objects containing decoded values (datas) 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 are provided for any transaction depending on its success or fail. 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 exemple to filter only the events list of a balance transfert transaction :
const balanceTransfertEvents = BlockchainEvents.findEvents(BalancesTransferEvent)
note : BlockchainEvents is the result of submitTxBlocking
function. It can be stored in a constant for exemple.
To get a better understanding of 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 handle manually signing or sending your transaction, each of the Ternoa extrinsics feature comes with two functions to execute a transaction and an easy one to directly get the required events list. See the exemple below :
When the balancesTransferTx
function creates an unsigned unsubmitted transaction hash, the balancesTransfer
function signs and submits the transaction to provide the events list.
In order to make the returned events datas usefull, we provide both the native format and a friendly ready to use format design format :
- a string as an AccountId32 correspond to a classic user valid address.
- a string as u128 is a BN value as string natively used under the hood by the chain.
- a rounded data (ex: amoutRounded) is the "human" version of a data, (usually a BN) that can be directly used.
- some events from the utility pallet do not return any data.
-
- Summary: Some amount was withdrawn from the account
-
Datas returned:
- who: string as AccountId32
- amount: string as u128
- amountRounded: number
-
- Summary: Some amount was deposited.
-
Datas returned:
- who: string as AccountId32
- amount: string as u128
- amountRounded: number
-
- Summary: Transfer succeeded.
-
Datas returned:
- from: string as AccountId32
- to: string as AccountId32
- amount: string as u128
- amountRounded: number
-
- Summary: An account was created with some free balance
-
Datas returned:
- account: string as AccountId32
- to: string as AccountId32
- freeBalance: string as u128
- freeBalanceRounded: number
-
- Summary: Some funds have been deposited.
-
Datas returned:
- account: string as AccountId32
- to: string as AccountId32
- value: string as u128
- valueRounded: number
-
- Summary: An NFT has been created.
-
Datas 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
-
- Summary: An NFT has been burned.
-
Datas returned:
- nftId: number
-
- Summary: An NFT has been delegated.
-
Datas returned:
- nftId: number
- recipient: string as AccountId32 or null
-
- Summary: The NFT's royalty has been set.
-
Datas returned:
- nftId: number
- royalty: number
-
- Summary: An NFT has been transfered.
-
Datas returned:
- nftId: number
- sender: string as AccountId32
- recipient: string
-
- Summary: An NFT has been added to a collection.
-
Datas returned:
- nftId: number
- collectionId: number
-
- Summary: A Collection has been created.
-
Datas returned:
- collectionId: number
- owner: string as AccountId32
- offchainData: string
- limit: number or null
-
- Summary: The collection's limit has been set.
-
Datas returned:
- collectionId: number
- limit: number
-
- Summary: A collection has been closed.
-
Datas returned:
- collectionId: number
-
- Summary: A collection has been burned.
-
Datas returned:
- collectionId: number
-
- Summary: A marketplace has been created.
-
Datas returned:
- marketplaceId: number
- owner: string as AccountId32
- kind: the marketplace kind : Public or Private
-
- Summary: The marketplace owner has been set.
-
Datas returned:
- marketplaceId: number
- owner: string as AccountId32
-
- Summary: The marketplace kind has been set.
-
Datas returned:
- marketplaceId: number
- kind: the marketplace kind : Public or Private
-
- Summary: The marketplace configuration has been updated. Parameters can be unchanged (Noop), Removed or Set
-
Datas returned:
- marketplaceId: number
- commissionFeeType: optionnal string : Remove or Set
- commissionFee: optionnal string
- commissionFeeRounded: optionnal Number
- listingFeeType: optionnal string : Remove or Set
- listingFee: optionnal string
- listingFeeRounded: optionnal Number
- accountList: optionnal Array of strings as AccountId32
- offchainData: optionnal string
-
- Summary: The marketplace mint fee has been set.
-
Datas returned:
- fee: string
- feeRounded: number
-
- Summary: An NFT has been listed for sale on a marketplace.
-
Datas returned:
- nftId: number
- marketplaceId: number
- price: string
- priceRounded: number
- commissionFeeType: optionnal string : Percentage or Flat value
- commissionFee: optionnal string
- commissionFeeRounded: optionnal number
-
- Summary: An NFT has been unlisted from a marketplace.
-
Datas returned:
- nftId: number
-
- Summary: An NFT has sold.
-
Datas returned:
- nftId: number
- marketplaceId: number
- buyer: string
- listedPrice: string
- listedPriceRounded: number
- marketplaceCut: string
- marketplaceCutRounded: number
- royaltyCut: string
- royaltyCutRounded: number
-
- Summary: A single item within a Batch of dispatches has completed with no error.
-
Datas returned:
- This is an empty event : it does not return any specific event.
-
- Summary: Batch of dispatches did not complete fully. Index of first failing dispatch given, as well as the error.
-
Datas returned:
- index: number
- error: object
- module: object
- index: number
- error: string
- module: object
- errorType: optionnal string
- details: optionnal string
-
- Summary: Batch of dispatches completed fully with no error.
-
Datas returned:
- This is an empty event : it does not return any specific event.
-
- Summary: An extrinsic failed.
-
Datas returned:
- dispatchError: object
- module: object
- index: number
- error: string
- module: object
- errorType: optionnal string
- details: optionnal string
- dispatchInfo: object
- weigth: string
- class: string
- paysFee: string
- dispatchError: object
-
- Summary: An extrinsic completed successfully.
-
Datas returned:
- dispatchInfo: object
- weigth: string
- class: string
- paysFee: string
- dispatchInfo: object
-
- Summary: A new account was created.
-
Datas returned:
- account: string as AccountId32