Questions tagged [erc-20-approve]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
15 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. ...
1 vote
2 answers
24 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 ...
0 votes
1 answer
24 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 ...
1 vote
0 answers
18 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) ...
0 votes
0 answers
20 views

how to fix "ERC20: insufficient allowance" error? [duplicate]

I wrote a very simple contract to use the erc20 functions in another contract and the first thing I tried was transferFrom function, which works perfectly when I'm sending tokens from msg.sender(which ...
0 votes
0 answers
23 views

Transferring ERC20 tokens from a Multi Signature Wallets to a Smart Contract using `approve(...)` and `transferFrom(...)`

I believe I grasp how an on-chain Multi-Signature transfer works from MultiSigWallet → OtherWallet. I get that for a 2 of 2 Multi-Signature Wallet both Owner 1 and Owner 2 would need to individually ...
  • 125
0 votes
1 answer
30 views

"insuffiecient allowance" running my unit test

I'm developing in remix a lottery SC. I have a problem when I run buyTicket() function. On remix I fix it giving approve to SC address from erc20 function, but I don't know how to do it when I run my ...
0 votes
1 answer
32 views

approve contract in wbnb

I deployed a contract on the bsc network to execute functions on the blockchain then I approved my contract at the wbnb address to make purchases and/or sales from the contract. What am I allowing ...
0 votes
0 answers
35 views

How to allow adding liquidity to the pool only if you are the owner of the token

I have created an ERC20 in bsc (testnet), and I have added liquidity with the owner (BUSD-CustomToken), later I have passed a few CustomToken to another account, but I have also been able to create ...
  • 1
0 votes
2 answers
24 views

How IncreaseAllowance and DecreaseAllowance function solve mitgation problem?

I was going through openzeppline code for ERC20 Token and found that While working with approve function in IERC20 interface they describe mitigation problem : Link I don't understand how ...
  • 23
0 votes
0 answers
15 views

Creating / Tracking ERC20 Transfers on Chain

I am creating a contract where users can come and deposit a certain stable coin to the contract. Let's say using these invested funds, the contract owner can use it and be given a certain interest for ...
0 votes
1 answer
86 views

Testing `approve` function

I would like to test a contract where I use the approve function of an ERC20 token. Is there any test suite that allows doing that? truffle? hardhat? Any suggestion would be highly appreciated!
  • 101
0 votes
1 answer
142 views

Can Metamask be used for all ERC20 token?

How can I use WETH with Metamask wallet? I can see ETH in my Metamask (Rinkeby TestNet, it works on Mainnet) but can not use other tokens. Any Repository or lead will be appreciated. If yes, What will ...
0 votes
0 answers
27 views

ERC721 transferring NFTs and currency

I have a contract that I want to use as an NFT marketplace. It extends ERC721URIStorage contract NftMarketplace is ERC721URIStorage ... In on function I use _transfer() to move an NFT from the seller ...
  • 13
0 votes
0 answers
19 views

How to code an approval function

Can someone help me with coding an approval function for Ether, if you could show methe most basic way to do this i would be able to figure out the rest thanks.
0 votes
1 answer
969 views

function selector was not recognized error

I'm extending OpenZeppelins ERC20 to create a Token that I use for testing in another smart contract. Here's how it looks: //SPDX-License-Identifier: Unlicense pragma solidity ^0.8.0; import "@...
0 votes
0 answers
7 views

write contract for "access to your wallet and can transfer USDT to others"? [duplicate]

i have usdt in my wallet , is it possible to give a smart contract permission to access and transfer the usdt from my wallet on my behalf using the "approve" and "transferfrom" ...
0 votes
1 answer
35 views

transfer vs transferFrom "amount exceeds allowance" when sender is the same as msg.sender

I know the reasons for using transfer vs transferFrom but made the mistake of using the second one whilst doing some testing and I got the error "ERC20: transfer amount exceeds allowance". ...
0 votes
1 answer
398 views

How to buy NFTs from my smart contract with custom ERC20 token? [duplicate]

i want to launch a NFT genesis collection for all the holders of the previous collection. The previous collection gave the holders a ERC20 Token airdropped. So the holders have the custom ERC20 Token. ...
0 votes
2 answers
227 views

how to use function approve() and function transferfrom() in a dapp?

hello Me and my team are working on a staking/subscribing dApp on the ethereum blockchain using erc20 stablecoins like usdt and dai. We encounterd an error on the approve() and transferfrom() ...
0 votes
1 answer
398 views

Unable to get ERC20 token approval to accept BUSD

I've tried almost every tutorial and help available online trying to accept BUSD or any ERC20 token in my solidity smart contract. I'm deploying the contract on Binance Testnet and I have 20 BUSD in ...
0 votes
0 answers
24 views

Should ether be stored(in Proxy or Implmentation) if your Upgradeable contract is making a call to some ERC20 token contract?

I have made a contract(say MYNFT contract) which is upgradeable. Now I have a proxy contract and implementation contract (MYNFT contract). In Implementation, an user can mint a NFT if the user wires ...
0 votes
1 answer
253 views

