setupfunction in the Buildo Begins example. Now, let's see the next steps.
TypedValueitems. Erdjs provides helper classes to keep strong typings for each type of argument. This is required to prepare the payload for the transactions correctly. So below, you will find an example.
BytesValue.fromUTF8. The initial supply is a
BigUIntValuefrom BigNumber. And the number of decimals is
U32Value. What's left? Right the properties. When issuing the token, you can set predefined ESDT token properties to true or false. You will find more info about them here: Configuration properties of an ESDT token. Ok, let's see how we can add them to the args array.
propertyis the property's name, and
propertyEnabledis a boolean, true for enabled and false for disabled. You can loop through all properties and push them to the args array. So, first the name, then the boolean flag, then the next property name and the boolean flag. Booleans as strings encoded to BytesValue.
argsvariable. Let's see what's next.
argsarray here, but we also need to pass the smart contract function to call. Here it is a built-in
issuefunction. Again you will find all the information about ESDT in the docs here: Issuance of fungible ESDT tokens.
datapayload, we are ready to construct the final form of the transaction to sign.
datais our previously created payload. Then we have the
payment. Also, our previously created payment instance. Remember? The 0.05 EGLD for issuance.
Dis for the devnet,
Tis for the testnet and
1is for the mainnet. We will use the
signerand network provider for signing and sending. All are also described at the beginning of the article. Remember? The
setupfunction from the Buildo Begins.
txhere. Check above.
provider, we also have the
accounthere, described at the beginning of the article - section 'Initialize Account'.
signer.signfunction, and we need to pass our final
providerto send a signed transaction. What it will do is it will use the previously defined API endpoint and send the transaction with all required data and signature.
TransactionWatcherfrom erdjs SDK.
providerhere to be able to listen for changes. We also use
tx- the instance of our transaction.
watcher.awaitCompleted(tx);will keep polling the network to check if any changes occurred related to this particular transaction. Then it will return the state of the transaction or throw an error.
1instead of the
npm install buildo-begins -g. Check the readme.md in the repository for more documentation on it.