Questions tagged [transferfrom]
The transferfrom tag has no usage guidance.
100 questions
10
votes
3
answers
11k
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 ...
6
votes
1
answer
452
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 ...
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,...
3
votes
3
answers
28k
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);...
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 ...
3
votes
1
answer
771
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:...
2
votes
2
answers
1k
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 ...
2
votes
1
answer
6k
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 ...
2
votes
1
answer
686
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 ...
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
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 ...
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
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 ...
2
votes
1
answer
47
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
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 ...
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 ...
1
vote
1
answer
780
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 ...
1
vote
1
answer
252
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 ...
1
vote
1
answer
3k
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 ...
1
vote
1
answer
563
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
...
1
vote
1
answer
459
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 ...
1
vote
1
answer
202
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, ...
1
vote
1
answer
170
views
Before a transferFrom, is it better to check the allowance first?
transferFrom already checks the allowance, so does it make sense?
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
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 ...
1
vote
1
answer
69
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?
1
vote
2
answers
194
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 ...
1
vote
0
answers
110
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, ...
1
vote
0
answers
86
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 ...
1
vote
1
answer
67
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 ...
1
vote
1
answer
1k
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.
...
1
vote
0
answers
47
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 ...
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 ...
1
vote
2
answers
1k
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 ...
1
vote
1
answer
73
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 ...
1
vote
0
answers
153
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 ...
1
vote
0
answers
271
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 ...
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 = ...
1
vote
0
answers
233
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 ...
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'...
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 ...
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 ...
0
votes
1
answer
763
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 ...
0
votes
2
answers
462
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 ...
0
votes
2
answers
54
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 ...
0
votes
1
answer
595
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 ...
0
votes
2
answers
55
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, ...
0
votes
1
answer
34
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,...
0
votes
1
answer
1k
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 ...
0
votes
1
answer
329
views
USDT transferFrom reverting due to high gas consumption
I deployed a pre-sale contract for an ERC20 token and have the purchases being made in Tether USDT. The transactions have been failing when calling the transferFrom on the USDT interface because of ...