Sneak Peek: 0x Trade Widget

Instantly buy Ethereum tokens with 0x protocol

Recently, we have seen an abundance of 0x relayers popping up. These relayers usually have cryptocurrency traders as their target audience and create trading interfaces that feature plenty of red and green graphs and candlesticks. Serious traders need to take a few steps before they can trade using 0x, including setting their trading allowances on the 0x smart contract and converting ETH into WETH to make it tradable. These are friction points for new users who simply want to purchase tokens.

We see this as an area that could use some ❤️, so we built a simple trading widget that allows users to instantly purchase tokens with ETH in a single transaction using 0x protocol. Check out the example below!

A new user with only an ETH balance in their wallet is able to select the token they would like to purchase and the amount of ETH they would like to spend. Upon clicking Submit Order, a trade occurs behind the scenes using 0x protocol and the tokens show up in the user’s wallet. No setting allowances, no wrapping ETH, no deposits.

How does this all work?

Behind the scenes, the trade widget is using something we call a Forwarding contract. The Forwarding contract is just an Ethereum contract that takes care of some of the configuration steps that traders normally have to go through to trade using 0x protocol. Here is how it works:

The user sends ETH and a 0x order to the Forwarding contract. The Forwarding contract converts the user’s ETH into WETH. The Forwarding contract passes the order to the 0x smart contracts, covering the ZRX fee and exchanging the WETH for tokens. The Forwarding contract sends the newly acquired tokens back to the user.

All of the above steps are completed instantly, in a single Ethereum transaction. The only missing piece is the source of liquidity: the 0x orders. Orders could be provided by the dApp that is hosting the trade widget or they could be sourced from existing open order book relayers using 0x Connect and the Standard Relayer API.

We see the simple trade widget as a great way for mobile wallets and web apps to offer a pleasant on-boarding experience for those who are buying tokens for the first time. We also see this as a great solution for “crypto collectibles” or Non-Fungible Token apps and marketplaces when we add support for ERC-721 in the next version of our smart contracts.

What we have written is an MVP — it is not yet production-ready. We wanted to share what we’ve done so far and get feedback from our community and developers.

In the future, we will release a more production-ready Trade Widget that works with the v2 smart contracts and allows for NFTs, market orders and fee abstraction.