How to use the solc.compileStandard function in solc

To help you get started, we’ve selected a few solc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github trufflesuite / truffle-contract-schema / test / solc.js View on Github external
},
      settings: {
        outputSelection: {
          "*": {
            "*": [
              "abi",
              "evm.bytecode.object",
              "evm.bytecode.sourceMap",
              "evm.deployedBytecode.object",
              "evm.deployedBytecode.sourceMap"
            ]
          }
        }
      }
    });
    var solcOut = JSON.parse(solc.compileStandard(solcIn));

    // contracts now grouped by solidity source file
    var rawA = solcOut.contracts["A.sol"].A;

    var A = Schema.normalize(rawA);

    var expected = {
      abi: rawA.abi,
      bytecode: "0x" + rawA.evm.bytecode.object,
      deployedBytecode: "0x" + rawA.evm.deployedBytecode.object,
      sourceMap: rawA.evm.bytecode.sourceMap,
      deployedSourceMap: rawA.evm.deployedBytecode.sourceMap
    };

    Object.keys(expected).forEach(function (key)  {
      var expectedValue = expected[key];
github TrueBitFoundation / scrypt-interactive / test_manual / helpers / compiler.js View on Github external
function invokeCompiler(input) {
    if (useLocalSolc) {
        var result = child_process.spawnSync('solc', ['--optimize', '--standard-json', '-'], {input: input, encoding: 'utf-8'})
        if (result.status != 0) {
            console.log("Error invoking compiler:".red)
            console.log(result.output[2])
        }
        return result.output[1]
    } else {
        return require('solc').compileStandard(input)
    }
}
github trufflesuite / truffle-compile / test / test_ordering.js View on Github external
it("Complex ABI should be out of source order when solc compiles it", function(){
      var alphabetic = ['andThird', 'second', 'theFirst', 'LogB', 'LogA', 'LogD', 'LogC'];
      var input = {
        language: "Solidity",
        sources: { "ComplexOrdered.sol": { content: complexOrderedSource },
                   "InheritB.sol": { content: inheritedSource },},
        settings: { outputSelection: { "*": { "*": ["abi"] } } }
      };

      var result = solc.compileStandard(JSON.stringify(input));
      result = JSON.parse(result);
      var abi = result.contracts["ComplexOrdered.sol"]["ComplexOrdered"].abi.map(function(item){
        return item.name;
      });
      assert.deepEqual(abi, alphabetic);
    });