因为在外地,草草了结吧,把凌晨4点,当做昨天来算。
truffle+infura部署合约到ropsten
infura的接口好卡,本地测试很快的,上ropsten搞了好久。
首先需要配置truffle-config.js
ropsten: {
provider: new HDWalletProvider(mnemonic, net),
network_id: 3, // Ropsten's id
gas: 8000029, // Ropsten has a lower block limit than mainnet
gasPrice: 100000000000,
networkCheckTimeout: 600000,
confirmations: 2, // # of confs to wait between deployments. (default: 0)
timeoutBlocks: 200, // # of blocks before a deployment times out (minimum/default: 50)
skipDryRun: true // Skip dry run before migrations? (default: false for public nets )
},
这里mnemonic和net分别是私钥和infura接口
gasprice不用设这么高的
安装@truffle/hdwallet-provider:
npm install @truffle/hdwallet-provider
只要npm和web3装过了就行了,如果报error的错误不要管。
然后在部署到指定网络:
truffle migrate --network ropsten