0

library C {
   function a() public returns (uint) {
      return 15;
   }
}

contract A { 
    
   function a() public returns (uint) {
      return C.a();
   }
  
}

This is the code I am using. I am trying to figure out how library C ends up in contract A's bytecode.

Question 1) I use remix and I compile contract A. In the bytecode, I can see the following __$de3f906ec3d3531c3d498f8b283d7f02e6$__. It doesn't matter if I change library C's function a's name or if I change what it returns. In the bytecode, there's always the same __$de3f906ec3d3531c3d498f8b283d7f02e6$__. Of course, If I use the library's function 2 times, then I will meet that strange string 2 times in the bytecode. What is it ?

Question 2) The answer to the above question could be it's a placeholder, where in the end, it's library's address that ends up in there. If that's correct, then how does remix link library C to contract A ? because both library and contract are in the same file, and when I want to deploy, I only deploy contract A (i don't deploy or link library at all). Any idea ? How do I get the library address in that matter ?

1

__$de3f906ec3d3531c3d498f8b283d7f02e6$__ is a placeholder for library address.

The deployment process of smart contracts look somewhat like this

  • Library is compiled
  • Library is deployed, gets an address
  • Contract using library is compiled
  • Contract is "linked" - all placeholders in the bytecode are replaced with the library address
  • Contract is deployed
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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