diff --git a/docs/Welcome/01-ternoa-introduction.md b/docs/Welcome/01-ternoa-introduction.md new file mode 100644 index 0000000..f1dcf5a --- /dev/null +++ b/docs/Welcome/01-ternoa-introduction.md @@ -0,0 +1,19 @@ +--- +sidebar_label: "Ternoa introduction" +sidebar_position: 1 +--- + +# Teronoa Introduction + +Ternoa is the first NFT centric blockchain built with Substrate +To learn more please visit [Ternoa](https://www.ternoa.network/) + +## Key features + +- True ownership and Secret Content +- Combination and Fractionalization +- Delegating and Lending +- Auction and Royalties +- Mirroring and Interoperability + +Discover [ternoa ecosystem](https://www.ternoa.network/ecosystem) diff --git a/docs/Welcome/02-trusted-executed-environment.md b/docs/Welcome/02-trusted-executed-environment.md new file mode 100644 index 0000000..d65e7b5 --- /dev/null +++ b/docs/Welcome/02-trusted-executed-environment.md @@ -0,0 +1,10 @@ +--- +sidebar_label: "Trusted Executed Environment" +sidebar_position: 3 +--- + +# Trusted Executed Environment + +## TEE Architecture + +## Extrinsics diff --git a/docs/for-developers/cookbook/batch.md b/docs/for-developers/cookbook/batch.md index acf9bd2..469a3a2 100644 --- a/docs/for-developers/cookbook/batch.md +++ b/docs/for-developers/cookbook/batch.md @@ -19,7 +19,7 @@ In this example we are going to run the `batchAllTxHex` but because we want the ```js showLineNumbers export const nftsBatchMintingHex = async (nftMetadata, quantity) => { - // nftMetaData represents here the offChain datas of the NFT. + // nftMetaData represents here the offChain data of the NFT. // quantity is the number of NFT to be minted try{ ... diff --git a/docs/for-developers/cookbook/ipfs.md b/docs/for-developers/cookbook/ipfs.md index a03b733..d3979e0 100644 --- a/docs/for-developers/cookbook/ipfs.md +++ b/docs/for-developers/cookbook/ipfs.md @@ -10,7 +10,7 @@ created: 2022-12-09 ## Overview -IPFS (Interplanetary File Systems) is one of the solution we recommend to upload NFTs medias and other associated metadatas. Thus offchain datas are stored in a fully decentralized way and only the link to this metadata is stored on-chain as part of the NFT. This link is frequently a fingerprint called a cryptographic hash ID (e.g. `Qmf5RHhnUjSCfCN9d1Ee6sUWxe3Eqvogw1cTsssrxAxtPn`). IPFS files are accessible using those hashes. +IPFS (Interplanetary File Systems) is one of the solution we recommend to upload NFTs medias and other associated metadatas. Thus offchain data are stored in a fully decentralized way and only the link to this metadata is stored on-chain as part of the NFT. This link is frequently a fingerprint called a cryptographic hash ID (e.g. `Qmf5RHhnUjSCfCN9d1Ee6sUWxe3Eqvogw1cTsssrxAxtPn`). IPFS files are accessible using those hashes. On Ternoa NFTs are composed of two files: an asset file (e.g. image, video, music) and a metadata json file. The asset file hash is nested into the metadata file and both are stored on IPFS with their dedicated hashes. @@ -89,23 +89,27 @@ An IPFS client is available on ternoa-js SDK to make IPFS upload simple with onl Here is an example uploading an image "shining.jpg" from the movie: ```typescript -import { TernoaIPFS, File } from "ternoa-js" +import { TernoaIPFS, File } from "ternoa-js"; const main = async () => { - const file = new File([await fs.promises.readFile("shining.jpg")], "shining.jpg", { - type: "image/jpg", - }) + const file = new File( + [await fs.promises.readFile("shining.jpg")], + "shining.jpg", + { + type: "image/jpg", + } + ); - const ipfsClient = new TernoaIPFS(new URL("IPFS_NODE_URL"), "IPFS_API_KEY") + const ipfsClient = new TernoaIPFS(new URL("IPFS_NODE_URL"), "IPFS_API_KEY"); const nftMetadata = { title: "Shining, a nice movie", description: "This is (not) my first Ternoa's NFT", - } + }; - const { Hash } = await ipfsClient.storeNFT(file, nftMetadata) - console.log("The off-chain metadata hash is ", Hash) -} + const { Hash } = await ipfsClient.storeNFT(file, nftMetadata); + console.log("The off-chain metadata hash is ", Hash); +}; ``` First the JPG image file named "shining.jpg" is read from the file system and wrapped in a specific `File` instance. The TernoaIPFS class is then used to create an IPFS client that connects to a specified IPFS node using a given API key. The metadata for the file is then defined in an object and passed to the `storeNFT` method of the client along with the `File` instance. The resulting `Hash` of the off-chain metadata is logged to the console. diff --git a/docs/for-developers/good-practices.tmp b/docs/for-developers/good-practices.tmp index e3010b2..a762e1e 100644 --- a/docs/for-developers/good-practices.tmp +++ b/docs/for-developers/good-practices.tmp @@ -6,7 +6,7 @@ sidebar_label: Good practices # Good practices - init API -- Offchain datas - IPFS +- Offchain data - IPFS - on-chain, off-chain - keyring signing - no keyring, signer diff --git a/docs/for-developers/guides/NFT/basic-NFT/prepare-assets.md b/docs/for-developers/guides/NFT/basic-NFT/prepare-assets.md index 5fbc43a..91637a8 100644 --- a/docs/for-developers/guides/NFT/basic-NFT/prepare-assets.md +++ b/docs/for-developers/guides/NFT/basic-NFT/prepare-assets.md @@ -7,7 +7,7 @@ sidebar_label: How to prepare Basic NFT assets A Ternoa NFT is composed of two files: an asset file (e.g. image, video, music) and a metadata json file. The asset file CID is nested into the metadata file and both are stored on IPFS (Interplanetary File Systems) with their dedicated hashes. -IPFS (Interplanetary File Systems) is one of the solution we recommend to upload NFTs medias and other associated metadatas. Thus offchain datas are stored in a fully decentralized way and only the link to this metadata is stored on-chain as part of the NFT. This link is frequently a fingerprint called a cryptographic ID (e.g. `Qmf5RHhnUjSCfCN9d1Ee6sUWxe3Eqvogw1cTsssrxAxtPn`). IPFS files are accessible using those hashes. +IPFS (Interplanetary File Systems) is one of the solution we recommend to upload NFTs medias and other associated metadatas. Thus offchain data are stored in a fully decentralized way and only the link to this metadata is stored on-chain as part of the NFT. This link is frequently a fingerprint called a cryptographic ID (e.g. `Qmf5RHhnUjSCfCN9d1Ee6sUWxe3Eqvogw1cTsssrxAxtPn`). IPFS files are accessible using those hashes. Ternoa provides its own IPFS public nodes on different HTTP gateways based on the network environement: diff --git a/docs/for-developers/guides/NFT/soulbound-NFT/prepare-assets.md b/docs/for-developers/guides/NFT/soulbound-NFT/prepare-assets.md index e50dd2d..d41b556 100644 --- a/docs/for-developers/guides/NFT/soulbound-NFT/prepare-assets.md +++ b/docs/for-developers/guides/NFT/soulbound-NFT/prepare-assets.md @@ -15,7 +15,7 @@ The asset preparation for a Soulbound NFT is exactly the same as the one describ A Ternoa NFT is composed of two files: an asset file (e.g. image, video, music) and a metadata json file. The asset file CID is nested into the metadata file and both are stored on IPFS (Interplanetary File Systems) with their dedicated hashes. -IPFS (Interplanetary File Systems) is one of the solution we recommend to upload NFTs medias and other associated metadatas. Thus offchain datas are stored in a fully decentralized way and only the link to this metadata is stored on-chain as part of the NFT. This link is frequently a fingerprint called a cryptographic ID (e.g. `Qmf5RHhnUjSCfCN9d1Ee6sUWxe3Eqvogw1cTsssrxAxtPn`). IPFS files are accessible using those hashes. +IPFS (Interplanetary File Systems) is one of the solution we recommend to upload NFTs medias and other associated metadatas. Thus offchain data are stored in a fully decentralized way and only the link to this metadata is stored on-chain as part of the NFT. This link is frequently a fingerprint called a cryptographic ID (e.g. `Qmf5RHhnUjSCfCN9d1Ee6sUWxe3Eqvogw1cTsssrxAxtPn`). IPFS files are accessible using those hashes. Ternoa provides its own IPFS public nodes on different HTTP gateways based on the network environement: diff --git a/docs/for-developers/guides/collection/create-collection/prepare-assets.md b/docs/for-developers/guides/collection/create-collection/prepare-assets.md index dcdae94..b0864dd 100644 --- a/docs/for-developers/guides/collection/create-collection/prepare-assets.md +++ b/docs/for-developers/guides/collection/create-collection/prepare-assets.md @@ -7,7 +7,7 @@ sidebar_label: How to prepare Collection assets A Ternoa Collection is composed of three files: a profile picture image, a banner image and a metadata json file. The image files CID is nested into the metadata file and all are stored on IPFS (Interplanetary File Systems) with their dedicated hashes. -IPFS (Interplanetary File Systems) is one of the solution we recommend to upload NFTs medias and other associated metadatas. Thus offchain datas are stored in a fully decentralized way and only the link to this metadata is stored on-chain as part of the NFT. This link is frequently a fingerprint called a cryptographic ID (e.g. `Qmf5RHhnUjSCfCN9d1Ee6sUWxe3Eqvogw1cTsssrxAxtPn`). IPFS files are accessible using those hashes. +IPFS (Interplanetary File Systems) is one of the solution we recommend to upload NFTs medias and other associated metadatas. Thus offchain data are stored in a fully decentralized way and only the link to this metadata is stored on-chain as part of the NFT. This link is frequently a fingerprint called a cryptographic ID (e.g. `Qmf5RHhnUjSCfCN9d1Ee6sUWxe3Eqvogw1cTsssrxAxtPn`). IPFS files are accessible using those hashes. Ternoa provides its own IPFS public nodes on different HTTP gateways based on the network environement: diff --git a/docs/for-developers/sdk-references/indexer/Introduction.md b/docs/for-developers/sdk-references/indexer/Introduction.md index 70b5a87..0fe667e 100644 --- a/docs/for-developers/sdk-references/indexer/Introduction.md +++ b/docs/for-developers/sdk-references/indexer/Introduction.md @@ -4,11 +4,12 @@ sidebar_position: 1 # Introduction -The indexer is an Open, Flexible, Fast tool based on the **[SubQuery Framework](https://doc.subquery.network/).** It is used to transform blockchain data into a **graphql queryable database**. +The indexer is an Open, Flexible, Fast tool based on the **[SubQuery Framework](https://doc.subquery.network/).** It is used to transform blockchain data into a **graphql queryable database**. ### How it works: + The indexer scans through each block and their events to see what happened on the Ternoa Blockchain. It then parses all that data into entities and inserts it in a postgres DB. -Ternoa deploys its own indexer, and anybody can run his own. +Ternoa deploys its own indexer, and anybody can run his own. > You can get more information on the **[SubQuery official documentation](https://doc.subquery.network/faqs/faqs.html)** @@ -16,6 +17,6 @@ Ternoa deploys its own indexer, and anybody can run his own. ### The most important files are: -- Project.yaml: setup the endpoint, the genesis hash, the types file, and the different filter to get only the specific events / extrinsics needed. We can also filter on the success status of the event / extrinsic. (More details on the **[docs](https://doc.subquery.network/build/manifest/polkadot.html)**) -- Schema.graphql: specifies the custom data we need to record in our postgres db. -- The Mappings folder : Your mappingHandlers will handle the functions to transform the blockchain datas into the needed GraphQL entities contained in the Schema.graphql. More info [here](https://academy.subquery.network/build/mapping/polkadot.html) \ No newline at end of file +- Project.yaml: setup the endpoint, the genesis hash, the types file, and the different filter to get only the specific events / extrinsics needed. We can also filter on the success status of the event / extrinsic. (More details on the **[docs](https://doc.subquery.network/build/manifest/polkadot.html)**) +- Schema.graphql: specifies the custom data we need to record in our postgres db. +- The Mappings folder : Your mappingHandlers will handle the functions to transform the blockchain data into the needed GraphQL entities contained in the Schema.graphql. More info [here](https://academy.subquery.network/build/mapping/polkadot.html) diff --git a/docs/for-developers/sdk-references/indexer/_category_.json b/docs/for-developers/sdk-references/indexer/_category_.json index 1e41108..0bb7f9e 100644 --- a/docs/for-developers/sdk-references/indexer/_category_.json +++ b/docs/for-developers/sdk-references/indexer/_category_.json @@ -3,6 +3,6 @@ "position": 2, "link": { "type": "generated-index", - "description": "If you are looking for building a fast and performant dApp, this section is made for you. Let's explore our Indexer and get datas from the Ternoa blockchain." + "description": "If you are looking for building a fast and performant dApp, this section is made for you. Let's explore our Indexer and get data from the Ternoa blockchain." } } diff --git a/docs/for-developers/sdk-references/indexer/advanced/aggregation-plugin.md b/docs/for-developers/sdk-references/indexer/advanced/aggregation-plugin.md index 902feb2..2fb39b6 100644 --- a/docs/for-developers/sdk-references/indexer/advanced/aggregation-plugin.md +++ b/docs/for-developers/sdk-references/indexer/advanced/aggregation-plugin.md @@ -6,8 +6,8 @@ sidebar_position: 1 Some aggregation plugins are available to count some data. You can use them in simple queries. -If you look at the indexer playground docs and schema on the right panel, you can see some aggregate fields. -They allow to make some mathematical calculations for some specific datas. Let's keep the example to query some NFT filtered by a specific owner and calculate the total amount in CAPS for each listed NFT. +If you look at the indexer playground docs and schema on the right panel, you can see some aggregate fields. +They allow to make some mathematical calculations for some specific data. Let's keep the example to query some NFT filtered by a specific owner and calculate the total amount in CAPS for each listed NFT. ```graphql showLineNumbers query { @@ -34,7 +34,7 @@ query { } ``` -The expected outcome will be : +The expected outcome will be : ```graphql showLineNumbers ... @@ -48,11 +48,8 @@ aggregates: { > ![filterFields](./aggregate.png) - - - \ No newline at end of file +``` --> diff --git a/docs/for-developers/sdk-references/indexer/dictionary/index.md b/docs/for-developers/sdk-references/indexer/dictionary/index.md index 0194016..f475b11 100644 --- a/docs/for-developers/sdk-references/indexer/dictionary/index.md +++ b/docs/for-developers/sdk-references/indexer/dictionary/index.md @@ -7,10 +7,11 @@ sidebar_label: Overview Ternoa Dictionary records all the native substrate on-chain data of the Ternoa blockchain: blocks, extrinsics, and events. It is a glossary of data that pre-indexes chain events, drastically improving the overall indexing performance. Unlike the Indexer, no data relating to the Ternoa pallets is covered by the Dictionary. -If you already looked at our documentation, you should now [understand](/ternoa-wiki/offchain-components/builder-tools/dictionary) that the indexing datas provided by the chain can be retrieved both on our (**[alphanet indexer](https://indexer-alphanet.ternoa.dev/)** or **[mainnet indexer](https://indexer-mainnet.ternoa.network/)**), but also on our [dictionary](https://dictionary-mainnet.ternoa.dev/). +If you already looked at our documentation, you should now [understand](/ternoa-wiki/offchain-components/builder-tools/dictionary) that the indexing data provided by the chain can be retrieved both on our (**[alphanet indexer](https://indexer-alphanet.ternoa.dev/)** or **[mainnet indexer](https://indexer-mainnet.ternoa.network/)**), but also on our [dictionary](https://dictionary-mainnet.ternoa.dev/). + +Since the [Dictionary](/for-developers/#what-are-the-differences-between-the-dictionary-or-the-indexer) is focused on native substrate on-chain data contained in **blocks**, (instead of being focused on listening events like the indexer), you can use it for : -Since the [Dictionary](/for-developers/#what-are-the-differences-between-the-dictionary-or-the-indexer) is focused on native substrate on-chain data contained in **blocks**, (instead of being focused on listening events like the indexer), you can use it for : - [Installing](/for-developers/indexer/dictionary/use-dictionary) it into your own indexer as we do to improve performance. -- Use it as an to [query datas](http://localhost:3000/for-developers/indexer/dictionary/use-dictionnary-explorer) exactly like on the indexer +- Use it as an to [query data](http://localhost:3000/for-developers/indexer/dictionary/use-dictionnary-explorer) exactly like on the indexer -_If you want to know which tool suits you the best, look at the official [documentation](https://academy.subquery.network/academy/tutorials_examples/dictionary.html)._ +_If you want to know which tool suits you the best, look at the official [documentation](https://academy.subquery.network/academy/tutorials_examples/dictionary.html)._ diff --git a/docs/for-developers/sdk-references/indexer/getting-started/playground.md b/docs/for-developers/sdk-references/indexer/getting-started/playground.md index c9949a0..66e66d5 100644 --- a/docs/for-developers/sdk-references/indexer/getting-started/playground.md +++ b/docs/for-developers/sdk-references/indexer/getting-started/playground.md @@ -6,18 +6,16 @@ sidebar_position: 1 ## USE IT FROM PLAYGROUND -Depending on the datas you are looking for, you can directly query any data needed on: +Depending on the data you are looking for, you can directly query any data needed on: + - **[The Alphanet indexer](https://indexer-alphanet.ternoa.dev/)** - **[The Mainnet indexer](https://indexer-mainnet.ternoa.network/)** -#### You just need to create the graphql request, for example, a simple request to get the 10 last listed nft: +#### You just need to create the graphql request, for example, a simple request to get the 10 last listed nft: + ```graphql { - nftEntities( - first: 10, - offset: 0, - orderBy: TIMESTAMP_LIST_DESC - ) { + nftEntities(first: 10, offset: 0, orderBy: TIMESTAMP_LIST_DESC) { totalCount nodes { nftId @@ -29,10 +27,13 @@ Depending on the datas you are looking for, you can directly query any data need } } ``` + #### Same example in the playground: + ![exemple](./playground-example.png) #### You can access the hole schema in the right panel of the playground: + ![playgroundPanel](./playground-schema.png) -Or directly in our **[repository](https://github.com/capsule-corp-ternoa/ternoa-subql/blob/main/schema.graphql)**. \ No newline at end of file +Or directly in our **[repository](https://github.com/capsule-corp-ternoa/ternoa-subql/blob/main/schema.graphql)**. diff --git a/docs/for-developers/sdk-references/ternoa-js/events.md b/docs/for-developers/sdk-references/ternoa-js/events.md index 7abfd07..aff84ea 100644 --- a/docs/for-developers/sdk-references/ternoa-js/events.md +++ b/docs/for-developers/sdk-references/ternoa-js/events.md @@ -4,291 +4,315 @@ sidebar_position: 4 # Events -___ +--- ## Overview: What are chain 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 example to filter only the events list of a balance transfer transaction :* +**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 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 example to filter only the events list of a balance transfer transaction :_ ```javascript -const balanceTransfertEvents = BlockchainEvents.findEvents(BalancesTransferEvent) +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 feature 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.* +**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 feature 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: -## About the Event Design Format: -To make the returned events data usefull, we provide both the native format and a friendly ready to use format: -- a string as an AccountId32 correspond to a classic user valid address. +To make the returned events data usefull, we provide both the native format and a friendly ready to use format: + +- a string as an AccountId32 correspond 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. -- a rounded data (ex: amoutRounded) is the "human" version of a data, (usually a BN) that can be directly used. +- 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. -___ +--- -## The events below are the Events handled in the Ternoa SDK sorted by categories -* [Balances](https://github.com/capsule-corp-ternoa/ternoa-js/wiki/4-Events#balances) -* [Treasury](https://github.com/capsule-corp-ternoa/ternoa-js/wiki/4-Events#treasury) -* [NFT](https://github.com/capsule-corp-ternoa/ternoa-js/wiki/4-Events#nft) -* [Collection](https://github.com/capsule-corp-ternoa/ternoa-js/wiki/4-Events#collection) -* [Marketplace](https://github.com/capsule-corp-ternoa/ternoa-js/wiki/4-Events#marketplace) -* [Utility](https://github.com/capsule-corp-ternoa/ternoa-js/wiki/4-Events#utility) -* [System](https://github.com/capsule-corp-ternoa/ternoa-js/wiki/4-Events#system) +## The events below are the Events handled in the Ternoa SDK sorted by categories -___ +- [Balances](https://github.com/capsule-corp-ternoa/ternoa-js/wiki/4-Events#balances) +- [Treasury](https://github.com/capsule-corp-ternoa/ternoa-js/wiki/4-Events#treasury) +- [NFT](https://github.com/capsule-corp-ternoa/ternoa-js/wiki/4-Events#nft) +- [Collection](https://github.com/capsule-corp-ternoa/ternoa-js/wiki/4-Events#collection) +- [Marketplace](https://github.com/capsule-corp-ternoa/ternoa-js/wiki/4-Events#marketplace) +- [Utility](https://github.com/capsule-corp-ternoa/ternoa-js/wiki/4-Events#utility) +- [System](https://github.com/capsule-corp-ternoa/ternoa-js/wiki/4-Events#system) + +--- ## Balances -- ### BalancesWithdrawEvent - - **Summary:** Some amount was withdrawn from the account - - **Datas returned:** - - who: *string as AccountId32* - - amount: *string as u128* - - amountRounded: *number* - -- ### BalancesDepositEvent - - **Summary:** Some amount was deposited. - - **Datas returned:** - - who: *string as AccountId32* - - amount: *string as u128* - - amountRounded: *number* - -- ### BalancesTransferEvent - - **Summary:** Transfer succeeded. - - **Datas returned:** - - from: *string as AccountId32* - - to: *string as AccountId32* - - amount: *string as u128* - - amountRounded: *number* + +- ### BalancesWithdrawEvent + + - **Summary:** Some amount was withdrawn from the account + - **Datas returned:** + - who: _string as AccountId32_ + - amount: _string as u128_ + - amountRounded: _number_ + +- ### BalancesDepositEvent + + - **Summary:** Some amount was deposited. + - **Datas returned:** + - who: _string as AccountId32_ + - amount: _string as u128_ + - amountRounded: _number_ + +- ### BalancesTransferEvent + + - **Summary:** Transfer succeeded. + - **Datas 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 - - **Datas returned:** - - account: *string as AccountId32* - - to: *string as AccountId32* - - freeBalance: *string as u128* - - freeBalanceRounded: *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_ [Back to top](https://github.com/capsule-corp-ternoa/ternoa-js/wiki/4-Events) -___ + +--- ## Treasury + - ### TreasuryDepositEvent - - **Summary:** Some funds have been deposited. - - **Datas returned:** - - account: *string as AccountId32* - - to: *string as AccountId32* - - value: *string as u128* - - valueRounded: *number* + - **Summary:** Some funds have been deposited. + - **Datas returned:** - account: _string as AccountId32_ + - to: _string as AccountId32_ + - value: _string as u128_ + - valueRounded: _number_ [Back to top](https://github.com/capsule-corp-ternoa/ternoa-js/wiki/4-Events) -___ +--- ## NFT - - ### NFTCreatedEvent - - **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* - - - ### NFTBurnedEvent - - **Summary:** An NFT has been burned. - - **Datas returned:** - - nftId: *number* - - - ### NFTDelegatedEvent - - **Summary:** An NFT has been delegated. - - **Datas returned:** - - nftId: *number* - - recipient: *string as AccountId32 or null* - - - ### NFTRoyaltySetEvent - - **Summary:** The NFT's royalty has been set. - - **Datas returned:** - - nftId: *number* - - royalty: *number* - - - ### NFTTransferredEvent - - **Summary:** An NFT has been transferred. - - **Datas returned:** - - nftId: *number* - - sender: *string as AccountId32* - - recipient: *string* - - - ### NFTAddedToCollection - - **Summary:** An NFT has been added to a collection. - - **Datas returned:** - - nftId: *number* - - collectionId: *number* - + +- ### NFTCreatedEvent + + - **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_ + +- ### NFTBurnedEvent + + - **Summary:** An NFT has been burned. + - **Datas returned:** + - nftId: _number_ + +- ### NFTDelegatedEvent + + - **Summary:** An NFT has been delegated. + - **Datas returned:** + - nftId: _number_ + - recipient: _string as AccountId32 or null_ + +- ### NFTRoyaltySetEvent + + - **Summary:** The NFT's royalty has been set. + - **Datas returned:** + - nftId: _number_ + - royalty: _number_ + +- ### NFTTransferredEvent + + - **Summary:** An NFT has been transferred. + - **Datas returned:** + - nftId: _number_ + - sender: _string as AccountId32_ + - recipient: _string_ + +- ### NFTAddedToCollection + - **Summary:** An NFT has been added to a collection. + - **Datas returned:** + - nftId: _number_ + - collectionId: _number_ + [Back to top](https://github.com/capsule-corp-ternoa/ternoa-js/wiki/4-Events) -___ +--- ## Collection - - ### CollectionCreatedEvent - - **Summary:** A Collection has been created. - - **Datas returned:** - - collectionId: *number* - - owner: *string as AccountId32* - - offchainData: *string* - - limit: *number or null* - - - ### CollectionLimitedEvent - - **Summary:** The collection's limit has been set. - - **Datas returned:** - - collectionId: *number* - - limit: *number* - - - ### CollectionClosedEvent - - **Summary:** A collection has been closed. - - **Datas returned:** - - collectionId: *number* + +- ### CollectionCreatedEvent + + - **Summary:** A Collection has been created. + - **Datas returned:** + - collectionId: _number_ + - owner: _string as AccountId32_ + - offchainData: _string_ + - limit: _number or null_ + +- ### CollectionLimitedEvent + + - **Summary:** The collection's limit has been set. + - **Datas returned:** + - collectionId: _number_ + - limit: _number_ + +- ### CollectionClosedEvent + + - **Summary:** A collection has been closed. + - **Datas returned:** + - collectionId: _number_ - ### CollectionBurnedEvent - - **Summary:** A collection has been burned. - - **Datas returned:** - - collectionId: *number* + - **Summary:** A collection has been burned. + - **Datas returned:** - collectionId: _number_ [Back to top](https://github.com/capsule-corp-ternoa/ternoa-js/wiki/4-Events) -___ +--- ## Marketplace - - ### MarketplaceCreatedEvent - - **Summary:** A marketplace has been created. - - **Datas returned:** - - marketplaceId: *number* - - owner: *string as AccountId32* - - kind: *the marketplace kind : Public or Private* - - - ### MarketplaceOwnerSetEvent - - **Summary:** The marketplace owner has been set. - - **Datas returned:** - - marketplaceId: *number* - - owner: *string as AccountId32* - - - ### MarketplaceKindSetEvent - - **Summary:** The marketplace kind has been set. - - **Datas 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 - - **Datas 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. - - **Datas returned:** - - fee: *string* - - feeRounded: *number* - - - ### NFTListedEvent - - **Summary:** An NFT has been listed for sale on a marketplace. - - **Datas 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. - - **Datas returned:** - - nftId: *number* - - - ### NFTSoldEvent - - **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* + +- ### MarketplaceCreatedEvent + + - **Summary:** A marketplace has been created. + - **Datas returned:** + - marketplaceId: _number_ + - owner: _string as AccountId32_ + - kind: _the marketplace kind : Public or Private_ + +- ### MarketplaceOwnerSetEvent + + - **Summary:** The marketplace owner has been set. + - **Datas returned:** + - marketplaceId: _number_ + - owner: _string as AccountId32_ + +- ### MarketplaceKindSetEvent + + - **Summary:** The marketplace kind has been set. + - **Datas 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 + - **Datas 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. + - **Datas returned:** + - fee: _string_ + - feeRounded: _number_ + +- ### NFTListedEvent + + - **Summary:** An NFT has been listed for sale on a marketplace. + - **Datas 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. + - **Datas returned:** + - nftId: _number_ + +- ### NFTSoldEvent + - **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_ [Back to top](https://github.com/capsule-corp-ternoa/ternoa-js/wiki/4-Events) -___ +--- ## Utility + - ### ItemCompletedEvent - - **Summary:** A single item within a Batch of dispatches has been completed with no error. - - **Datas returned:** - - This is an empty event : it does not return any specific event. + + - **Summary:** A single item within a Batch of dispatches has been completed with no error. + - **Datas 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. - - **Datas returned:** - - index: *number* - - error: *object* - - module: *object* - - index: *number* - - error: *string* - - errorType: *optional string* - - details: *optional string* - -- ### BatchCompletedEvent - - **Summary:** Batch of dispatches completed fully 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_ + - errorType: _optional string_ + - details: _optional string_ + +- ### BatchCompletedEvent + - **Summary:** Batch of dispatches completed fully with no error. + - **Datas returned:** - This is an empty event : it does not return any specific event. [Back to top](https://github.com/capsule-corp-ternoa/ternoa-js/wiki/Events) -___ +--- ## System -- ### ExtrinsicFailedEvent - - **Summary:** An extrinsic failed. - - **Datas returned:** - - dispatchError: *object* - - module: *object* - - index: *number* - - error: *string* - - errorType: *optional string* - - details: *optional string* - - dispatchInfo: *object* - - weigth: *string* - - class: *string* - - paysFee: *string* + +- ### ExtrinsicFailedEvent + + - **Summary:** An extrinsic failed. + - **Datas returned:** + - dispatchError: _object_ + - module: _object_ + - index: _number_ + - error: _string_ + - errorType: _optional string_ + - details: _optional string_ + - dispatchInfo: _object_ + - weigth: _string_ + - class: _string_ + - paysFee: _string_ - ### ExtrinsicSuccessEvent - - **Summary:** An extrinsic completed successfully. - - **Datas returned:** - - dispatchInfo: *object* - - weigth: *string* - - class: *string* - - paysFee: *string* -- ### NewAccountEvent - - **Summary:** A new account was created. - - **Datas returned:** - - account: *string as AccountId32* + - **Summary:** An extrinsic completed successfully. + - **Datas returned:** - dispatchInfo: _object_ - weigth: _string_ - class: _string_ - paysFee: _string_ +- ### NewAccountEvent + - **Summary:** A new account was created. + - **Datas returned:** - account: _string as AccountId32_ -[Back to top](https://github.com/capsule-corp-ternoa/ternoa-js/wiki/4-Events) \ No newline at end of file +[Back to top](https://github.com/capsule-corp-ternoa/ternoa-js/wiki/4-Events) diff --git a/docs/for-developers/sdk-references/ternoa-js/introduction.md b/docs/for-developers/sdk-references/ternoa-js/introduction.md index 71bf390..b4808b6 100644 --- a/docs/for-developers/sdk-references/ternoa-js/introduction.md +++ b/docs/for-developers/sdk-references/ternoa-js/introduction.md @@ -4,15 +4,15 @@ sidebar_position: 1 # Introduction -___ +--- -## Overview ⚙️ +## Overview ⚙️ Welcome to the Ternoa-js developer documentation. Ternoa-js main objective is to be: **one of the most user-friendly tools to build web3 projects** on top of the Ternoa Chain. Based on Polkadot{.js} API and Javascript, it offers developers the ability to query and interact with substrate chains like the Ternoa chain. It provides a seamless experience and allows you to start building at a glance: an extra short init and just a few lines of code, and your first NFT will be live on the chain. ### Forward Together -Ternoa-js is an open-source project. Feel free to interact and move forward with us. If you have questions about anything related to Ternoa, need help, or want to request features, you can open a discussion on our [GitHub Discussions]([https://github.com/capsule-corp-ternoa/ternoa-js/discussions](https://github.com/capsule-corp-ternoa/ternoa-js/discussions)) And if you find an issue, lets us know in our [GitHub Issues]([https://github.com/capsule-corp-ternoa/ternoa-js/issues](https://github.com/capsule-corp-ternoa/ternoa-js/issues)) section. +Ternoa-js is an open-source project. Feel free to interact and move forward with us. If you have questions about anything related to Ternoa, need help, or want to request features, you can open a discussion on our [GitHub Discussions](<[https://github.com/capsule-corp-ternoa/ternoa-js/discussions](https://github.com/capsule-corp-ternoa/ternoa-js/discussions)>) And if you find an issue, lets us know in our [GitHub Issues](<[https://github.com/capsule-corp-ternoa/ternoa-js/issues](https://github.com/capsule-corp-ternoa/ternoa-js/issues)>) section. ## API Architecture @@ -20,25 +20,25 @@ Ternoa SDK handles the main features proposed by the Ternoa chain. It allows you ### The main handlers are the ones below: -- [blockchain](https://github.com/capsule-corp-ternoa/ternoa-js/tree/main/src/blockchain): the CORE blockchain function. The API brain to randomly: init the API, execute transactions, query datas, batch transactions, etc. -- [account](https://github.com/capsule-corp-ternoa/ternoa-js/blob/main/src/account/): the functions that allows you to generate a new seed and a keyring -- [balance](https://github.com/capsule-corp-ternoa/ternoa-js/tree/main/src/balance): the Balance pallet with its extrinsics, query and storage. -- [nft](https://github.com/capsule-corp-ternoa/ternoa-js/tree/main/src/nft): the NFT pallet with its extrinsics, query and storage. -- [marketplace](https://github.com/capsule-corp-ternoa/ternoa-js/tree/main/src/nft): the Marketplace pallet with its extrinsics, query and storage. -- [events](https://github.com/capsule-corp-ternoa/ternoa-js/blob/main/src/events.ts): the events list returned when `submitTxBlocking` function is triggered +- [blockchain](https://github.com/capsule-corp-ternoa/ternoa-js/tree/main/src/blockchain): the CORE blockchain function. The API brain to randomly: init the API, execute transactions, query data, batch transactions, etc. +- [account](https://github.com/capsule-corp-ternoa/ternoa-js/blob/main/src/account/): the functions that allows you to generate a new seed and a keyring +- [balance](https://github.com/capsule-corp-ternoa/ternoa-js/tree/main/src/balance): the Balance pallet with its extrinsics, query and storage. +- [nft](https://github.com/capsule-corp-ternoa/ternoa-js/tree/main/src/nft): the NFT pallet with its extrinsics, query and storage. +- [marketplace](https://github.com/capsule-corp-ternoa/ternoa-js/tree/main/src/nft): the Marketplace pallet with its extrinsics, query and storage. +- [events](https://github.com/capsule-corp-ternoa/ternoa-js/blob/main/src/events.ts): the events list returned when `submitTxBlocking` function is triggered ### Handlers Architecture For those familiar with Polkadot, you will quickly recognize the design structure of the features. If you don't know yet, no worries, the basic principles are easy to understand. Depending on the pallet or handler category, you will retrieve the following: -- _**Constants**_ to request the chain runtime. -- _**Storage**_ to query the chain state. -- _**Extrinsics**_ to execute the transactions. -- _Utils_ when available provides some additional usefull functions you can directly import in your project. +- _**Constants**_ to request the chain runtime. +- _**Storage**_ to query the chain state. +- _**Extrinsics**_ to execute the transactions. +- _Utils_ when available provides some additional usefull functions you can directly import in your project. ### Response Format -As it makes sense for us to provide the most accessible tools to build on the Ternoa chain, **we also tried to simplify the response format of our functions whenever we could**. Depending if you want to get things done for you or if you go with the fully customizable way and handle your callback, we invite you to choose the correct function: _Events and features datas will be provided directly on some function while only transaction hash hex will be returned on others._ We will cover this topic later in the doc. +As it makes sense for us to provide the most accessible tools to build on the Ternoa chain, **we also tried to simplify the response format of our functions whenever we could**. Depending if you want to get things done for you or if you go with the fully customizable way and handle your callback, we invite you to choose the correct function: _Events and features data will be provided directly on some function while only transaction hash hex will be returned on others._ We will cover this topic later in the doc. ## Ready to discover more? diff --git a/docs/for-developers/sdk-references/ternoa-js/sdk-workflows.md b/docs/for-developers/sdk-references/ternoa-js/sdk-workflows.md index 9a2b039..824d67c 100644 --- a/docs/for-developers/sdk-references/ternoa-js/sdk-workflows.md +++ b/docs/for-developers/sdk-references/ternoa-js/sdk-workflows.md @@ -4,17 +4,17 @@ sidebar_position: 3 # SDK Workflows 🏁 -This section will go through the main workflow process to execute a transaction. -In just a few steps, you will be able to init the Ternoa SDK API and start using it. +This section will go through the main workflow process to execute a transaction. +In just a few steps, you will be able to init the Ternoa SDK API and start using it. -___ +--- ## INIT THE API It's optional, but it's good practice to initialize the API as soon as possible. If this call is omitted, the first SDK call will return an exception. The default chain endpoint is: `DEFAULT_CHAIN_ENDPOINT = "wss://alphanet.ternoa.com"`. It can be modified by passing a new endpoint as the first argument to the _initializeApi()_ function. - -``` js showLineNumbers + +```js showLineNumbers // Import import { initializeApi } from "ternoa-js" @@ -32,7 +32,7 @@ async function main() { Simply pass the required endpoint to the _initializeApi()_ function. -``` js showLineNumbers +```js showLineNumbers ... //endpoint here will make the init API on the Ternoa mainnet network await initializeApi('wss://mainnet.ternoa.io'); @@ -45,7 +45,7 @@ Simply pass the required endpoint to the _initializeApi()_ function. **Note:** Ternoa SDK provides **a very useful** `getRawApi()` function to interact with the API. If the API is connected, it will be directly returned -``` js showLineNumbers +```js showLineNumbers ... //we assume that API has been initiated before const api = await getRawApi() @@ -57,22 +57,22 @@ Simply pass the required endpoint to the _initializeApi()_ function. } ``` -___ +--- ## Let's Create! -Now that we know how to init our SDK API, let's get into a feature example. The Ternoa-js provides _the most friendly way to build_ on the chain and execute a transaction. Let's go into detail and see an example of **how to create an NFT**. +Now that we know how to init our SDK API, let's get into a feature example. The Ternoa-js provides _the most friendly way to build_ on the chain and execute a transaction. Let's go into detail and see an example of **how to create an NFT**. ## The most automated and easiest way -For most of the main chain features (we consider here our extrinsics) the SDK provides two functions. One of these is an all-in-one function that allows going to the entire transaction workflow process: It **Creates** a tx, **Signs** the tx and **Submits** the tx for you in a single line function. +For most of the main chain features (we consider here our extrinsics) the SDK provides two functions. One of these is an all-in-one function that allows going to the entire transaction workflow process: It **Creates** a tx, **Signs** the tx and **Submits** the tx for you in a single line function. **_Going back to the NFT creation example:_** -This single line `createNft()` function, requires a few parameters: some offchainData metadatas*, a royalty, a collectionId if you want this NFT to belong to a collection, a boolean to define its isSoulbound status, the keyring that will be used to sign and submit the transaction, and a waitUntil callback parameter, to define at which point we want to get the results of the transaction execution. +This single line `createNft()` function, requires a few parameters: some offchainData metadatas\*, a royalty, a collectionId if you want this NFT to belong to a collection, a boolean to define its isSoulbound status, the keyring that will be used to sign and submit the transaction, and a waitUntil callback parameter, to define at which point we want to get the results of the transaction execution. -_*In most cases this will be an IPFS hash that points to a JSON file which contains fields as "name", "description" or "image". In other cases this can be a link to a either a static or a dynamic file, plain text or a small JSON string._ In the example below, we just pass a string. +_\*In most cases this will be an IPFS hash that points to a JSON file which contains fields as "name", "description" or "image". In other cases this can be a link to a either a static or a dynamic file, plain text or a small JSON string._ In the example below, we just pass a string. -``` js showLineNumbers +```js showLineNumbers // Imports import { initializeApi } from "ternoa-js" import { createNft } from "ternoa-js/nft" @@ -82,7 +82,7 @@ const createMyFirstNFT = async () => { // We initialize the API instance await initializeApi() - ... //we assume your keyring is already created and provided with CAPS to support transactions fees. + ... //we assume your keyring is already created and provided with CAPS to support transactions fees. // Here we create, sign and submit the NFT transaction with your keyring const newNFT = await createNft("My first NFT", 10, undefined, false, keyring, WaitUntil.BlockInclusion) @@ -99,16 +99,15 @@ const createMyFirstNFT = async () => { ## The versatile but more complex way -Now we have seen the most friendly way to create an NFT in a signle line, with the automation of the workflow (**Create => Sign => Send**), we can dig a bit more. For some reason, **_you will need to go manually into the whole process_**. This way is more complex, but offers more versatilty: ex if you split the process and execute it by yourself, _you will be able for example to make a batch of transactions_ (this concept is covered in the [example](#) section) instead of doing it one by one. It's very useful if you want to create a large amount of NFT and avoid to sign and send them one by one. +Now we have seen the most friendly way to create an NFT in a signle line, with the automation of the workflow (**Create => Sign => Send**), we can dig a bit more. For some reason, **_you will need to go manually into the whole process_**. This way is more complex, but offers more versatilty: ex if you split the process and execute it by yourself, _you will be able for example to make a batch of transactions_ (this concept is covered in the [example](#) section) instead of doing it one by one. It's very useful if you want to create a large amount of NFT and avoid to sign and send them one by one. -Let's go into the detail of each step to create an NFT manually. +Let's go into the detail of each step to create an NFT manually. -### STEP 1 - Create an NFT transaction +### STEP 1 - Create an NFT transaction First, instead of using the `createNft()` function, you will use the `createNftTx()`. And instead of creating, signing and submitting the transaction and getting the returned events, it will create an unsigned and unsubmitted Create-NFT **Transaction Hash** ready to be used and valid for 5 minutes. - -``` js showLineNumbers +```js showLineNumbers // Imports import { initializeApi } from "ternoa-js" import { createNftTx } from "ternoa-js/nft" @@ -129,13 +128,11 @@ const create createNFTManually = async () => { } ``` - ### STEP 2 - Sign a transaction hash -Now we have the txHash, and we can move to the signing step. But before detailing it, it's good to know that _"signing"_ can be directly embedded in the submit function. It means that depending on the submit function you are using (see the last step [below](#)), _signing your tx hash before submitting might not be necessary_. In case you sign manually the tx hash, you will receive a hex value of the signed transaction ready to be sent. The `signTxHex()` function expect **a keyring** that will sign the transaction and the **transaction hash to be signed**. - +Now we have the txHash, and we can move to the signing step. But before detailing it, it's good to know that _"signing"_ can be directly embedded in the submit function. It means that depending on the submit function you are using (see the last step [below](#)), _signing your tx hash before submitting might not be necessary_. In case you sign manually the tx hash, you will receive a hex value of the signed transaction ready to be sent. The `signTxHex()` function expect **a keyring** that will sign the transaction and the **transaction hash to be signed**. -``` js showLineNumbers +```js showLineNumbers const create createNFTManually = async () => { try { ... @@ -143,7 +140,7 @@ const create createNFTManually = async () => { // STEP 2 : Here we sign the transaction hash. nftTxHash is the name of the tx hash from the function we created before. const signTxHash = await signTxHex(keyring, nftTxHash) - // Do something with the hex value. + // Do something with the hex value. console.log(signTxHash); ... } catch (e) { @@ -154,21 +151,21 @@ const create createNFTManually = async () => { ### STEP 3 - Submit a transaction -Submitting a transaction is generally the last step of the transaction execution process. Ternoa-js provide up to 3 ways to submit a transaction. From the raw and native way to the fully handled and most easy to use. Depending of the result format you are expecting and the specific case you want to handle (simply submit, batching some transaction (...)) you will need to go with **one of the following functions** : +Submitting a transaction is generally the last step of the transaction execution process. Ternoa-js provide up to 3 ways to submit a transaction. From the raw and native way to the fully handled and most easy to use. Depending of the result format you are expecting and the specific case you want to handle (simply submit, batching some transaction (...)) you will need to go with **one of the following functions** : -* `submitTxHex()` - The most versatile and customizable way to submit your txHash. You can manage the callback function yourself. It obvioulsy requires the hex value to be submitted, but also an optionnal callback. This function requires the transaction hash to be signed before being sent. +- `submitTxHex()` - The most versatile and customizable way to submit your txHash. You can manage the callback function yourself. It obvioulsy requires the hex value to be submitted, but also an optionnal callback. This function requires the transaction hash to be signed before being sent. -``` js showLineNumbers +```js showLineNumbers const create createNFTManually = async () => { try { ... - // STEP 3.1 : Here we submit the transaction hex value. + // STEP 3.1 : Here we submit the transaction hex value. // Here no callback function is used but the second parameter can be a callback function that help you to handle the result. // Once again, we use here the tx hex signedTxHash, from the previous step. const submitTxHash = await submitTxHex(signTxHash) - // Do something with the final tx hash. + // Do something with the final tx hash. console.log(submitTxHash); ... } catch (e) { @@ -177,22 +174,21 @@ const create createNFTManually = async () => { } ``` -* `submitTxBlocking()` - The most convenient way to get [Events](https://github.com/capsule-corp-ternoa/ternoa-js/wiki/Events) and datas: This function will sign the transaction for you if you pass a keyring (one less thing to worry about) and it's blocking the execution flow until the transaction is either in a block or in a finalized block. Since submitting needs to work with all kinds of transactions, the result is an object that contains all the events that have happened (instead of only specific ones). +- `submitTxBlocking()` - The most convenient way to get [Events](https://github.com/capsule-corp-ternoa/ternoa-js/wiki/Events) and data: This function will sign the transaction for you if you pass a keyring (one less thing to worry about) and it's blocking the execution flow until the transaction is either in a block or in a finalized block. Since submitting needs to work with all kinds of transactions, the result is an object that contains all the events that have happened (instead of only specific ones). -Note: Here you do not need to necessarily pass a signed txHash. If you pass the Keyring as a parameter and an unsigned tx hash as the signing process will be done here for you. +Note: Here you do not need to necessarily pass a signed txHash. If you pass the Keyring as a parameter and an unsigned tx hash as the signing process will be done here for you. - -``` js showLineNumbers +```js showLineNumbers const create createNFTManually = async () => { try { ... - // STEP 3.2 : Here we submit the transaction hex value signed before. + // STEP 3.2 : Here we submit the transaction hex value signed before. // We could have used the unsigned tx Hash and pass a keyring as a third parameter instead. // Once again, we use the tx hex signTxHash, from the previous step. const submitTxHash = await submitTxBlocking(signTxHash, WaitUntil.BlockInclusion) - // Do something with the events received. + // Do something with the events received. console.log(submitTxHash.findEvents(NFTCreatedEvent)); ... } catch (e) { @@ -201,21 +197,20 @@ const create createNFTManually = async () => { } ``` -* `submitTxNonBlocking()`: This one works as the `submitTxBlocking` but in a nonblocking way. It returns a pair of objects that are used to track the progress of the transaction execution. The first returned object is a conditional variable that can yield the information if the operation is finished. The second returned objects is an array of events that gets populated automatically once the operation is finished. - +- `submitTxNonBlocking()`: This one works as the `submitTxBlocking` but in a nonblocking way. It returns a pair of objects that are used to track the progress of the transaction execution. The first returned object is a conditional variable that can yield the information if the operation is finished. The second returned objects is an array of events that gets populated automatically once the operation is finished. -``` js showLineNumbers +```js showLineNumbers const create createNFTManually = async () => { try { ... // STEP 3.3 : It get the same parameters as the submitTxBlocking - // Here we submit the transaction hex value signed before. + // Here we submit the transaction hex value signed before. // We could have used the unsigned tx Hash and pass a keyring as a third parameter instead. // Once again, we use the tx hex signTxHash, from the previous step 2. const submitTxHash = await submitTxNonBlocking(signTxHash, WaitUntil.BlockInclusion) - // Do something with the events received. + // Do something with the events received. console.log(submitTxHash); ... } catch (e) {