0

In truffle quick start, its contract MetaCoin has dependency of library ConvertLib. Then in the deployment file, deployer.link(ConvertLib, MetaCoin) is manually added, and if deployer.link is deleted, there is failure when do migrate.

However, if I add a library called MySafeMath(its content is the well-known SafeMath), and import it to contract MetaCoin, then add a line using MySafeMath for uint256, and a function

function getBalanceInMath(address addr) public view returns(uint) {
    return balances[addr] * 2000;
}

and do truffle migrate again, there is no failure.

So why MySafeMath does NOT need a deployer.link?
Do I need to recursively find out all the dependencies which could be a lot of work for a large project?

Your Answer

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

Browse other questions tagged or ask your own question.