相关疑难解决方法(0)

处理事务时VM异常:缺少气体

我使用testrpc,web3 1.0和solidity来构建一个简单的Dapp,但我总是得到这个错误,我找不到有什么问题.请帮忙.

我的javascript文件:

const Web3 = require('web3');
const fs = require('fs');

const web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));

const code = fs.readFileSync('Voting.sol').toString();
const solc = require('solc');
const compiledCode = solc.compile(code);

// deploy contract
const abiDefinition = JSON.parse(compiledCode.contracts[':Voting'].interface);
const VotingContract = new web3.eth.Contract(abiDefinition);
const byteCode = compiledCode.contracts[':Voting'].bytecode;
const deployedContract = VotingContract
.deploy({data: byteCode, arguments: [['a','b','c']]})
.send({
  from: '0x386fd5fbe3804f24b35477f06aa78a178ce021bd',
  gas: 4700000,
  gasPrice: '2000000000'
}, function(error, transactionHash) {})
.on('error', function(error){})
.on('transactionHash', function(transactionHash){})
.on('receipt', function(receipt){
   console.log(receipt.contractAddress);
})
.then(function(newContractInstance) {
  newContractInstance.methods.getList().call({from: '0x386fd5fbe3804f24b35477f06aa78a178ce021bd'}).then(console.log);
});
Run Code Online (Sandbox Code Playgroud)

我的合同文件:

pragma solidity …
Run Code Online (Sandbox Code Playgroud)

ethereum solidity smartcontracts web3js

5
推荐指数
1
解决办法
3545
查看次数

标签 统计

ethereum ×1

smartcontracts ×1

solidity ×1

web3js ×1