> For the complete documentation index, see [llms.txt](https://docs.safeswap.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.safeswap.io/builders/api-integration-guide/perform-a-swap/cancel-refund.md).

# Cancel/Refund

The original funds can be reclaimed by the user if they no longer want to complete the swap (took too long, lost the secret, swap failed, etc.)

### Example

```javascript

const SWAP_CONTRACT_ADDRESS_ON_SOURCE_CHAIN = "0x..."; // get this from the docs for your network
const ABI = '{
    "constant": false,
    "inputs": [
      {
        "internalType": "bytes32",
        "name": "_contractId",
        "type": "bytes32"
      }
    ],
    "name": "refund",
    "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_ON_SOURCE_CHAIN, ABI, signer);

const response = await safeSwap.refund(swapInfo.sourceContractId, { gasLimit: 200000 });
return response.hash;
```
