Skip to content

conflux-fans/espace-contract-guide

Repository files navigation

eSpace contract guide

This project provides basic template for deploying and verifying contracts on Conflux eSpace testnet using hardhat or foundry.

Hardhat

The hardhat project is a basic template for deploying and verifying contracts on Conflux eSpace testnet. It comes with a sample contract, a test for that contract, and a script that deploys that contract.

Setup

Create .env file in the root directory from .env.example and update the PRIVATE_KEY with your dev private key. Make sure it has some eSpace testnet CFX.

Note: You can get some testnet CFX from eSpace faucet

Install dependencies

yarn

Common hardhat tasks

After installing the dependencies(npm install or yarn), try running some of the following tasks:

npx hardhat help
npx hardhat test
REPORT_GAS=true npx hardhat test
npx hardhat node
npx hardhat run scripts/deploy.ts

Deploy in eSpace

npx hardhat run scripts/deploy.ts --network espaceTestnet

Verify in eSpace

npx hardhat verify --network espaceTestnet <contract address> <space separated constructor parameters>

For example, if you get following message for deploying Lock contract:

Lock with 0.001ETH and unlock timestamp 1735008251 deployed to 0x8771b69CFE2c774Ea93eD65DE042CD20bcbf1319

You can verify the contract by running (as 1735008251 is the constructor parameter):

npx hardhat verify --network espaceTestnet 0x8771b69CFE2c774Ea93eD65DE042CD20bcbf1319 1735008251

Foundry

Setup

Remember to init all submodules

git submodule update --init --recursive
curl -L https://foundry.paradigm.xyz | bash
foundryup

Build

forge build

Test

forge test

Deploy

forge script scripts/Deploy.s.sol --rpc-url conflux_testnet --broadcast -g 200

The -g 200 is the gas multiplier, which is used to estimate the gas cost. It is set to 200, whereas 200%, because Conflux eSpace has a different opcode gas cost setting compared to Ethereum, this setting would make sure the deployment is successful.

Verify

Currently there is an API break with foundry command line verification, please check verification for the latest progress.

Resources

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •