Differences

This shows you the differences between two versions of the page.

Link to this comparison view

fob:laboratoare:04 [2022/11/10 15:27]
costin.carabas [Practical Session 04.]
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**:+__Fungible ​vs Non-Fungible Tokens:__
   * Fungibility refers to an asset'​s ability to be exchanged for something else of equal value;   * 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;   * Some examples of fungible assets include currencies, commodities,​ and precious stones;
Line 42: Line 42:
 <code bash> <code bash>
 IssuanceTransaction { IssuanceTransaction {
-    Sender: ​erd1sg4u62lzvgkeu4grnlwn7h2s92rqf8a64z48pl9c7us37ajv9u8qj9w8xg+    Sender: ​<account address of the token manager>
     Receiver: erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqzllls8a5w6u     Receiver: erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqzllls8a5w6u
     Value: 50000000000000000 # (0.05 EGLD)     Value: 50000000000000000 # (0.05 EGLD)
     GasLimit: 60000000     GasLimit: 60000000
     Data: "​issue"​ +     Data: "​issue"​ +
-          "@416c696365546f6b656e73" +  // "​AliceTokens"​ hex encoded +          "​@"​ + <token name in hexadecimal encoding>​ + 
-          "@414c43" +                  // "​ALC"​ hex encoded +          "​@"​ + <token ticker in hexadecimal encoding>​ + 
-          "@f3d7b4c0" +                // 4091000000 hex encoded +          "​@"​ + <initial supply in hexadecimal encoding>​ + 
-          "@06" ​                       // 6 hex encoded  ​+          "​@" ​+ <number of decimals in hexadecimal encoding>​
 } }
 </​code>​ </​code>​
Line 174: Line 174:
 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]]. 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]].
  
