require("@nomiclabs/hardhat-waffle");
require('@nomiclabs/hardhat-ethers');
const { mnemonic } = require('./secrets.json');
// This is a sample Hardhat task. To learn how to create your own go to
// https://hardhat.org/guides/create-task.html
task("accounts", "Prints the list of accounts", async () => {
const accounts = await ethers.getSigners();
for (const account of accounts) {
console.log(account.address);
}
});
// You need to export an object to set up your config
// Go to https://hardhat.org/config/ to learn more
/**
* @type import('hardhat/config').HardhatUserConfig
*/
module.exports = {
defaultNetwork: "mainnet",
networks: {
localhost: {
url: "http://127.0.0.1:8545"
},
hardhat: {
},
testnet: {
url: "https://testnet.bosagora.org/",
chainId: 2019,
gasPrice: 20000000000,
accounts: {mnemonic: mnemonic}
},
mainnet: {
url: "https://mainnet.bosagora.org/",
chainId: 2151,
gasPrice: 20000000000,
accounts: {mnemonic: mnemonic}
}
},
solidity: {
version: "0.8.0",
settings: {
optimizer: {
enabled: true
}
}
},
paths: {
sources: "./contracts",
tests: "./test",
cache: "./cache",
artifacts: "./artifacts"
},
mocha: {
timeout: 20000
}
};
참고
제공자에 대해 전달되는 니모닉이 필요합니다. 이는 배포하려는 계정의 시드 구문입니다. 루트 디렉토리에 새 .secret파일을 만들고 시작하려면 12단어 니모닉 시드 구문을 입력하십시오. 메타마스크 지갑에서 시드워드를 얻으려면 메타마스크 설정으로 이동한 다음 메뉴에서 보안 및 개인정보 보호를 선택하면 시드 단어 공개라는 버튼이 표시됩니다.
스마트 컨트랙트 컴파일하기
Hardhat 프로젝트를 컴파일하려면 프로젝트가 있는 디렉토리의 루트로 변경한 후 터미널에 다음을 입력하십시오.
npx hardhat compile
Agora(BizNet)에 배포하기
프로젝트 디렉터리의 루트에서 다음 명령을 실행합니다.
npx hardhat run --network testnet scripts/deploy.js
귀하의 주소, transaction_hash 및 기타 제공된 세부 정보가 다를 수 있음을 기억하십시오. 위는 구조에 대한 아이디어를 제공하기 위한 것입니다.
축하합니다! ERC20 스마트 계약을 성공적으로 배포했습니다. 이제 스마트 계약과 상호 작용할 수 있습니다.