Questions tagged [erc-20-approve]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
2 votes
0 answers
16 views

Getting error ERC20: insufficient allowance even after the user approving the tokens. Need help with debugging

The following code is from a Stablecoin project. To gain more context, please refer to this Github repo. I've added a new function to the DSCEngine.sol name collapseDsc() which is responsible for ...
alfheimrShiven's user avatar
1 vote
1 answer
18 views

Can approve function be malicious?

I'm so confused on how approve functions works: If myToken contract has an approve function but the owner did not approve the contract B. Then contract B deploys a function and create a function that ...
anonauditor's user avatar
1 vote
1 answer
34 views

Invalid Permit Signature - Same Signature Generated by Different Address?

Our dApp uses Permit for gasless token approvals. We are generating a signature request with signTypedData, and it works except for a few strange occurrences where I am getting back an invalid ...
Jeffrey Dennison's user avatar
2 votes
1 answer
29 views

Transfer tokens to and from smart contract [closed]

I would like to have a new ERC20 token and one or two smart contracts to do automatic trade with specific cryptos. Example: I can buy 1 token from the contract in exchange for 1 USDT. I can sell a ...
Roger that's user avatar
0 votes
1 answer
24 views

Execute ERC20 Approve outside of ERC20 contract

I am rewriting the solidty-by-example.org crowdfunding exercise. IERC20 public immutable token; function pledge(uint _id, uint _amount) external { Campaign storage campaign = campaigns[_id]; ...
stevealock's user avatar
0 votes
0 answers
26 views

How to check approvals for bunch of addresses

I have a list of ethereum addresses and I need to check which contracts and which approvals for a particular token they gave. I only need query approvals for one specific token. is there some ...
user122885's user avatar
0 votes
1 answer
28 views

ERC20 approval confusion

I have a smart contract which looks like this. // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import "@openzeppelin/...
Joby Ingram-Dodd's user avatar
0 votes
0 answers
20 views

Fantom cannot approve spending USDC token

I am doing simple approve operation on USDC token in Fantom network. Here is my payload: functionParams { from: '0xd775b00b5cf6e954aed8408202367a1bae6ac55f', to: '...
Oleksandr Tserkovnyi's user avatar
1 vote
2 answers
56 views

Implementing an ERC20 Smart-Contract within another Smart-Contract

I’m trying to create a contract that lets people choose to pay for their transactions with either ETH, or another ERC20 Token - one that I’m creating and for now calling “DummyCoin”. So basically when ...
Mark55's user avatar
  • 959
0 votes
1 answer
91 views

Metamask - get value entered from calling ERC20 "approve()" method

When we're asking a user to approve() the spending of a proprietary ERC20 Token for the first time (like say DAI, or SUSHI, etc.), the user has to enter the amount they're willing to approve - like ...
Mark55's user avatar
  • 959
0 votes
0 answers
23 views

I am trying to create a contract to stake ERC20 token and getting this error "ERC20: insufficient allowance". I used approveContract to approve

I first approve allowance through 'approveContract' function and then try to transfer the amount using 'transferFrom' function of ERC20. But getting error :ERC20: insufficient allowance: function ...
Kanak Jaiswal's user avatar
0 votes
1 answer
44 views

insufficient allowance Error .. ERC20

// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/utils/math/SafeMath.sol"; import &...
kaay's user avatar
  • 7
0 votes
1 answer
38 views

Token allowance of router address

Pretty much every coin with taxes has an allowance function to give the router allowance over max uint to be able to sell the tokens. However, I always see the allowance given to 'router', which ...
Andy's user avatar
  • 185
0 votes
1 answer
40 views

transferFrom not working. Estimate gas fee error. Cant find the bug

Code of contract followed by an explanation and requirements. Everything works but trade function. /** *Submitted for verification at Etherscan.io on 2023-05-16 */ // SPDX-License-Identifier: ...
SideChain Labs's user avatar
0 votes
1 answer
2k views

How can I remove custom spending cap on Metamask?

When I call the approve function of the ERC20 token standard, it asks me to set a custom spending cap, as shown below. But I need to use the default value every time without clicking "use ...
deKaV's user avatar
  • 1
1 vote
0 answers
148 views

Can I cut a fee using multicall on Uniswap V3?

I developed my own frontend for Uniswap V3, and I was asking myself if I could cut a small fee of the input token using multicall. Basically, I would calculate what 2 percent of the input token would ...
Mhaas's user avatar
  • 19
0 votes
0 answers
20 views

Why my ERC20 approval function has the same owner and spender?

Why my ERC20 approval function has the same owner and spender? //SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/...
Gisha's user avatar
  • 1
0 votes
1 answer
199 views

Getting Fail with error 'ERC20: insufficient allowance'

First I'm deploying Cafe contract and get deployedId from it and then deploy CAFToken contract with deployedId of cafe contract. I've also added deploy script and test case, I guess everything is ...
Akshar Prajapati's user avatar
0 votes
1 answer
167 views

ERC20 increaseAllowance exploit?

I have my own smart contract. Users on my webpage needs to first approve (increaseAllowance) and then they call "donate" function and part of the assets are sent to my vault and the other ...
PoorMillionaire's user avatar
3 votes
2 answers
475 views

ERC-20 token approval fails if amount is close to maximum balance

So I am using Wagmi, which uses Ethers.js under the hood. I have to approve the router address first in order to buy the other token. It works when I use the exact or slightly greater amount than what ...
sanjay dev's user avatar
1 vote
1 answer
124 views

TranferFrom in delegate call

I have an ERC20 test contract, also I did multicall with delegatecall function instead of call. I have a three accounts: account1, account2, and account3. account1 can spend tokens from account2 (I ...
anguser's user avatar
  • 25
2 votes
0 answers
82 views

Use Brownie to send ERC20 tokens to a payable function with the amount of tokens as an argument to the function

I have the following AlgoToken contract: interface StableCoin { function balanceOf(address account) external view returns (uint256); function allowance(address owner, address spender) external ...
Steven Hochstadt's user avatar
1 vote
1 answer
595 views

ERC20 Tax on sell (via swap)

I'm struggling with taxing upon swapping a token back for ETH. I can't figure out what I'm doing wrong here. I'm using Hardhat testnet forking Goerli to work with the Uniswap contracts. Also made ...
matsmakeshift's user avatar
2 votes
1 answer
28 views

Manage tokens on the behalf of to call a smart contract

I would like to transfer tokens to defi smart contracts on the behalf of a third-party. I see no option apart from (1) the third-party to transfer to me directly (2) the third-party to pre-sign ...
Tango Juliet's user avatar
0 votes
2 answers
715 views

Failing to trying to approve contract using ethers.js (CALL_EXCEPTION or cannot estimate gas)

I am having trouble calling a simple ERC-20 approve function from the front end on the Arbitrum network. Any insight is greatly appreciated. I will outline my code below. I am retrieving the provider ...
qoze's user avatar
  • 3
1 vote
0 answers
225 views

estimateGas with prerequisites (gas estimation requires approvals first)

I am trying to estimateGas for an Ethereum transaction with ethers signer.estimateGas(). This transaction should execute several trades on arbitrary DEXs. To execute the transaction approvals of ERC-...
Philipp Schweiger's user avatar
0 votes
0 answers
16 views

Verifying signed messages

I sent signed messages to claim ownership of various tokens yesterday. I'm wondering how long to get them verified as I couldn't do it via the source contracts.
Doojzie Official's user avatar
2 votes
1 answer
2k views

"gas estimation failed" error using Uniswap. Can't fix it, please help

I can't sell alt-tokens back into ETH. This is an issue with multiple tokens, not just one and they all have very high liquidity ($Kabosu and $OHMI). I immediately get the error 'gas estimation failed'...
UniSwapper's user avatar
0 votes
2 answers
39 views

Approve and disapprove a transaction

i want to develop a contract student in which student sign a transaction to update its record and owner would be able to approve or disapprove this transaction how would I able to do this.
Saira Rao's user avatar
0 votes
1 answer
253 views

Token approval questions and issues

I had a DEX approve 1000 USDT. I then traded 1000 USDT. The next day I want to trade another 1000 USDT from the same address, but the same DEX asks me for approval again! On Etherscan Token Approvals ...
user1754501's user avatar
1 vote
1 answer
21 views

What happened to these tokens?

I send some Matic token in one of my wallets to the other for cover fee of a transaction (0.05)matic but as soon as transfer succeeded, this amount transferred to another address, without any approval ...
Alireza's user avatar
  • 350
0 votes
1 answer
138 views

Uncertain how to correctly implement Approve and TransferFrom for ERC20, could you kindly help me to understand?

Having trouble understanding how to correctly implement Approve and transferFrom. Some guidance would be much appreciated, thank you for your time. Below is my Deposit function: / Users can deposit ...
Hari's user avatar
  • 1
0 votes
1 answer
52 views

move approved ERC20 to another contract

I created a contract that acts as my entry contract and gets an address for my second contract that would then call UniSwap exactInputSingle(). for the token that I'm sending to the first contract, I ...
Patrick W. McMahon's user avatar
1 vote
4 answers
507 views

Allowing contract to take ERC20 tokens from msg.sender

I'm kind of new to Solidity and struggling with allowances and approvals. I want my smart contract to be allowed to take ERC20 tokens (LINK in this case) from the msg.sender. I'm using Remix on Goerli,...
TRS's user avatar
  • 131
0 votes
1 answer
236 views

How do i revoke an ERC20 or ERC721 token approval given to a smart contract

I've granted allowance to a smart contract to spend some tokens on my behalf, but it seems i gave it unlimited access. I want to revoke this access as i now know that this could be a potential opening ...
KelvinIOT's user avatar
  • 103
0 votes
1 answer
31 views

I am using safe-connect to make swaps between a wallet, i am not able to find how to approve for example in Pancake to enable cake

The implementation is based on this repository which is great: https://github.com/tschubotz/safe-connect/blob/main/src/App.tsx I am able to handle swap transactions, but i cant seem to find a way to ...
ezIlj's user avatar
  • 1
1 vote
2 answers
193 views

How to set approval for all my erc 20 token on my marketplace smart contract

I am trying to build an nft marketplace where users buy nft using my own erc20 tokens. I want to eliminate the need for the user to set approval for the marketplace smart contract before they want to ...
Fahad's user avatar
  • 9
0 votes
0 answers
36 views

How can I access current time inside transfer function in ERC20 contract?

I want to create a ERC20 contract in which inside the transfer() function I would check if the msg.sender can transfer tokens. This check will be like those we have in stock markets where when someone ...
Gaurav Pant's user avatar
0 votes
1 answer
49 views

Can a user transfer X and Y tokens to a smart contract in a single transaction/interaction with the smart contract?

I'm trying to develop a contract to which users would send certain amounts of tokens A and B to the smart contract. Easiest/obvious way to do it would be to do several transactions in this order: ...
Hiperfly's user avatar
0 votes
1 answer
337 views

Problem with setApprovalForAll( )

I was just scrutinizing the source code of an NFT marketplace. within the createNFT( ) function of their smart contract, I witnessed there is a setApprovalForAll(_marketplaceAddress) right after the ...
Sina Rahimi's user avatar
0 votes
2 answers
370 views

When address A approves a contract S to spend X ERC20 tokens from it, can anyone invoke that spend, or just address A?

Assuming standard flow of events User, who is owner of address A approves to spend X ERC20 tokens, using approve method to a smart-contract S from address A. Then, user calls S to spend that amount X ...
Rustem Mustafin's user avatar
0 votes
1 answer
153 views

Uniswap's swapExactTokensForTokensSupportingFeeOnTransferTokens gives "transfer amount exceeds allowance" error

I am experimenting with Uniswap's swapExactTokensForTokensSupportingFeeOnTransferTokens method by attempting to swap USDC -> WETH -> UNI-v2 using ethers.js just for the sake of understanding ...
astralmaster's user avatar
0 votes
2 answers
46 views

What happens if `transferFrom` fails after `approve` (Risk of remaining allowance)

I'm trying to call Uniswap V2 addLiquidity function, which calls transferFrom internally, and therefore approve must be called beforehand. I would like to do it from a TypeScript code. In that case, ...
ywat's user avatar
  • 177
0 votes
0 answers
141 views

I am unable to transfer an ERC721 token that is owned by the wallet calling the function to the contract address the function belongs to

This is the start of a contract i'm writing, to enable two parties to trade ERC721 tokens via an escrow service. The first step in the contract is that the trade initiator will deposit a token to the ...
0xr13r.eth's user avatar
0 votes
2 answers
142 views

Is it possible to have another wallet execute a transaction on your behalf?

Is it possible to sign a message/transaction, then have another wallet execute the signed message/transaction without first calling "Approve"? This question is for both ERC20 and ETH.
ALL's user avatar
  • 11
0 votes
1 answer
14 views

Why we give crazy amount of approval to DEXs?

I just discovered that we give a crazy amount of approval to DEXs when we approve to swap tokens. What is that? Doesn't that mean their contract can take all the balance? The contract probably doesn'...
Bora Özenbirkan's user avatar
0 votes
1 answer
374 views

How to run the approve method of Matic smart contract on Mumbai Chain?

I am trying to interact with Matic smart contract on Mumbai chain. The contract address would be - 0x0000000000000000000000000000000000001010. This code below is calling the approve method. ...
Abu Sayeed Mondal's user avatar
1 vote
2 answers
258 views

giving contract permission to spend eth

Since eth does not have a contract address, how does one allow a contract to spend it. For example - I put in a swap request - 10 eth for its amount in usdt for example - could the contract spend my ...
user avatar
0 votes
1 answer
767 views

Staking and ERC20 Approve (RPC Error: execution reverted: ERC20: transfer amount exceeds allowance)

I apologize if this question might seem a bit simple beforehand. I'm trying call the deposit function from my frontend, but it gives me the error mentioned above. I am confused as to if this is a ...
HeeeeSark's user avatar
1 vote
0 answers
156 views

Approve and Transfer ERC20 Tokens in contract

I'm pretty new to solidity and struggling with some pretty simple stuff so I was hoping somebody would be able to help me out. Basically, I want to be able to send an existing ERC20 token (ie: USDT) ...
l1nkm4rine's user avatar