- Send approve tx on Ethereum
- Send lock tx on Ethereum
- Wait for storeman response on Wanchain
- Send redeem tx on Wanchain
- Wait for storeman response on Ethereum
to
- the receiving Wanchain accountfrom
- the sending Ethereum accountvalue
- the value to be transferred (in wei)storeman
- the storeman (wan/eth) accounts to useredeemKey
- the tx redeem key, including x and xHashtoken
- the token addresses on Wanchain and Ethereum
to
- the receiving Wanchain accountredeemKey
- the tx redeem key, including x and xHashtoken
- the token addresses on Wanchain and Ethereum
from
- the sending Ethereum accountredeemKey
- the tx redeem key, including x and xHashtoken
- the token addresses on Wanchain and Ethereum
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(() => {
const approveTx = cctx.buildApproveTx(opts);
return webeth.eth.sendTransaction(approveTx);
}).then(receipt => {
const lockTx = cctx.buildLockTx(opts);
return webeth.eth.sendTransaction(lockTx);
}).then(receipt => {
return cctx.listenLock(opts);
}).then(log => {
...