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