通过原始帖子和评论有很多不同的错误消息。我认为最好的办法是提供使用 Truffle 部署到 Rinkeby 的分步指南:
格思
首先,创建要用于此测试的帐户。看起来您已经完成了这项工作,但为了完整起见,将其包括在内。请注意,我使用的是自定义密钥库目录,因为我喜欢将我的密钥库在不同的网络中分开。
geth --rinkeby --keystore ./eth/accounts/rinkeby/keystore account new
输入密码后,您将找回您的新地址。创建帐户后,创建一个名为 pass.txt 的新文本文件,并将用于创建帐户的密码放入文件中并保存。
显然,这不是保证密码安全的首选方式。不要在现场环境中这样做
您还需要在您的帐户中添加一些以太币。使用faucet.rinkeby.io。
接下来,确保您正确地开始启动 Geth 并且它处于正确的状态。我使用自定义数据和密钥库目录。如果您愿意,可以使用默认值。
geth --rpc --datadir ./eth/geth/data/rinkeby --keystore ./eth/accounts/rinkeby/keystore --rinkeby --rpccorsdomain '*' --rpcapi 'web3,eth,net,personal' --unlock '0x25e6C81C823D4e15084F8e93F4d9B7F365C0857d' --password ./pass.txt --syncmode="full" --cache=1024
用您创建的地址替换我的地址。启动时,您应该会看到如下内容:
INFO [02-13|17:47:24] Starting peer-to-peer node instance=Geth/TrustDevTestNode/v1.7.3-stable-4bb3c89d/windows-amd64/go1.9
INFO [02-13|17:47:24] Allocated cache and file handles database=C:\\cygwin\\home\\adamk\\eth\\geth\\data\\rinkeby\\geth\\chaindata cache=1024 handles=1024
INFO [02-13|17:47:47] Initialised chain configuration config="{ChainID: 4 Homestead: 1 DAO: <nil> DAOSupport: true EIP150: 2 EIP155: 3 EIP158: 3 Byzantium: 1035301 Engine: clique}"
INFO [02-13|17:47:47] Initialising Ethereum protocol versions="[63 62]" network=4
INFO [02-13|17:47:47] Loaded most recent local header number=1766839 hash=6d71ad…ca5a95 td=3285475
INFO [02-13|17:47:47] Loaded most recent local full block number=1766839 hash=6d71ad…ca5a95 td=3285475
INFO [02-13|17:47:47] Loaded most recent local fast block number=1766839 hash=6d71ad…ca5a95 td=3285475
INFO [02-13|17:47:47] Loaded local transaction journal transactions=0 dropped=0
INFO [02-13|17:47:47] Regenerated local transaction journal transactions=0 accounts=0
INFO [02-13|17:47:48] Starting P2P networking
2018/02/13 17:47:50 ssdp: got unexpected search target result "upnp:rootdevice"
2018/02/13 17:47:50 ssdp: got unexpected search target result "uuid:2f402f80-da50-11e1-9b23-001788409545"
2018/02/13 17:47:50 ssdp: got unexpected search target result "urn:schemas-upnp-org:device:basic:1"
2018/02/13 17:47:50 ssdp: got unexpected search target result "upnp:rootdevice"
2018/02/13 17:47:50 ssdp: got unexpected search target result "uuid:2f402f80-da50-11e1-9b23-001788409545"
INFO [02-13|17:47:51] UDP listener up self=enode://751bc7825c66f9ab5b87f933d6b6302fd14434b7ed4d7c921c3f39684915843078eda4e995c927561067946b4f856ca2a35ea7285c27439c0f535338aaca80e9@172.88.30.226:30303
INFO [02-13|17:47:51] RLPx listener up self=enode://751bc7825c66f9ab5b87f933d6b6302fd14434b7ed4d7c921c3f39684915843078eda4e995c927561067946b4f856ca2a35ea7285c27439c0f535338aaca80e9@172.88.30.226:30303
INFO [02-13|17:47:51] IPC endpoint opened: \\.\pipe\geth.ipc
INFO [02-13|17:47:51] HTTP endpoint opened: http://127.0.0.1:8545
INFO [02-13|17:47:52] Unlocked account address=0x25e6C81C823D4e15084F8e93F4d9B7F365C0857d
- 确认网络 = 4。
- 确认显示正在解锁的帐户的最后一行成功且没有错误。
- 一旦您的节点启动,请确保它已完全同步。
松露
truffle.js(如果是 Windows,则为 truffle-config.js):
module.exports = {
networks: {
development: {
host: "localhost",
port: 8545,
network_id: "*" // Match any network id
},
rinkeby: {
host: "localhost",
port: 8545,
from: "0x25e6c81c823d4e15084f8e93f4d9b7f365c0857d",
network_id: "4"
}
}
};
使用 Truffle 控制台确认您的节点和帐户:
$ truffle console --network rinkeby
truffle(rinkeby)> web3.eth.blockNumber
1767136 // Confirm latest block number on https://rinkeby.etherscan.io/
truffle(rinkeby)> web3.eth.getBalance('0x25e6c81c823d4e15084f8e93f4d9b7f365c0857d');
{ [String: '2956062100000000000'] s: 1, e: 18, c: [ 29560, 62100000000000 ] }
退出控制台并运行您的编译/迁移(这将需要大约一分钟才能运行):
$ truffle migrate --network rinkeby
Compiling .\contracts\LoopExample.sol...
Writing artifacts to .\build\contracts
Using network 'rinkeby'.
Running migration: 1_initial_migration.js
Deploying Migrations...
... 0xf377be391a2eaff821c0405256c6a1f50389650ea9754bdc2711296b02533e02
Migrations: 0x9cef8d8959d0611046d5144ec0439473ad842c7c
Saving successful migration to network...
... 0x4cf989973ea56a9aa4477effaccd9b59bfb80cc0e0e1b7878ff25fa5cae328db
Saving artifacts...
Running migration: 2_deploy_contracts.js
Deploying LoopExample...
... 0x4977c60fd86e1c4ab09d8f970be7b7827ee25245575bfbe206c19c6b065e9031
LoopExample: 0x56b9c563f287cdd6a9a41e4678ceeeb6fc56e104
Saving successful migration to network...
... 0x5628d64dc43708ccb30d7754a440e8e420a82a7b3770539cb94302fe7ad9098f
Saving artifacts...
在 etherscan 上确认部署:https ://rinkeby.etherscan.io/address/0x56b9c563f287cdd6a9a41e4678ceeeb6fc56e104