Hi guys,
does anyone knows how I call to a function parameter like this with ether.js ?
Rewards[] calldata _rewards or with memory?

Rewards :
struct Rewards {
address to;
uint256 amount;
}

I was trying with Rewards[] memory rewards = abi.decode(_rewards, (Rewards[])); in the Solidity and
const rewardsParam = abi.encode(
["Rewards[]"], // encode as address array
rewards );
But Error: invalid type (argument="type", value="Rewards", code=INVALID_ARGUMENT, version=abi/5.7.0)

Nov 14, 2022, 9:40 PM
In the beginning the func was :
function distribute(Rewards[] memory _rewards, uint256 _total) external onlyOwner {

and now I'm trying to migrate using bytes memory (or calldata) and decode inside.

function distribute(bytes memory _rewards, uint256 _total) external onlyOwner {
Rewards[] memory rewards = abi.decode(_rewards, (Rewards[]));
console.log("...distribute");
...
}
Nov 14, 2022, 9:46 PM

© 2024 Draquery.com All rights reserved.