Questions tagged [erc-20-approve]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
12 votes
4 answers
6k views

Is it possible to batch approve + transfer an ERC-20 token?

In our dapp, we currently have the following user flow: Approve the Sablier contract to spend up to x ERC20 tokens Transfer the x ERC20 tokens to the Sablier contract This is not super bad UX, but ...
Paul Razvan Berg's user avatar
6 votes
0 answers
282 views

Not able to use DAI's permit() function

I'm having trouble testing the permit() functionality from the DAI contract. I've read the documentation and a couple of other resources, although, I got the contract code and deployed myself a copy ...
João Quintanilha's user avatar
5 votes
1 answer
2k views

Difference between Approve() and IncreaseAllowance() in ERC20 contract

Over the last few days, I have been looking up the best and clear explanation of the differences between Approve() and increaseAllowance() of the ERC20 contract. Still, I couldn't come up with a ...
Sina Rahimi's user avatar
4 votes
2 answers
13k views

What is the use case of transferFrom function in ERC20 token contract?

In @openZeppelin's ERC20 implementation here is the code for function transferFrom: function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { ...
user938363's user avatar
4 votes
1 answer
22k views

Ethers.js - Error: invalid BigNumber string

I am trying to approve a larger amount of erc-20 tokens (it has 18 decimals). await token.connect(signer).approve(contractAddress, BigNumber.from((1000*(tenToPowerOf18Digits)).toString())) : If I try ...
David's user avatar
  • 153
4 votes
1 answer
6k views

How to transfer ERC20 token to another contract and calling contracts function

I need to send an ERC20 Token from a contract to another contract and calling a function of the other contract at the same time. I know how to transfer an ERC20 Token from solidity to another contract,...
kavofa's user avatar
  • 43
4 votes
1 answer
2k views

What is the best way to use uniswap without router?

I just bought a scam token. The liquidity pool is still there but I couldn't sell because I couldn't approve the token in Uniswap. When I try to approve, the error "execution reverted: ERC20: ...
Ingtellect's user avatar
4 votes
3 answers
870 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
3 votes
2 answers
20k views

Fail with error 'TransferHelper: TRANSFER_FROM_FAILED' even approved in contract

