i'm working on a erc21 contract. People are not supposed to send eth to it, but if they do, is there an easy way to enable me to withdraw any eth sent to it?

Sep 6, 2021, 5:40 PM
you can use fallback function, put this (bool sent,) = address(to).call{value : amount}("");
Sep 6, 2021, 5:53 PM
erc21?
Sep 6, 2021, 5:54 PM
sorry 721
Sep 6, 2021, 5:55 PM
ah ok
I don't have experience with it but, if I am not wrong, if you don't add the fallback function the contract will automaticly revert any eth transfer
Sep 6, 2021, 5:55 PM
If you don't make a receive or payable fallback in it a transfer of eth to it will revert
Sep 6, 2021, 6:02 PM
receive() external payable {
require(false,"Don't gimme money");
}
Even if people want to send eth, they won't be able to :)
Sep 6, 2021, 6:27 PM
Isn't it the same if you don't put it at all?
Sep 6, 2021, 6:30 PM
Mm no
Contract can receive eth
From normal transfer
Sep 6, 2021, 6:31 PM
Oh I guess my brain is lagging then ahahah, idk from what I remember if there's no payable fallback/receive it should automatically revert
I might be wrong tho, maybe once I get back on pc I quickly try that
Sep 6, 2021, 6:32 PM
For contract transfer
contract to contract
If user sends from EOA, no issues
Sep 6, 2021, 6:34 PM
Oh ok thanks
Sep 6, 2021, 6:35 PM
mm what?
Sep 6, 2021, 6:50 PM
Eoa to contract
Sep 6, 2021, 6:52 PM
https://testnet.bscscan.com/tx/0xfb9f986383e0cd9f64396485ee37199d8a83e9f4b372c530691e00455a15943a
nope
you can't send without fallback
https://testnet.bscscan.com/tx/0xbda90a72bdc51aa8b432e844eab71fb9ae6f76bc4b6ff9f9b07750ec4413b8e3
Sep 6, 2021, 6:53 PM
Oh interesting thanks freezy for trying that out 😁
Sep 6, 2021, 6:55 PM
yw
Sep 6, 2021, 6:55 PM
Heh
I guess it doesn't xD
Sep 6, 2021, 6:55 PM
thanks btw because I had the doubt for a while
Sep 6, 2021, 6:56 PM

© 2024 Draquery.com All rights reserved.