Complete the Swap
When the Swap is ready, it is time to claim the funds
Example
const SWAP_CONTRACT_ADDRESS_ON_DESTINATION = "0x..."; // get this from the docs for your network
const ABI = '{
"constant": false,
"inputs": [
{
"internalType": "bytes32",
"name": "_contractId",
"type": "bytes32"
},
{
"internalType": "bytes32",
"name": "_preimage",
"type": "bytes32"
}
],
"name": "withdraw",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
}';
const provider = new ethers.providers.Web3Provider(window.ethereum);
const signer = provider.getSigner();
const safeSwap = new ethers.Contract(SWAP_CONTRACT_ADDRESS, ABI, signer);
const response = await safeSwap.withdraw(swapInfo.targetContractId, secret, { gasLimit: 200000 });
return response.hash;Last updated