I saw the following : what does `deploy.link` exactly do in `truffle`

I have safe.sol

library safe {
    function safeMultiply(uint256 a, uint256 b) internal pure returns (uint256) {
        if (a == 0) {
            return 0;
        } else {
            uint256 c = a * b;
            assert(c / a == b);
            return c;


In my contract, I have this:

import "../libraries/safe.sol";

contract TokenSale {

  function test() public view returns (uint256){

        return safe.safeMultiply(5, 10);



Now, when deploying contract, I just have deployer.deploy(myContract) , It deploys the contract successfully and , test function works as expected. There was no need to use deployer.link from truffle.

So , why does the stackoverflow question above I linked or even truffle's website explain like this that deployer.link is needed to make this work ?


Your Answer

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