If the locked funds are not redeemed by a certain amount of time, then the
cross-chain transaction changes to a state of Revoked
within the smart
contracts. Once it changes to Revoked
, the funds can no longer be redeemed by
the receiver, but instead must be revoked by the sender.
The amount of time before the cross-chain transaction expires is defined by the cross-chain smart contracts. For the ERC20 integration it is 8 hours on mainnet and 4 hours on testnet.
Just as with the Ethereum integration, revoking an ERC20 cross-chain transaction involves only making a single contract call. For our example, going inbound from DAI to Wanchain, we need to make the call on Ethereum so that we can get our DAI sent back to the Ethereum account.
Let’s start by making a new script file for the revoke.
$ vi dai2wdai-revoke.js
The top portion of the script can be copied from the dai2wdai.js
script. The
only things we need to do are:
First, let’s make sure to add in the redeemKey generated by the expired inbound transaction.
const opts = {
...
redeemKey: {
x: '<the x value>',
xHash: '<the xHash value>',
}
};
Then we can set up the revoke call.
Promise.resolve([])
.then(sendRevoke)
.catch(err => {
console.log('Error:', err);
});
function sendRevoke() {
// Get the raw revoke tx
const revokeTx = cctx.buildRevokeTx(opts);
// Send the revoke transaction on Ethereum
const receipt = await utils.sendRawEthTx(web3eth, revokeTx, opts.from, ethPrivateKey)
console.log('Revoke sent:', receipt);
}
Go ahead and run the script.
$ node dai2wdai-revoke.js
You should just see some output once the revoke call confirms. If you see an error, it is more than likely due to one of two following problems.
Now that we have successfully sent and revoked inbound ERC20 cross-chain transactions, we are ready to move on to discussing outbound ERC20 cross-chain transactions.