合约尚未部署到 Rinkeby Network 上检测到的网络(网络/工件不匹配)

Sho*_*310 5 ethereum smartcontracts truffle consensys-truffle

我一直遇到标题中指定的。

我开发了一个智能合约并成功编译并部署到网络如下: 1. 运行 testrpc 2. truffle compile 3. truffle migrate

但是,仍然显示上述错误。然后我尝试删除构建文件并按照以下步骤操作: 1. 运行 testrpc 2. truffle compile 3. truffle migrate --network rinkeby

错误仍然显示。

下面是 truffle.js 文件

module.exports = {
  migrations_directory: "./migrations",
  networks: {
development: {
  host: "localhost",
  port: 8545,
  network_id: "*" // Match any network id
},
rinkeby: {
  host: "localhost", // Connect to geth on the specified
  port: 8545, 
  network_id: "*",
}
Run Code Online (Sandbox Code Playgroud)

} };

如果有人遇到任何类似的问题并已解决,如果您能分享您是如何解决的,我将不胜感激。

提前致谢

Eri*_*tel 14

对我来说,以下步骤有效:使用代码在迁移文件夹中创建文件 2_deploy_contract.js

var myContract = artifacts.require("myContract");

module.exports = function(deployer){
  deployer.deploy(myContract);
}
Run Code Online (Sandbox Code Playgroud)

并在终端上运行

$ truffle migrate --reset
Run Code Online (Sandbox Code Playgroud)

我不需要更改 truffle-config.js 中的任何设置


小智 5

我遇到了同样的问题,并使用以下代码在迁移文件夹中创建了文件 2_deploy_contract.js:

var myContract = artifacts.require("myContract");

module.exports = function(deployer){
  deployer.deploy(myContract);
}
Run Code Online (Sandbox Code Playgroud)

我还使用默认设置检查了文件夹根目录下的 truffle-config.js:

rinkeby: {
  host: "localhost", 
  port: 8545, 
  from: "0x0085f8e72391Ce4BB5ce47541C846d059399fA6c", // default address to use for any transaction Truffle makes during migrations
  network_id: 4,
  gas: 4612388 // Gas limit used for deploys
}
Run Code Online (Sandbox Code Playgroud)


Ada*_*nis 0

通过原始帖子和评论,有很多不同的错误消息。我认为最好的办法是提供使用 Truffle 部署到 Rinkeby 的分步指南:

\n\n

盖斯

\n\n

首先,创建您要用于此测试的帐户。看起来您已经完成了此操作,但为了完整性而将其包括在内。请注意,我使用自定义密钥库目录,因为我喜欢在不同网络之间保持我的密钥库独立。

\n\n

geth --rinkeby --keystore ./eth/accounts/rinkeby/keystore account new

\n\n

输入密码后,您将取回您的新地址。创建帐户后,创建一个名为 pass.txt 的新文本文件,并将用于创建帐户的密码放入该文件中并保存。

\n\n

显然这不是保证密码安全的首选方法。不要在现场环境中执行此操作

\n\n

您还需要向您的帐户添加一些以太币。使用faucet.rinkeby.io

\n\n

接下来,确保您正确启动 Geth 并且它处于正确的状态。我使用自定义数据和密钥库目录。如果您选择,可以使用默认值。

\n\n
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\n
Run Code Online (Sandbox Code Playgroud)\n\n

将我的地址替换为您创建的地址。开始时,您应该看到类似这样的内容:

