Trustless Trading of ERC20 Tokens with 0x Protocol from your Ethereum Contract

With Ethereum tossing up the de-platform standard of ERC20 for the crypto asset or token there has been a emerging trend to conceptualise the domain/industry specific economics based on such crypt-assets or ERC20 Tokens. Each such Token on the ethereum main-net is likely to hold some value either in terms of equity or some kind of utility, which in-turn rises the need of exchange of such value among the holding parties.

Many such exchange platform listing and allowing the ERC20 token's trade are functional these days some of them are controlled centrally as web based platform by some organisations and some are emerging as the trust-less decentralised exchange gearing the control over to the autonomous smart contracts to carry out the exchange trade. One of such standard is provided by 0x Protocol which we will be evaluating over.

 

Odoo CMS - a big picture

  Filling an order from Solidity Smart contract for the 0x Protocol signed Order offer 

Components to Understand

Ethereum VM

Ethereum as a permissionless Blockchain (allows anyone on globe an ability to connect their Node/Wallet without permission) allows anyone with External ETH account to deploy always running Software bundle which we call Smart contracts.

Ethereum itself as collective virtual computing and storage engine hides the actual replications of transaction and Smart contract on every network node and hence can be conceptually visualised as global virtual machine.  

Application Smart Contract

As Ethereum allows the smart contracts to hold the token as well as native ethereum currency, there a lots many application coming up these days providing the trustless and decentralised autonomous solutions driven without control of any central ownership/authority.

Here App contract can be assumed to be one of such application which can holds various ERC20 Token balances on its smart contract’s address.  

Relay Platform (0x Compatible)

A relay platform in general can be visualized as advertising platform where an order offer can be posted by the ‘Party A’ willing to sell some ‘Token A’ in barter or some ‘Token B’. Such orders are then utilized by some ‘Party B’ to fill against on 0x Exchange Smart contract.

0x Exchange

Set of smart contracts required for 0x Exchange Order validation and trustless settlement of the ERC20 token trade order. 

Filling as Taker on unfilled Order

Understanding Workflow

  • Consider an Order Offer as information bundle for advertisement to sell.

  • The order is signed by the maker ( seller in other words). Signing an order is basically private key signature by the Maker onto the hash (checksum) of the Order Information values.

  • As the information bundle is independent of Technology and media - it can be posted anywhere where the Taker party can get it handy. Eg. On the Exchange’s Relay.

  • OTOH, a Taker on getting hand of such matching Order can fill against such Order.

  • The Order information bundler as per 0x protocol standard has the Exchange address where it is authorized by Maker/Seller to fill against.

  • This means the Maker/Seller party decides where his/her order should be filled or settled while initially signing