:
Guys anyone of know
What exactly TransferFrom function does in real ?
Like we use in tokens

I don't understand
There is from, to , value..
But it can only be called by the owner of the smart contract right ?

Mar 2, 2022, 5:45 PM
only token owner or approved wallets can call transferfrom
Mar 2, 2022, 5:47 PM
So we have to manually enter
From:
To:
Value: ?
Mar 2, 2022, 5:47 PM
yes
you must be approved enough amount from from
Mar 2, 2022, 5:48 PM
Tell me real example which is happening in to crypto world
Yaa I got it but what is the need ?
Mar 2, 2022, 5:49 PM
real example? all tokens - FT/NFT use this kind of transfer
just assume you want to transfer your friend Alice's 10 dollars to some Bob,
Mar 2, 2022, 5:50 PM
I say Vitalik holds all the eth supply for instance
Why would he give someone this token
Rather than he can do it by himself
Mar 2, 2022, 5:50 PM
if Alice did not give you approval for 10 dollars, how can you do it?
Vitalk holds all eth right, but eth is not contract and we are talking about tokens
Mar 2, 2022, 5:51 PM
So like the owner approves defi platforms the amount of tokens which will be rewarded to users for staking ?
Mar 2, 2022, 5:51 PM
Basic example: a token holder approves some staking contract the ability to move their tokens...i.e. the staking contract "deposit" code calls transferFrom to move the tokens into the contract when called by the user
Mar 2, 2022, 5:53 PM
hmm, a bit different.. approve usually happens before stake transaction because defi contracts need to call transferFrom(your_account, its_own_account, amount)
Mar 2, 2022, 5:54 PM
Why just he cannot transfer the token amount ?
Rather approval
Mar 2, 2022, 5:54 PM
he can just transfer tokens directly, but that doesn't cause the smart contract to run any code (i.e. track his deposit, etc)
Mar 2, 2022, 5:54 PM
I am getting VM exception while processing transaction error

While using transferFrom
Mar 2, 2022, 7:23 PM
hard to say what the issue is without seeing the code, but check that the approval is correct, and that the from address balance is sufficient, etc.
Mar 2, 2022, 7:26 PM
@coffeeconverter
Mar 2, 2022, 7:35 PM
can you toNumber() those? Can't tell the bignumber values there
or toString() is fine too
Mar 2, 2022, 7:38 PM
100
Mar 2, 2022, 7:39 PM
is fromAccount == accounts[0] ?
Mar 2, 2022, 7:40 PM
Nope it's different acc
Mar 2, 2022, 7:40 PM
then why did you check your allowance against accounts[0] ?
Mar 2, 2022, 7:40 PM
Account [0] is owner
Mar 2, 2022, 7:41 PM
you need to have an allowance for sendingAccount to spend "from"'s tokens
in this case you're trying to transfer fromAccount's tokens as spendingAccount, so you should have an allowance for that...your code above checked accounts[0] which is not the one whose tokens are being moved in your example
so check tokenInstance.allowance(fromAccount, spendingAccount)
Mar 2, 2022, 7:44 PM
So this statement relies that fromAccount has given approval to spendingAccount
To transferFrom tokens?
Mar 2, 2022, 7:48 PM
yes
Mar 2, 2022, 7:48 PM
Yeah it worked find 👍🏽
Mar 2, 2022, 7:48 PM
nice
Mar 2, 2022, 7:48 PM

© 2024 Draquery.com All rights reserved.