Skip to content

Instantly share code, notes, and snippets.

@maurelian
Created September 1, 2017 13:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maurelian/1b80e0de2a24bdcd54a3c789ff29b4de to your computer and use it in GitHub Desktop.
Save maurelian/1b80e0de2a24bdcd54a3c789ff29b4de to your computer and use it in GitHub Desktop.
multiple solc versions
const solc = require('solc');
const solcV0410 = solc.useVersion('v0.4.10+commit.f0d539ae')
const simpleContract = 'contract Simple { function g() {} }';
var outputLatest = solc.compile(simpleContract);
console.log(outputLatest.contracts[':Simple']['bytecode']);
// get a legacy version
// This requires this file: https://raw.githubusercontent.com/ethereum/solc-bin/gh-pages/bin/soljson-v0.4.10%2Bcommit.f0d539ae.js
// to be located in node_modules/solc/bin
// to do that, run
// `$ wget https://raw.githubusercontent.com/ethereum/solc-bin/gh-pages/bin/soljson-v0.4.10%2Bcommit.f0d539ae.js ./node_modules/solc/bin/
var outputV0410 = solcV0410.compile(simpleContract, 1)
console.log(outputV0410.contracts[':Simple']['bytecode']);
@alxiong
Copy link

alxiong commented Sep 1, 2017

John, That's a perfect download source. It worked for me.
One question:
Do this solc-bin/ subfolder has all the versions and according "soljson....js" file ?
One weird thing:
./node_module/solc/bin doesn't help me create the /bin subfolder since by default I don't have them. I have to manually add that in my file system and then execute the download command. -- which means we still need to do the add mkdir in our script, but I'm not sure whether that require authentication enforced by node access control .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment