Calling hooks in real world component

itā€™s a moralis functionā€¦

that code doesnā€™t not workā€¦ call fetch and nothing happensā€¦

useWeb3ExecuteFunction works if isWeb3Enabled is true, so you can add isWeb3Enabled to the dependencies of the hook and check if itā€™s true before calling the fetch. Also try log error from the hook to keep track of the execution status

I donā€™t think you all understandā€¦

you are not using real world examples in your docsā€¦

maybe it works if itā€™s just that one function on the page and nothing elseā€¦

it runs that function and returns the resultsā€¦

when you have a bunch of other functions on the the same pageā€¦ as MOST real world applications haveā€¦ it doesnā€™t workā€¦

it shouldnā€™t be this hard to mint an nft

(web3, enableWeb3, isWeb3Enabled} = useMoralis()
your web3 doesnā€™t expose utils, or .eth so runcontactnative web3 doesnā€™t workā€¦

The docs provides basic examples required to get basic things done which can be built upon to get complex things done.
Since youā€™re using react too, react docs explained in similar way ( basic example that can be used to build complex works )

real world examples would be A LOT more helpfulā€¦
most devs arenā€™t going to have a page with one function on it

Real-world examples are showcased in the weekly project series.

Error: Provided address 5.676064741032766e+47 is invalid, the capitalization checksum test failed, or itā€™s an indirect IBAN address which canā€™t be converted.

What are you trying to do ?

just trying to mint an nftā€¦
have tried it this way

  const [_mintForm, setMintForm] = useState(null)

  useEffect(()=>{
    console.log('fetching....')
    const mintnftea = async()=> {
  
    {data_, error_ fetch, isFetching}  await useWeb3ExecuteFunction({
        abi: _nftea,
        contractAddress: '0x636c5AC57F13DdAB170d4064F0A3EB3f2949B885',
        functionName: "mint",
        params: {
          secondsAgos: [_mintForm.amount,_mintForm.redeems,_mintForm.metadataurl_.charCodeAt(0),_mintForm.ipfs,_mintForm.payTo,_mintForm.splitwith,_mintForm.split,_mintForm.redeemfrequency],
        },
      });
    }
  
  
  }, [mintnftea])

form gets submittedā€¦ NFTea gets mintedā€¦

web3, and every other way from your docsā€¦

    const JSONdata = JSON.stringify(dataMint_)
    const endpoint = '/api/mintnftea'
    const options = {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
      },
      body: JSONdata,
    }
    const response = await fetch(endpoint, options)
    const result = await response.json()

sent it to the back end for the evm to do it

export default async function handler(req, res) {

  const body = req.body

  const functionName = 'mint';

  const chain = EvmChain.GOERLI;
  const params = {quantity_:body.amount,redeems_:body.redeems,data_:body.metadataurl_.charCodeAt(0),ipfs_:body.ipfs,payto_:body.payTo,splitwith_:body.splitwith,splitpercent_:body.split,redeemfrequency_:body.redeemfrequency};
  const address = process.env.NFTEA;

  await Moralis.start({
      apiKey: process.env.MORALIS_API_KEY,
  });

  const response = await Moralis.EvmApi.utils.runContractFunction({
      functionName,
      params,
      address,
      chain,
  });
  console.log(response.result);


    res.status(200).json({
      data: response.result
    });
}

doesnā€™t work and .charCodeAt(0) doesnā€™t work for the hex converstion

this way

      const {data_, error_, fetch, isFetching_}  = useWeb3ExecuteFunction({
        abi: _nftea,
        contractAddress: '0x636c5AC57F13DdAB170d4064F0A3EB3f2949B885',
        functionName: "mint",
        params: {
          secondsAgos: [_mintForm.amount,_mintForm.redeems,_mintForm.metadataurl_.charCodeAt(0),_mintForm.ipfs,_mintForm.payTo,_mintForm.splitwith,_mintForm.split,_mintForm.redeemfrequency],
        },
      });

then call fetch after the images is uploaded and saved to ipfs

fetch({params:dataMint_})

nothing happensā€¦

Regards the first part of the code here, you can get it fixed as Glad mentioned above that hooks should be at the top level.

  const { isWeb3Enabled, enableWeb3 } = useMoralis();
  const [_mintForm, setMintForm] = useState(null);
  const { fetch } = useWeb3ExecuteFunction();

  useEffect(() => {
    const mintnftea = async () => {
      if (!isWeb3Enabled) await enableWeb3();
      
      fetch({
        params: {
          abi: _nftea,
          contractAddress: "0x636c5AC57F13DdAB170d4064F0A3EB3f2949B885",
          functionName: "mint",
          params: {
            secondsAgos: [
              _mintForm.amount,
              _mintForm.redeems,
              _mintForm.metadataurl_.charCodeAt(0),
              _mintForm.ipfs,
              _mintForm.payTo,
              _mintForm.splitwith,
              _mintForm.split,
              _mintForm.redeemfrequency,
            ],
          },
        },
        onSuccess: (res) => console.log(res),
        onError: (err) => console.log(err),
      });
    };
    mintnftea();
  }, []);

You should fix the dependency hook depending on what and when you want it to fire
You can keep track of the process with the logs from onSuccess and onError

As mentioned in the docs, runContractFunction run a given function of a contract abi and retrieve readonly data.

almost got it goingā€¦

      const {data, error, fetch, isFetching_}  = useWeb3ExecuteFunction({
        abi: _nftea,
        contractAddress: "0x636c5AC57F13DdAB170d4064F0A3EB3f2949B885",
        functionName: "mint",
        params: {
          quantity_: _mintForm.amount,
          redeems_: _mintForm.redeems,
          data_: _mintForm.metadataurl_.charCodeAt(0),
          ipfs_:  _mintForm.ipfs,
          payto_: _mintForm.payTo,
          splitwith_: _mintForm.splitwith,
          splitpercent_:_mintForm.redeemfrequency,
          redeemfrequency_:_mintForm.split
        },
      });

invalid address or ENS name (argument=ā€œnameā€, value=0, code=INVALID_ARGUMENT, version=contracts/5.6.0)

is there a special way to set addresses in react?
with qoutes, withoutā€¦ doesnā€™t work

Check if the address passed is a valid contract address

You should set it with quotes

invalid address or ENS name (argument=ā€œnameā€, value=0, code=INVALID_ARGUMENT, version=contracts/5.6.0)

Try hardcoding the contratc address and see if it works

set it as
export const _contractTea = ā€œ0x636c5AC57F13DdAB170d4064F0A3EB3f2949B885ā€;

still getting invalid address or ENS name (argument=ā€œnameā€, value=0, code=INVALID_ARGUMENT,

Then you should import it properly where itā€™s required.