Skip to content

Instantly share code, notes, and snippets.

@plutoegg
Created April 1, 2019 14:47
Show Gist options
  • Save plutoegg/26f87e9417d4bc0039d27f9aec114c37 to your computer and use it in GitHub Desktop.
Save plutoegg/26f87e9417d4bc0039d27f9aec114c37 to your computer and use it in GitHub Desktop.
Using TrustlessOTC

Trustless OTC Trade

The Trustless OTC smart contract is deployed at (0x62f49e904af170Ea377F399aCa76C13fF25a6F5E)[https://etherscan.io/address/0x62f49e904af170ea377f399aca76c13ff25a6f5e#code]

This contract allows trading of any tokens, between two counterparties without the need for a trusted escrow.

The instructions here assume the use of MyCrypto or a similar wallet to interact with the Ethereum blockchain.

Setting up a new trade

User A wants to sell 1000 Token YYY for 2000 Token ZZZ.

User A must first give approval for the OTC contract to interact with their balance of Token YYY.

Call 'approve' on Token YYY

  1. Visit MyCrypto and navigate to Tools > Interact with Contracts.
  2. Enter the smart contract address for Token YYY and the ABI (these can be found from Etherscan).
  3. Select the 'approve' function from the dropdown list.
  4. Spender field should be set to the OTC contract address: 0x62f49e904af170Ea377F399aCa76C13fF25a6F5E
  5. Amount should be set to 10000000000000000000000000000000000000000000000
  6. Confirm the transaction

Initialise the new trade

  1. Visit MyCrypto and navigate to Tools > Interact with Contracts.
  2. Enter the smart contract address for the OTC contract and the ABI (these can be found from Etherscan).
  3. Select the 'initiateTrade' function from the dropdown list.
  4. tokenFrom field should be token YYY address
  5. tokenTo field should be token ZZZ address
  6. amountFrom field should be token YYY amount to sell (including trailing zeros to represent decimals - 18 in most cases)
  7. amountTo field should be token ZZZ amount to buy (including trailing zeros to represent decimals - 18 in most cases)
  8. Confirm the transaction

Retrieve trade ID

  1. Once the transaction has succeeded a trade ID will be emitted in an event on the contract.
  2. This contains the trade ID which must be given to the trading partner you wish to fill your offer.
  3. Send the trade ID to your counterparty.

Filling an offer

Call 'approve' on Token ZZZ

  1. Visit MyCrypto and navigate to Tools > Interact with Contracts.
  2. Enter the smart contract address for Token ZZZ and the ABI (these can be found from Etherscan).
  3. Select the 'approve' function from the dropdown list.
  4. Spender field should be set to the OTC contract address: 0x62f49e904af170Ea377F399aCa76C13fF25a6F5E
  5. Amount should be set to 10000000000000000000000000000000000000000000000
  6. Confirm the transaction

Take the offered trade

  1. Visit MyCrypto and navigate to Tools > Interact with Contracts.
  2. Enter the smart contract address for the OTC contract and the ABI (these can be found from Etherscan).
  3. Select the 'take' function from the dropdown list.
  4. tradeID field should be the ID given by your counterparty.
  5. Confirm the transaction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment