Hardhat Conflux 插件
Hardhat is an exceptional tool for building smart contracts. It serves as a development environment, testing framework, and asset pipeline for Ethereum-like blockchains, such as Conflux. The Hardhat Conflux Plugin adds Conflux Core Space support to Hardhat.
Developers can use Hardhat to compile Solidity code and the Hardhat-Conflux plugin to deploy, interact with, and test contracts on Core Space.
The Hardhat-Conflux plugin is built on top of js-conflux-sdk
, making its usage for deployment and interaction very similar to that of js-conflux-sdk
.
如果您不熟悉 Hardhat,请参考 Hardhat 文档。
安装
After installing Hardhat, you can install the plugin with:
npm install hardhat-conflux js-conflux-sdk
Configuration
First, import the plugin in your hardhat.config.js
:
require("hardhat-conflux");
Or in hardhat.config.ts
:
import "hardhat-conflux";
Then, add the Conflux network to your hardhat.config.js
:
const PRIVATE_KEY = "0x0123456789012345678901234567890123456789012345678901234567890123"; // replace with your private key
module.exports = {
defaultNetwork: "cfxTestnet",
networks: {
cfx: {
url: "https://main.confluxrpc.com",
accounts: [PRIVATE_KEY],
chainId: 1029,
},
cfxTestnet: {
url: "https://test.confluxrpc.com",
accounts: [PRIVATE_KEY],
chainId: 1,
},
}
}
If your configuration file is hardhat.config.ts
, the settings are similar.
Ensure that the private key's account you use has enough balance to interact with Core Space. If not, you can use the faucet to obtain some test tokens.