28 ms·
In case you’re wondering what happened, from the thread: He sent ETH to the WETH contract, received WETH as expected. Then he wanted to do the reverse and sen
by ssiddharth 5y ago
In case you’re wondering what happened, from the thread:
He sent ETH to the WETH contract, received WETH as expected.
Then he wanted to do the reverse and sent WETH, but will not receive anything, because you're supposed to swap your WETH to ETH in exchanges like Uniswap, or call the "withdraw" function in the contract.
For contracts that want to only work with ERC-20 tokens, you use WETH, which comes from a contract that takes 1 eth and gives you 1 WETH.
A known problem with ERC-20 tokens is that transferring them to a contract that isn't made to access them is equivalent to burning them. You should almost never transfer ERC-20 to a smart contract. You instead use approve to give the smart contract permission to withdraw, then call the function you want to receive and tell it to make the withdraw (the contract will internally call transferFrom).
- rob_c 5y agoSo to paraphrase. Broken technology with serious bugs Therefore anyone looking to do anything other than gain speculative wealth should stay well away. Another one born every minute...
- dragonwriter 5y agoSo it's super-bad UX where radically different interaction patterns are used for what are to the user similar kinds of interaction, creating a trap.
- T0Bi 5y agoThe thing is that there are enough frontends using this smart contract where you can simply chose 'WETH to ETH' and you'll get the right transaction. For whatever reason this person thought it'd be a great idea to interact with the smart contract directly. This is possible and fine if you either know what you're doing or read the smart contract beforehand. This user unfortunately did neither.
- dragonwriter 5y ago> The thing is that there are enough frontends using this smart contract where you can simply chose 'WETH to ETH' and you'll get the right transaction. For whatever reason this person thought it'd be a great idea to interact with the smart contract directly. Getting out of the supposed user-opacity of legalese to something that was safe and reasonable for a non-elite-priesthood users to understand, trust, and interact with directly without an intermediary was, I thought, the whole allure of smart contracts over using the old-fashioned dumb kind to manage transactions and business relations.
- zxcvbn4038 5y agoWhy was this person experimenting with $500k? Even with traditional ACH I send a $1 test transaction before any significant sum. I also use the “don’t fuck with paste” browser extension to ensure there are no typeos in the routing or account number, but just the same I still want to see a transfer work before I send a significant amount. With crypto where everything is much more complicated, there are no do-overs, and no bank to step in and undo a mistake, I’m even more cautious. I think this more a story of poor risk management. But they are in good company. I was on the Bear Stearns trading floor when they went bankrupt and I saw a hundred people loose their entire life savings and all their kid’s college money in a few hours. Those were licensed financial experts that were fully knowledgeable and practiced in a variety of risk mitigation techniques - which they failed to apply to their personal portfolios. The company was bought by JPMorganChase and a year later everyone that came over from Bear was gone - JPMC really just wanted the client list and their midtown office tower.
- vmception 5y agoIve been thinking about this in my own smart contract designs: cant a contract have a approve and transfer method that can accept an erc20 contract hash and transfer method from its ABI? Allowing that contract access to the erc20 tokens sent/assigned to it?
- drdeca 5y agoSeems like maybe it would have been good if the ERC-20 standard had been designed such that you couldn’t send the token to an address controlled by a smart contract unless the smart contract had marked itself as being able to receive that kind of ERC-20 token (or as being able to receive all kinds of ERC-20 tokens) Like, if the contract for the ERC-20 token would, when handling a send instruction, would check whether the recipient address was a contract address or an address controlled by a keypair, and if the former, would check if the recipient had been marked (not sure if this marking would be stored as data on the recipient contract or as data on the ERC-20 contract) as being able to handle the token in question, and if not, cancel the transaction (other than gas costs). This seems like it would prevent this kind of error (or at least, reduce the problems resulting from this kind of error to just paying the gas fees), but it would also maybe increase the gas cost of sending transactions with the ERC-20 tokens and I’m not sure whether this increased cost would be negligible or not.
- deleted 5y ago[deleted]
- _theory_ 5y agoSimple enough, right? /s
- ab_testing 5y agoI think this is a problem with crypto that will forever prevent it from becoming mainstream. The average person understands the concept of money but understanding smart contracts is out of scope for a large part of the general population m
- vmception 5y agoIts more analogous to being surprised that a VCR might occassionally eat up and destroy a VHS tape, and thinking “this will stop mainstream adoption”
- vmception 5y agoBillions have been transferred through that contract with no problem. Its pretty much the worse example to bring up that copypasta. This was an early adopter that just got around to experimenting and didnt even try to keep up with how things work now.
- kylebenzle 5y ago
- Cyberdog 5y agoAgreed. It's so powerful but always so complex and confusing and there's just way too many footguns like this. "Gas" is one of those concepts where I have to relearn what it is every time I read about it but never can retain it for very long. (See also Big O notation.) Say what you will about the primitiveness of Bitcoin and other early coins but at least they're quite a bit more comprehensible.
- Traubenfuchs 5y ago> gas Isn‘t that just the fee for transfering cryptocoins from one wallet to another? And you can decide on how much it is for your transfers, but if it‘s too low, your transfer will take a long time, up to „infinity/never“.
- 5y ago
- hughrr 5y agoThe problem with crypto is despite your explanation, I have no idea what any of your post means. Not any of it.
- vmception 5y agoThen learn. There is standardized education available now.
- birracerveza 5y agoHow is you being unable (or unwilling) to understand an explanation of a domain you're unfamiliar with a problem with crypto?
- choward 5y agoI honestly thought it was satire at first.
- peakaboo 5y agoYou are on the Internet - you can find out anything (uncensored). :) But yeah who has the time...
- ur-whale 5y ago>The problem with crypto is despite your explanation, I have no idea what any of your post means. Not any of it. Not entirely sure what point you're trying to make here. Or, in other words: the exact same thing happens to my 80 year old grandmother when I explain about my android phone. Doesn't make the device any less useful.
- noduerme 5y agoWell it makes it less useful if your grandmother can't use it to call you.
- NoboruWataya 5y ago... or if your grandmother tries to use it and loses half a million dollars.
- noduerme 5y agoWait. I'm not letting anyone off the hook for not knowing the above if they put $5 into something, let alone $500k. But even as a coder and someone who was deeply involved in crypto at one point (2011) I find it hard to make heads or tails of wtf this means. All I hear are a lot of acronyms and bizarre edge cases upon edge cases. It sounds like those arguments you'd hear between kids in junior high over magic cards or pogs or something. If this is the level of magical knowledge required to deal with these tokens, it sure seems like a sucker's market.
- footlose_3815 5y ago[dead]
- ALittleLight 5y agoThis is one thing that really confuses me about crypto. Whenever I've worked on a website there is an underlying idea that things need to be simple and intuitive because users aren't going to struggle to figure out how to use your site - they'll just bounce. It's hard to reconcile my experiences with trying to get users to understand and use relatively simple things with the inscrutable nature of the crypto space. Crypto is overflowing with unwieldy acronyms and punishing rakes to step on. And yet, people are putting massive amounts of money into this?
- RaiausderDose 5y agoI would not really call a "one way only exchange contract" magical knowledge.
- fsh 5y agoI still don't get WETH. What is the purpose of exchanging ETH, which is a token on the Ethereum blockchain, for WETH, which is also a token on the Ethereum blockchain (with the same nominal value)?
- guiambros 5y agoERC-20 is a token standard [1] that lives on top of Ethereum blockchain. It defines the API that any contract running on ethereum must implement in order to be considered ERC-20 compatible - e.g., transfer(), approve(), and so on. This is what gives tokens composability, and allow DeFi applications to build on top of each other. As ERC-20 runs on top of ETH, it requires gas (paid in ETH) to execute the contract. But ETH itself is not ERC-20 compatible (after all, it's just the base layer; there's no "ETH contract"), so some folks came up with the idea of wrapping ETH into an ERC-20-compatible contract, thus giving birth to WETH. The advantage is that now ETH (in the form of WETH) can now provide interoperability with the rest of the standardized tokens, including staking, lending, or anything else implemented via a contract. Pure non-wrapped ETH would never give you that; basically you can send your ETH to someone, and that's it. Now, the weak link is that you're relying on the trustworthiness and the quality of the implementation of the contract, which - more often than not - is questionable. The WETH contract itself is pretty simple, with only 62 lines of code [3]. But one may argue it's overly simplistic, and they failed to implement basic safeguards, like sending WETH to itself, which is what caused OP to lose half a million dollars. The other side of the argument is that WETh contract was simple by design. Every line of code in Solidity requires gas to execute, so adding even a basic checking to protect against what OP did would have increased the cost by millions of dollars in aggregate fees for everyone else, besides potentially introducing the risk of attacks or additional bugs. Given that only ~250 WETH transactions[4] (out of 5,562,041 total tx), made the mistake OP did, one could argue that the design wasn't that bad. That's a 99.9955% success rate. (to be clear: if I were the original WETH developer, I would have added the checking, in spite of costing a few additional bucks for everyone else. But I understand why someone may have thought otherwise. Besides, it was 2017; a lot has changed since then) [1] https://ethereum.org/en/developers/docs/standards/tokens/erc-20/ https://ethereum.org/en/developers/docs/standards/tokens/erc... [2] https://www.investopedia.com/news/what-erc20-and-what-does-it-mean-ethereum/ https://www.investopedia.com/news/what-erc20-and-what-does-i... [3] https://etherscan.io/address/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2#code https://etherscan.io/address/0xc02aaa39b223fe8d0a0e5c4f27ead... [4] Mentioned in the reddit thread; have not confirmed myself.
- gws 5y agoI don’t understand why these contracts don’t let addresses that make this particular error recover their funds, it would be easy to implement at contract creation or am I missing something?
- deleted 5y ago[deleted]
- GaylordTuring 5y agoBasically the smart contract could have been written so that this transaction was rejected or so that the money could have been sent back, but that would make inteacting with the contract a little bit more expensive for everybody. Or maybe the developers wanted it to be possible to burn tokens by sending them to the contract address.
- pshc 5y agoThat would be a good fix, and it is a glaring omission. But the contract can't be upgraded, so all existing contracts depending on wETH would have to be migrated or replaced too.
- pshc 5y agoAlso, ERC-777 tokens were supposed to fix this egregious problem by having all transfers check with their destinations (through hooks). There are also various similar extensions to ERC-20 I believe. Unfortunately, practically no one uses 777 as far as I'm aware? Certainly the OG Wrapped ETH contract doesn't, and it can't be upgraded because it's immutable.
- Hermel 5y agoThe additional transaction fees that using ERC-777 would cost in the Ethereum network are probably much higher than someone losing half a million every now and then. So economically, adopting ERC-777 would be a step backwards.
- pshc 5y agoI agree that deploying the full 777 would be too costly, yes, and probably open up reentrancy attacks. But one simple check in the transfer function would have saved this person half a million. I would gladly pay that tiny extra bit of gas for their sake. I wonder how the math shakes out over time.
- ohgodplsno 5y agoEconomically, KYC in the real world is a step backwards. Economically, laws made to restrict trading is a step backwards. There's still a damn good reason we do it, but the crypto grifters seem to only see the economical part of it for some reason.
- ljm 5y agoIn that sense, crypto to me is like a consultancy taking a complex, legacy codebase and saying it'll be easier to rewrite it from scratch. We see how that plays out all the time. Something shiny and new is produced but it completely fails to take into account why the original system was so complex. Given enough time, it becomes just as complex as the old system, if not more complex.
- 5y ago
- tluyben2 5y agoBut why wouldn't the contract decline this kind of 'invalid' transaction? It is invalid as it is now stuck over there forever, meaning it's a case that should be rejected.
- trizuz 5y ago
- raverbashing 5y agoAnd WETH is "Wrapped ETH" because of compatibility and protocol issues (ERC-20)
- helsinkiandrew 5y agoThis reminded me of John Cleeses classroom instructions in "Monty Pythons meaning of life" https://www.youtube.com/watch?v=yKg7IinlUfI https://www.youtube.com/watch?v=yKg7IinlUfI
- oblio 5y agoDidn't you listen?
- truetraveller 5y agoI'm a senior developer with a massive breadth of knowledge. I read like crazy. I have no idea what you just said. I'm sure I could probably understand after a some research. The point is: this stuff is not for the average Joe! It's like the famous quote by some dude: "A monad is just a monoid in the category of endofunctors, what's the problem?"
- alexandrerond 5y agoI'm an average Joe and I understand what you explained and thank you for it.
- throwawaysea 5y agoCan someone explain this in plain English for a newbie that isn’t familiar with these complicated crypto technologies?
- thiagobbt 5y agoImagine there's a machine that you can deposit dollar bills and it registers in an internal database how much you have. The machine calls these stored values as wrapped dollar. You can withdraw your wrapped dollars back as dollar bills whenever you want. This machine also allows you to send these wrapped dollars to other people - it just subtracts from your balance and adds to the other person's. What this guy did is transferring his wrapped dollars to an address no one controls instead of withdrawing as he should. This address was the machine's address, but it's not programmed to handle the balance in it's own account and it runs code that can't be upgraded, so any values sent there are lost. In this example dollar = ETH, wrapped dollar = WETH, machine = the WETH smart contract. The real problem here was thinking a ETH transfer (dollar bill deposit in the example) works the same as a WETH transfer (database transaction in the example).
- throwawaysea 5y agoThanks. This all sounds so complicated and frankly scares me away from using these technologies. I would be worried about making this kind of mistake or worse.
- danielvf 5y agoHere is background on this for a developer-but-not-crypto-developer. The Ethereum blockchain has its own money that is built right into "OS" of the blockchain. It's called ETH. Any time one program calls another, the actual function call itself can send ETH along with it. In fact, to transfer ETH from your account, you just make a function call to another account with no parameters, ignore return values, and transfer some ETH along with it. Now it soon became apparent that this scheme left a bit to be desired: First developers wanted to create their own moneys. ETH is hardcoded into the system, no one else can use that mechanism. Secondly, funds can only be sent, never pulled. It turns out that it is really convenient to have funds pulled by trusted programs. It allows funds to be moved when you are not online. For example, you could make an offer to purchase something, and if the seller accepts, the money can be transferred to seller, and the whatever can be transferred to the buyer in the same atomic transaction. This also allows trusted programs to do the math for you using live market conditions. Lastly, it's a giant security pain to actually have to call someone else's code, and give them the ability to execute right in the middle of the your code, any time code wants to transfer money. (This exact vulnerability lead to the first big hack on Ethereum.) After a period of experimentation with people making their own money programs, the ERC20 standard was born. This standard is just a very small set of methods calls that a program has respond to in order to count as money. This isn't baked into the OS, it's just a standardized API interface between programs. So you can call "transfer(...)" to move money, and you can call "balanceOf(...)" to find out how much money someone has etc. It works reasonably well. The biggest ERC20 you have probably heard of is USDT / Tether. It actualy slightly predates the standardization, and so slightly doesn't match the behavior of everything else. This makes all programs that want to move money have to use a function that checks if the money is acting like USDT or acting like everything else. Now the ecosystem has two kinds of money: ETH that works at the OS level, and everything else that works as a standard program. And these two have different security properties, and different ways of calling them. It's a pain to securely support both of them because the entire architecture of your code for working with them entirely different. And then there's the matter of not being able to pull ETH, which people often need. So people decided to make a program that "wrapped" up ETH into and let others treat it as an ERC20 program. It's called wETH. You send the wETH program some ETH, it holds it, and it internally stores that you now have an amount of wETH to match the ETH you sent in. You can then spend it like any ERC20. Anyone can then ask the wETH program reduce the amount of wETH they hold, and give them back a matching amount of ETH. Most new big blockchain programs, DeFi/NFT/Multichain bridges have switched over to only using ERC20's and requiring users to wrap ETH into wETH to use them. There's even talk/grumbling that the Ethereum blockchain should just provide a special interface allows someone to treat their ETH balance as ERC20.
- deleted 5y ago[deleted]
- awb 5y ago> A known problem with ERC-20 tokens is that transferring them to a contract that isn't made to access them is equivalent to burning them. Is this a bug or a feature?
- hnu0847 5y agoWhere should one go to learn how all of these systems work? I've been trying to make an honest effort to understand how smart contracts, protocols, decentralized exchanges, etc. work, but after reading about the absolute basics quickly get bogged down in a sea of acronyms and jargon that seemingly lacks any clear explanation. This doesn't even include all of the shills, scams, etc.
- guiambros 5y ago> Where should one go to learn how all of these systems work? Here's the path I'd suggest: 1) If you have no basic understanding of blockchains, read Satoshi's Bitcoin original paper, and Ethereum's Yellow paper. 2) Read about ERC-20 [1][2], to understand what "tokens" really are (TLDR: basically a hashtable stored in the ethereum blockchain, containing a mapping of balances to addresses, and the expectation that you must implement a standard API to be considered an ERC-20 token) 3) Learn about Solidity. The language is dead simple if you have any programming background (preferable C, but not too different than Rust/Python/Go), although it takes some time to wrap your head around the idea that the state is stored permanently in the blockchain. There's plenty of tutorials, but I found Ivan on Tech [3] to be excellent, and Moralis Academy [4] if you want something more structured (plus they offer many other courses in this area). Solidity documentation [5] is also excellent. And Remix IDE [6] makes it really easy to experiment and run your "hello world" solidity programs in a simulated environment, without worrying about deploying to testnet, faucets, etc. [1] https://ethereum.org/en/developers/docs/standards/tokens/erc-20/ https://ethereum.org/en/developers/docs/standards/tokens/erc... [2] https://www.investopedia.com/news/what-erc20-and-what-does-it-mean-ethereum/ https://www.investopedia.com/news/what-erc20-and-what-does-i... [3] https://www.youtube.com/watch?v=ILw-7mplRlI&list=PLo0ddf4DBUYv6fyf5uRVsvS-acu2EMFNF https://www.youtube.com/watch?v=ILw-7mplRlI&list=PLo0ddf4DBU... [4] https://academy.moralis.io/ https://academy.moralis.io/ [5] https://docs.soliditylang.org/en/v0.8.11/ https://docs.soliditylang.org/en/v0.8.11/ [6] https://remix.ethereum.org/ https://remix.ethereum.org/