Published: 28 Aug 2021 › Updated: 28 Aug 2021
Polygon Mumbai测试网布署合约 / 学习智能合约#48
https://mumbai.polygonscan.com
Polygon生态发展得挺不错,可以算是成熟的layer2了。再加上它的矿工费是以太坊的万分之一吧,是现在开发应用的不二选择。我最近开发的项目就准备直接在Polygon上布署。
先试试测试网Mumbai。找到水龙头申请点测试币。再使用truffle把开发好的合约布署到测试网上。
找到开发手册,找准参数这些,如下:
const HDWalletProvider = require('@truffle/hdwallet-provider');
const fs = require('fs');
const mnemonic = fs.readFileSync(".secret").toString().trim();
module.exports = {
networks: {
development: {
host: "127.0.0.1", // Localhost (default: none)
port: 8545, // Standard Ethereum port (default: none)
network_id: "*", // Any network (default: none)
},
mumbai: {
provider: () => new HDWalletProvider(mnemonic, `https://rpc-mumbai.matic.today`),
network_id: 80001,
confirmations: 2,
timeoutBlocks: 200,
skipDryRun: true
},
},
直接拷进truffle.js中试试,貌似布署失败,总是报错,试了多次也不行!找找以太坊上的参数,对照着看看,对timout、gagPrice这两个参数没设置,是不是这两个参数的原因呢?把它们加上,再试试,结果一切正常!正确的配置如下:
const HDWalletProvider = require('@truffle/hdwallet-provider');
const fs = require('fs');
const mnemonic = fs.readFileSync(".secret").toString().trim();
module.exports = {
networks: {
mumbai: {
provider: () => new HDWalletProvider(mnemonic, `https://rpc-mumbai.matic.today`),
network_id: 80001,
confirmations: 2,
timeoutBlocks: 200,
skipDryRun: true,
networkCheckTimeout: 10000000,
gasPrice: 30000000000
},
},
对于新手来说,还是蛮多坑点的,多参照多尝试才能找到正确答案!
Leave Polygon Mumbai测试网布署合约 / 学习智能合约#48 to:
Read more #smartcontract posts
Best Posts From lemooljiang
We have not curated any of lemooljiang's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.