Deploy with Foundry

After connecting to the Plume testnet and funding your wallet with bridged SepoliaETH, you can easily deploy any EVM-compatible smart contract using the same tools used in Ethereum, Arbitrum, Optimism, and Polygon development.

Network Parameters

All tools will require that you provide some or all of the Plume testnet network parameters so they can deploy to the testnet. You can refer to them here:

NameValue

Network Name

Plume Testnet

HTTP RPC URL

WebSockets RPC URL

Chain ID

161221135

Currency Symbol

ETH

Block Explorer URL

Foundry Setup

Foundry is a Solidity framework for deploying smart contracts, built by Paradigm and written in Rust to be blazingly fast. Simply follow their "Getting Started" documentation to install and run Foundry, then follow their "Projects" documentation to create a new project:

$ curl -L https://foundry.paradigm.xyz | bash
$ foundryup
$ forge init

Let's write a simple one-of-one NFT contract based on OpenZeppelin's open-source ERC-721 implementation to tokenize our CBO's prized Rolex watch on Plume. First, install the dependency on OpenZeppelin:

$ forge install openzeppelin/openzeppelin-contracts@v4.9.5

Note that we must use an older version of the OpenZeppelin contracts because the Plume testnet doesn't support Solidity compiler versions 0.8.20 and above, which is the minimum compiler version in v5 of the OpenZeppelin contracts.

Save this smart contract in src/RolexYachtMaster40.sol then run forge build to compile it:

// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

import {Ownable} from "lib/openzeppelin-contracts/contracts/access/Ownable.sol";
import {ERC721} from "lib/openzeppelin-contracts/contracts/token/ERC721/ERC721.sol";

contract RolexYachtMaster40 is Ownable, ERC721 {
    error NFTAlreadyMinted();
    bool private _minted;

    constructor() ERC721("Rolex Yacht-Master 40", "") {}

    function mint(address owner) public onlyOwner returns (uint256) {
        if (_minted) {
            revert NFTAlreadyMinted();
        }
        _safeMint(owner, 0);
        _minted = true;
        return 0;
    }
}

Deploy NFT Contract

To deploy your smart contract to the Plume testnet with Foundry, follow the instructions in the "Deploying" documentation and set your ETH_RPC_URL environment variable to the Plume RPC URL. We have to add the --legacy flag because Foundry has a bug with gas estimation on L2s.

$ export ETH_RPC_URL=https://testnet-rpc.plumenetwork.xyz/http
$ export PRIVATE_KEY=<your_plume_private_key>
$ forge create src/RolexYachtMaster40.sol:RolexYachtMaster40 \
    --rpc-url $ETH_RPC_URL --private-key $PRIVATE_KEY --legacy
[⠢] Compiling...
[⠒] Compiling 1 files with 0.8.19
[⠑] Compiler run successful!
[⠘] Solc 0.8.19 finished in 435.45ms
Deployer: 0x96774F9f5693dFb95c973b676DFE6EaFc6f95E6d
Deployed to: 0x2094274284904Fa7EF04cd9912392E495c980974
Transaction hash: 0x651ed7b05933ca2cbac061316b707bc6ea830c2648ff5d5edbfeb0b08ed7bd59

You can see the resulting smart contract on the Plume block explorer.

Verify NFT Contract

The Plume testnet block explorer is built using Blockscout's open-source technology, and supports verification of contracts via its Etherscan-compatible API. See the "Smart Contract Verification" section for more details.

To verify your smart contract, follow the instructions in Blockscout's "Foundry Contract Verification" page. Make sure to add the extra \? to the end of the verified URL, otherwise the verification will fail:

$ export ETH_RPC_URL=https://testnet-rpc.plumenetwork.xyz/http
$ export VERIFIER_URL=https://testnet-explorer.plumenetwork.xyz/api\?
$ export PRIVATE_KEY=<your_plume_private_key>
$ forge create src/RolexYachtMaster40.sol:RolexYachtMaster40 \
    --rpc-url $ETH_RPC_URL --private-key $PRIVATE_KEY --legacy \
    --verify --verifier blockscout --verifier-url $VERIFIER_URL
[⠢] Compiling...No files changed, compilation skipped
[⠆] Compiling...
Deployer: 0x96774F9f5693dFb95c973b676DFE6EaFc6f95E6d
Deployed to: 0x41b5Bd0dFC1EF2d73630D3676867eA328b6E7706
Transaction hash: 0x6e20a2d47c2c8c255e983484c56e459409317bd85472ad9d699a65d45fd71251
Starting contract verification...
Waiting for blockscout to detect contract deployment...
Start verifying contract `0x41b5Bd0dFC1EF2d73630D3676867eA328b6E7706` deployed on 161221135

Submitting verification for [src/RolexYachtMaster40.sol:RolexYachtMaster40] 0x41b5Bd0dFC1EF2d73630D3676867eA328b6E7706.
Submitted contract for verification:
        Response: `OK`
        GUID: `41b5bd0dfc1ef2d73630d3676867ea328b6e770665c10e39`
        URL:
        https://testnet-explorer.plumenetwork.xyz/address/0x41b5bd0dfc1ef2d73630d3676867ea328b6e7706
Contract verification status:
Response: `OK`
Details: `Unknown UID`

You can see the resulting verified smart contract on the Plume block explorer.

Fork testing

Run the following, additionally you can parse flags like --fork-block-number 1 to set the block number

$ forge test --fork-url https://plume-testnet.rpc.caldera.xyz/http

Common issues

You may run into errors with gas estimation when deploying using Foundry. To circumvent that, ensure that:

  • Your foundry.toml explicitly sets EVM version

    evm_version = "paris"
  • Your forge create or deployment script has these flags

    --legacy --skip-simulation

Last updated