Utility Methods
Utility methods handle approvals, allowances, refunds, and wallet authentication.allowance
Returns the current ERC-20 token allowance granted by a wallet to a spender contract.Parameters
| Field | Type | Description |
|---|---|---|
blockchain | BlockchainName | Blockchain where the token lives |
tokenAddress | string | ERC-20 token contract address |
walletAddress | string | Token owner address |
spenderAddress | string | Spender contract address (e.g. Rubic router) |
Example
checkApprove
Determines whether an ERC-20 approval is needed and, if so, returns the approval transaction data ready to send.Parameters
ExtendsAllowanceRequestInterface, plus:
| Field | Type | Description |
|---|---|---|
blockchain | BlockchainName | Blockchain where the token lives |
tokenAddress | string | ERC-20 token address |
walletAddress | string | Wallet that will approve |
spenderAddress | string | Spender to approve |
amount | string | Token amount to approve in token units (not wei) |
Response: ApproveResponseInterface
| Field | Type | Description |
|---|---|---|
needApprove | boolean | Whether an approval transaction is needed |
transaction | TransactionInterface | undefined | Approval tx data (present only if needApprove is true) |
message | string | Human-readable explanation |
Example
Tip: TheapprovalAddressfield in theswapresponse contains the address to approve tokens for. Always use that value, as it may differ per provider.
claim
Returns transaction data for claiming tokens that are ready to be redeemed via the Arbitrum Bridge (ETH ↔ Arbitrum). Used whenwaitForStatus resolves with status === 'READY_TO_CLAIM'.
Parameters
| Field | Type | Description |
|---|---|---|
sourceTransactionHash | string | The source chain transaction hash |
fromBlockchain | EvmBlockchainName | Source blockchain: 'ETHEREUM' or 'ARBITRUM' |
Example
celerRefund
Returns transaction data for refunding a failed Celer Bridge cross-chain swap.Parameters
| Field | Type | Description |
|---|---|---|
sourceTransactionHash | string | The source chain transaction hash |
fromBlockchain | CbridgeSupportedBlockchain | Source blockchain |
Example
authWalletMessage
Returns a message that the user must sign with their wallet for Retrobridge provider authentication. The resulting signature must be passed in thesignature field of the swap request.