XinFin TOKENS: XRC-20 VS. XRC-223 VS. XRC-777
XinFin, as we know, is a global open-source platform for decentralized applications. Using XinFin Network, one can write code that runs exactly as programmed, controls digital value, and can be accessed from anywhere in the world. Developers can build new kinds of applications on the XinFin Network. XinFin Network is a foundation for the new era of the internet which is built on an open-access, neutral infrastructure that is not controlled by any company or person.
What Is An XinFin Network Token?
XinFin Network tokens are digital assets that are built on top of the XinFin blockchain. These may represent anything from a physical object like Gold. In the future, these may also represent financial instruments like bonds and stocks. They benefit from the existing infrastructure of XinFin as developers need not construct an entirely new blockchain. They strengthen the XinFin ecosystem by driving the demand for XDC, XinFin Network native currency, that is needed to power the smart contracts. Smart contracts are self-executing contracts where the terms of the agreement between the buyer and seller are directly written into lines of code.
In this article, we will be comparing the three XinFin tokens, namely XRC-20, XRC-223, AND XRC-777.
XRC-20 is one such XinFin Network token standard. It is a famous token standard that has been used by all the ICOs which have used the XinFin platform. By default, developers use it to create new tokens. Wallets and exchanges accept these tokens easily. Before the launch of the XRC-20 token, XinFin developers had to set rules for their token to follow, and this approach lacked standardization. XRC-20 token is more standardized.
Functions prescribed by XRC-20 standard while developing a XinFin Network token
- Get the total supply of tokens by using the “total supply” function.
- Retrieve the token balance from another owner account.
- Send the tokens to another owner account. These are “EOA” accounts. For this, we use the transfer function.
- Send the tokens from one address to the other. Token addresses are contract addresses. For this, we will use the “transferFrom” function.
- Allow another account to repeatedly withdraw funds from your account, within a specified limit. For this, we use the “approve” function.
- By using the allowance function, spenders can return unused tokens to owners.
An XRC-20 bug that burns tokens
Though the XRC-20 token is well-documented and well-implemented overall, the XRC-20 token standard has a bug. This bug has burnt tokens worth millions of US dollars. With the transfer function, you can only send tokens to the EOA account. If you use the “transfer” function, you will see a successful transaction, but the contract will never receive the tokens. This burns the tokens forever, and they can’t be retrieved. By using the wrong function, several users have lost their tokens for good!
XRC-223 Token Standard- a proposed resolution for the XRC-20 bug
The draft of the XRC-223 token standard proposes the following solution:
- It considers transactions on the XinFin blockchain as events.
- If users use the “transfer” function, it will display an error and subsequently cancel the transaction.
- Though the user pays the XDC as a “Gas price,” he doesn’t lose any token.
- An additional parameter of checking whether the receiving address is a contract account is added to the “transfer” function.
- If it finds that the recipient address is a contract account and not an EOA account, it assumes that the contract has implemented a “tokenFallback.”
- Using a “toeknFallback” function, we can call back the token so that the transaction doesn’t burn the token.
- Though the XRC-223 function solves the XRC-20 bug to a great extent, there is a weak point in this proposal. In case the recipient smart contract does not have the “tokenFallback” function, the “Fallback” function will run, resulting in the loss of tokens.
XRC-777- an improved proposal to the XRC-20 bug
The proposal of XRC-777 includes the following:
- New functions introduced are “send” instead of “transfer,” “authoriseoperator” instead of “approve,” and “tokensReceived” instead of “tokenFallback.”
- Until now, developers couldn’t identify the functions which can be implemented by smart contracts. Another token standard called the XRC-820 has implemented a central registry of contracts on the network. So, it is now possible to know the interfaces and functions a smart contract has. XRC-777 uses this to identify the interfaces a smart contract uses. Developers will now know beforehand if a contract has the functions required to receive tokens sent through certain functions.
- “Whitelisting” of operators is possible with XRC-777. So, XinFin network users will now be capable of rejecting payment from blacklisted addresses. An address can be blacklisted due to reasons such as a history of illegal activities and attempts to hack the network.
- You will now be able to understand that out of these three tokens, the XRC-777 token provides developers with multiple options to prevent the loss of tokens. However, the XRC-777 standard is also associated with risks such as:
- Some XinFin developers are of the opinion that the “authoriseoperator” function is deprecated; so developers shouldn’t use it. This function will need more “Gas,” and it will put additional strain on the network.
- Using a central registry of smart contracts to look up the interfaces a contract uses is risky. It is possible for the central registry to have bugs, and anything that depends on it will have an adverse impact.
Conclusion
Only time will tell as to which standard will be accepted as the “Gold standard” by the XinFin ecosystem. It is your primary responsibility, as a developer, to protect the funds of traders and investors. If you accept such a responsible position, you will probably agree that the XRC-777 standard must be adopted and implemented, despite the risks.
In the meantime, if you have any questions about XRC tokens types or you are a DeFi project and want to know more about how to migrate your project to XinFin Network you can always contact me via Telegram @Ruslan_wing
For any support, connect via XDC Network’s Social media communities on Slack, Twitter, and Discord.