Skip to main content

Deploy with Foundry

This tutorial walks through deploying a contract describing an ERC-20 token to Neon Devnet.


This tutorial is based on an example in GitHub.


This page is a quickstart based on a specific example program. For more details on installing Foundry, refer to the Foundry documentation.


Step 1: Installation

1.1 Clone the example Foundry project from the remote repository and navigate to it:

git clone
cd neon-tutorials/foundry

1.2 Install Foundryup with:

curl -L | bash

foundryup installs the latest (nightly) precompiled binaries: forge, cast, anvil, and chisel.

1.3 Install the required libraries:

forge install foundry-rs/forge-std --no-commit
forge install openzeppelin/openzeppelin-contracts --no-commit

Step 2: Set up an environment file


This step requires an EVM-compatible wallet such as MetaMask, connected to Neon Devnet, with a balance in Devnet NEON available from NeonFaucet.

The following tutorials assist you to meet these prerequisites:

2.1 Obtain the private key for your wallet account.

To obtain the private key from MetaMask, from the hamburger menu, click Account Details > Show Private Key, enter your password, and click Confirm for access to the private key for that account.

2.2 Create a .env file and add these lines:


Replace <YOUR_PRIVATE_KEY> with your data.

2.3 Run:

source .env

Step 3: Compile contracts

The contracts are located in the project's src/ directory. Before these contracts can be run, they must first be compiled.

3.1 To compile the project's contracts, run the following command:

forge build

After running this step, you should see output similar to the following:

[⠢] Compiling...
[⠒] Compiling 24 files with 0.8.21
[⠃] Solc 0.8.21 finished in 2.48s
Compiler run successful!

3.2 (Optional) test the smart contracts with:

forge test

Step 4: Deploy Contracts

  1. To deploy the project's contracts, run:
forge create --rpc-url $RPC_URL_DEVNET --private-key $PRIVATE_KEY src/TestERC20/TestERC20.sol:TestERC20 --constructor-args "Test ERC20 Token" "TERC20" --legacy

On running this step you should get console output similar to:

[⠰] Compiling...
No files changed, compilation skipped
Deployer: 0x4455E84Eaa56a01676365D4f86348B311969a4f4
Deployed to: 0x5537599aa2F97Dd60a66342522a465A7f2e40Ff9
Transaction hash: 0x6de9dab8a526cbac33008056d185b93dff725605efb791bf116b6bece4f0c486

Step 5: Contract verification

5.1 Verify the deployment of our smart contract on the explorer Neon Blockscout using following command:

forge verify-contract --chain-id $CHAIN_ID_DEVNET <contract_address> src/TestERC20/TestERC20.sol:TestERC20 --verifier-url $VERIFIER_URL_BLOCKSCOUT --verifier blockscout

Replace <contract_address> with your smart contract address.

After successfully running this step you should get console output similar to:

Start verifying contract `0x5537599aa2F97Dd60a66342522a465A7f2e40Ff9` deployed on 245022926
Submitting verification for [src/TestERC20/TestERC20.sol:TestERC20] "0x5537599aa2F97Dd60a66342522a465A7f2e40Ff9".
Submitted contract for verification:
Response: `OK`
GUID: `5537599aa2f97dd60a66342522a465a7f2e40ff9654118b3`

5.2 Copy/paste this link in your browser, remembering to replace contract_address with your freshly deployed contract address:<contract_address>

Was this page helpful?