December 2018
Beginner to intermediate
564 pages
17h 34m
English
If your solidity source code references libraries, then the generated byte code will contain placeholders for the real addresses of the referenced libraries. These have to be updated via a process called linking before deploying the contract.
solcjs provides the linkByteCode method to link library addresses to the generated byte code.
Here is an example to demonstrate this:
var solc = require("solc"); var input = { "lib.sol": "library L { function f() returns (uint) { return 7; } }", "cont.sol": "import 'lib.sol'; contract x { function g() { L.f(); } }" }; var output = solc.compile({sources: input}, 1); var finalByteCode = solc.linkBytecode(output.contracts["x"].bytecode, { 'L': '0x123456...' });
Read now
Unlock full access