[SOLVED] Returning a query function in the smart contract

const getLink = {
contractAddress: smartContractAddr,
functionName: “getPartnerWithWallet”,
abi: smartContractABI,
params: {
wallet: addr

        try {
            getLinkPartner = await Moralis.executeFunction(getLink);
        } catch (error) { ...


Hi Guys.

Execution of the function returns 5 values ​​(uint256, uint8, uint7, uint8, bool). It performs correctly. But I need to get the value of uint256 to work in the frontend. I AM confused as to how to do this?

getLink returns an object that I don’t know how to work to get the returned value.

what you see if you print that object as JSON.stringify(getLinkPartner)?
what the function returns is not what you will get at output, usually you’ll have to parse events/logs to get more information about what that function did

1 Like

function getPartnerWithWallet(address wallet) external view returns (uint256, uint8, uint8, uint8, uint8, bool) {
uint256 id = _isPartner[wallet];
return (id, _idPartner[id].rebate, _idPartner[id].rebateBuyer, _idPartner[id].rebateAnoter, _idPartner[id].rebateAirDrop, _idPartner[id].customRebate);

It’s a simple function in the smart contract.

I just need to access the first return value (the first uint256).

I don’t know how you can do that on how that function is wrote now, you’ll have to emit an event with those values in order to get that information in front end.

I got it : ), after better analyzing the return as you suggested. Thanks. I was querying the constant that returns the ABI of the contract (getLink) rsrsrs… and not getLinkPartner . getLinkPartner correctly returns the function’s return object… : )… with getLinkPartner[0] I managed to get the value of uint256… I wrote the function like this, because it is queried by the user, with interaction with the web3 provider in front end - metamask etc. It’s the first time I’m looking at the smart contract function return… so I was in doubt. Thanks a lot for the help.

1 Like