Hi,
I trying function of React Moralis, but when i use component for transfer token , the function ârunContractFunctionâ dont go, in other case my code work (in case of SimpleStorage).
I havenât idea because this.
this is my code:
import React,{useState,useRef} from 'react'
import { useWeb3Contract} from 'react-moralis';
import { Button,Input} from '@chakra-ui/react';
import Token from '../contract/Token.json'
export default function SendERC20() {
const {data, error, runContractFunction,isFetching,isLoading} = useWeb3Contract();
const [_recipient, setRecipient] = useState(undefined);
const [_amount , setAmount] = useState(undefined);
const options = {
abi:Token.abi,
contractAddress: Token.networks[5777].address,
functionName:"transfer",
params:{
recipient:_recipient,
amount:_amount ,
}
}
function SendToken(){
runContractFunction({ params: options })
}
return (
<div>
<Input id='name' placeholder='0x70bc0d94bccb808e3e2717d5f8b5432279266524' value={_recipient} onChange={(e)=>setRecipient(e.target.value)} />
<Input id='amount' value={_amount} onChange={(e)=> setAmount(+(e.target.value))}/>
<Button colorScheme='teal' variant='outline' onClick={()=>SendToken()} disabled={isFetching}>
Send
</Button>
</div>
)
}