Created
September 1, 2017 13:11
-
-
Save maurelian/1b80e0de2a24bdcd54a3c789ff29b4de to your computer and use it in GitHub Desktop.
multiple solc versions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 .