🚀

Deploying a Contract on Neon EVM

Jul 24, 2024

Deploying a Contract on Neon EVM with Foundry

Introduction

  • Speaker: Daria, Developer Relations Engineer for Neon
  • Purpose: Video walkthrough on deploying a smart contract using Neon EVM with Foundry.

Setting Up MetaMask

  1. Install MetaMask:
    • Link provided in the tutorial.
  2. Add Neon EVM to MetaMask:
    • Access chain list page through links in the docs.
    • Click 'Connect Wallet' to add Neon DevNet to MetaMask.
    • Switch network to DevNet.

Acquiring DevNet Tokens

  • Get DevNet Tokens:
    • Navigate to the Neon faucet.
    • Connect MetaMask wallet.
    • Request 50 Neon tokens.
    • Confirm the transaction was successful.

Installing Foundry

  • Installation Process:
    • Follow instructions in the Foundry book.
    • Run the curl command in the terminal to install.

Initializing the Foundry Project

  1. Create Project Folder:
    • mkdir neon_test
    • cd neon_test
  2. Initialize Foundry:
    • Run forge init to create project files including:
      • Deployment script
      • Counter contract
      • Test files
  3. Open Project in Editor:
    • Use preferred code editor (e.g., VS Code).

Customizing the Deployment

  1. Create Environment File:
    • Store environment variables (e.g., RPC URL, Chain ID, Private Key).
  2. Fetch Private Key from MetaMask:
    • Go to account details, press 'Show Private Key'.
  3. Populate the env File:
    • Add RPC URL, MainNet URL, Chain IDs, and Private Key.
  4. Load Environment Variables:
    • Run source .env in the terminal to use the variables.

Deploying the Contract

  1. Run Deployment Command:
    • Command format: forge create --rpc-url <devnet_url> --private-key <your_private_key> <contract_path> --legacy
    • Use counter.sol from the source folder for the contract.
  2. Verify Deployment:
    • Check the transaction hash and deploy address in the terminal.
    • Visit Neon Scan, paste transaction hash, ensure it's set to DevNet.

Conclusion

  • Successfully deployed contract on Neon using Foundry.
  • Encouragement to try it out and ask questions in the comments.
  • Thank you for watching!