diff --git a/lib/core/modules/coderunner/runCode.js b/lib/core/modules/coderunner/runCode.js index 746dd0d5..236bc00b 100644 --- a/lib/core/modules/coderunner/runCode.js +++ b/lib/core/modules/coderunner/runCode.js @@ -29,7 +29,16 @@ class RunCode { } getWeb3Config() { - return {defaultAccount: this.context.web3.eth.defaultAccount, providerUrl: this.context.web3.currentProvider.connection._url}; + const Web3 = require('web3'); + const provider = this.context.web3.currentProvider; + let providerUrl; + if(provider instanceof Web3.providers.HttpProvider){ + providerUrl = provider.host; + } + else if(provider instanceof Web3.provider.WebsocketProvider){ + providerUrl = provider.connection._url; + } + return {defaultAccount: this.context.web3.eth.defaultAccount, providerUrl: providerUrl}; } }