How to Deploy

This section will cover how to deploy contracts to the AirDAO network using Hardhat or Foundry project setup.

This tutorial cover both cloning existing project and initializing from scratch.

From Scratch

Hardhat

For hardhat example we use default hardhat template contract.

Install dependencies and initiate project:

npm i hardhat
npx hardhat init

Follow the initialization process and wait for installation process.

Hardhat creates default contract, and we will use it for that example.

Configuration for AIRDAO network:

Open ./hardhat.config.js (or ./hardhat.config.ts) and modify the following parameters

  1. Modify networks:

// Some imports here ...

const YOUR_PRIVATE_KEY = process.env.PRIVATE_KEY

module.exports = {
// Hardhat configuration ...
  networks: {
    devnet: {
      url: "https://network.ambrosus-dev.io",
      accounts: [YOUR_PRIVATE_KEY]
    },
    testnet: {
      url: "https://network.ambrosus-test.io",
      accounts: [YOUR_PRIVATE_KEY]
    },
    mainnet: {
      url: "https://network.ambrosus.io",
      accounts: [YOUR_PRIVATE_KEY]
    }
  },
// Hardhat configuration ...
}
  1. Modify the compiler settings, the evmVersion should be istanbul/petersburg:

  1. (Optional for verifying contracts) Modify the hardhat-verify parameters (etherscan and sourcify):

Deployment process:

Follow the ignition deployment process and the address will be printed to console.

Contract verification:

  1. via explorer

    1. search for deployed address

    2. drag & drop file from artifacts/build-info to explorer verification page in β€œContractβ€œ section.

  2. with cmd

Foundry

For the foundry example we will use hello_foundry template.

Initiate project:

Configuration for AIRDAO network:

Modify the foundry.toml file with configuration

Use --verifier sourcify --verifier-url https://sourcify.ambrosus.io/ --verify when deploying to verify your contracts.

Deployment process:

Once you will be ready with deployment script, run it with --legacy flag and additional values for verification, network and keys (example for script/Counter.s.sol:CounterScript)

Contract verification:

  1. via explorer

    1. search for deployed address

    2. drag & drop file from out/build-info to explorer verification page in β€œContractβ€œ section.

  2. with cmd

Forking

If you want to fork existing project just fork and edit the configuration.

We will use GitHub - Polymarket/PolyLend: PolyLend as example of forking into our network.

To deploy this project in AirDAO we didn’t modify any solidity file! All that needed to be done was to write scripts for deployment (since they were not in the repository), and specify our networks in the configuration file (see above)

Foundry

Update the foundry.toml config with EVM version and RPCs like here.

Create deployment script like that:

Run the script via CLI:

Hardhat

For completeness purposes, we tried to use hardhat framework with this project.

Update the hardhat.config.[j,t]s config with EVM version and RPCs like here.

Copy project contracts and dependencies to hardhat empty project.

Create hardhat ignition script to deploy contracts:

Then run npx hardhat ignition deploy ./ignition/modules/PolyLend.js --network testnet

Verified contracts

After contracts deployed and verified, anyone can easily call any method on contract using AirDAO | AirDAO Network Explorer.

Last updated