fallback function only works for ether/gas token... you can know how many ether in msg.value inside the fallback function

for erc20 tokens u could use _beforeTokenTransfer or _afterTokenTransfer functions to create a similar functionality

Jun 28, 2022, 11:39 AM
yeah, thats right. but fallback triggered on unknown function signature i.e. direct transfer and direct ERC20 transfer also has msg.data, and i was interested maybe there is some method to get number of received tokens from msg.data
Jun 28, 2022, 11:42 AM
nope
you need to implement a custom function that will be called by the token contract
like deposit()
Jun 28, 2022, 11:48 AM
there's another function like fallback to handle msg.data (so instead of fallback the other one is called and msg.data is filled) but i can't remember the name rn lol
Jun 28, 2022, 11:50 AM
yes, but in my situation i only can use fallback, because it has to be only direct transfer to the sc
i will do more research, thanks )
Jun 28, 2022, 11:51 AM
https://solidity-by-example.org/sending-ether

hope it helps, receive and fallback and explained there
Jun 28, 2022, 11:52 AM
https://ethereum.stackexchange.com/questions/84699/method-like-fallback-function-for-erc20-tokens
Jun 28, 2022, 11:52 AM
@ismailb @FreezyDev thanks guys 👍
Jun 28, 2022, 11:53 AM

© 2024 Draquery.com All rights reserved.