Skip to main content
15 votes
Accepted

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

The use-case is that you give permission for someone else to transfer from your account. That someone else can be either an externally-owned account or a smart-contract account. For example, suppose ...
goodvibration's user avatar
9 votes
Accepted

Ethers.js - Error: invalid BigNumber string

The problem is that the toString of the number will convert it to a scientific representation which cannot be interpreted by the BigNumber. The cleanest way to get around this is to use BigNumber when ...
Richard's user avatar
  • 5,024
8 votes
Accepted

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

The issue is that you need to approve the pair and not the router. Looking at the transaction you linked you can see that it revert on the transfer from 0xa89C6f52Ce3Ce1BFF6CAac1E1c98b4f9b3AA5f63 (...
Richard's user avatar
  • 5,024
6 votes

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

it is possible to batch approve+transfer in one atomic call transaction using Create2 opcode check this link for more information https://medium.com/coinmonks/on-efficient-ethereum-transactions-...
snaketh4x0r's user avatar
6 votes

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

This particular behaviour can be seen throughout most Dapps which interact with a user's token balance in some way or another. Uniswap, 1inch, Bancor and many more of the leading Dapps require the ...
Bobface's user avatar
  • 385
5 votes
Accepted

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

In ERC20, you need to first approve the token for the contract providing the service. Then you can use transferFrom function of ERC20 Token within your service contract to use the approved amount of ...
Achala Dissanayake's user avatar
5 votes
Accepted

Approve ERC20 token inside a contract function

Thus, to approve my contract to spend token for some tokens' holder, the msg.sender in the approve function of ERC20 should be the token holder, hence the token holder should call the function ...
hroussille's user avatar
  • 7,751
4 votes
Accepted

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

Yes, technically the _spender can take up to 999999999999999000000000000000000 of your tokens. Unfortunately, this is common practice, as it makes token transactions of this nature more user-friendly. ...
Shane Fontaine's user avatar
3 votes
Accepted

Solidity: ERC-20 TransferFrom reverts after approval

Your problem is that you can't do approve and transferFrom in the same transaction. The approve has to be performed by the token owner. So basically the token owner calls the token contract's approve ...
Lauri Peltonen's user avatar
3 votes

Usecase for approve and allowance functions of ERC20 token

The original use case from back 2016 is that back in a day, smart contracts had no way to interact to incoming token transfer. (This has been now fixed with ERC-777 token standard and send()). For ...
Mikko Ohtamaa's user avatar
3 votes

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

The simple difference is that approve updates the approval to a specific (given) amount, while increaseAllowance increases the current allowance by the given amount. The former is part of the ERC20 ...
Lauri Peltonen's user avatar
3 votes
Accepted

Execute ERC20 Approve outside of ERC20 contract

No, it is not possible to implement this inside the function. As you might already know that when we call functions of contract "A" via contract "B" then contract B becomes the msg....
Zartaj Afser's user avatar
  • 4,464
3 votes

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

The only options I can think of are: Sign a transaction sending Eth and give this to someone. They can broadcast this when/if they want to use your Eth. Lots of downsides, for example that the nonce ...
Lauri Peltonen's user avatar
2 votes

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

Yes, a contract can approve another contract to make transfer from its tokens. contract A { ERC20 token; function approveAndCall(B recipient, uint amount) public { // Approve ...
Ismael's user avatar
  • 30.5k
2 votes

How to approve user to spend all my ERC20 tokens?

What is usually done (you can see such cases on decentralized exchanges) is to approve a very large number of tokens (greater than the total supply). A library such as bignumber.js can help you to ...
clement's user avatar
  • 4,322
2 votes

How to interact with a smart contract without ABI

If you do not have ABI you can interact with the smart contract by hand-crafting the Data payload for the transaction yourself. Here are instructions how to construct the data field payloads by hand. ...
Mikko Ohtamaa's user avatar
2 votes

How can I check on the frontend if an ERC20 address has approved a contract? (Approval)

You will need to use a Web3 library such as Web3.js. Regarding any smart contract, call the allowance method. AND/OR Specific to a farm, you can check with Zapper API by following this link: https://...
AvocadoChocolate's user avatar
2 votes
Accepted

Current ERC20 approval best practices?

IMO it is, as long as you trust the contract you approve to be good. limited allowances are definitely safer (in the case an exploit would be discovered somehow that would allow a malicious actor to ...
Foxxxey's user avatar
  • 4,337
2 votes

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

You must change the mint function. If it is callable by the end user, why would you want it to take as a parameter _tokenamount? You only need to know the amount of NFT tokens the user would like to ...
Riccardo Perego's user avatar
2 votes
Accepted

Can Metamask be used for all ERC20 token?

All ERC20 tokens are fully supported in Metamask, and WETH is an ERC20 token. The tricky thing is that you have to manually add the tokens, since otherwise Metamask doesn't know which tokens you have. ...
Lauri Peltonen's user avatar
2 votes
Accepted

move approved ERC20 to another contract

To move an approved ERC20 token from one contract to another, you can use the transferFrom function of the ERC20 contract. The transferFrom function allows you to transfer tokens from one address (the ...
Hasan S.'s user avatar
2 votes
Accepted

ERC20 increaseAllowance exploit?

From what I see the malicious contract attacked the old MetaOchtapas contract That contract didn't have any verification regarding the sender, so anyone could have withdraw the funds once the proxy ...
Ismael's user avatar
  • 30.5k
2 votes
Accepted

Getting Fail with error 'ERC20: insufficient allowance'

You're having this error because you didn't give allowance for your transferFrom to succeeds. transferFrom works with approve. You can fix this by using transfer or by calling approve before using ...
Adam Boudj's user avatar
  • 2,411
2 votes

How can I remove custom spending cap on Metamask?

Simple answer, you cannot for good reason. Find your answer here. We designed this interface to give you more control and visibility over your token allowances, since you'll be prompted to always ...
norym's user avatar
  • 176
2 votes

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

when you send the transaction you cannot override the argument again if you do that that will be another transaction. in your case you hardcoded the 1000 to be approved and in metamask user can enter ...
mahyar's user avatar
  • 75
2 votes

Transfer tokens to and from smart contract

in order to do this, you need to merge the deposit and claim functionality in one function. Depositing 1 USDT and receiving the token in exchange is what it means. Claim is for the user to transfer ...
Jaskaran Singh's user avatar
2 votes
Accepted

ERC20 without approve

A token where someone else can deduct the balance of the user is not safe. Any action that causes cost to the user must be initiated by the user.
Mikko Ohtamaa's user avatar
1 vote

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

There are at least a couple of mistakes: 1/ You are inheriting from FUDX and receive FUDX in the constructor. So it is likely you have two unrelated copies of FUDX. Then you call approve from the ...
Ismael's user avatar
  • 30.5k
1 vote

Be notified when an Ethereum event occurs

You can use OpenZeppelin Defender it has a Sentinels functionality that allows to monitor a deployed contract, and you can choose to be notified via Email, Slack, Telegram, or Discord, push data to ...
Julissa DC's user avatar
  • 1,916
1 vote
Accepted

How can I send my NFT (ERC721) Token (minted on ContractA) to another Smartcontract (ContractB) so that it is allowed to transfer it?

It's totally possible. If you are the NFT owner (ContractA would return your address for call ownerOf and your NFT id) you could simply call safeTransferFrom (where from address would be yours). If ...
ashhanai's user avatar
  • 516

Only top scored, non community-wiki answers of a minimum length are eligible