Superbridge
Start typing to search...

Guides

Approvals

Handle token approval transactions before bridging

Quotes may include token approval transactions that need to be executed before the initiating transaction. These are optional fields on the route quote — consumers should use their own allowance checking logic to determine if approvals are actually needed.

Always use the contractAddress from the approval object when checking and setting allowances. The approval target is not always the same contract that is called in the initiating transaction.

tokenApproval

An ERC-20 token approval for the bridging contract to spend the token being bridged. Includes the tokenAddress, amount, contractAddress, and a pre-built tx object.

Check the current allowance for tokenAddress on contractAddress. If the allowance is less than amount, submit the tx.

revokeTokenApproval

Some tokens (like USDT) require the spending allowance to be reset to zero before it can be set to a new value. If revokeTokenApproval is present, the current allowance must be revoked before tokenApproval can be submitted.

gasTokenApproval

Some rollups use a custom gas token instead of ETH. When bridging to one of these rollups, you need to approve spending of the gas token so it can be sent alongside your bridged token to pay for execution of the destination transaction.

The structure is the same as tokenApproval.

Worst case example

Consider bridging USDT to a rollup with a custom gas token. In this scenario, three approvals may be needed:

  1. revokeTokenApproval — USDT has a non-zero allowance that must be reset to zero first
  2. tokenApproval — approve the bridge contract to spend USDT
  3. gasTokenApproval — approve the bridge contract to spend the gas token for destination chain execution

All three must be confirmed before submitting the initiating transaction.