A simple ERC20 token contract with permit functionality, built using OpenZeppelin contracts.
- ERC20 standard implementation
- Permit functionality (EIP-2612)
- Ownable with minting capabilities
- Initial supply minting on deployment
- Foundry
- Node.js and npm
- A wallet with RON tokens for Ronin Saigon Testnet
- Clone the repository:
git clone <repository-url>
cd <repository-name>- Install dependencies:
forge install- Create environment file:
cp .env.example .env- Edit
.envfile with your values:
# Your wallet private key (without 0x prefix)
PRIVATE_KEY=your_private_key_here
# Ronin Saigon Testnet RPC URL
RONIN_SAIGON_RPC_URL=https://saigon-testnet.roninchain.com/rpc
# Optional: Ronin Explorer API Key for verification
RONIN_EXPLORER_API_KEY=your_ronin_explorer_api_key_hereRun the test suite:
forge test -vv-
Make sure you have RON test tokens in your wallet. You can get them from:
- Ronin Discord server
- Ronin Saigon Testnet Faucet
-
Deploy the contract:
forge script script/MyTokenRonin.s.sol:MyTokenRoninScript \
--rpc-url https://saigon-testnet.roninchain.com/rpc \
--broadcast \
-vvvvThe script will deploy the contract with the following parameters:
- Initial owner: Your deployer address
- Initial recipient: Your deployer address
- Initial supply: 1 million tokens (with 18 decimals)
-
Make sure you have RON test tokens in your wallet.
-
Deploy the contract:
forge script script/BloomsCollection.s.sol:BloomsCollectionScript \
--rpc-url https://saigon-testnet.roninchain.com/rpc \
--broadcast \
-vvvvThe script will deploy the contract with the following parameters:
- Name: "Blooms Collection"
- Symbol: "BLOOM"
- Base URI: "https://api.blooms.com/token/" (replace with your actual base URI)
- Max Supply: 10000 tokens
- Price: 0.1 RON per token
- Max Mint Per Transaction: 10 tokens
After deployment, verify your contract on Ronin Explorer:
- Generate flattened source code:
forge flatten src/MyToken.sol > flattened/MyToken.flattened.sol
forge flatten src/BloomsCollection.sol > flattened/BloomsCollection.flattened.sol- Go to Ronin Saigon Explorer and:
- Navigate to your contract address
- Click on the "Code" tab
- Click "Verify & Publish"
- Fill in the verification form:
- Contract Name:
MyTokenorBloomsCollection - Compiler Version:
v0.8.22 - Optimization:
Yes(200 runs) - Enter the flattened source code
- Enter the constructor arguments (ABI-encoded) from deployment output
- Contract Name:
- Click "Verify & Publish"
constructor(
address initialOwner, // Address that will own the contract
address recipient, // Address that will receive initial supply
uint256 initialSupply // Initial token supply (in wei)
)constructor(
string memory name, // Name of the collection
string memory symbol, // Symbol of the collection
string memory baseURI, // Base URI for token metadata
uint256 maxSupply, // Maximum number of tokens that can be minted
uint256 price, // Price per token in RON
uint256 maxMintPerTx // Maximum number of tokens that can be minted in a single transaction
)mint(address to, uint256 amount): Mints new tokens (owner only)permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s): Approves spending via signature- All standard ERC20 functions (transfer, approve, etc.)
mint(uint256 amount): Mints new tokens (payable)setBaseURI(string memory newBaseURI): Updates the base URI (owner only)setPrice(uint256 newPrice): Updates the minting price (owner only)setMaxMintPerTx(uint256 newMaxMintPerTx): Updates the maximum mint per transaction (owner only)withdraw(): Withdraws collected funds (owner only)- All standard ERC721 functions (transfer, approve, etc.)
- The contracts use OpenZeppelin's audited contracts
- Only the owner can perform administrative functions
- Initial supply is minted to the specified recipient on deployment
- Permit functionality allows gasless approvals
- BloomsCollection includes safeguards against:
- Exceeding max supply
- Exceeding max mint per transaction
- Insufficient payment
- Unauthorized access
MIT License