Hi!
Any know what set data in useWeb3ExecuteFunction or fetch next i compile form? because if set data before code work, but if i set data next , code don’t work.
this problem :
params: {
to : account,
_name : "imp",//String(statisticNft.name),
_lifepoint :11,// Number(statisticNft.lifepoint),
_power: 1,//(statisticNft.power),
_dex : 1, //Number(statisticNft.dex),
_stamina :1, // Number(statisticNft.stamina),
_speed :1 // Number(statisticNft.speed),
},
import { Button,
FormControl,
FormLabel,
FormErrorMessage,
FormHelperText,
NumberInput,NumberInputField, NumberIncrementStepper,NumberDecrementStepper,Input,NumberInputStepper} from '@chakra-ui/react';
import React,{useState} from 'react'
import { useWeb3ExecuteFunction} from 'react-moralis'
import { useMoralis } from 'react-moralis';
import StikiWar from '../../contract/StikiWar.json'
export default function MintingStiki() {
const { user,account } = useMoralis();
const [stat,setStat] = useState(15);
const [statisticNft, setStatisticNft] = useState({
name : "",
lifepoint : 11,
power: 1,
dex : 1,
stamina : 1,
speed : 1,
})
const { data, error, fetch, isFetching, isLoading } = useWeb3ExecuteFunction({
abi: StikiWar.abi,
contractAddress: StikiWar.networks[1337].address,
functionName: "mint",
params: {
to : account,
_name : "imp",//String(statisticNft.name),
_lifepoint :11,// Number(statisticNft.lifepoint),
_power: 1,//(statisticNft.power),
_dex : 1, //Number(statisticNft.dex),
_stamina :1, // Number(statisticNft.stamina),
_speed :1 // Number(statisticNft.speed),
},
});
function PointAvvalible(){
setStat(15 - (statisticNft.lifepoint,statisticNft.dex,statisticNft.power,statisticNft.speed,statisticNft.stamina))
}
function arise(){
fetch();
}
return (
<FormControl>
<FormLabel htmlFor='first-name'>Warrior Name</FormLabel>
<Input id='name' type='text' onChange={(e)=>setStatisticNft({name:e.target.value})} />
<FormHelperText>Set name for your nft</FormHelperText>
<FormLabel htmlFor='amount'>Set stat points: {stat} </FormLabel>
LifePoint
<NumberInput min={1} onChange={(e)=>{setStatisticNft({lifepoint : e})}}>
<NumberInputField id='amount' />
<NumberInputStepper>
<NumberIncrementStepper />
<NumberDecrementStepper />
</NumberInputStepper>
</NumberInput>
Power
<NumberInput min={1} onChange={(e)=>{setStatisticNft({power : e})}}>
<NumberInputField id='amount' />
<NumberInputStepper>
<NumberIncrementStepper />
<NumberDecrementStepper />
</NumberInputStepper>
</NumberInput>
Dex
<NumberInput min={1} onChange={(e)=>{setStatisticNft({dex : e})}}>
<NumberInputField id='amount' />
<NumberInputStepper>
<NumberIncrementStepper />
<NumberDecrementStepper />
</NumberInputStepper>
</NumberInput>
Stamina
<NumberInput min={1} onChange={(e)=>{setStatisticNft({stamina : e})}}>
<NumberInputField id='amount' />
<NumberInputStepper>
<NumberIncrementStepper />
<NumberDecrementStepper />
</NumberInputStepper>
</NumberInput>
Speed
<NumberInput min={1} onChange={(e)=>{setStatisticNft({speed : e})}}>
<NumberInputField id='amount' />
<NumberInputStepper>
<NumberIncrementStepper />
<NumberDecrementStepper />
</NumberInputStepper>
</NumberInput>
<Button onClick={()=>arise()}>Arise {statisticNft.name}</Button>
</FormControl>
)
}