Skip to main content
This guide covers environment setup, contract deployment, and interaction with Plasma’s EVM compatible testnet using Hardhat. It assumes basic familiarity with Ethereum tooling and smart contract development.

Prerequisites

  • Node.js 20+
  • Basic knowledge of Ethereum development
  • Browser wallet

Environment Setup

Use Hardhat to build and deploy contracts.

Hardhat Setup

  1. Create a new project directory and initialize:
  2. Follow the steps to create a JavaScript project. Save the project wherever you want. You likely don’t need a .gitignore file for this quickstart.
  3. Configure hardhat.config.js for Plasma testnet:

Wallet & Testnet Setup

Add Plasma Testnet to Your Browser Wallet

  1. Open your browser wallet (MetaMask, Trust Wallet, or Rabby) and click the network selector.
  2. Select the option to add a custom network (for example, Add Network, Add manually, or Add custom network).
  3. Enter these details:
    • Network Name: Plasma Testnet
    • New RPC URL: https://testnet-rpc.plasma.to
    • Chain ID: 9746
    • Currency Symbol: XPL
    • Block Explorer URL: https://testnet.plasmascan.to
  4. Save the network and switch to the Plasma Testnet in your wallet.

Get Testnet Tokens

  1. Copy your wallet address from your browser wallet.
  2. Visit openfaucet.org.
  3. Enter your address and request testnet tokens.
  4. Wait for the transaction to complete (it should appear in your wallet within a few seconds).

Set Up Environment Variables

  1. Export your account’s private key using your browser wallet’s account settings.
  2. Create a .env file in your project root:
Never commit your private key or mnemonic to version control. Add .env to your .gitignore file.

Write a Simple Smart Contract

  1. Create a basic storage contract contracts/SimpleStorage.sol:
  2. Compile the contract:
    This should output something like:

Testing

  1. Create a test script test/SimpleStorage.js:
  2. Run the tests:
    This should output something like:

Deploy to Plasma Testnet

  1. First, make a scripts directory:
  2. Next, create a script to deploy the contract scripts/deploy.js:
  3. Deploy the contract:
    This should output something like:
  4. Make a note of the deployed to: address. This is the address of your contract on the Plasma testnet.

Verify Deployment

  1. Copy the contract address.
  2. Visit the Plasma testnet explorer.
  3. Search for your contract address to view the deployment transaction.

Troubleshooting