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
-
Create a new project directory and initialize:
-
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.
-
Configure
hardhat.config.js for Plasma testnet:
Wallet & Testnet Setup
Add Plasma Testnet to Your Browser Wallet
- Open your browser wallet (MetaMask, Trust Wallet, or Rabby) and click the network selector.
- Select the option to add a custom network (for example, Add Network, Add manually, or Add custom network).
- 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
- Save the network and switch to the Plasma Testnet in your wallet.
Get Testnet Tokens
- Copy your wallet address from your browser wallet.
- Visit openfaucet.org.
- Enter your address and request testnet tokens.
- Wait for the transaction to complete (it should appear in your wallet within a few seconds).
Set Up Environment Variables
-
Export your account’s private key using your browser wallet’s account settings.
-
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
-
Create a basic storage contract
contracts/SimpleStorage.sol:
-
Compile the contract:
This should output something like:
Testing
-
Create a test script
test/SimpleStorage.js:
-
Run the tests:
This should output something like:
Deploy to Plasma Testnet
-
First, make a
scripts directory:
-
Next, create a script to deploy the contract
scripts/deploy.js:
-
Deploy the contract:
This should output something like:
-
Make a note of the
deployed to: address. This is the address of your contract on the Plasma testnet.
Verify Deployment
- Copy the contract address.
- Visit the Plasma testnet explorer.
- Search for your contract address to view the deployment transaction.
Troubleshooting