runContractFunction can't get any data from smart contract ABI [NextJS]

No, I mean in admin.moralis.io.

What is the connection with tables?

There is a function at the end, one specific to runContractFunction

1 Like

Ok I guess itā€™s not the problem with connection between next app and moralis, but weirdā€¦ There should be data for this address, what is other way to check the data of my address if it got those rewards etc.

Try to format that parameter. It didnā€™t work yet

1 Like

example that should work:

curl -X 'POST' \
  'https://deep-index.moralis.io/api/v2/0xe11b8e0243e3eed9df387ca279caad4d2b35951a/function?chain=rinkeby&function_name=uri' \
  -H 'accept: application/json' \
  -H 'X-API-Key: API_KEY_HERE' \
  -H 'Content-Type: application/json' \
  -d '{
  "abi": [{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"uri","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"}],
  "params": {"id": 100 }
}'
1 Like

Are you French? :smiley: (Just curious, Iā€™m not), but if itā€™s you, you amazed me with this image

Ok it finally worked with different function, still got troubles with ā€˜rewardsā€™ function, but Iā€™m on a good path, daaamnā€¦

1 Like

Wow, I would say it works, thank you so much <3 Iā€™ve spent so many days on thisā€¦ Now I have to do the same inside next app, maybe it will work :smiley: The only thing that curious me is that it show different value than it should be :thinking: What function would you recommend for write functions, like stakeā€¦ executeFunction? Could you type example code? Thanks! Youā€™re amazing, I hope you get paid well, awesome moderationā€¦ 20 mins for response, have a good day :muscle:

Moralis.executeFunction should work, there is also an equivalent in react for it

1 Like

Ok, thanksā€¦ I will try it out, we will see

Wait noā€¦ It doesnā€™t change anything, Iā€™ve used the ABI from my code, admin panel returns value, but I didnā€™t get data with useApiContract :confused:

what do you see in network tab? still 400 error?

1 Like

I think I might find a solution, but not sure how to fix thatā€¦ If I put wallet address inside " " it returns normal address inside ā€œā€, but if I donā€™t use " " it returns that

image

Maybe it canā€™t be inside " " to find data of that address inside contract, but it itā€™s too long and not inside " " it changes the input toā€¦ You know

image

it should be inside those " " so it sees it as a string

1 Like

Ok so still 400 error

can you paste the server url?

1 Like

const {
      runContractFunction,
      data,
      error,
      onSuccess,
      onError,
    } = useApiContract({
      address: "0xE0C255a5D89b6D9fedb5C4e43c11341a072e3bcc",
      functionName: "rewards",
      abi: {
        "constant": true,
        "inputs": [
            {
                "internalType": "address",
                "name": "_address",
                "type": "address"
            }
        ],
        "name": "rewards",
        "outputs": [
            {
                "internalType": "uint256",
                "name": "",
                "type": "uint256"
            }
        ],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    },
    chain: 'bsc',
    params: { _address: '0xF009428BE1A9a550f2d5DB7e49FF439617928097' }
    });

      useEffect(() => {
        if(isInitialized) runContractFunction({
          onSuccess: (res) => console.log(res),
          onError: (err) => console.log(err),
        });
      }, [isInitialized])

      console.log(data);

you just have to write the abi in another format, to also have [], just add [ and ] for your abi

1 Like