Skip to content

Commit 6aed7cc

Browse files
authored
Add sweep to the contract execution guide (#155)
1 parent d57df93 commit 6aed7cc

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

references/api/api_guides/calling-integration-guide.mdx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,12 +412,29 @@ quote_request = {
412412

413413
</CodeGroup>
414414

415+
### Sweeping ERC20 Balance
416+
417+
Relay's router contract has a useful function that you can call to transfer out full balance of an ERC20 token, even if you don't know the full balance. There are currently two methods for doing this:
418+
419+
* [cleanupErc20s](https://github.com/relayprotocol/relay-periphery/blob/db8d066881e6d190bd33cbe6abd94e23deeb6b31/src/v2/RelayRouter.sol#L82-L113)
420+
* [cleanupNative](https://github.com/relayprotocol/relay-periphery/blob/db8d066881e6d190bd33cbe6abd94e23deeb6b31/src/v2/RelayRouter.sol#L158-L172)
421+
422+
You can use these by passing in the txs field as follows:
423+
424+
```json
425+
{
426+
"to": "0xRouterContractAddress",
427+
"data": "0xEncodedCalldata", // encoded calldata for cleanupErc20s or cleanupNative
428+
"value": 0,
429+
}
430+
```
431+
415432
### ERC20 Troubleshooting Guide
416433

417434
**Problem**: "ERC20: transfer amount exceeds allowance" error
418435
**Solution**: Ensure you include the approval transaction before your contract call
419436

420-
**Problem**: Transaction reverts with "ERC20: insufficient allowance"\
437+
**Problem**: Transaction reverts with "ERC20: insufficient allowance"
421438
**Solution**: Check that the approval amount is sufficient for your contract call
422439

423440
**Problem**: Approval transaction succeeds but contract call fails

0 commit comments

Comments
 (0)