This shows you the differences between two versions of the page.
fob:laboratoare:04 [2022/10/09 12:48] costin.carabas |
fob:laboratoare:04 [2022/11/10 21:22] (current) costin.carabas |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ===== Practical Session 04. ===== | + | ===== Fungible Tokens ===== |
+ | __Fungible vs Non-Fungible Tokens:__ | ||
+ | * Fungibility refers to an asset's ability to be exchanged for something else of equal value; | ||
+ | * Some examples of fungible assets include currencies, commodities, and precious stones; | ||
+ | * Non-fungible assets are unique, requiring much more complex valuation before a sale and include things like real estate, art, and sports cards. | ||
+ | |||
+ | Think about the following example if fungible or non-fungible: | ||
+ | * Diamond rock; | ||
+ | * Penthouse apartment in Manhattan; | ||
+ | * Mona Lisa painting; | ||
+ | * LeBron James sport card; | ||
+ | * LeBron James shirt he played in the 2020 NBA Finals; | ||
+ | * A character in World of Warcraft. | ||
+ | |||
+ | ==== ESDT Tokens ==== | ||
+ | |||
+ | **ESDT** stands for //Elrond Standard Digital Token//. | ||
+ | |||
+ | Custom tokens at native speed and scalability, like EGLD. | ||
+ | |||
+ | The Elrond network natively supports the issuance of custom tokens, without the need for contracts such as ERC20 (Ethereum), but addressing the same use-cases. And due to the native in-protocol support, transactions with custom tokens do not require the VM at all. In effect, this means that custom tokens are as fast and as scalable as the native EGLD token itself. | ||
+ | |||
+ | The balances of ESDT tokens held by an Account are stored directly under the data trie of that Account. It also implies that an Account can hold balances of any number of custom tokens, in addition to the native EGLD balance. The protocol guarantees that no Account can modify the storage of ESDT tokens, neither its own nor of other Accounts. | ||
+ | |||
+ | ESDT tokens can be issued, owned and held by any Account on the Elrond network, which means that both users and smart contracts have the same functionality available to them. Due to the design of ESDT tokens, smart contracts can manage tokens with ease, and they can even react to an ESDT transfer. | ||
+ | |||
+ | === Issuance of fungible ESDT tokens === | ||
+ | |||
+ | ESDT tokens are issued via a request to the Metachain, which is a transaction submitted by the Account which will manage the tokens. When issuing a token, one must provide a token name, a ticker, the initial supply, the number of decimals for display purpose and optionally additional properties. | ||
+ | The issuance cost is set to 0.05 EGLD. | ||
+ | |||
+ | The receiver address ''erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqzllls8a5w6u'' is a built-in system smart contract (not a VM-executable contract), which only handles token issuance and other token management operations, and does not handle any transfers. The contract will add a random string to the ticker thus creating the **token identifier**. The random string starts with “-” and has 6 more random characters (3 bytes - 6 characters hex encoded). For example, a token identifier could look like //ALC-6258d2//. | ||
+ | |||
+ | If you want to make an ''erdpy'' transaction use the info from [[https://docs.elrond.com/tokens/esdt-tokens/#parameters-format | Elrond documentation]] to correctly format your parameters. | ||
+ | |||
+ | <note tip> | ||
+ | You can find more details [[https://docs.elrond.com/tokens/esdt-tokens/|here]]. | ||
+ | </note> | ||
+ | Issuance example: | ||
+ | |||
+ | <code bash> | ||
+ | IssuanceTransaction { | ||
+ | Sender: <account address of the token manager> | ||
+ | Receiver: erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqzllls8a5w6u | ||
+ | Value: 50000000000000000 # (0.05 EGLD) | ||
+ | GasLimit: 60000000 | ||
+ | Data: "issue" + | ||
+ | "@" + <token name in hexadecimal encoding> + | ||
+ | "@" + <token ticker in hexadecimal encoding> + | ||
+ | "@" + <initial supply in hexadecimal encoding> + | ||
+ | "@" + <number of decimals in hexadecimal encoding> | ||
+ | } | ||
+ | </code> | ||
+ | |||
+ | <note important> | ||
+ | You can use [[https://elrond.tools/elrond-converters/|this]] tool for conversion. | ||
+ | </note> | ||
+ | |||
+ | == TASK == | ||
+ | |||
+ | Issue an ESDT token of your own. | ||
+ | |||
+ | === Mint fungible ESDT tokens === | ||
+ | |||
+ | <note important> | ||
+ | Actions **issue** and **mint** are distinct! | ||
+ | First, one must **issue** the token to exist on the blockchain. | ||
+ | Second, the owner/issuer of the token must **mint** tokens. | ||
+ | </note> | ||
+ | |||
+ | <note important> | ||
+ | On Mainnet, starting with epoch 432, global mint is disabled so one has to use local mint instead. | ||
+ | </note> | ||
+ | |||
+ | <code bash> | ||
+ | LocalMintTransaction { | ||
+ | Sender: <address with ESDTRoleLocalMint role> | ||
+ | Receiver: <same as sender> | ||
+ | Value: 0 | ||
+ | GasLimit: 300000 | ||
+ | Data: "ESDTLocalMint" + | ||
+ | "@" + <token identifier in hexadecimal encoding> + | ||
+ | "@" + <supply to mint in hexadecimal encoding> | ||
+ | } | ||
+ | </code> | ||
+ | |||
+ | Verify if the transaction worked. | ||
+ | |||
+ | == Setting ESDTRoleLocalMint == | ||
+ | |||
+ | Assign ESDTRoleLocalMint to your address: | ||
+ | |||
+ | <code bash> | ||
+ | RolesAssigningTransaction { | ||
+ | Sender: <address of the ESDT manager> | ||
+ | Receiver: erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqzllls8a5w6u | ||
+ | Value: 0 | ||
+ | GasLimit: 60000000 | ||
+ | Data: "setSpecialRole" + | ||
+ | "@" + <token identifier in hexadecimal encoding> + | ||
+ | "@" + <address to assign the role(s) in a hexadecimal encoding> + | ||
+ | "@" + <role in hexadecimal encoding> + | ||
+ | "@" + <role in hexadecimal encoding> + | ||
+ | ... | ||
+ | } | ||
+ | </code> | ||
+ | You can find more details [[https://docs.elrond.com/tokens/esdt-tokens/#setting-and-unsetting-special-roles | here]] | ||
+ | |||
+ | == TASK == | ||
+ | |||
+ | Set roles for your address. | ||
+ | |||
+ | == Minting ESDT Tokens == | ||
+ | |||
+ | An account with the //ESDTRoleLocalMint// role set can perform a local mint. | ||
+ | |||
+ | <code bash> | ||
+ | LocalMintTransaction { | ||
+ | Sender: <address with ESDTRoleLocalMint role> | ||
+ | Receiver: <same as sender> | ||
+ | Value: 0 | ||
+ | GasLimit: 300000 | ||
+ | Data: "ESDTLocalMint" + | ||
+ | "@" + <token identifier in hexadecimal encoding> + | ||
+ | "@" + <supply to mint in hexadecimal encoding> | ||
+ | } | ||
+ | </code> | ||
+ | |||
+ | == TASK == | ||
+ | |||
+ | Mint 1.000.000 ESDT Tokens you created. | ||
+ | |||
+ | == Burning ESDT Tokens == | ||
+ | |||
+ | Anyone that holds an amount of ESDT tokens may burn it at their discretion, effectively losing them permanently. This operation reduces the total supply of tokens, and cannot be undone, unless the token manager mints more tokens. | ||
+ | |||
+ | Do you have roles for burning? | ||
+ | <note tip> | ||
+ | Check the creation transaction. | ||
+ | </note> | ||
+ | |||
+ | <code bash> | ||
+ | LocalBurnTransaction { | ||
+ | Sender: <address with ESDTRoleLocalBurn role> | ||
+ | Receiver: <same as sender> | ||
+ | Value: 0 | ||
+ | GasLimit: 300000 | ||
+ | Data: "ESDTLocalBurn" + | ||
+ | "@" + <token identifier in hexadecimal encoding> + | ||
+ | "@" + <supply to burn in hexadecimal encoding> | ||
+ | } | ||
+ | </code> | ||
+ | |||
+ | == Task == | ||
+ | |||
+ | Burn 30% of your ESDTTokens | ||
+ | |||
+ | |||
+ | === Other actions for ESDTTokens === | ||
+ | |||
+ | == Pausing and Unpausing == | ||
+ | |||
+ | The manager of an ESDT token may choose to suspend all transactions of the token, except minting, freezing/unfreezing and wiping. Check more details [[https://docs.elrond.com/tokens/esdt-tokens/#pausing-and-unpausing |here]]. | ||
+ | |||
+ | == Freezing and Unfreezing == | ||
+ | |||
+ | The manager of an ESDT token may freeze the tokens held by a specific Account. As a consequence, no tokens may be transferred to or from the frozen Account. Freezing and unfreezing the tokens of an Account are operations designed to help token managers to comply with regulations. | ||
+ | The manager of an ESDT token may choose to suspend all transactions of the token, except minting, freezing/unfreezing and wiping. Check more details [[https://docs.elrond.com/tokens/esdt-tokens/#freezing-and-unfreezing |here]]. | ||
+ | |||
+ | == Wiping == | ||
+ | |||
+ | The manager of an ESDT token may wipe out all the tokens held by a frozen Account. This operation is similar to burning the tokens, but the Account must have been frozen beforehand, and it must be done by the token manager. Wiping the tokens of an Account is an operation designed to help token managers to comply with regulations. | ||
+ | The manager of an ESDT token may choose to suspend all transactions of the token, except minting, freezing/unfreezing and wiping. Check more details [[https://docs.elrond.com/tokens/esdt-tokens/#wiping |here]]. | ||