Skip to main content

Prerequisites

  • Node.js 16+
  • Familiarity with Ethereum development
  • A wallet with testnet tokens (see testnet chain details)

Contract Preparation

The following example contract will be used throughout this guide:

Deploy with Foundry

Foundry is a fast, Rust-based toolkit for Ethereum development.
  1. Install Foundry:
    You may have to source your .bashrc or .zshrc file
  2. Set up a new Foundry project:
  3. Update foundry.toml with Plasma testnet settings:
  4. Create a .env file in your project root:
  5. Load the environment variables:
  6. Save the contract code as src/SimpleStorage.sol, then deploy:
    Foundry will output the deployment transaction hash and contract address:
  7. Test your deployed contract using Foundry’s cast tool. First, read the stored data:
  8. Then update the data and read it again:
    This should output something like:

Deploy with Hardhat

Hardhat is a full-featured development framework with rich plugin support.
  1. Make sure you have the following:
  • Node.js 20+ (required for modern Hardhat compatibility)
  • Familiarity with Ethereum development
  • A wallet with testnet tokens (see testnet chain details)
Node.js 18 and below are no longer supported by Hardhat and may cause ES module compatibility issues.
  1. Verify Node.js version:
    If you’re using Node.js 18 or below, upgrade to Node.js 20+:
  2. Initialize a new Hardhat project:
    If you encounter compatibility issues, check the Hardhat documentation for the latest supported versions.
    Choose Create a JavaScript project when prompted.
  3. Update hardhat.config.js:
  4. Create a .env file in your project root:
  5. Create scripts directory and deployment script:
  6. Create scripts/deploy.js:
  7. Save the contract code as contracts/SimpleStorage.sol, then deploy:
  8. You’re done!

Deploy with Ethers.js

Ethers.js provides a minimal, programmatic deployment flow.
  1. Create a new project:
  2. Create a .env file in your project root:
  3. Create compile.js to compile your Solidity contract:
  4. Save your contract as SimpleStorage.sol, then compile:
    This should output:
  5. Create deploy.js:
  6. Run the deployment script:
    This should output something like:

Verify Deployment

After deploying with any of the above methods, verify your contract deployment.

Troubleshooting

ES Module Compatibility Issues

If you encounter errors like Error [ERR_REQUIRE_ESM]: require() of ES Module, this typically means:
  1. Node.js version is too old: Upgrade to Node.js 20+ as mentioned in prerequisites
  2. Dependency version mismatch: If upgrading Node.js isn’t possible, you can downgrade the problematic dependency:

Node.js Version Warnings

If you see warnings about unsupported Node.js versions:
Upgrade to Node.js 20+ following the steps in the prerequisites section.

Insufficient Funds

Ensure your wallet has enough testnet tokens. Visit a testnet faucet.

Wrong Network Configuration

Verify your network configuration matches the testnet chain details.

Gas Estimation Failure

Set explicit gas limits in your deployment configuration: