I tried insert a direct valeu instead of a string and get the same error, I don’t think this is the problem.
This is the initial part and final part of the code, I think this is the last thing I have to solve to complete this game.
const ALLOWANCE_ASKED = 10e30
export const BUSDAllowanceWrapper: FC = ({ children }) => {
const { web3 } = useMoralis()
const userAddress = useUserAddress()
const [ loading, setLoading ] = useState(false)
const [ allowance, setAllowance ] = useState<number>()
const busdContract = useMemo(() => new web3.eth.Contract(busdAbi as AbiItem[], appEnv.busdAddress), [ web3 ])
async function allow() {
setLoading(true)
try {
const approveBusdContract = busdContract.methods.approve(appEnv.contractAddress, `0x${ALLOWANCE_ASKED.toString(16)}`)
await approveBusdContract.send({ from: userAddress })
const newAllowance = await busdContract.methods.allowance(userAddress, appEnv.contractAddress).call({ from: userAddress })
setAllowance(newAllowance)
} finally {
setLoading(false)
}
}
useEffect(() => {
if (userAddress) {
setLoading(true)
busdContract.methods.allowance(userAddress, appEnv.contractAddress).call({ from: userAddress }).then((allowed: number) => {
setAllowance(allowed)
console.log(allowed)
}).finally(() => setLoading(false))
}
}, [ busdContract, userAddress ])