0

In pragma solidity ^0.6.4;

I wrote a contract and can get the byte code as follow:

const solc = require("solc");
const path = require("path");
const fs = require("fs");

const inboxPath = path.resolve(__dirname, "contracts", "Inbox.sol");
const source = fs.readFileSync(inboxPath, "utf8");

var input = {
  language: "Solidity",
  sources: { "test.sol": { content: source } },
  settings: {
    outputSelection: {
      "*": {
        "*": ["*"]
      }
    }
  }
};
var output = JSON.parse(solc.compile(JSON.stringify(input)));

for (var contractName in output.contracts["test.sol"]) {
  console.log(
    contractName +
      ": " +
      output.contracts["test.sol"][contractName].evm.bytecode.object
  );
}

this code returns bytecode however I do not know how I can access to ABI code.

  • In solc 0.5 there was output.contracts["test.sol"][contractName].abi. – Ismael Mar 31 at 17:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.