February 4, 2026

Solidity Tutorial: all about Libraries – Jean Cvllr

Solidity Tutorial: all about Libraries – Jean Cvllr

Solidity Tutorial: all about Libraries – Jean Cvllr

Solidity Tutorial: all about Libraries – Jean Cvllr

If we call add() function of the Math library from our contract, the address of MyContract will be returned and not the library address. The add() function is compiled as an external call ( DELEGATECALL ) but if we check the address from the address(this) (the contract address), we will see our contract address (not the library contract’s address). The same applies for all other msg properties ( msg.value, msg.data and msg.gas).

  • At compile time, the EVM pulls internal function B into contract A. It would be like if function B was hardcoded in contract A.
  • A regular JUMP call will be used instead of a DELEGATECALL.
  • types stored in memory will be passed by reference and not copied.
// Some code here 

We want to use a library function !

Ok enough theory, let’s look at some practical examples ! ?

pragma solidity ^0.5.0;contract MyContract 

library MathLib

}

Published at Thu, 01 Aug 2019 13:48:48 +0000

{flickr|100|campaign}

Previous Article

Dow Sputters to Half-Hearted Recovery as Investors Digest Fed Fallout

Next Article

The Real Blockchain Trilemma – Tony Vazz

You might be interested in …

Binance’s Listing of Dogecoin Makes Waves

Binance’s Listing of Dogecoin Makes Waves

Binance’s Listing of Dogecoin Makes Waves Dogecoin (DOGE) first gained attention in crypto when Jackson Palmer, a computer programmer, posted the now infamous Shiba Inu dog with the comment, “Pretty sure it’s the next big […]