\n\n
INFO [02-13|17:47:24] Starting peer-to-peer node               instance=Geth/TrustDevTestNode/v1.7.3-stable-4bb3c89d/windows-amd64/go1.9\nINFO [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\nINFO [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}"\nINFO [02-13|17:47:47] Initialising Ethereum protocol           versions="[63 62]" network=4\nINFO [02-13|17:47:47] Loaded most recent local header          number=1766839 hash=6d71ad\xe2\x80\xa6ca5a95 td=3285475\nINFO [02-13|17:47:47] Loaded most recent local full block      number=1766839 hash=6d71ad\xe2\x80\xa6ca5a95 td=3285475\nINFO [02-13|17:47:47] Loaded most recent local fast block      number=1766839 hash=6d71ad\xe2\x80\xa6ca5a95 td=3285475\nINFO [02-13|17:47:47] Loaded local transaction journal         transactions=0 dropped=0\nINFO [02-13|17:47:47] Regenerated local transaction journal    transactions=0 accounts=0\nINFO [02-13|17:47:48] Starting P2P networking\n2018/02/13 17:47:50 ssdp: got unexpected search target result "upnp:rootdevice"\n2018/02/13 17:47:50 ssdp: got unexpected search target result "uuid:2f402f80-da50-11e1-9b23-001788409545"\n2018/02/13 17:47:50 ssdp: got unexpected search target result "urn:schemas-upnp-org:device:basic:1"\n2018/02/13 17:47:50 ssdp: got unexpected search target result "upnp:rootdevice"\n2018/02/13 17:47:50 ssdp: got unexpected search target result "uuid:2f402f80-da50-11e1-9b23-001788409545"\nINFO [02-13|17:47:51] UDP listener up                          self=enode://751bc7825c66f9ab5b87f933d6b6302fd14434b7ed4d7c921c3f39684915843078eda4e995c927561067946b4f856ca2a35ea7285c27439c0f535338aaca80e9@172.88.30.226:30303\nINFO [02-13|17:47:51] RLPx listener up                         self=enode://751bc7825c66f9ab5b87f933d6b6302fd14434b7ed4d7c921c3f39684915843078eda4e995c927561067946b4f856ca2a35ea7285c27439c0f535338aaca80e9@172.88.30.226:30303\nINFO [02-13|17:47:51] IPC endpoint opened: \\\\.\\pipe\\geth.ipc\nINFO [02-13|17:47:51] HTTP endpoint opened: http://127.0.0.1:8545\nINFO [02-13|17:47:52] Unlocked account                         address=0x25e6C81C823D4e15084F8e93F4d9B7F365C0857d\n
Run Code Online (Sandbox Code Playgroud)\n\n
    \n
  • 确认网络=4。
  • \n
  • 确认显示帐户解锁的最后一行成功且没有错误。
  • \n
  • 节点启动后,请确保其完全同步。
  • \n
\n\n

松露

\n\n

truffle.js(如果是 Windows,则为 truffle-config.js):

\n\n
module.exports = {\n  networks: {\n    development: {\n      host: "localhost",\n      port: 8545,\n      network_id: "*" // Match any network id\n    },\n    rinkeby: {\n      host: "localhost",\n      port: 8545,\n      from: "0x25e6c81c823d4e15084f8e93f4d9b7f365c0857d",\n      network_id: "4"\n    }\n  }\n};\n
Run Code Online (Sandbox Code Playgroud)\n\n

使用 Truffle 控制台确认您的节点和帐户:

\n\n
$ truffle console --network rinkeby\ntruffle(rinkeby)> web3.eth.blockNumber\n1767136 // Confirm latest block number on https://rinkeby.etherscan.io/\ntruffle(rinkeby)> web3.eth.getBalance(\'0x25e6c81c823d4e15084f8e93f4d9b7f365c0857d\');\n{ [String: \'2956062100000000000\'] s: 1, e: 18, c: [ 29560, 62100000000000 ] }\n
Run Code Online (Sandbox Code Playgroud)\n\n

退出控制台并运行编译/迁移(运行大约需要一分钟):

\n\n
$ truffle migrate --network rinkeby\nCompiling .\\contracts\\LoopExample.sol...\nWriting artifacts to .\\build\\contracts\n\nUsing network \'rinkeby\'.\n\nRunning migration: 1_initial_migration.js\n  Deploying Migrations...\n  ... 0xf377be391a2eaff821c0405256c6a1f50389650ea9754bdc2711296b02533e02\n  Migrations: 0x9cef8d8959d0611046d5144ec0439473ad842c7c\nSaving successful migration to network...\n  ... 0x4cf989973ea56a9aa4477effaccd9b59bfb80cc0e0e1b7878ff25fa5cae328db\nSaving artifacts...\nRunning migration: 2_deploy_contracts.js\n  Deploying LoopExample...\n  ... 0x4977c60fd86e1c4ab09d8f970be7b7827ee25245575bfbe206c19c6b065e9031\n  LoopExample: 0x56b9c563f287cdd6a9a41e4678ceeeb6fc56e104\nSaving successful migration to network...\n  ... 0x5628d64dc43708ccb30d7754a440e8e420a82a7b3770539cb94302fe7ad9098f\nSaving artifacts...\n
Run Code Online (Sandbox Code Playgroud)\n\n

确认 etherscan 上的部署:https://rinkeby.etherscan.io/address/0x56b9c563f287cdd6a9a41e4678ceeeb6fc56e104

\n