these single examples are not real world use caseā¦
in real appsā¦ thereās multiple function calls in one component/page
const ShowUniswapObserveValues = () => {
const { data, error, runContractFunction, isFetching, isLoading } =
useWeb3Contract();
const options = {
abi: usdcEthPoolAbi,
contractAddress: usdcEthPoolAddress,
functionName: "observe",
params: {
secondsAgos: [0, 10],
},
};
return (
<div>
{error && <ErrorMessage error={error} />}
<button
onClick={() => runContractFunction({ params: options })}
disabled={isFetching}
>
Fetch data
</button>
{data && <pre>{JSON.stringify(data)}</pre>}
</div>
);
};
being new to reactā¦ I donāt understand calling hooks
my code
const HomePage = () => {
const [tab, setTab] = React.useState(2)
///other states
if(user && !_user ){
setUser(user.get("ethAddress"))
start()
}
async function start(){
const usernfts_ = await getNFTBalances()
setCafe(usernfts_)
}
function handleClick(value_) {
if(value_==1 && _user){
start()
}
setTab(value_);
}
/// other functions
}
now I need to call a hookā¦ your examples donāt show how to call a hook within a component like thisā¦
how do I call this hook?
const { data, error, fetch, isFetching, isLoading } = useWeb3ExecuteFunction({
abi: _nftea,
contractAddress: '0x636c5AC57F13DdAB170d4064F0A3EB3f2949B885',
functionName: "mint",
params: {
secondsAgos: [0, 10],
},
});
within the component above?
I assembled my mint form
const handleMint = async (event) => {
event.preventDefault()
let metaData = new Object()
metaData.name = event.target.title.value
metaData.external_url = 'https://nftea.app/cafe/'+_user
metaData.amount = event.target.amount.value
metaData.redeems = event.target.redeems.value
metaData.redeemfrequency = 'every ' + event.target.redeemfrequency.value || 0 + 'days'
metaData.description = event.target.story.value
metaData.splitwith = event.target.splitWith.value || _dead
metaData.animation_url = _media
metaData.animation_type = _mediaType
metaData.youtube_url = event.target.youtube.value || null
metaData.attributes = []
metaData.created = new Date()
metaData.image = _image
metaData.creator = _user
metaData.contract = 0x636c5AC57F13DdAB170d4064F0A3EB3f2949B885
const metadata_ = new Moralis.File("metadata.json", {base64 : btoa(JSON.stringify(metaData))});
await metadata_.saveIPFS();
const metadataurl_ = await metadata_.ipfs();
const dataMint_ = {
title: event.target.title.value,
amount: event.target.amount.value,
redeems: event.target.redeems.value,
redeemfrequency: event.target.redeemfrequency.value || 0,
payTo: event.target.payTo.value || _user,
splitwith: event.target.splitWith.value || _dead,
split: event.target.split.value || 0,
youtube: event.target.youtube.value || '0',
story: event.target.story.value,
image: _image,
media: _media,
ipfs:metadataurl_,
metadataurl_: metadataurl_,
}
now I need to call āfetchā in the useWeb3ExecuteFunctionā¦