When I run my code ,it told me that
“TypeError: Cannot read property 'abiDefinition' of undefined”
The error code is:
console.log(calcCompiled["info"]["abiDefinition"]);
The code that I am using is:
let source = "
pragma solidity ^0.4.0;
contract Calc {
uint count;
function add(uint a, uint b) returns(uint){ count++; return a + b; }
function getCount() constant returns (uint){ return count; }}
";
let calcCompiled = web3.eth.compile.solidity(source); console.log(calcCompiled);
console.log("ABI definition:");
console.log(calcCompiled["info"]["abiDefinition"]);
What should I do?
Best Answer
The method
eth_compileSolidity
whichweb3.eth.compile.solidity
relies on is deprecated and does not exist nor is available anymore.An alternative is to compile using
solc
:which generates the ABI file:
Or compiling with solc in node.js: