Questions tagged [erc-20-approve]
The erc-20-approve tag has no usage guidance.
142
questions
12
votes
4
answers
5k
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 ...
6
votes
0
answers
266
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 ...
4
votes
2
answers
12k
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) {
...
4
votes
1
answer
21k
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 ...
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,...
4
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 ...
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: ...
4
votes
3
answers
654
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 ...
3
votes
2
answers
18k
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);...
2
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 ...
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 ...
2
votes
1
answer
34
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 ...
2
votes
1
answer
900
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 ...
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/...
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 ...
2
votes
2
answers
484
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 ...
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(...
2
votes
1
answer
35
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 ...
2
votes
0
answers
88
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 ...
2
votes
1
answer
32
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 ...
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'...
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 ...
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?
1
vote
1
answer
24
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 ...
1
vote
1
answer
52
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 ...
1
vote
1
answer
786
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 ...
1
vote
4
answers
634
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,...
1
vote
2
answers
226
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 ...
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 ...
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 ...
1
vote
1
answer
633
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 ...
1
vote
1
answer
716
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 = ...
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 ...
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 ...
1
vote
1
answer
493
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.
...
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(...
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 ...
1
vote
1
answer
909
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....
1
vote
1
answer
48
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://...
1
vote
2
answers
91
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 ...
1
vote
0
answers
161
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 ...
1
vote
1
answer
161
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 ...
1
vote
0
answers
267
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-...
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 ...
1
vote
2
answers
331
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 ...
1
vote
0
answers
233
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) ...
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
1
vote
1
answer
496
views
IWETH9 withdraw function - where is this function sending the ether to?
I've written the following function which swaps DAI back to WETH and then withdraws the WETH and returns the Ether.
After running the function on REMIX I've got the Ether on the contract balance as I ...
1
vote
1
answer
474
views
Estimated Gas in JS Doesn't Match Metamask Gas Fee
I need help with figuring out the estimated gas for an approval. I'm able to get a number but it doesn't match what's in metamask. I'm a noob to web3 and so I'm not even sure I'm passing the correct ...
1
vote
0
answers
163
views
ERC20 approve attack: may its success be dependent on mainer decision about transaction order?
My question is related to the possible attack vector on ERC20 contracts described here. This attack effectively boils down to these steps:
First transaction (mined): Alice calls approve(addressOfBob, ...