Questions tagged [transferfrom]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
9 votes
3 answers
10k views

Why does ERC721 have transferFrom and safeTransferFrom?

ERC721 has both safeTransferFrom and transferFrom, where safeTransferFrom throws if the receiving contract's onERC721Received method doesn't return a specific magic number. This is to ensure a ...
BlakeMScurr's user avatar
6 votes
1 answer
401 views

Why ERC721 does not have direct transfer function?

I was researching the ERC721 standard on Openzeppelin and I have noticed that there is not public or external "transfer" function. I see internal "_transfer" function, that is ...
Alexander Herranz's user avatar
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
3 votes
3 answers
22k 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
1k views

Why does SafeERC20 assume that the token's transfer and transferFrom return value is optional?

In openZeppelin's SafeERC20, the functions safeTransfer and safeTransferFrom call an internal function called _callOptionalReturn, which makes a low-level call to the token's transfer and transferFrom ...
Liron Achdut's user avatar
3 votes
1 answer
743 views

Overflow error when calling ERC20 method 'transferFrom' from web3

I'm just trying to transfer from one of my smart contracts in Ropsten to my wallet 1.02 WETH with this line const deposit = weth.methods.transferFrom(contract,wallet,1020000000000000000).send({from:...
Hiperfly's user avatar
  • 459
2 votes
2 answers
966 views

What is best practice for transferFrom out of these two ways

