Ethereum tokens exchange methods
As head of the ECR20 ID, it is probably curious about the different methods that exchange their brands for other cryptocurrencies. In this article, we deepen the different approaches and explain how to determine what method is used when changing.
ERC -20 Token Standard
Before immersing yourself in the special characteristics of tokens exchange, it is necessary to understand the ERC-20 standard, which is the basis of all ECR20 grilles. The ERC-20 standard defines a set of rules to create and manage digital funds, including types of symbols such as ECR20.
Exchange methods
Several methods to change the IDs are available in the Ethereum ecosystem:
- Non -specified ID standard (NFT) : This method is used to change NFT, which represents unique digital elements.
- ERC-721 NFT standard in the additional field
: Some of the ERC-721 implementations contain additional fields that can be used to store modified label data.
- Change of ERC-20 : This is a standard method to change the token ECR20 and another token ERC-20.
Specific Methods of Token ECR20
As head of the ECR20 ID, you are probably interested in understanding how to change the brand. Here are some methods that can be used:
- STANDARD ERC-721 NFT : Change your ECR20 to another ECR20 using the ERC-721 characters not specified, you are:
* Believe an example of the « ERC721`agreement in Ethereum (for example, through OpenZepelin "ERC721
).
* Set the Tokenuri
function to indicate its original ECR20.
* Specify a new variable for the modified ID and begin with your destination ID in the direction.
- ERC-20 Token Swap : Change the ECR20 ID to another ERC-20 identification using a standard method, you have:
* Believe an example of the « ERC20implementation in Ethereum (for example, through OpenZepelin" ERC20
.
* Establish the « address » function to indicate its original ECR20.
* Specify a new variable for the modified ID and begin with your destination ID in the direction.
Example code
Let’s look at these concepts, explore the example using the Openzeppelin ‘ERC721 « Convention:
`SOLIDITY
Pragman solidity ^0.8.0;
Mytoken agreement {
// Implementation of the Token ECR20 standard
Struct NFT {
Bytes256;
}
Functional exchange (NFT NFT memory) public {
// Establish the Tokenuri function to indicate its original ECR20
nft.tokenuri = "0x ...";
// Configure a new variable in the modified ID and begin with your destination ID in
SWAPEDTOKENADDRESS address = 0x ...;
// Update the balance of changed identification
Swaptaken (SwapetedTokenaddress, Nft. Message);
}
Function Swapken (SwaTucentoCokenadddress address, bytes memory) Public {
// Verify if the sign has been replaced and updates its balance
REQUIRE (MSG.SEENDER! = ADDRESS (0), "REPLACE ONLY THE TOKEN ECR20");
Balance Uint256 = Total Number ();
Swaptken.balanceof (MSG.sender, 0, Swapeckenaddress);
}
Total Number Function () Public View returns (Uint256) {
Return 1;
}
}
In this example, the "SWAP function establishes the » Tokenuri « feature of the NFT to indicate its original ID ECR20 and define a new variable for the modified ID.
conclusion
Understanding how to change the different methods may seem complicated, but divide it into smaller stages and familiarize it with the ERC-20 standard makes it manageable. Be sure to monitor the best practices for the safety and development of intelligent contracts by implementing your character in their Ethereum projects.