无法将Solidity Contract部署到Rinkeby网络(无效的asm.js:无效的stdlib成员)

时间:2019-05-20 23:19:56

标签: javascript node.js node-modules ethereum solidity

我一直在使用Stephen Grider的this course来学习Solidity,直到现在我一直在努力,在那里我正尝试将my code部署到Rinkeby测试网络。

作为参考,我将Node 11.15.0和npm 6.7.0与以下依赖项结合使用:

"dependencies": {
    "ganache-cli": "^6.4.3",
    "mocha": "^6.1.4",
    "nan": "^2.14.0",
    "scrypt": "^6.0.3",
    "solc": "^0.4.25",
    "truffle": "^4.1.15",
    "truffle-hdwallet-provider": "0.0.4",
    "web3": "^1.0.0-beta.35" }

我花了数小时在Node.js版本,npm版本和各种依赖关系组合之间进行切换,从最新版本到课程中指定的版本。当我遇到许多问题时,最突出的两个问题似乎是

(node:32436) V8: C:\Desktop\solidity\inbox\node_modules\solc\soljson.js:3 Invalid asm.js: Invalid member of stdlib

C:\Desktop\solidity\inbox\node_modules\solc\soljson.js:1
var Module;if(!Module)Module=(typeof Module!=="undefined"?Module:null)||{};var moduleOverrides={};for(var key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}var ENVIRONMENT_IS_WEB=typeof window==="object";var ENVIRONMENT_IS_WORKER=typeof importScripts==="function";var ENVIRONMENT_IS_NODE=typeof process==="object"&&typeof require==="function"&&!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_WORKER;var ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER;if(ENVIRONMENT_IS_NODE){if(!Module["print"])Module["print"]=function print(x){process["stdout"].write(x+"\n")};if(!Module["printErr"])Module["printErr"]=function printErr(x){process["stderr"].write(x+"\n")};var nodeFS=require("fs");var nodePath=require("path");Module["read"]=function read(filename,binary){filename=nodePath["normalize"](filename);var ret=nodeFS["readFileSync"](filename);if(!ret&&filename!=nodePath["resolve"](filename)){filename=path.joi

Error: CONNECTION ERROR: Couldn't connect to node rinkeby.infura.io/v3/acb10732334e4450ba7dc55e618eb70a.
    at Object.InvalidConnection (C:\Desktop\solidity\inbox\node_modules\truffle-hdwallet-provider\node_modules\web3\lib\web3\errors.js:28:16)
    at HttpProvider.sendAsync (C:\Desktop\solidity\inbox\node_modules\truffle-hdwallet-provider\node_modules\web3\lib\web3\httpprovider.js:129:25)
    at Web3Subprovider.handleRequest (C:\Desktop\solidity\inbox\node_modules\web3-provider-engine\subproviders\web3.js:13:17)
    at next (C:\Desktop\solidity\inbox\node_modules\web3-provider-engine\index.js:95:18)
    at FilterSubprovider.handleRequest (C:\Desktop\solidity\inbox\node_modules\web3-provider-engine\subproviders\filters.js:87:7)
    at next (C:\Desktop\solidity\inbox\node_modules\web3-provider-engine\index.js:95:18)
    at HookedWalletSubprovider.handleRequest (C:\Desktop\solidity\inbox\node_modules\web3-provider-engine\subproviders\hooked-wallet.js:109:7)
    at next (C:\Desktop\solidity\inbox\node_modules\web3-provider-engine\index.js:95:18)
    at Web3ProviderEngine._handleAsync (C:\Desktop\solidity\inbox\node_modules\web3-provider-engine\index.js:82:3)
    at Web3ProviderEngine._fetchBlock (C:\Desktop\solidity\inbox\node_modules\web3-provider-engine\index.js:191:8)
    at Web3ProviderEngine._fetchLatestBlock (C:\Desktop\solidity\inbox\node_modules\web3-provider-engine\index.js:167:8)
    at Web3ProviderEngine._startPolling (C:\Desktop\solidity\inbox\node_modules\web3-provider-engine\index.js:144:8)
    at Web3ProviderEngine.start (C:\Desktop\solidity\inbox\node_modules\web3-provider-engine\index.js:38:8)
    at new HDWalletProvider (C:\Desktop\solidity\inbox\node_modules\truffle-hdwallet-provider\index.js:46:15)
    at Object.<anonymous> (C:\Desktop\solidity\inbox\deploy.js:6:18)
    at Module._compile (internal/modules/cjs/loader.js:816:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:827:10)
    at Module.load (internal/modules/cjs/loader.js:685:32)
    at Function.Module._load (internal/modules/cjs/loader.js:620:12)
    at Function.Module.runMain (internal/modules/cjs/loader.js:877:12)
    at internal/main/run_main_module.js:21:11

我的问题是根据我的代码是否有针对这些问题的任何修复程序,或者是否有更简单的方法来部署到区块链?预先谢谢你。

3 个答案:

答案 0 :(得分:1)

  

Office.context.mailbox.subject.setAsync -> Office.context.mailbox.item.subject.setAsync Office.context.mailbox.body.setAsync -> Office.context.mailbox.item.body.setAsync

您可能是说Error: CONNECTION ERROR: Couldn't connect to node rinkeby.infura.io/v3/acb10732334e4450ba7dc55e618eb70a.(您错过了https://rinkeby.infura.io/...。)

答案 1 :(得分:0)

我遵循与 OP 相同的教程。如果您使用的是 node v14.15.4 和 npm v6.14.10,我想确认以下 package.json 解决了这个问题:

{
  "name": "inbox",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "mocha"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "ganache-cli": "^6.4.3",
    "mocha": "^6.1.4",
    "solc": "^0.4.25",
    "truffle-hdwallet-provider": "0.0.4",
    "web3": "^1.0.0-beta.35"
  }
}

然后通过删除您的项目的 node_modules 来重建您的依赖项,然后运行

npm install

答案 2 :(得分:-1)

也跟随上述课程。我能够按照 user1506104 的建议解决这个问题。删除 node_modules,并使用 web3 ^1.0.0-beta.35 和 solc ^0.4.25 重新编写 package-lock.json,然后运行 ​​npm install。