yarn hardhat
const { ethers } = require("hardhat"); async function main() { const contractFactory = await ethers.getContractFactory("SimpleStorage"); const contract = await contractFactory.deploy(); console.log(contract.address); await contract.deployed(); } main() .then(() => { process.exit(0); }) .catch((error) => { console.error(error); process.exit(1); });
package.json
{ "dependencies": { "dotenv": "^16.0.3", "ethers": "^5.7.1", "fs-extra": "^10.1.0", "prettier": "^2.7.1", "prettier-plugin-solidity": "^1.0.0-beta.24", "solc": "0.8.7-fixed" }, "scripts": { "compile": "yarn solcjs --bin --abi --include-path node_modules/ --base-path . -o . SimpleStorage.sol" } }
官网:ganache
Quickly fire up a personal Ethereum blockchain which you can use to run tests, execute commands, and inspect state while controlling how the chain operates.
官网: https://learnblockchain.cn/docs/ethers.js/
ethers.js 库是为以太坊 提供的一个的小而完整的 JavaScript 库。
npm install --save ethers
const ethers = require('ethers');
地点:搜狐新媒体大厦