The contract has a struct which is used in an mapping. The blockchain explorers "code read" section allows to receive the result by providing a wallet address.

Solidity Code

struct Share {
    uint256 amount;
    uint256 totalExcluded;
    uint256 totalRealised;
mapping (address => Share) public shares;

I'm trying to receive the struct for one wallet like below

 var contract = new ethers.Contract(contractCA, abi, provider)
 walletSharesRealized = await contract.shares(account);

The error output I receive is as below

Uncaught (in promise) TypeError: no matching function (argument="key", value="shares", code=INVALID_ARGUMENT, version=6.4.0)

What am I doing wrong here?

1 Answer 1


Found the explanation here, https://docs.ethers.org/v5/api/utils/abi/formats/#abi-formats--human-readable-abi

You can write a human readable abi code. The struct is translated into a tuple.


function shares(address addr) public view returns (tuple(uint amount, uint totalExcluded, uint totalRealised))

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.