Hi everyone, is there a way to code a receive but when a contract receives any token, not just ether?

Feb 13, 2022, 11:27 AM
If you mean a deposit function, then yes.
Feb 13, 2022, 11:40 AM
i don't think so, receive is for the native blockchain token like eth
Feb 13, 2022, 11:44 AM
I want to capture the event when a smart contract receives a token and automatically do something. Should I search for deposit function then?
Feb 13, 2022, 11:48 AM
No, is the token owned by the contract?
Feb 13, 2022, 11:50 AM
No, but it will have an allowance
Feb 13, 2022, 11:51 AM
So the contract calls transferfrom, or is the token transfer called from somewhere else?
Feb 13, 2022, 11:53 AM
Yes, the contract calls transferFrom
Feb 13, 2022, 11:53 AM
Then you need to declare an event, and emit it in the function, that calls transferfrom based on the arguments in the function.
Feb 13, 2022, 11:57 AM
Mmm I think I wasn't clear: I want to replicate the behaviour of a receive fallback function that works with ether but for when my contract receives a specific token the contract is aware of already. Is there a way to implement this behaviour?
Feb 13, 2022, 12:00 PM
no
uint8 costs less than uint256?
Feb 13, 2022, 12:47 PM
The EVM works with 256bit/32byte words (debatable design decision). Every operation is based on these base units. If your data is smaller, further operations are needed to downscale from 256 bits to 8 bits, hence why you see increased costs.
Feb 13, 2022, 12:49 PM
it surely a debateable decision, I shouldn't be paying for uint256 on uint8
Feb 13, 2022, 12:50 PM
found this
https://blog.8bitzen.com/posts/06-03-2019-solidity-global-uint8-variables-cost-more-gas-than-global-uint256-variables/
Feb 13, 2022, 12:52 PM
WTF?!
Really weird
thanks for the info
It this means use uint<256 only for packed structs for save gas?
Feb 13, 2022, 1:05 PM
Very interesting article, thanks for share with us
Also guys, I want share this tool, you can debug transactions line by line, you can simulate transactions, this tool save my life xD https://dashboard.tenderly.co/explorer
Feb 13, 2022, 3:42 PM
solidity is so beautiful
https://www.gemini.com/cryptopedia/what-are-stablecoins-how-do-they-work
Feb 13, 2022, 4:20 PM
Thanks 🙏
Feb 13, 2022, 4:22 PM
yes and python is good for what is needed
not for EVM world
Java another suicide
most of the standrads are in soldity no?
noone said you can't study
but I think that is better to start and specialize with one first
Feb 13, 2022, 4:34 PM
from a python lover, i agree.
Discovered Vyper some time later, but solidity is really cool
Feb 13, 2022, 4:51 PM
anyone worked his maths to develop contracts ? like to find complex formula that would calculate returns for a certain balance and time etc and constantly adapt
Feb 13, 2022, 4:57 PM
@karola96
You've mentioned Vyper, so maybe you know about it's current status in the community.
Feb 13, 2022, 5:00 PM
using comma
Feb 13, 2022, 5:01 PM
Vyper contracts are being deployed every day, someone must be using it.
Feb 13, 2022, 5:02 PM
what would be a good formula for a staking contract that would collect transaction fees
Feb 13, 2022, 5:10 PM
IERC20(Token).balanceOf(user)
Feb 13, 2022, 5:51 PM

© 2024 Draquery.com All rights reserved.