- 
-==== Non-Fungible Tokens ==== 
- 
-The Elrond protocol introduces native NFT support by adding //​metadata//​ and //​attributes//​ on top of the already existing ESDT. This way, one can issue a semi-fungible token or a non-fungible token which is quite similar to an ESDT, but has a few more attributes, as well as an assignable URI. Once owning a quantity of a NFT/SFT, users will have their data store directly under their account, inside the trie.  
- 
-<note important>​ 
-The flow of issuing and transferring non-fungible or semi-fungible tokens is: 
-  - register/​issue the token 
-  - set roles to the address that will create the NFT/SFTs 
-  - create the NFT/SFT 
-  - transfer quantity(es) 
-</​note>​ 
- 
-=== Issuance of Non-Fungible Tokens === 
- 
-One has to perform an issuance transaction in order to register a non-fungible token. Non-Fungible 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 and optionally additional properties. 
- 
-<code bash> 
-IssuanceTransaction { 
-    Sender: <account address of the token manager> 
-    Receiver: erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqzllls8a5w6u 
-    Value: 50000000000000000 # (0.05 EGLD) 
-    GasLimit: 60000000 
-    Data: "​issueNonFungible"​ + 
-          "​@"​ + <token name in hexadecimal encoding>​ + 
-          "​@"​ + <token ticker in hexadecimal encoding>​ 
-} 
-</​code>​ 
- 
-Optionally, the properties can be set when issuing a token. Example: 
- 
-<code bash> 
-IssuanceTransaction { 
-    Sender: <account address of the token manager> 
-    Receiver: erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqzllls8a5w6u 
-    Value: 50000000000000000 # (0.05 EGLD) 
-    GasLimit: 60000000 
-    Data: "​issueNonFungible"​ + 
-          "​@"​ + <token name in hexadecimal encoding>​ + 
-          "​@"​ + <token ticker in hexadecimal encoding>​ + 
-          "​@"​ + <"​canFreeze"​ hexadecimal encoded> + "​@"​ + <"​true"​ or "​false"​ hexadecimal encoded> + 
-          "​@"​ + <"​canWipe"​ hexadecimal encoded> + "​@"​ + <"​true"​ or "​false"​ hexadecimal encoded> + 
-          "​@"​ + <"​canPause"​ hexadecimal encoded> + "​@"​ + <"​true"​ or "​false"​ hexadecimal encoded> + 
-          "​@"​ + <"​canTransferNFTCreateRole"​ hexadecimal encoded> + "​@"​ + <"​true"​ or "​false"​ hexadecimal encoded> + 
-          "​@"​ + <"​canChangeOwner"​ hexadecimal encoded> + "​@"​ + <"​true"​ or "​false"​ hexadecimal encoded> + 
-          "​@"​ + <"​canUpgrade"​ hexadecimal encoded> + "​@"​ + <"​true"​ or "​false"​ hexadecimal encoded> + 
-          "​@"​ + <"​canAddSpecialRoles"​ hexadecimal encoded> + "​@"​ + <"​true"​ or "​false"​ hexadecimal encoded> + 
-          ... 
-} 
-</​code>​ 
- 
-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. For example, a token identifier could look like ALC-6258d2. 
- 
- 
-=== Issuance of Semi-Fungible Tokens === 
- 
-One has to perform an issuance transaction in order to register a semi-fungible token. Semi-Fungible 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 semi-fungible token, one must provide a token name, a ticker and optionally additional properties. ​ 
- 
-<code bash> 
-IssuanceTransaction { 
-    Sender: <account address of the token manager> 
-    Receiver: erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqzllls8a5w6u 
-    Value: 50000000000000000 # (0.05 EGLD) 
-    GasLimit: 60000000 
-    Data: "​issueSemiFungible"​ + 
-          "​@"​ + <token name in hexadecimal encoding>​ + 
-          "​@"​ + <token ticker in hexadecimal encoding>​ 
-} 
-</​code>​ 
- 
-== TASK == 
- 
-Issue your own SFT or NFT. 
- 
- 
-=== NFT Roles === 
- 
-In order to be able to perform actions over a token, one needs to have roles assigned. The existing roles are: 
- 
-For NFT: 
-  * ESDTRoleNFTCreate : this role allows one to create a new NFT 
-  * ESDTRoleNFTBurn : this role allows one to burn quantity of a specific NFT 
-  * ESDTRoleNFTUpdateAttributes : this role allows one to change the attributes of a specific NFT 
-  * ESDTRoleNFTAddURI : this role allows one add URIs for a specific NFT 
-  * ESDTTransferRole : this role enables transfer only to specified addresses. The owner of the NFT and the address with the ESDTTransferRole should be located on the same shard. The addresses with the transfer role can transfer anywhere. 
- 
-For SFT: 
- 
-  * ESDTRoleNFTCreate : this role allows one to create a new SFT 
-  * ESDTRoleNFTBurn : this role allows one to burn quantity of a specific SFT 
-  * ESDTRoleNFTAddQuantity : this role allows one to add quantity of a specific SFT 
-  * ESDTTransferRole : this role enables transfer only to specified addresses. The owner of the SFT and the address with the ESDTTransferRole should be located on the same shard. The addresses with the transfer role can transfer anywhere. 
- 
- 
-Roles can be assigned by sending a transaction to the Metachain from the ESDT manager. 
-Within a transaction of this kind, any number of roles can be assigned (minimum 1). 
- 
-<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>​ 
- 
-=== NFT/SFT Fields === 
- 
-Fields of an NFT/SFT: 
-  * Name 
-  * Quantity (for NFT must be 1) 
-  * Royalties (allows creator to receive royalties for any transaction involving their NFT) 
-  * Hash (of NFT metadata) 
-  * Attributes (additional 
-  * URIs (mandatory, png, jpeg, mp3, gif, [[https://​docs.elrond.com/​tokens/​nft-tokens/#​supported-media-types|etc]].) 
- 
- 
- 
-=== Creation of an NFT === 
- 
-<code bash> 
-NFTCreationTransaction { 
-    Sender: <address with ESDTRoleNFTCreate role> 
-    Receiver: <same as sender> 
-    Value: 0 
-    GasLimit: 3000000 + Additional gas (see below) 
-    Data: "​ESDTNFTCreate"​ + 
-          "​@"​ + <token identifier in hexadecimal encoding>​ + 
-          "​@"​ + <initial quantity in hexadecimal encoding>​ + 
-          "​@"​ + <NFT name in hexadecimal encoding>​ + 
-          "​@"​ + <​Royalties in hexadecimal encoding>​ + 
-          "​@"​ + <Hash in hexadecimal encoding>​ + 
-          "​@"​ + <​Attributes in hexadecimal encoding>​ + 
-          "​@"​ + <URI in hexadecimal encoding>​ + 
-          "​@"​ + <URI in hexadecimal encoding>​ + 
-          ... 
-} 
-</​code>​ 
- 
-== TASK == 
- 
-Create your own NFT. 
- 
-Example of NFT Creation: 
-<code bash> 
-{ 
-    Sender: <address with ESDTRoleNFTCreate role> 
-    Receiver: <same as sender> 
-    Value: 0 
-    GasLimit: 3000000 
-    Data: "​ESDTNFTCreate"​ + 
-          "​@414c432d317132773365"​ +  # previously fetched token identifier 
-          "​@01"​ + # quantity: 1 
-          "​@42656175746966756c20736f6e67"​ + # NFT name: '​Beautiful song' in hexadecimal encoding 
-          "​@1d4c"​ + # Royalties: 7500 =75%c in hexadecimal encoding 
-          "​@00"​ + # Hash: 00 in hexadecimal encoding 
-          "​@6d657461646174613a697066734349442f736f6e672e6a736f6e3b746167733a736f6e672c62656175746966756c2c6d75736963"​ + # Attributes: metadata:​ipfsCID/​song.json;​tags:​song,​beautiful,​music ​  in hexadecimal encoding>​ + 
-          "​@55524c5f746f5f646563656e7472616c697a65645f73746f726167652f736f6e672e6d7033"​ + # URI: URL_to_decentralized_storage/​song.mp3 in hexadecimal encoding>​ + 
-          "​@"​ + <​additional optional URI in hexadecimal encoding>​ + 
-} 
-</​code>​ 
- 
-=== Other management operations === 
- 
-[[https://​docs.elrond.com/​tokens/​nft-tokens/#​transfer-nft-creation-role |Transfer NFT Creation Role]], 
-[[https://​docs.elrond.com/​tokens/​nft-tokens/#​stop-nft-creation| Stop NFT creation]], 
-[[https://​docs.elrond.com/​tokens/​nft-tokens/#​change-nft-attributes|Change NFT Attributes]],​ 
-[[https://​docs.elrond.com/​tokens/​nft-tokens/#​add-uris-to-nft|Add URIs to NFT]], 
-[[https://​docs.elrond.com/​tokens/​nft-tokens/#​wiping-a-single-nft|Wiping a single NFT]], 
-[[https://​docs.elrond.com/​tokens/​nft-tokens/#​other-management-operations| etc.]]. 
- 
- 
- 
-=== Transfer NFT === 
- 
-<code bash> 
-TransferTransaction { 
-    Sender: <account address of the sender> 
-    Receiver: <same as sender> 
-    Value: 0 
-    GasLimit: 1000000 + length of Data field in bytes * 1500 
-    Data: "​ESDTNFTTransfer"​ + 
-          "​@"​ + <​collection identifier in hexadecimal encoding>​ + 
-          "​@"​ + <the NFT nonce in hexadecimal encoding>​ + 
-          "​@"​ + <​quantity to transfer in hexadecimal encoding>​ + 
-          "​@"​ + <​destination address in hexadecimal encoding>​ 
-} 
-</​code>​ 
- 
-== TASK == 
- 
-Transfer your NFT to ''​erd1xex9ptczwwce4w9zejpjranj6mt8q5sqseenfj7ym55gfcpgq7cq5e9amz''​. 
- 
-=== Transfer to a Smart Contract === 
- 
-<code bash> 
-TransferTransaction { 
-    Sender: <account address of the sender> 
-    Receiver: <same as sender> 
-    Value: 0 
-    GasLimit: 1000000 + extra for smart contract call 
-    Data: "​ESDTNFTTransfer"​ + 
-          "​@"​ + <​collection identifier in hexadecimal encoding>​ + 
-          "​@"​ + <the nonce after the NFT creation in hexadecimal encoding>​ + 
-          "​@"​ + <​quantity to transfer in hexadecimal encoding>​ + 
-          "​@"​ + <​destination address in hexadecimal encoding>​ + 
-          "​@"​ + <name of method to call in hexadecimal encoding>​ + 
-          "​@"​ + <first argument of the method in hexadecimal encoding>​ + 
-          "​@"​ + <second argument of the method in hexadecimal encoding>​ + 
-          <...> 
-} 
-</​code>​ 
fob/laboratoare/04.1668086822.txt.gz · Last modified: 2022/11/10 15:27 by costin.carabas
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0