I'm rying to swap some BNB -> Token, then swap it back, all in one solidity function. Here's my code: interface IERC20 { function approve(address spender, uint256 value) external returns (bool);...
aj3423's user avatar
  • 251
3 votes
2 answers
2k views

Approve ERC20 token inside a contract function

I would like to understand why, approving an ERC20 token inside a contract function doesn't work. Suppose that I create a function in my contract, that calls an approve for an ERC20 token for the ...
xcsob's user avatar
  • 167
3 votes
1 answer
71 views

Is it possible to allow a third-party relayer to spend ETH on your behalf?

With the ERC-20 standard, it is possible to approve a third-party relayer to spend the tokens on your behalf. This can be done by calling the approve function and providing a high allowance value, ...
Paul Razvan Berg's user avatar
2 votes
1 answer
2k views

i am new to this, can someone steal my erc20 token with the Function approve()

I have been using yield Farming (YFValue) and I noticed when I accept the contract via MetaMask. I set faming 500 USDT but in the contract the input was: Function: approve(address _spender, uint256 ...
Tk Gz's user avatar
  • 23
2 votes
2 answers
40 views

ERC20 without approve

Is is good practice if I have a custom-made ERC20 that takes its own tokens out of the user for doing other stuff? I ask since doing it this way there's no need for the user to call approve() ...
dNyrM's user avatar
  • 892
2 votes
1 answer
42 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
2 votes
1 answer
924 views

Current ERC20 approval best practices?

I've been reading some (old) discussions about the potential attack vector of using ERC20 approve (for example: https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729) but I've been ...
MoonGusto's user avatar
2 votes
1 answer
3k views

How to interact with a smart contract without ABI

So I bought a scamcoin (I know). I have the contract and I've managed to decompile the bytecode. How can I interact with the contract to approve the token? https://bscscan.com/address/...
Radu Ștefănescu's user avatar
2 votes
1 answer
2k views

How to approve user to spend all my ERC20 tokens?

In ERC20 we approve a user to spend our token and then they can spend as much allowed using transferFrom, but if the allowance limit exceed then I have to approve again, is there any way to allow them ...
Shubham Singh's user avatar
2 votes
2 answers
524 views

Approve many tokens with one transaction

I need the users to approve the ERC-721 token before the smart contract and transfer it to someone. the default "approve" function works fine. but I'm wondering how to approve many tokens at ...
vajad57's user avatar
  • 205
2 votes
1 answer
1k views

Fail with error 'TransferHelper: TRANSFER_FROM_FAILED' Although approved

I'm trying to make a swap programmatically, I did the following approvals using ethers.js: token0.approve(wallet.address, amount); token1.approve(wallet.address, amount); token0.approve(...
0x_Anakin's user avatar
  • 121
2 votes
1 answer
55 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
2 votes
0 answers
97 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
2 votes
1 answer
40 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
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
1 vote
1 answer
1k views

Usecase for approve and allowance functions of ERC20 token

Could you please enlighten me on how approve and allowance functions work using a usecase? I dont understand the underlying operations of these functions. Especially, when a token owner delegates the ...
Muni V K's user avatar
1 vote
1 answer
150 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
  • 1,011
1 vote
1 answer
2k views

Is it possible for a contract to erc20 approve another contract?

I want my contract (#1) to be able to approve another contract (#2) to transfer erc20 tokens from #1 to #2. Is this possible?
Michael C's user avatar
  • 443
1 vote
1 answer
54 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
75 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
1 vote
1 answer
984 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
1 vote
4 answers
800 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
1 vote
2 answers
256 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
1 vote
1 answer
2k views

Reverted with reason string 'ERC20: insufficient allowance'

I'm newbie on solidity and I'm trying a simple ERC20 on hardhat with task for understand use case I follow this steps Mint in owner Owner owns N token Owner would to approve Receiver for receive ...
Fabio Spadaro's user avatar
1 vote
2 answers
2k views

How do you approve + transfer ERC20 tokens in 1 transaction?

I want to approve my tokens to allow a smart contract to transfer them for me to another contract. Steps: I approve my tokens for Contract A to spend on my behalf. Contract A transfers my tokens to ...
Adrian D.'s user avatar
  • 544
1 vote
1 answer
704 views

Is "approve" required only for transferring tokens? Not a native coin?

Speaking of Ethereum blockchain, or any other one compatible with it: Polygon, Avalanche and others: is calling the function approve(...) mandatory only, and only, when there's a token involved in ...
Markus736's user avatar
1 vote
1 answer
754 views

delegatecall approve of an ERC20 contract

I try to call approve from a contract of another ERC20 contract: The delegate call: // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract Delegate { address public constant f24 = ...
user66732's user avatar
  • 435
1 vote
3 answers
1k views

Why is there no approve function for MATIC token contract?

MATIC token is advertised as an ERC20 token. So why is there no approve function for MATIC token contract? https://polygonscan.com/address/0x0000000000000000000000000000000000001010#code What is the ...
user92683's user avatar
1 vote
2 answers
2k views

Cant pass large uint in react.js (2**256-1) into solidity approve function

I am trying to call a simple approve() to allow my contract to spend my tokens. Trying to make the amount argument = (2**256 - 1) however I am getting the below error message every time. Unhandled ...
Kane Lawless's user avatar
1 vote
1 answer
531 views

Approve and Swap/Deposit at the same time [duplicate]

So one of the most annoying things for me is having to Approve before calling Swap or Deposit. I would love there to be a proxy contract which just calls Approve and Swap/Deposit in the same function. ...
doctopus's user avatar
  • 315
1 vote
3 answers
5k views

IERC20.approve(spender, amount) thinks the owner is also the contract

I have these functions and deployed my contract to Ropsten testnet. function setSmartContractAllownace(uint daiAmountIn) public { IERC20 daiToken = IERC20(ropstenDAI); daiToken.approve(...
Saehun Sean Oh's user avatar
1 vote
1 answer
3k views

Contract with function payable to receive ERC20 token in one shot?

I am trying to write a smart contract with a function that receives an ERC20 token (i.e.: DAI), but the transaction to call this function is always failing. Let's assume I first record the ERC20 ...
Sergi Juanati's user avatar
1 vote
1 answer
916 views

How to make a delegatecall to external ERC20 token's approve function?

What I would like to do is something like this: function testCall(uint amount) public virtual returns (bool) { address tta = address(0xE7B6....); (bool success, bytes memory result) = tta....
Damir Olejar's user avatar
1 vote
1 answer
77 views

Metatransaction EIP-712 compliant reverted on Tether USDT Polygon contract

I have a problem with the execution of a metatransaction EIP-712 compliant, I show you the backend code with ethers.js and the link of the contract on mainnet :slight_smile: Contract : https://...
Giovanni Maria Mazza's user avatar
1 vote
2 answers
153 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
  • 1,011
1 vote
0 answers
174 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
1 vote
1 answer
193 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
1 vote
0 answers
291 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
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
1 vote
2 answers
402 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
1 vote
0 answers
321 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
1 vote
3 answers
1k views

What does web3's approve do before a token sell?

I'm trying to implement a bot with python and web3 from some code examples. All of them call the approve function before selling a token? What is this function for and is it necessary? Thanks
Mjg's user avatar
  • 11