Deploy with Hardhat
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.
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:
Hardhat Setup
Hardhat is a Node.js framework for deploying smart contracts, built by the non-profit Nomic Foundation as an open-source public good. Simply follow their "Getting Started" documentation to create a new Node.js project and install Hardhat. We'll also install the Nomic Foundation's hardhat-ethers
plugin, which adds ethers.js
to the Hardhat Runtime Environment and allows us to write scripts to interact with the chain.
Select "Create an empty hardhat.config.js
", as we will be writing our own smart contracts from scratch. 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:
Make the following adjustments to the auto-generated hardhat.config.js
file to prepare to deploy to the Plume testnet:
Import the
hardhat-ethers
plugin into the Hardhat Runtime Environment.In order to use the latest version of the OpenZeppelin contracts, make sure that the Solidity compiler version is
0.8.20
or above.Add the Plume testnet network parameters. You can store your testnet private keys directly in the configuration file, load it from an environment file using
dotenv
, or manually runexport PRIVATE_KEY=...
before executing the following commands.
Now, save the following smart contract in contracts/RolexYachtMaster40.sol
. If you plan to verify this contract, insert your name into the comment on line 2 so that the uploaded source code is different from anyone else that is following this guide. Run npx hardhat compile
to compile it:
Deploy NFT Contract
To deploy your smart contract to the Plume testnet with Hardhat, follow the instructions in the "Deploying Your Contracts" documentation. For example, you can save the following deployment script to scripts/deploy.js
:
After double checking that your private key is accessible to Hardhat and plume-testnet
is correctly configured in hardhat.config.js
, simply run the deployment script:
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 the hardhat-verify
plugin using its Etherscan-compatible API. See the "Smart Contract Verification" section for more details.
To verify your smart contract, follow the instructions in Blockscout's "Hardhat Verification Plugin" page. Note that the hardhat-etherscan
plugin in those docs has been renamed to hardhat-verify
, which you will have to install:
Make the following adjustments to your existing hardhat.config.js
file:
Import the
hardhat-verify
plugin into the Hardhat Runtime Environment.Unlike Etherscan, Blockscout does not require an API key, but the
hardhat-verify
plugin requires that you put in any non-empty string, so we can just use"test"
as a placeholder.Add the Plume testnet block explorer URLs. Make sure to add the extra
\?
to the end of the API URL, otherwise the verification will fail.
Let's verify our existing contract by saving our constructor arguments (i.e. the deployer's address) to an environment variable and running the verify
command on the previously deployed contract address:
You can see the resulting verified smart contract code on the Plume block explorer.
Fork Testing
To deploy smart contracts on a fork of Plume Testnet, make sure to install Hardhat with the unknown-txs
tag on version 2.20.x:
Compile using this Hardhat version and the following to your hardhat.config.js
in networks
:
Run the forked node:
Last updated