您的位置:首页 > 理论基础 > 计算机网络

如何将DAPP部署到测试网络

2018-12-30 21:46 211 查看
版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。 本文链接:https://blog.csdn.net/qq_38371144/article/details/85412824
  1. 注册infura账户:https://infura.io/
  2. 生成自己的服务连接: https://ropsten.infura.io/v3/788b2b5a40bd4a168b94e24aae5346c7
  3. 下载truffle-hdwallet-provider@0.0.3 包

truffle migrate --network rospten

使用步骤

truffle.js举例

如果是web3部署,则只需要let web3 = new Web3(provider)即可

// Allows us to use ES6 in our migrations and tests.
require('babel-register')

let HDWalletProvider = require('truffle-hdwallet-provider')

// 助记词
// let mnemonic = 'candy maple cake sugar pudding cream honey rich smooth crumble sweet treat'
let mnemonic = 'scout same naive genius cannon maze differ acquire penalty habit surround ice'

let ip = 'https://ropsten.infura.io/v3/788b2b5a40bd4a168b94e24aae5346c7'

// let provider = new HDWallet(mnemonic, ip)

module.exports = {
networks: {
ganache: {
host: '127.0.0.1',
port: 7545,
network_id: '*' // Match any network id
},

ropsten: {
provider: function () {
return new HDWalletProvider(mnemonic, ip)
},
network_id: '1',
gas: 4500000,
gasPrice: 10000000000
}
}
}

执行部署

truffle migrate --network ropsten

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: