• all contracts use pragma solidity ^0.4.17;
  • the compiler is 0.4.18+commit.9cf6e910.Emscripten.clang
  • OS is MacOS X

My token contract uses a Math library that is defined like so

library Math {...

In the token contract it is imported and then simply used in the functions

import "../Math.sol";
data.setBalances(src, Math.sub(data.balances(src), wad));

I compiled the contract with truffle compile and used the resulting bytecode to deploy the contract in parity

The surprising part is that it works and I'd like to understand why. There is no mention of the library in the bytecode. I would expect something like ____Math____ but this is not present.

1 Answer 1


It appears that the latest version of solidity (or maybe prior to that) improved the usage of libraries and now internal functions will be copied into the calling contract to be able to use them with JUMP instead of DELEGATECALL

from the solidity documentation on libraries:

Furthermore, internal functions of libraries are visible in all contracts, just as if the library were a base contract. Of course, calls to internal functions use the internal calling convention, which means that all internal types can be passed and memory types will be passed by reference and not copied. To realize this in the EVM, code of internal library functions and all functions called from therein will be pulled into the calling contract, and a regular JUMP call will be used instead of a DELEGATECALL.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.