0

I'm having a function IN A LIB that require a contract as parameter.

function createCalendarEntry(uint256 releaseTime,
    SPToken token) public pure returns (CalendarEntry memory) {
    return CalendarEntry(releaseTime, token);
}

To test this function im doing:

    const spToken = await SPToken.new(token, {from: accounts[1]});
    const cal = await myLib.createCalendarEntry.call(web3.utils.toBN(now), spToken);

as error im getting Error: invalid type (argument="type", value="SPToken", code=INVALID_ARGUMENT, version=abi/5.0.7)

What should i do to make this spToken javascript instance a valid parameter as contract for the function?

Thanks!

Edit: added information that this function is inside a library.

1 Answer 1

0

Truffle's contract isn't smart enough to know that a contract has an address

If I remember correctly you have to pass spToken.address as the parameter.

const spToken = await SPToken.new(token, {from: accounts[1]});
const cal = await myLib.createCalendarEntry.call(web3.utils.toBN(now), spToken.address);
1
  • I tried that too and i got the same error.
    – jvinai
    Feb 3, 2022 at 16:32

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.