Any idea why the const allowance would send to my metamask wallet continuously? I have no useEffects, and exuecute the function on click the same as you do for swap function. It works properly on the swap function that I built with your help, but in the funciton below it is set up the same way, and practically breaks my browser within 10 seconds.
async function fetchDexBuy() {
var tokenAmount = () => {
if(checked === "eth") {
return String(amount *(baseLine.padEnd(18+baseLine.length, '0')))
}else if (checked === "usd"){
return String((amount/cryptoDetails.price) * (baseLine.padEnd(18+ baseLine.length, '0'))) ;
} else {
return String((amount * ethExRate) * (baseLine.padEnd(18+baseLine.length, "0")))
};
}
const allowance = await axios.get(https://api.1inch.io/v5.0/1/approve/allowance?tokenAddress=0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE&walletAddress=${address})
if(allowance.data.allowance === "0"){
const approve = await axios.get(`https://api.1inch.io/v5.0/1/approve/transaction?tokenAddress=${ethAddress}`)
setTxDetails(approve.data)
console.log("Not Approved")
return
}
const tx = await axios.get(
`https://api.1inch.io/v5.0/1/swap?fromTokenAddress=${ethAddress}&toTokenAddress=${tokenObject.address}&amount=${tokenAmount()}&fromAddress=${address}&slippage=${slippage}&fee=1.25`
)
let decimals = Number(`1E${tokenObject.decimals}`)
let tokenTwo = (Number(tx.data.toTokenAmount)/decimals).toFixed(2)
console.log(tokenTwo);
setTxDetails(tx.data.tx)
}
Additionally, I would like to start a DAO, and as I am planning on using your swap page on my site would like to give tokens to yourself or Moralis whomever claims the intellectual property. I have plans to get more developers involved at DEFIProtocol/deployed-gridlock. My site is https://gridlock.live.
Any idea why the const allowance would send to my metamask wallet continuously? I have no useEffects, and exuecute the function on click the same as you do for swap function. It works properly on the swap function that I built with your help, but in the funciton below it is set up the same way, and practically breaks my browser within 10 seconds.
async function fetchDexBuy() {
var tokenAmount = () => {
if(checked === "eth") {
return String(amount *(baseLine.padEnd(18+baseLine.length, '0')))
}else if (checked === "usd"){
return String((amount/cryptoDetails.price) * (baseLine.padEnd(18+ baseLine.length, '0'))) ;
} else {
return String((amount * ethExRate) * (baseLine.padEnd(18+baseLine.length, "0")))
};
}
const allowance = await axios.get(
https://api.1inch.io/v5.0/1/approve/allowance?tokenAddress=0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE&walletAddress=${address})Additionally, I would like to start a DAO, and as I am planning on using your swap page on my site would like to give tokens to yourself or Moralis whomever claims the intellectual property. I have plans to get more developers involved at DEFIProtocol/deployed-gridlock. My site is https://gridlock.live.