Migrate 文件
1 导入合约的2种形式
const openherobox = await OpenHeroBox.deployed();
const openherobox = await OpenHeroBox.at("0x159275AE3cA6354f7F23FF8CA9fFEc2B00257F9E");
2 部署
普通部署
const hero = await deployProxy(HERO, [], {deployer, kind:"uups"});
uups部署
const openherobox = await OpenHeroBox.deployed();
3 调用方法
await hero .grantRole("0x9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a6", openherobox.address);
await hero.hasRole.call(myAddress);
4 打印
console.log("OpenBox", );
配置文件
验证合约
npm truffle-plugin-verify 插件
可配置代理
verify: {
proxy: {
host: '127.0.0.1',
port: '1081'
}
}
网络配置
mnemonic = "私钥"
bsctest: {
networkCheckTimeout: 1000*60000,
provider: () => new HDWalletProvider(mnemonic, `https://data-seed-prebsc-2-s3.binance.org:8545/`),
network_id: 97,
confirmations: 2,
timeoutBlocks: 20000,
skipDryRun: true,
deploymentPollingInterval: 5000,
gas: 18500000,
gasPrice: 10000000000, // 20 gwei (in wei) (default: 100 gwei)
},
测试文件
需要先部署合约
migrate 出现
{
code: -32603,
message: 'ETIMEDOUT',
data: { originalError: { code: 'ETIMEDOUT', connect: true } }
}
解决方案 : 取消编译过程 migrate --compile-none