The contracts of newton.
git clone --recurse-submodules https://github.com/newtonproject/contracts.git
npm install --save-dev hardhat
npx hardhat
npx hardhat accounts
npx hardhat compile
npx hardhat test
在script
目录中,有js引用的部署入口
npx hardhat run scripts/sample-script.js
启动内置节点
npx hardhat node
npx hardhat run scripts/sample-script.js --network localhost
要设置配置,您必须从中导出一个对象hardhat.config.js eg:
module.exports = {
defaultNetwork: "rinkeby",
networks: {
hardhat: {
},
rinkeby: {
url: "https://eth-mainnet.alchemyapi.io/v2/123abc123abc123abc123abc123abcde",
accounts: [privateKey1, privateKey2, ...]
}
},
solidity: {
version: "0.5.15",
settings: {
optimizer: {
enabled: true,
runs: 200
}
}
},
paths: {
sources: "./contracts",
tests: "./test",
cache: "./cache",
artifacts: "./artifacts"
},
mocha: {
timeout: 20000
}
}
编译完成之后,可以在 artifacts/contracts/SampleERC721.sol/SampleERC721.json
中获取 abi
和 bin
信息,
使用 tokenCommander 部署到 newchain
tokenCommander deploy --abi {abiPath} --bin {binPath} --name SampleERC721 TOKEN_NAME TOKEN_SYMBOL