Skip to main content
TLDR:
  • Plasma is an EVM-compatible blockchain with ~1-second block times and PlasmaBFT consensus.
  • Mainnet chain ID is 9745; testnet chain ID is 9746. Currency symbol is XPL.
  • Configure MetaMask manually or use the Chainstack Connect wallet button for automatic injection.
  • Set up Hardhat or Foundry with proper network configurations to deploy smart contracts.
  • Get testnet tokens from gas.zip or through community support in Discord.

Overview

This tutorial walks through connecting your development tools to the Plasma network using a Chainstack node. You will configure MetaMask for wallet interactions, set up Hardhat and Foundry for smart contract deployment, and verify your connection is working correctly. By the end, you will have a fully configured development environment ready to deploy and interact with contracts on Plasma mainnet or testnet.

Prerequisites

Network parameters

Use these values when configuring your tools:

Mainnet

ParameterValue
Network namePlasma Mainnet
Chain ID9745
Currency symbolXPL
Block explorerhttps://plasmascan.to

Testnet

ParameterValue
Network namePlasma Testnet
Chain ID9746
Currency symbolXPL
Block explorerhttps://testnet.plasmascan.to
Replace YOUR_CHAINSTACK_ENDPOINT in all examples with your actual Chainstack HTTPS endpoint. See View node access and credentials.

Configure MetaMask

Automatic setup

On Chainstack, navigate to your Plasma node and click Connect wallet. MetaMask will prompt you to add the network with all parameters pre-filled.

Manual setup

If you prefer to add the network manually:
  1. Open MetaMask and click the network dropdown.
  2. Click Add network > Add a network manually.
  3. Enter the following values for mainnet:
    • Network name: Plasma Mainnet
    • New RPC URL: YOUR_CHAINSTACK_ENDPOINT
    • Chain ID: 9745
    • Currency symbol: XPL
    • Block explorer URL: https://plasmascan.to
  4. Click Save.
For testnet, use chain ID 9746 and block explorer https://testnet.plasmascan.to.
Your Chainstack endpoint includes authentication. Never share it publicly or commit it to version control.

Configure Hardhat

  1. Create a new project or navigate to an existing one:
    mkdir plasma-project && cd plasma-project
    npm init -y
    npm install --save-dev hardhat @nomicfoundation/hardhat-toolbox dotenv
    npx hardhat init
    
  2. Create a .env file with your credentials:
    CHAINSTACK_PLASMA_MAINNET=YOUR_CHAINSTACK_ENDPOINT
    CHAINSTACK_PLASMA_TESTNET=YOUR_CHAINSTACK_ENDPOINT
    PRIVATE_KEY=your_wallet_private_key
    
  3. Update hardhat.config.js:
    require("@nomicfoundation/hardhat-toolbox");
    require("dotenv").config();
    
    module.exports = {
      solidity: "0.8.26",
      networks: {
        plasmaMainnet: {
          url: process.env.CHAINSTACK_PLASMA_MAINNET,
          chainId: 9745,
          accounts: [process.env.PRIVATE_KEY]
        },
        plasmaTestnet: {
          url: process.env.CHAINSTACK_PLASMA_TESTNET,
          chainId: 9746,
          accounts: [process.env.PRIVATE_KEY]
        }
      },
      etherscan: {
        apiKey: {
          plasmaMainnet: "not-needed",
          plasmaTestnet: "not-needed"
        },
        customChains: [
          {
            network: "plasmaMainnet",
            chainId: 9745,
            urls: {
              apiURL: "https://plasmascan.to/api",
              browserURL: "https://plasmascan.to"
            }
          },
          {
            network: "plasmaTestnet",
            chainId: 9746,
            urls: {
              apiURL: "https://testnet.plasmascan.to/api",
              browserURL: "https://testnet.plasmascan.to"
            }
          }
        ]
      }
    };
    
  4. Test the connection:
    npx hardhat console --network plasmaTestnet
    
Never commit your .env file. Add it to .gitignore to prevent exposing your private key and endpoint credentials.

