CRYPTO NEWS

How to reference a contract’s library function in hardhat testing

I have a contract that uses an eth/usd price feed library to convert a uint value into its USD equivalent.

pragma solidity 0.8.0;  import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";  library PriceConverter {   // No state variables inside of libraries   // All functions must be internal    function getPrice(AggregatorV3Interface priceFeed)     internal     view     returns (uint256 _price)   {     (, int256 price, , , ) = priceFeed.latestRoundData();     return uint256(price * 1e10);   }    function getConversionRate(uint256 ethAmount, AggregatorV3Interface priceFeed)     internal     view     returns (uint256)   {     uint256 price = getPrice(priceFeed);     uint256 ethAmountInUsd = (price * ethAmount) / 1e18;     return (ethAmountInUsd);   } }  pragma solidity 0.8.0;  import "./PriceConverter.sol";  contract Foo {   using priceConverter for uint256;   MINIMUM_USD = 7000000000000      function bar() public payable {      require(msg.value.getConversionRate() > MINIMUM_USD)   } }  

In my hardhat test I am trying to call the getConversionRate() uint256 function in my contract to test some values, but I am unsure how to access it.

contract.methods.payFund is not a function. Unable to call any of my contract function

I am unable to call any function of my contact………….. when I am printing my contract object it shows that all the functions are in the object but unable to call. It is the output when i print my contract instance It is a function that raised an error Error description: – Although i had::Listen

I am unable to call any function of my contact………….. when I am printing my contract object it shows that all the functions are in the object but unable to call.

It is the output when i print my contract instance enter image description here

It is a function that raised an error

enter image description here

Error description: – enter image description here

Although i had tried to call other public functions of my contract but i got the same error.

this is my contract code enter image description here

How to reference a contract’s library function in hardhat testing

Shopping cart
There are no products in the cart!
Continue shopping
0