0

I was trying to check something I saw in the tutorial on the simpler example. In the tutorial it was:
using My_PriceConverter for uint256;
I tried to check it using simple contract and library
MyContract:


import "./MyLibrary.sol";

contract MyContract {
    using MyLibrary for uint256;
    uint256 public myUint;

    function setMyUint(uint256 _myUint) public {
        myUint = _myUint.getNumber();
    }
}

MyLibrary:

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.9;

library MyLibrary {
    function getNumber() public pure returns (uint256) {
        return 123;
    }
}

I don't know why it's possible to use My_PriceConverter but I get error like that

1 Answer 1

0
using MyLibrary for uint256;
uint256 public myUint;

_myUint.getNumber() == MyLibrary.getNumber(_myUint)

using syntactic sugar: https://medium.com/coinmonks/soliditys-using-keyword-c05c18aaa088

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.