Arbitrum Stylus logo

Stylus by Example

ERC-20

Any contract that follows the ERC-20 standard is an ERC-20 token.

ERC-20 tokens provide functionalities to

  • transfer tokens
  • allow others to transfer tokens on behalf of the token holder

Here is the interface for ERC-20.

1interface IERC20 {
2    function totalSupply() external view returns (uint256);
3    function balanceOf(address account) external view returns (uint256);
4    function transfer(address recipient, uint256 amount)
5        external
6        returns (bool);
7    function allowance(address owner, address spender)
8        external
9        view
10        returns (uint256);
11    function approve(address spender, uint256 amount) external returns (bool);
12    function transferFrom(address sender, address recipient, uint256 amount)
13        external
14        returns (bool);
15}
1interface IERC20 {
2    function totalSupply() external view returns (uint256);
3    function balanceOf(address account) external view returns (uint256);
4    function transfer(address recipient, uint256 amount)
5        external
6        returns (bool);
7    function allowance(address owner, address spender)
8        external
9        view
10        returns (uint256);
11    function approve(address spender, uint256 amount) external returns (bool);
12    function transferFrom(address sender, address recipient, uint256 amount)
13        external
14        returns (bool);
15}

Example implementation of an ERC-20 token contract written in Rust.

src/erc20.rs

1Loading...
1Loading...

src/lib.rs

1Loading...
1Loading...

Cargo.toml

1Loading...
1Loading...

src/main.rs

1Loading...
1Loading...