Is this the correct way to handle a approval for ERC20

Please let me know if this is correct. function handleApproval(IERC20 _token, uint256 _numTokens) public returns(bool){ _token.approve(address(this), _numTokens); return(true); }
0 votes
1 answer
151 views

Differenciate logs entry Approval between ERC20 and ERC721

For a dapp, I'm currently focused on the Approval event to track and list the tokens approvals for a given address. ERC20 and ERC721 are quite similar. They offer Approval events : ERC20 : Approval(...
0 votes
0 answers
25 views

Redo infinite approval?

If I have a function that adds liquidity to a Curve pool each time that it's called, and it gives infinite approval the first time, do I have to write a condition to go around the infinite approval on ...
  • 369
0 votes
1 answer
130 views

ERC 20 Royalty implementation

Hello Guys i want to implement a royalty fee on whenever my custom ERC20 token gets transfer between accounts any idea to implement this or any tutorial pls any help would be appreciated function ...
0 votes
1 answer
661 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 ...
0 votes
1 answer
231 views

How to call ".approve()" function of a token which ABI I don't have? In web3.js/ethers

I need to call .approve() function of a token which I address I know but which ABI I don't have. How to do it? Will it be enough to create ABI string which will contain the signature of .approve() ...
1 vote
2 answers
864 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 ...
  • 392
1 vote
1 answer
174 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 ...
2 votes
1 answer
419 views

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

Over the last few days, I was looking up the best and clear explanation of the differences between Approve() and increaseAllowance() of the ERC20 contract, but couldn't come up with a proper ...
0 votes
0 answers
557 views

web3.py - How to get status from ERC20 approve?

I have a web3.py script that approves ERC20 tokens to maximum - Web3.toWei((2**256)-1,'wei') - to bunch of different ER20 tokens (some have 18 decimals, some have 6) on Fantom chain. When i try to ...
  • 101
1 vote
3 answers
601 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
  • 11
0 votes
0 answers
89 views

Can I bypass the "approval" mechanism for tokens within my own ecosystem?

Let's say I have my own ERC20 token FOO. I'd like my users to be able to send their FOO to my smart contract FooSwap. Is it acceptable practice to bypass the approval mechanism in the ERC20 Foo ...
1 vote
1 answer
255 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 = ...
  • 319
0 votes
1 answer
245 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 ...
0 votes
0 answers
49 views

Does any Stablecoin have permit() or approveAndCall() function in polygon mainnet?

I'm trying to develop a DAPP with a stablecoin under the polygon mainnet. Having permit() or approveAndCall() in the token is necessary to complete a transaction in single call, for a better user ...
  • 72
0 votes
0 answers
80 views

Best way for a smart contract to be approved to transfer tokens from a different ERC20 smart contract to an address

I have two smart contracts; tokenContract otherContract tokenContract is an ERC20 contract with a fixed supply of tokens. otherContract is a separate contract that users of our application interact ...
  • 7
2 votes
1 answer
7k 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 ...
  • 81
1 vote
0 answers
78 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 ...
  • 185
0 votes
1 answer
198 views

Can a smart contract approve a pending transaction on a multisig wallet?

Suppose I have a multisig wallet like a Gnosis Safe, which requires (say) two or three signers to approve any given transaction. In other words, the multisig wallet has its own wallet address, and 2 ...
  • 227
1 vote
1 answer
250 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 ...
0 votes
1 answer
39 views

Contract reverts when making calls to erc20 token contract from my contract

i have this basic contract that should work, but it keeps reverting because of the approve call in the constructor, i also notice transferFrom calls from my contract also fails after manually ...
2 votes
2 answers
7k 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);...
  • 213
0 votes
0 answers
1k views

ethers.js - approve function returns "Error: cannot estimate gas"

I tried to create an ERC-20 token on the Ropsten testnet and then tried to call the approve() function but it returns this error: Error: cannot estimate gas; transaction may fail or may require ...
0 votes
0 answers
19 views

Is it possible to add a creator royalty fee for ERC-20 tokens? [duplicate]

What the title says. Is it possible to add (on-chain) creator royalty fees to an erc-20 token. If not, are there any token standards that do allow for this?
0 votes
0 answers
146 views

Do I need to use the approve function to transfer erc20 tokens from one address to another?

I'm making an nft marketplace and I want the buyers to buy the nfts with WETH. function createMarketSale(address nftContract, uint256 itemId) public nonReentrant { ...
  • 31
0 votes
0 answers
152 views

ERC20 ‘TransferFrom’ function test within a ‘createStake’ function

During my searching, I would like a piece of advice on the following problem: I have this function to test in my smart contract createStake (uint256 _stake, address _tokenAddress) /** @notice ...
  • 11
0 votes
0 answers
215 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 ...
  • 121
0 votes
1 answer
160 views

In airdrop contract, I want each registered user to claim free airdrop tokens

I'm writing a simple airdrop contract in which user will register himself using register(), and his address will be added to an array registered[]. After the registration period is over, admin (who ...