Skip to content

akoita/chainlink-bootcamp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MyToken ERC20 Contract

A simple ERC20 token contract with permit functionality, built using OpenZeppelin contracts.

Features

  • ERC20 standard implementation
  • Permit functionality (EIP-2612)
  • Ownable with minting capabilities
  • Initial supply minting on deployment

Prerequisites

  • Foundry
  • Node.js and npm
  • A wallet with RON tokens for Ronin Saigon Testnet

Setup

  1. Clone the repository:
git clone <repository-url>
cd <repository-name>
  1. Install dependencies:
forge install
  1. Create environment file:
cp .env.example .env
  1. Edit .env file 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_here

Testing

Run the test suite:

forge test -vv

Deployment to Ronin Saigon Testnet

MyToken Deployment

  1. Make sure you have RON test tokens in your wallet. You can get them from:

    • Ronin Discord server
    • Ronin Saigon Testnet Faucet
  2. Deploy the contract:

forge script script/MyTokenRonin.s.sol:MyTokenRoninScript \
    --rpc-url https://saigon-testnet.roninchain.com/rpc \
    --broadcast \
    -vvvv

The 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)

BloomsCollection Deployment

  1. Make sure you have RON test tokens in your wallet.

  2. Deploy the contract:

forge script script/BloomsCollection.s.sol:BloomsCollectionScript \
    --rpc-url https://saigon-testnet.roninchain.com/rpc \
    --broadcast \
    -vvvv

The 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

Contract Verification

After deployment, verify your contract on Ronin Explorer:

  1. Generate flattened source code:
forge flatten src/MyToken.sol > flattened/MyToken.flattened.sol
forge flatten src/BloomsCollection.sol > flattened/BloomsCollection.flattened.sol
  1. 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: MyToken or BloomsCollection
      • Compiler Version: v0.8.22
      • Optimization: Yes (200 runs)
      • Enter the flattened source code
      • Enter the constructor arguments (ABI-encoded) from deployment output
    • Click "Verify & Publish"

Contract Details

MyToken Constructor Parameters

constructor(
    address initialOwner,    // Address that will own the contract
    address recipient,       // Address that will receive initial supply
    uint256 initialSupply    // Initial token supply (in wei)
)

BloomsCollection Constructor Parameters

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
)

Functions

MyToken

  • 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.)

BloomsCollection

  • 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.)

Security Considerations

  • 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

License

MIT License

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages