- 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
to
- the receiving Ethereum accountfrom
- the sending Wanchain accountvalue
- the value to be transferred (in wei)storeman
- the storeman (wan/eth) accounts to useredeemKey
- the tx redeem key, including x and xHashoutboundFee
- the value of fee (in wei)
to
- the receiving Ethereum accountredeemKey
- the tx redeem key, including x and xHash
from
- the sending Wanchain accountredeemKey
- the tx redeem key, including x and xHash
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 => {
...