Hi!
What should I write the amount value in the params if I want to have an infinite access to the user’s token amount when implementing Approve function using Moralis.executeFunction(approve)?
from https://blocksecteam.medium.com/unlimited-approval-in-erc20-convenience-or-security-1c8dce421ed7
:
Unlimited Approval:The approval amount equals the max value of uint256 (0xffff…ffff) or the total supply of the tokens.This type of approval is frequently used by many DeFi platforms (such as exchanges, lending platforms).
Can you send me a sample code of how you later implemented it
Answered here
here it calls approve function inside approve function?
I am having the same issue as before. I created an erc20 smart contract which has it’s own token, when a call the approve function it approves the user to spend my erc20 token instead of the users on own token.
I am creating a web3 exchange site when a user clicks on buy i will credit the vendor myself from the user own token i.e usdc or usdt.
You need to fix the following for the approve function. and make sure you’re on the right network
let approval = await Moralis.executeFunction({
await approval.wait();
console.log(approval);
console.log("success");
...options
I am having the same issue as before. I created an erc20 smart contract which has it’s own token, when a call the approve function it approves the user to spend my erc20 token instead of the users on own token.
I am creating a web3 exchange site when a user clicks on buy i will credit the vendor myself from the user own token i.e usdc or usdt.
Or should i change the smart contract address?
the approve will be done for the address that signs that approve transaction
How do i make it to approve the user token instead of the one i created… should i just change the contract address?
It should be the same process, you need to change the contract address. As @cryptokid mentioned, the approved spender can call a transferFrom method to send the tokens
Ok Thanks for your reply… But what contract address do i change it to that will be able to approve the spender on all erc20 tokens.
What if i want up to 7k token approval, I have to copy each smart contract address and use it on my dapp… That’s very tiring.
Thank you for your replies you saved me from a lot of stress.
last question how do i specify a specific token in my code?
You can do an approval at a time from the client, you should be able to do multiple times using private key
That should be the spender passed to the approve function if I got your question right
My question is how do i specify the user to approve a specific token…
for example a user has usdc and another one has busd how do make the approve function to know and approve the token
pls someone should help me