Replies: 1 comment 6 replies
-
requestApproval is using what? as far as i know, requestApproval is usually using 2 args. Owner Address, Spender Address. i dunno why you put function name in the arguments. const [approve, setApprove] = useState() const {data} = useContractWrite(request) }; useEffect(() => { perhaps something like this? |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi
Im doing an useContractWrite but one of the arguments is not filled in the real payload/input data on the Blockchain. When I console log the request I can see that the arguments are correct. However when I see the input data on the Blockchain the debouncedToEncodedData is empty. I tried a lot of different variations and probably am doing something really weird. Please advice on how to do this correctly? It feels like there is some race condition.
const [debouncedToEncodedData] = useDebounce(encodedData, 500) // Maybe really not needed?
const { config: config_request_approval } = usePrepareContractWrite({
address: contractAddress,
abi: ABI,
functionName: 'requestApproval',
gasLimit: 50000000,
args: [customERC20ContractAddress, "transfer", debouncedToEncodedData],
onSuccess(data) {
console.log("config_request_approval", "Success", "data", data, debouncedToEncodedData);
},
onError(err) {
console.error("error", err.message);
},
});
const { data, isLoading, isSuccess, write: requestApproval } = useContractWrite(config_request_approval)
Then its getting the encoded data from here:
setEncodedData(encodeFunctionData({
abi: erc20ABI,
functionName: 'transfer',
args: [debouncedTo, debouncedAmount]
}))
useEffect(() => {
requestApproval?.()
}, [encodedData])
Beta Was this translation helpful? Give feedback.
All reactions