How To Use A Smart Contract Custody Exchange (“SCCE”)
Smart Contract Custody Exchanges (“SCCE”) were the very first generation of decentralized exchange mechanisms. They enable anyone with an Internet connection to trade between ETH and ERC20 pairs entirely on the Ethereum blockchain without providing any personal information.
SCCEs are made up of individual smart contracts that handle all aspects of a trade from custody, order book management, and trade settlement — all performed entirely on-chain. This is different from Relayers, which use a hybrid approach where order books are centrally managed off-chain and trades are settled on-chain.
This article provides a step-by-step overview of what it’s like to actually make a trade on from start to finish on the Ethereum blockchain. I chose to use EtherDelta, as it is one of the first (and most popular) SCCEs.
It only makes sense to trade very small amounts on SCCEs. As always, never spend more than you can afford to lose entirely.
🦊 Step 1: Download & Install MetaMask
Follow the instructions to setup your MetaMask wallet.
💸 Step 2: Fund your MetaMask Wallet
Once you’ve installed your MetaMask wallet, it’s time to fund it! Click the “…” button on the top right and select either the “Show QR Code” or “Copy Address to clipboard” option to get your wallet address:
Use your exchange/wallet of choice to send ETH to your wallet address.
🌐 Step 3: Go to https://etherdelta.com
If you have not logged into MetaMask prior to going to EtherDelta, you will see the following message:
Log into MetaMask by clicking the fox logo in the top right of your browser window and entering your password:
Your screen should now look something like this:
💎 Step 4: Select the Asset You Want to Buy
Click the PPT button in the top left to select the asset that you want to buy:
I like ZRX for reasons stated in my previous article, so I chose that.
💰 Step 5: Deposit ETH
Now that you’re on the right order book, it’s time to deposit ETH! Enter the amount that you want to transfer from MetaMask and click deposit:
Clicking the “Deposit” button will cause MetaMask to present a notification; make sure you have sufficient gas settings (I recommend a Gas Limit of 250k and Gas Price of 25 GWEI) then click the “SUBMIT” button to continue:
You should then see this confirmation from EtherDelta:
You have now given custody of your ETH to the EtherDelta smart contract; once the transaction confirms you will be ready to trade!
🤝 Step 6: Make A Trade!
There are two ways to make a trade on EtherDelta — Limit and Market Orders.
Limit Orders are where you set the price at which you want to buy an asset and wait for someone else to take it — you are “limiting” the price at which you are willing to buy. Limit Orders give you the opportunity to buy at a price lower than the market price, but you must wait for someone to fill your order.
You can make Limit Order in EtherDelta using the NEW ORDER box:
You’ll see the following notice from MetaMask after clicking the “Buy” button. Don’t be alarmed — click the “Sign” button to give EtherDelta permission to place your order:
You will see your Order appear in the MY TRANSACTIONS box:
Market Orders are where you take a piece (or all) of someone else’s existing Limit Sell order. This can be accomplished by clicking the lowest-priced order that appears in red (the order closest to the ZRX/ETH divider):
Clicking an order on the order book will bring up the order so you can fill it:
You will again have to confirm this transaction with MetaMask; don’t forget to include sufficient gas:
You’ll then get a confirmation from EtherDelta:
❓ So Now What?
You now technically have ZRX “IOU’s” in the EtherDelta smart contract that are available to be withdrawn so that you actually own the tokens. Generally it is a good idea to withdraw tokens soon after you are done trading.
💸 Step 7: Withdraw Coins from EtherDelta!
Now it’s time to take back custody of your coins from the EtherDelta smart contract! You can withdraw back to the same MetaMask address used to send your deposit to EtherDelta or transfer to another ETH address.
Withdraw to MetaMask
Enter the amount of the token you want to withdraw then click the “Withdraw” tab in the BALANCE box on the top left:
Click the “Withdraw” button to trigger the MetaMask confirmation:
As usual, an EtherDelta confirmation notice will follow:
The ERC20 tokens will be transferred to your MetaMask wallet, but there are some additional steps that will need to be taken to see them in MetaMask:
Transfer to Another ERC20-Compatible Wallet
You may also transfer your freshly-acquired tokens to an ERC20-compatible wallet using the “Transfer” tab in the BALANCE box on the top left:
The “Transfer” button will display the familiar MetaMask confirmation:
Click “SUBMIT” to complete the withdrawal:
🎯 A Note About “Decentralization”
Many people would consider SCCEs like EtherDelta to be a “Decentralized Exchange” — and they wouldn’t exactly be wrong. However, if “Decentralized” is meant to imply that it is somehow more secure to stable, that is simply not true, as evidenced by the EtherDelta DNS hack in December 2017 and a service interruption as recent as March 1st this year:
Having to send a transaction for deposits and order creation/changes is expensive and time-consuming. This is where Relayers offer an advantage, as they use a hybrid approach of off-chain order book management and on-chain trade settlement. My next article will be a step-by-step overview of Relayers.