I try to compile the following contract (tested on remix) with solc-js
pragma solidity ^0.4.21;
contract Calculator {
uint8 public result = 0;
function add(uint8 value) public {
result = result + value;
}
}
This is the code I am using
const { readFileSync } = require('fs');
const solc = require('solc');
const Web3 = require('web3');
// connect to the local instance
const web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
const params = {
language: "Solidity",
sources: {
'example': {
content: readFileSync('./contracts/example.sol', 'utf-8')
}
}
};
const compiled = JSON.parse(solc.compileStandardWrapper(JSON.stringify(params)));
// check the result
console.log(compiled);
I follow the instruction from the solc repo and the compiler input JSON spec. It works without any error but the result is very empty
{
"contracts": {
"example": {
"Calculator": {
"evm": {}
}
}
},
"sources": {
"example": {
"id": 0
}
}
}
It doesn't have a lot of content as described at the output description. I am not sure what goes wrong in my code.