* there's a smart contract to which you can send ETH (directly), it sends WETH back
* however the inverse operation (WETH -> ETH) is not done by sending the WETH, you're supposed to call a special conversion function of the contract
I guess the smart contract only looks for ETH in its wallet (at its address), it ignores the WETH entirely, and thus the WETH become inaccessible.
So the contract is a deposit ATM where you can deposit cash and it spits out a bank check, but if you deposit a bank check it just shreds the check.
Or a currency conversion machine where you can shove USDs in the slot to get EURs, but if you shove EURs in, to the shredder they go,
>Or a currency conversion machine where you can shove USDs in the slot to get EURs, but if you shove EURs in, to the shredder they go,
Very good explanation, thanks, though the machine you describe would not probably be called a "smart" ATM.
This example is kinda funny. If your bank notes were accidentally damaged in germany, you could send them to the federal bank and have them replaced as long as more than half of the bank note can be reconstructed. This is a service intended especially for victims of fire or flood catastrophes, though dog related accidents aren't unheard of either.
Why would you ever want to “shred the check”? Is this the intended functionality or a bug?
You don't, and it's not what technically happens, but it's the closest I could find as the actual behaviour can not be replicated in the real world.
The actual behaviour, at least in my understanding, is that the bank check goes in a box to which only the ATM has access, but the ATM was never coded to look for bank checks in the box, and it's not possible to update it, so it's not possible to get the bank checks out of the box.
In the real world you could take the box out and force it open, but in "the blockchain" the contract has sole control of the wallet, an updated version of the contract would be a different contract with a different address.
> Is this the intended functionality or a bug?
It is, in the broadest sense, a bug: the contract was not coded to handle anything other than ETH inputs, so it ignores everything else, but the other things were still moved into the box.
I don't go to a geneticist and go "the problem with genetics is I have no idea what any of it means".
What the redditor did was analogous to ignoring the exposed UI elements on a web page and instead opening up the console and calling the JavaScript functions directly. The average user doesn’t try to do that, and so any such failure is not an issue of the website “needing an advanced understanding”; simply following its UI elements is enough.
So it’s unfair to equate the understanding needed for the top explanation with the understanding needed to use a cryptocurrency app.
That user could have used it how other people use it.
There are a lot of things here that have nothing to do with “crypto needs to be simpler” copypasta. This particular thing was not simple and never will be unless everyone stops using it. Focus on that one thing: How to design a better smart contract? How to design a better UI for the end user? Thats a great discussion for a programming forum actually.
There is an absolute need for cleaner UX on top of this with assurance/insurance to avoid this scenario (both of which exist and are being improved regularly). In the same way you don't directly interface with SWIFT APIs when doing bank transfers, you should not interface directly with ERC20 approve/transferFrom APIs in Ethereum, unless you really know what you are doing.
If you are seriously comparing your monetary system to something that evolved by chance there is a problem with your monetary system.
We shouldn’t shill any technology, and anytime we do talk about it’s virtues we should discuss its shortcomings and why people should be hesitant to use it.
I mean unless you decide to use Amazon EKS for a side project of course...
Which I think drives the point of all this crypto talk in acronyms contributes to it being incomprehensible.
It it a way of storing the same kind of thing that JSON can store.
Though, unlike JSON, it supports comments, uses a python-like significant indentation, and has a few uh, things not in quotes sometimes being taken as strings, but if it is `NO` then instead, if there are no quotes, it will be interpreted as the constant false .
Smart contracts are simply programs stored on a blockchain that run when predetermined conditions are met. They typically are used to automate the execution of an agreement so that all participants can be immediately certain of the outcome, without any intermediary’s involvement or time loss. They can also automate a workflow, triggering the next action when conditions are met.
contract WETH9 {
string public name = "Wrapped Ether";
string public symbol = "WETH";
uint8 public decimals = 18;
event Approval(address indexed src, address indexed guy, uint wad);
event Transfer(address indexed src, address indexed dst, uint wad);
event Deposit(address indexed dst, uint wad);
event Withdrawal(address indexed src, uint wad);
mapping (address => uint) public balanceOf;
mapping (address => mapping (address => uint)) public allowance;
function() public payable {
deposit();
}
function deposit() public payable {
balanceOf[msg.sender] += msg.value;
Deposit(msg.sender, msg.value);
}
function withdraw(uint wad) public {
require(balanceOf[msg.sender] >= wad);
balanceOf[msg.sender] -= wad;
msg.sender.transfer(wad);
Withdrawal(msg.sender, wad);
}
function totalSupply() public view returns (uint) {
return this.balance;
}
function approve(address guy, uint wad) public returns (bool) {
allowance[msg.sender][guy] = wad;
Approval(msg.sender, guy, wad);
return true;
}
function transfer(address dst, uint wad) public returns (bool) {
return transferFrom(msg.sender, dst, wad);
}
function transferFrom(address src, address dst, uint wad)
public
returns (bool)
{
require(balanceOf[src] >= wad);
if (src != msg.sender && allowance[src][msg.sender] != uint(-1)) {
require(allowance[src][msg.sender] >= wad);
allowance[src][msg.sender] -= wad;
}
balanceOf[src] -= wad;
balanceOf[dst] += wad;
Transfer(src, dst, wad);
return true;
}
}Knowing nothing about it, this is the question that remains unanswered to me after reading through dozens of comments on this debacle. What was the person who lost half a million trying to accomplish? For what benefit?
I assume that if you just want to use ETH to buy and sell stuff, you don't have to get involved with any of these smart contracts.
I'm still kind of confused how ypu go from one ERC-20 chain to another. I know there's wrapped Ether on other chains but I'm not clear on how it got there or whether it's a good idea to hold that. Seems like a "not my keys" situation in a way.
Correct. If you want to send someone money unconditionally, you can just send it without a smart contract.
> What was the person who lost half a million trying to accomplish?
Why/when to use WETH? From the beginning:
Like Bitcoin, ETH is a crypto currency that has it's own token called ETH (or Ether), you can hold it, send it from one address to another address and earn it by mining. Providing a basic finance and value excahnge platform.
In addition to ETH, Ethereum supports (via Smart Contracts) things called tokens, that are effectively alternative cryptocurrencies. Pre-Ethereum, people needed to create a new chain for each new token, for example you have "NameCoin" and "LiteCoin" and "DogeCoin" and so on. Each has it's own network, initial block, wallet client, mining pools, etc. It's a copy and paste and edit of Bitcoin each time.
With Ethereum, you can create a new token with it's own separate initial supply, precision, allocations etc. on the same blockchain (Ethereum) using a Smart Contract. People can use these tokens on the same network, using the same tools. However there are limits on how different they can be - you can only do what the Ethereum tech allows.
Now as time went on, there were a lot of tokens, and so they developed a standard, ERC20, which is like a C# or Java interface that defines a standard token. With this in place people can write code that interacts with "any token".
I could create a stock exchange contract where people list, place orders etc. to swap tokens. Even once this stock exchange is written and deployed, people can create brand new ERC20 tokens, and because those new tokens meet the interface, the stock exchange will work with it.
This all hots up and of course people naturally want to use these stock exchange, and other contracts (be it gambling, lending, escrow or whatever...) with the original ETH token, since everyone playing has ETH (you need ETH to pay network fees), and it's value is going up and wotnot.
But ETH is not a smart contract. It's hard coded into Ethereum. It was written before ERC20 was standardized. So you can't use Ethereum as one of the tokens in your stock exchange.
WETH offers a way to wrap Ethereum in an ERC20 token and solve that problem!
Since smart contracts can define rules about deposits, withdrawals, etc, and smart contracts can own their own Ethereum. This wrapping can be done purely in code. No need to trust "WETH Inc"*.
WETH is basically an "adaptor" from the gang of 4 design patterns.
* Other wrapped coins usually require trust. For example "Tether" wraps USD, but it requires a company to manage the bank accounts. People may decide they don't believe that company really has the funds, or the parent company could be put out of business by a government. WETH on the other hand is wrapping something on the blockchain in a code-automated way.
You can make mistakes (like the OP) but unless there is a big security hole no one has discovered, you can't have the money stolen or confiscated unless your private keys are compromised.*
1. Buy ETH
2. Convert to WETH
3. Swap for TOKEN
4. Hold TOKEN
5. Swap token back for WETH (hopefully made a profit there)
6. Convert WETH back for ETH
I did this using Metamask / Uniswap so it is all done for you. So I had no need to understand how the contract works. Also didn't have anywhere near $500k!
function() public payable {
deposit();
}
If it didn't have this no-arg behavior, then the mistake wouldn't have been made.Cryptocurrency is designed for general use. Kubernetes is designed to abstract specific problems away for specialists.
But yeah who has the time...
He did test but using the wrong mental model.
The supporters here are saying "yeah, it shreds dollars, he should have known that". And yeah, if you have a machine that shreds dollars, you better know what it does. That's a good reason for not having such a machine.
Anyway, ETH seems to be full of those features where it shreds money on places that are really not obvious and sometimes gets every single person by surprise.
Fuck knows. No legit reason that I can see; because cryptards are idiots, is the only thing that comes to mind.
> Who anywhere is interested in a dollar shredding feature?
Nobody with the least bit of sense. (But, see above...) That's why he was complaining about 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.