1.首先在测试网络通过水龙头1 水龙头2获取一些代币。
2.在Remix中选择不同的部署网络,并部署
3.然后在Metamask中点击确定
4.获取ABI
5.在MyEtherWallet中初始化合约调用
Truffle+Infura
1.注册Infura账户
2.下载插件
1
| npm install -g truffle-hdwallet-provider
|
3.将truffle的网络配置换为infura的网络
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| # 编辑文件 vim truffle.js var HDWalletProvider = require("truffle-hdwallet-provider");
var infura_apikey = ""; var mnemonic = "";
module.exports = { // See <http://truffleframework.com/docs/advanced/configuration> // to customize your Truffle configuration! networks: { development: { host: "127.0.0.1", port: 8545, network_id: "*" }, ropsten: { provider: function() { return new HDWalletProvider(mnemonic, "https://ropsten.infura.io/"+infura_apikey) }, network_id: 3, gas: 3012388, gasPrice: 30000000000 }, main: { provider: function() { return new HDWalletProvider(mnemonic, "https://mainnet.infura.io/"+infura_apikey) }, network_id: 3, gas: 21000, gasPrice: 1000000000 } } };
# 编译 truffle compile # 部署 truffle migrate --reset --network ropsten
|
Truffle + Etherum Full Node (Geth,Parity)
1.本地下载以太坊的全节点。
2.部署时选用main的主配置。
1 2 3 4 5 6
| vim truffle.js main: { host: "127.0.0.1", port: 8545, network_id: "*" }
|