Open
Description
In the Ethereum world, ERC-20 is a standard with a specific API. This API has several features that are absent from the Fungible
application in Linera.
There is a reference implementation Open Zeppelin ERC-20 which is extremely widely used and therefore it makes sense to take it as a starting point for Linera.
Notes:
- This basic ERC-20 implementation could be extended by adding multichain capabilities to it. The extended version could be called
ERC20Multichain
. - The
totalSupply
function is constant for ERC-20 basic OpenZeppelin (there are variantsERC20Burnable
/ERC20Mintable
). For a true multichain, it is almost impossible to have a functiontotalSupply
that queries all chains in which a token could be instantiated. - An application satisfying the ERC-20 could be used by DeFi EVM applications running on Linera. If the multichain effort is done by
ERC20Multichain
then this could lighten the efforts of Ethereum developers moving to Linera.
The ERC-20 API:
interface IERC20 {
// Returns the total number of tokens in existence
function totalSupply() external view returns (uint256);
// Returns the amount of tokens owned by `account`
function balanceOf(address account) external view returns (uint256);
// Transfers `amount` tokens to `recipient`
function transfer(address recipient, uint256 amount) external returns (bool);
// Returns the remaining number of tokens that `spender` is allowed to spend on behalf of `owner`
function allowance(address owner, address spender) external view returns (uint256);
// Sets `amount` as the allowance of `spender` over the caller’s tokens
function approve(address spender, uint256 amount) external returns (bool);
// Moves `amount` tokens from `sender` to `recipient` using the allowance mechanism
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
// Emitted when `value` tokens are moved from one account (`from`) to another (`to`)
event Transfer(address indexed from, address indexed to, uint256 value);
// Emitted when the allowance of a `spender` for an `owner` is set by a call to `approve`
event Approval(address indexed owner, address indexed spender, uint256 value);
}