Skip to content

Latest commit

 

History

History
88 lines (55 loc) · 1.78 KB

eth-outbound.md

File metadata and controls

88 lines (55 loc) · 1.78 KB

Ethereum - Outbound (WETH ⇒ ETH)

Basic Steps

  • Get outbound fee
  • Send lock tx on Wanchain with outbound fee
  • Wait for storeman response on Ethereum
  • Send redeem tx on Ethereum
  • Wait for storeman response on Wanchain

Required and optional fields

Lock fields

  • to - the receiving Ethereum account
  • from - the sending Wanchain account
  • value - the value to be transferred (in wei)
  • storeman - the storeman (wan/eth) accounts to use
  • redeemKey - the tx redeem key, including x and xHash
  • outboundFee - the value of fee (in wei)

Redeem fields

  • to - the receiving Ethereum account
  • redeemKey - the tx redeem key, including x and xHash

Revoke fields

  • from - the sending Wanchain account
  • redeemKey - the tx redeem key, including x and xHash

Using Wanx

Simple Usage: if the specified Wanchain and Ethereum accounts are open, then you can do the whole crosschain transaction all in one call. You will want to set up event handlers to watch for progress.

cctx.send(opts);

cctx.on('info', info => {
...

Alternatively, you can do the lock and redeem steps separately.

// do lock
cctx.lock(opts);

cctx.on('info', info => {
...

// later, and even maybe elsewhere, do redeem
cctx.redeem(opts);

Advanced Usage: if you need to handle each step separately, like if some steps need to happen on the client and others on the server, you can manually handle each step of the crosschain transaction.

// fine grain handling
Promise.resolve([]).then(() => {

  return cctx.getOutboundFee(opts);

}).then(fee => {

  opts.outboundFee = fee;

  const lockTx = cctx.buildLockTx(opts);
  return webwan.eth.sendTransaction(lockTx);

}).then(receipt => {

  return cctx.listenLock(opts);

}).then(log => {
...