I want to know which among these is best practice when dealing with transferFrom. that is when one should wrap it in require and when not to. require(token.transferFrom(msg.sender, address(0),token ...
Sabreena's user avatar
2 votes
1 answer
5k views

What is the difference between safeTransferFrom() and transferFrom() functions in openzapplin ERC721 token contract?

I feel there is no need to have safeTransferFrom , the basic tasks can be doable with transferFrom(). Could you please let me know whether can I go ahead with removing safeTransferFrom() function ...
Ashok Sandhyala's user avatar
2 votes
1 answer
676 views

TransferFrom ERC20 token to burn address from another Contract

I am working on a migration contract and the flow is as follows: Contract function calculates balance of XXX coin -> Contract sends amount XXX of OLD token to burn address -> Contract sends xxx ...
Joe_Bloggs'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
1 answer
2k views

How to approve() a ERC721 token to an unknown address which buys the token at some later point?

I am building an NFT marketplace where the user actions are as follows. Address A uploads an image to create an NFT. This action calls smart contract functions createToken() to create ERC721 token ...
Anil Dharni's user avatar
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
2 answers
2k views

How to use erc20 transfer in another contract in remix ethereum using metamask?

I read a lot of documentation in here and another web pages, I have a question and I so tried to solved but nothing works for me. I am using this example. It works fine with truffle, but I don't ...
Kypanz's user avatar
  • 39
2 votes
1 answer
41 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
2 answers
4k views

How can I invoke an approve() function call from the user and not the contract?

I am working on a basic staking platform for practice. I understand that the user of the platform has to call the approve() function and pass the contract into it in order for the contract to use the ...
user68609's user avatar
2 votes
1 answer
43k views

TRANSFER_FROM_FAILED error when trying to swap BCLNC tokens for ETH on Uniswap

I'm attempting to swap BCLNC tokens for ETH on Uniswap, but I get the following error: The transaction cannot succeed due to error: TransferHelper: TRANSFER_FROM_FAILED. This is probably an issue ...
Neo's user avatar
  • 158
1 vote
1 answer
773 views

Can't transfer ether from contract to another contract ^0.5.0

I try to transfer ether from one contract B to contract A. But I get "Transaction mined but execution failed" Code: pragma solidity ^0.5.0; contract A { address payable public owner; uint ...
geor's user avatar
  • 13
1 vote
1 answer
211 views

Request a transaction amount in a function

I'm trying to have a function generate a request such that it pops up a Metamask request. I know I can do: require(msg.value == amount); to require the function call has a certain value. But this ...
gmondok's user avatar
  • 87
1 vote
1 answer
2k views

deposite and withdraw erc20 token using smart contract

my goal is to create a smart contract which user can deposit erc20 and withdraw erc20 token using.i tried to implement this functionality using token transfer and transferfrom functions tried to send ...
Harish Manthurthi's user avatar
1 vote
1 answer
556 views

ERC721 testing transferFrom()

How can I test (truffle test or development console) the following: await nft.transferFrom(accounts[0], accounts[1], 1); await nft.transferFrom(accounts[1], accounts[0],1); The second line throws ...
user66732's user avatar
  • 455
1 vote
1 answer
160 views

How to check if safeTransferFrom succeeded?

safeTransferFrom function doesn't return any value: function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ...
Falcon Stakepool's user avatar
1 vote
1 answer
158 views

Before a transferFrom, is it better to check the allowance first?

transferFrom already checks the allowance, so does it make sense?
donnoh's user avatar
  • 123
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
1k views

Is it possible to transfer token from other address if I have private key from it?

I know that if someone owns tokens he can simply call transfer method of contract to send money. I also know that for ERC20 contract owner of tokens can call approve for my account, and then I can ...
Oroffe's user avatar
  • 263
1 vote
1 answer
66 views

Do dapps(contract) check allowance of buyer when he calls buy function?

When a buyer calls a buy function on dapp contract, some dapps check the buyer's allowance before transfer tokens(erc20). Is it usual?
lagoiz's user avatar
  • 147
1 vote
2 answers
100 views

How can I fix a problem with transferring ERC721 by approved contract?

Hey everyone I'm new to NFT development and developing an ERC721 token for property ownership and marketplace. I implemented two functions to enable a user to put their token on sale for another user ...
emtothed's user avatar
1 vote
1 answer
282 views

Uniswap V2 Transfer Tax Math

The normal question to get the amount of token received when doing a Uniswap V2 swap is amount_out = 0.997 * amount_in * reserves_out / (reserves_in + 0.997 * amount_in) I want to adjust this equation ...
galpo's user avatar
  • 145
1 vote
0 answers
47 views

ethers.js can't transferFrom USDT. Numeric_fault Underflow

Error: underflow [ See: https://links.ethers.org/v5-errors-NUMERIC_FAULT-underflow ] (fault="underflow", operation="BigNumber.from", value=178193613693.6, code=NUMERIC_FAULT, ...
kalik's user avatar
  • 11
1 vote
0 answers
54 views

Why WETH contract use src, dst, wad instead of from, to, values?

When I read WETH9 contract code, I felt strange. For example, generally "transferFrom" method has "from", "to", "value" as parameters but WETH9's transferFrom ...
ttt's user avatar
  • 97
1 vote
1 answer
39 views

"revert erc20 transfer amount exceeds allowance" error with transferFrom() but not with _transfer()

I confirmed that approval is accurate, yet I receive the "revert erc20 transfer amount exceeds allowance" error when using the transferFrom() function. Yet for some reason the internal ...
Gnostication's user avatar
1 vote
1 answer
778 views

multicall and transferFrom

so I have an account 0x1, and account 0x2. both of them have 0xToken. I want to send tokens to 0x3 with multicall transaction. I give allowance from 0x2 to 0x2 => 0x1 able to spend tokens from 0x2. ...
anguser's user avatar
  • 25
1 vote
0 answers
43 views

ERC721 - Undefined amount on TransferFrom

I've got a standard ERC721 - OpenZeppelin wizard generated contract deployed on Goerli network. I've minted a token and I'm trying to transfer said token to another wallet using the transferFrom and ...
mdlapla's user avatar
  • 89
1 vote
0 answers
75 views

can't get ERC721 transferFrom() to work

I'm using pragma solidity 0.8.15; and hardhat. Trying to send an ERC721 using transferFrom(), from an EOA to a contract. I did approve(address to, uint256 tokenId) first. But the transfer is still not ...
em_mutable's user avatar
1 vote
2 answers
993 views

Attack on ERC-777 smart contract and UniswapV2Pair resulting in 104 ETH liquidity drain

My ERC-777 smart contract (Schnoodle, symbol SNOOD) was attacked yesterday resulting in the entire liquidity in the UniswapV2Pair token being drained (104 ETH). The attack was by way of an attacker ...
Neo's user avatar
  • 158
1 vote
1 answer
70 views

Cryptozombies transferFrom function

What happens if function transferFrom is called by owner of _tokenId but with different _from parameter than msg.sender? require() is not checking that msg.sender is equal to _from so I can pass any ...
DP9's user avatar
  • 11
1 vote
0 answers
146 views

MetaMask not showing ERC-20 amount in Transaction - Only showing ETH gas fee

Im experimenting with sending my custom ERC-20 token with MetaMask to my contract. Im using react.js for a simple front end. I press a button which creates a transaction from my metamask account for a ...
Kane Lawless's user avatar
1 vote
0 answers
259 views

Transferring ERC20 token to a contract using custom function

I have a couple of questions related to transferring ERC20 token to a contract. I am developing a protocol that has its own token to provide incentive mechanisms. For certain operations I need to lock ...
DN_Euler's user avatar
1 vote
1 answer
1k views

transferFrom error. Exception thrown in smart contract transaction

I compiled smart contract in solidity on remix.ethereum.org. I made account via MetaMask and want to let other addresses send tokens to themselves using ropsten network. I mean - I am contract owner = ...
WR10's user avatar
  • 11
1 vote
0 answers
232 views

transferFrom is not displaying DAI amount on MetaMask verification popup

I am using web3.min_1.36.js to send DAI to a contract. I already called "approve", so transferFrom is working correctly without error. However, the Metamask verification popup does not display the ...
Tester's user avatar
  • 313
1 vote
1 answer
62 views

When I tap buy button in market how does wallet check my allowance instantly?

On CrytpoKitties, when I tap the buy button in a market, MetaMask comes up and shows if I can buy or not based on allowance instantly. How is this possible? Is it making query? Is it included in kitty'...
lagoiz's user avatar
  • 147
0 votes
2 answers
1k views

Is there a reason why the ERC20/ERC721 `safeTransferFrom` requires a `from` address? Why not just `safeTransferTo` directly?

I can understand that the from address in the safeTransferFrom function could be used by an approved operator. But I also wonder why not have another function for actual owners called just ...
xenon's user avatar
  • 455
0 votes
3 answers
1k views

transferFrom function not working in ICO Smart contract

I am facing issues with the transferFrom function of smart contract address 0x6560a9b6436e129cf835ab9da96201207facd4f8: I copied the smart contract code from etherscan.io and deployed on ropsten ...
Ashadipta's user avatar
0 votes
1 answer
751 views

Solidity: ERC-20 TransferFrom reverts after approval

i am trying to code a smart contract which takes the tokens of the player who enters. function enterToken(address token, uint amount) public { uint _amount = amount * 10 ** 18; IERC20 ...
Royal.Flush's user avatar
0 votes
2 answers
459 views

How bad is it to change a function inside ERC721 interface?

I'm creating a NFT and I want the transferFrom function to be payable. In order to do so I need to edit the ERC721 interface and make that function payable also there. If I do so everything compiles ...
Agilulfo's user avatar
0 votes
2 answers
34 views

transferFrom exceeds allowance though it's approved

I think I do everything correctly but... I get the transfer amount exceeds allowance error..... yes I could just use transfer() and that's it, but... should the transferFrom() also work? I don't get ...
Eugene1111's user avatar
0 votes
1 answer
448 views

Possible to send 0 ERC20 tokens using transferFrom, from any wallet without allowance?

I am seeing some unusual transactions on Etherscan where 0 USDT is being sent from wallets using the transferFrom ERC20 function - sending to an address that has not been given any allowance. It seems ...
Oscar Chambers's user avatar
0 votes
2 answers
50 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
  • 217
0 votes
1 answer
31 views

Why this transaction succeeded to transfer more than its balance?

On BSC chain, this transaction is minting an NFT(MstToken). The evm trace shows it called MstToken.transferFrom(fromUser, ..., 0x30927f74c9de0000) to send out 0x30927f74c9de0000 token and it succeeded,...
aj3423's user avatar
  • 251
0 votes
1 answer
17 views

I have enabled a smart contract with transferfrom - Getting GAS error

Any advice on where to start looking for my error?
Jim Mike's user avatar
0 votes
1 answer
707 views

How many transfer events are there in Ethereum?

So I learnt that ERC20 tokens have Transfer and TransferFrom event. From my understanding Transfer event is when a transaction comes from an address to the smart contract instructing the transfer of ...
Finlay Weber's user avatar