Yo, guys this payTokens function give me error, can someone tell me whats error?

**using IERC20 transfer function for transfer token from account caller to account recipien

Feb 19, 2023, 4:01 PM
which error do you get
Feb 19, 2023, 4:03 PM
"faild"
transfer faild
i did test another IERC20 tokens too, get faild too
Feb 19, 2023, 4:06 PM
does the contract hold that token?
Feb 19, 2023, 4:07 PM
no
Feb 19, 2023, 4:07 PM
then how do you pretend to transfer tokens?😅
Feb 19, 2023, 4:07 PM
thaha, i mean caller will call function for transfer, and function will send that token amounts he has to receive address
Feb 19, 2023, 4:08 PM
ah no ok
than you need to use transferFrom
Feb 19, 2023, 4:10 PM
it will give me allownce error :/🤦‍♂️🫠
i have used approwe but doesnt work
(bool success, ) = myTokenAddress.call(abi.encodeWithSignature("testTra(address,uint256)",_to,_amount));

saw this in stackoferflow, is good way?
Feb 19, 2023, 4:13 PM
testTra is a function?
Feb 19, 2023, 4:14 PM
yes, its mean testTransfer
Feb 19, 2023, 4:17 PM
because you can't call it from inside the contract
the user that call that function has to call approve() directly on the token contract
Feb 19, 2023, 4:20 PM
so what is way for fix this? is any soulation in solidity or should i use web3
Feb 19, 2023, 4:21 PM
address(your_address).call)abi.encodeWithSignature(“testTransfer(address, uint256)”, _to,_amount)
)
Try like this
Feb 19, 2023, 4:27 PM
okay i'll test :D
doesnt work
may should try transferFrom
Feb 19, 2023, 4:33 PM
I told you
the user has to go on token contract and call approve()
passing your contract as argument
Feb 19, 2023, 4:34 PM
so approve is for user, not contract
i mean problem for user, right?
Feb 19, 2023, 4:35 PM
Dawg, here are the steps to follow to transfer from other token:
- get enough allowance from the token address
- use the function mentioned above using transferFrom instead of testTransfer. Make sure you have enough allowance first
Feb 19, 2023, 4:37 PM
okay sir, let me try again
Feb 19, 2023, 4:38 PM
there is no problem here
you only need to understand the approve - transferFrom pattern
Feb 19, 2023, 4:38 PM
Don’t call me sir or I will shy 😂
Feb 19, 2023, 4:39 PM
didn't follow the discussion sorry
Feb 19, 2023, 4:40 PM
😂😂
Feb 19, 2023, 4:41 PM
I got issues upgrading proxy, I can’t see the transaction of creation of the new implementation when I upgrade a contract. I see only the Upgrade transaction and not the second transaction of the implementation
Feb 19, 2023, 4:48 PM
IERC20(_token).approve(msg.sender, _amount);
bool _paid = IERC20(_token).transferFrom(msg.sender, _to, _amount);

doesnt work yet
Feb 19, 2023, 4:48 PM
Nooo
I told you
the user has to call directly the approve on the token contravt
so Alice go on the token contract on etherscan for istance
and in the write section she calls approve()
arw you using oz plugin?
Feb 19, 2023, 4:51 PM
Use Bob, Alice ain’t that techy😂
Yeah
Feb 19, 2023, 4:51 PM
oh okay, i remove approve and test it again
Feb 19, 2023, 4:52 PM
can you share a snippet
and a tx
Feb 19, 2023, 4:53 PM
I got a doubt too:
If I got a variable in boxV1 that has value of 100, and I upgrade to BoxV2 with the value 101 does it change the value during the upgrade?
Sorry, I can’t send these information, I think I can share the units test snippets
Feb 19, 2023, 4:56 PM
without approve doesnt work too. idk why i get these errors
Transaction has been reverted by the EVM
Feb 19, 2023, 5:15 PM
i don't understand if you are fooling me😂
did you do what I said?
have you at least read it?🙈
show me that you approved the contract
Feb 19, 2023, 5:16 PM
😂🤦‍♂️
Feb 19, 2023, 5:18 PM
He’s confused as I was first time I went through this
Feb 19, 2023, 5:19 PM
https://testnet.bscscan.com/address/0xE47c9e25c2a6e3D0Cd0eF388E43b80f9Eb89d2c5
this is token
Feb 19, 2023, 5:20 PM
go on write section
on approve() and input your contract address and the amount to approve
Feb 19, 2023, 5:20 PM
i have approved it
i approved it before
Feb 19, 2023, 5:20 PM
I went trought this too, like everyone I think
but I don't know other ways to explain it😅
Google would help
share tx
Feb 19, 2023, 5:21 PM
Uhm, that is your contract
You need to approve from the contract of the token you need to call the transferFrom function
For example:
If you want transfer Token A from Token B, you need to go to approve on Token A for Token B and then call from Token B the function TransferFrom
Feb 19, 2023, 5:23 PM
maybe this help

https://ethereum.stackexchange.com/questions/46457/send-tokens-using-approve-and-transferfrom-vs-only-transfer
Feb 19, 2023, 5:23 PM
oh yea that works now! 😂
Feb 19, 2023, 5:23 PM
lol
Feb 19, 2023, 5:24 PM
but real question guys if we have multi contracts should we approve one by one? 🫠
Feb 19, 2023, 5:24 PM
I’m stucc’d with the Upgradeables and that’s frustrating but will overcome soon or later or I hope so
It depends what is your mission
Feb 19, 2023, 5:25 PM
once you call upgradeProxy
does it change or no?
you need to approve each contract that wants to use your tokens
Feb 19, 2023, 5:25 PM
Nope, the value of the variable remain the same and I don’t see the transaction of the new implementation
Feb 19, 2023, 5:26 PM
oh okay
I want the user to get some tokens from one pool
We will have different tokens in the pool
like one swap
but its no swap pool
Feb 19, 2023, 5:27 PM
I don’t understand if the value of the variable changes when upgrades or it remains the initial
Feb 19, 2023, 5:27 PM
no I mean the implementation address
does it change?
the storage is inside the proxy
but I don't know what proxy you are using
Feb 19, 2023, 5:28 PM
transparent Upgradeable
Feb 19, 2023, 5:29 PM
isn't useful to use ?
IERC20(address(this), _amount);
Feb 19, 2023, 5:36 PM
this doesn't mean anything
Feb 19, 2023, 5:36 PM
well i mean contract approve itself from token
@FreezyDev check answer1 section
https://ethereum.stackexchange.com/questions/114065/deposite-and-withdraw-erc20-token-using-smart-contract
_token.approve(address(_yourContractAddress), _amountToApprove, {from:_user});
Feb 19, 2023, 5:40 PM
if tokens are held by that contract yes
read this
it is not solidity
is js
Feb 19, 2023, 5:42 PM
well i know, i say is it good to use?
Feb 19, 2023, 5:45 PM
yes
Feb 19, 2023, 5:47 PM
thankyou freezy for taking time :D
Feb 19, 2023, 5:48 PM
Dragon too 🥹
I’m joking no problem
Feb 19, 2023, 5:57 PM
haha i forget you 😂🤍
my dragon
Feb 19, 2023, 5:57 PM
Thank you Virtual Homie
Feb 19, 2023, 5:58 PM

© 2024 Draquery.com All rights reserved.