Implementation example of an ERC-20 token contract written in Rust for Arbitrum Stylus.
Disclaimer: this code is unaudited and not fit for production use.
Follow the instructions in the Stylus quickstart to configure your development environment.
The scripts
folder contains two scripts to deploy and test the contract:
- ./scripts/deploy.sh deploys the contract to the chain specified in the .env file, using cargo-stylus
- ./scripts/test.sh performs a series of calls to verify that the contract behaves as expected
Remember to set the environment variables in an .env
file.
This project also includes a Solidity Proxy to deploy the ERC-20 contract behind it, so it can be upgraded in the future. To do this, use the script ./scripts/deployWithProxy.sh.
To update the logic contract, use the script ./scripts/updateLogic.sh.
Note that this Proxy is based on the TransparentUpgradeableProxy of Solidity, but the ERC-20 contract itself is not Initializable.
Instructions to setup a local Stylus dev node can be found here.
The Stylus testnet is an L3 chain that settles to Arbitrum Sepolia. The usual way of obtaining ETH is to bridge it from Arbitrum Sepolia through the Arbitrum Bridge. You can find a list of Arbitrum Sepolia faucets here.