@quantumcoin/solc
v0.7.7
Published
Solidity compiler for QuantumCoin with 32-byte address support
Downloads
216
Maintainers
Readme
@quantumcoin/solc
Solidity compiler for QuantumCoin with 32-byte address support.
This package is a QuantumCoin adaptation of ethereum/solc-js (v0.7.6). The compiler itself (soljson.js, an Emscripten/WebAssembly build of the QuantumCoin Solidity fork) is embedded directly in the package, so installation requires no downloads, no network access, and no external tooling.
Installation
npm install @quantumcoin/solcUsage
Compiling (Standard JSON input/output)
var solc = require('@quantumcoin/solc');
var input = {
language: 'Solidity',
sources: {
'test.sol': {
content: 'contract C { function f() public { } }'
}
},
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
);
}Import callbacks
function findImports(path) {
if (path === 'lib.sol') {
return { contents: 'library L { function f() internal returns (uint) { return 7; } }' };
}
return { error: 'File not found' };
}
var output = JSON.parse(solc.compile(JSON.stringify(input), { import: findImports }));Linking libraries (32-byte addresses)
QuantumCoin uses 32-byte addresses. Unlinked bytecode contains 64-character placeholders of the form __$<58 hex chars>$__. Use the linker to insert library addresses after compilation:
var linker = require('@quantumcoin/solc/linker.js');
var linkedBytecode = linker.linkBytecode(bytecode, {
'lib.sol:L': '0x4200000000000000000000000000000000000000000000000000000000000001'
});
// Find remaining (unlinked) references:
var references = linker.findLinkReferences(bytecode);Libraries can also be linked at compile time via settings.libraries in the Standard JSON input, using 32-byte addresses.
Command-line interface
npx solcjs --bin --abi contract.sol
# Standard JSON mode
cat input.json | npx solcjs --standard-json
# Resolve imports relative to a base path
npx solcjs --bin --base-path . contract.solVersion
The embedded compiler reports:
0.7.6+commit.4f25fa5d.mod.Emscripten.clangbuilt from quantumcoinproject/Solidity v32b.8.14, which is based on upstream Solidity 0.7.6 with 32-byte address support.
The npm package version (currently 0.7.7) tracks this bundle and its JavaScript wrapper, so its patch number advances with each compiler rebuild; only the major.minor is guaranteed to match the embedded compiler's reported version. The exact fork release is recorded in the solidityRelease field of package.json.
License and attribution
This package is derived from ethereum/solc-js v0.7.6, which is licensed under the MIT license; the original license text and copyright are retained in this repository.
The embedded soljson.js binary is built from the QuantumCoin Solidity fork, which (like upstream Solidity) is licensed under GPL-3.0. This mirrors the licensing of the upstream solc npm package, which also ships GPL-licensed compiler binaries under an MIT-licensed JavaScript wrapper.