Configure Foundry

  1. Install Foundry if you haven’t already:
    curl -L https://foundry.paradigm.xyz | bash
    foundryup
    
  2. Create foundry.toml in your project root:
    [profile.default]
    src = "src"
    out = "out"
    libs = ["lib"]
    solc = "0.8.26"
    
    [rpc_endpoints]
    plasma_mainnet = "${CHAINSTACK_PLASMA_MAINNET}"
    plasma_testnet = "${CHAINSTACK_PLASMA_TESTNET}"
    
    [etherscan]
    plasma_mainnet = { key = "", chain = 9745, url = "https://plasmascan.to/api" }
    plasma_testnet = { key = "", chain = 9746, url = "https://testnet.plasmascan.to/api" }
    
  3. Test the connection using Cast:
    cast chain-id --rpc-url $CHAINSTACK_PLASMA_TESTNET
    
    Expected output: 9746
  4. Get the latest block number:
    cast block-number --rpc-url $CHAINSTACK_PLASMA_TESTNET
    

Add network programmatically

For dApps, you can prompt users to add the Plasma network automatically:
async function addPlasmaNetwork(isTestnet = false) {
  const chainId = isTestnet ? '0x2612' : '0x2611'; // 9746 or 9745 in hex
  const networkName = isTestnet ? 'Plasma Testnet' : 'Plasma Mainnet';
  const explorerUrl = isTestnet
    ? 'https://testnet.plasmascan.to'
    : 'https://plasmascan.to';
  const rpcUrl = 'YOUR_PUBLIC_RPC_OR_CHAINSTACK_ENDPOINT';

  try {
    await window.ethereum.request({
      method: 'wallet_switchEthereumChain',
      params: [{ chainId }],
    });
  } catch (switchError) {
    if (switchError.code === 4902) {
      await window.ethereum.request({
        method: 'wallet_addEthereumChain',
        params: [{
          chainId,
          chainName: networkName,
          nativeCurrency: { name: 'XPL', symbol: 'XPL', decimals: 18 },
          rpcUrls: [rpcUrl],
          blockExplorerUrls: [explorerUrl]
        }],
      });
    }
  }
}

Get testnet tokens

Before deploying contracts on testnet, you need XPL for gas fees.

Option 1: gas.zip faucet

Visit gas.zip/faucet/plasma and connect your wallet. This faucet requires some mainnet wallet activity for eligibility.

Option 2: Community support

If the faucet doesn’t work for your wallet, ask in the Plasma Discord #developers channel or DM the team members listed there.
For most testing, 0.5 XPL is sufficient to deploy multiple contracts and run hundreds of transactions.

Verify your setup

Run these checks to confirm everything is configured correctly.

Check connection with curl

curl -X POST YOUR_CHAINSTACK_ENDPOINT \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"eth_chainId","params":[],"id":1}'
Expected response for testnet:
{"jsonrpc":"2.0","id":1,"result":"0x2612"}
The result 0x2612 is the hexadecimal representation of chain ID 9746.

Check connection with web3.py

from web3 import Web3

w3 = Web3(Web3.HTTPProvider('YOUR_CHAINSTACK_ENDPOINT'))
print(f"Connected: {w3.is_connected()}")
print(f"Chain ID: {w3.eth.chain_id}")
print(f"Latest block: {w3.eth.block_number}")

Check connection with ethers.js

const { ethers } = require("ethers");

const provider = new ethers.JsonRpcProvider("YOUR_CHAINSTACK_ENDPOINT", {
  chainId: 9746,
  name: "plasma-testnet"
});

async function checkConnection() {
  const blockNumber = await provider.getBlockNumber();
  const network = await provider.getNetwork();
  console.log(`Chain ID: ${network.chainId}`);
  console.log(`Latest block: ${blockNumber}`);
}

checkConnection();

Troubleshooting

Cannot connect to RPC

  • Verify the endpoint URL has no trailing slash.
  • Check that your Chainstack node is running and synced.
  • Confirm the URL includes your authentication credentials.

Chain ID mismatch error

  • Mainnet chain ID is 9745, testnet is 9746.
  • Remove the network from MetaMask and re-add it with correct values.
  • Clear MetaMask activity data: Settings > Advanced > Clear activity tab data.

Nonce errors after switching networks

MetaMask can cache nonce data from other networks. To fix:
  1. Open MetaMask and go to Settings > Advanced.
  2. Click Clear activity tab data.
  3. Check Also reset my local nonce data.
  4. Confirm and retry your transaction.

Transaction stuck as pending

  • Click the pending transaction in MetaMask and select Speed up to increase gas.
  • Alternatively, select Cancel to drop the transaction.
  • If multiple transactions are stuck, clear activity data to reset.

Hardhat deployment fails with verification error

If your deployment script includes automatic verification and fails:
  1. Separate deployment from verification—deploy first, verify later.
  2. Remove or comment out the verification section in your deploy script.
  3. See Plasma tooling for verification commands.

Next steps

Now that your environment is configured: