Wrapping Ether in an ERC20 Token

May 26, 2018 by Steve Marx

In this short post, I’ll show how ether can be “wrapped” in an ERC20-compatible token. This means ether can be used anywhere that an ERC20 token is expected.

Why Wrap Ether?

Ether is the native currency of Ethereum. It predates ERC20 and other token standards, so it doesn’t have the same interface. This can be the source of complexity in smart contracts. If a smart contract is to accept all types of currency, it must implement two interfaces: one for ether and one for ERC20 tokens.

“Wrapping” ether solves this problem by introducing a layer of indirection. Users can purchase ERC20-compatible “ether tokens” for native ether, at a 1:1 exchange rate. Then they can use those tokens with any smart contract that understands ERC20. Finally, the tokens can be exchanged back for ether, again at a 1:1 exchange rate.

The term “wrapping” comes from a token called W-ETH. That implementation is very similar to the contract presented in this post.