Skip to the article
NewsCrypto

Crypto markets, protocols and regulation

Difference between relayTokens and transferAndCall: token flow

Omnibridge relayTokens vs transferAndCall ERC-677 deposits differ in approval, token flow and receiver encoding. Choose the call your token supports.

The NewsCrypto Editors

Difference between relayTokens and transferAndCall: token flow

On Gnosis Bridge’s Omnibridge, relayTokens pulls ERC-20 tokens after approval, while ERC-677 transferAndCall sends tokens and calls the mediator in one transaction. The token contract determines which path you can use.

What happens in each deposit?

Say you are depositing an Ethereum ERC-20 that has no transferAndCall function. First, call approve(omnibridge, amount) on the token. Then call relayTokens(token, receiver, amount) on the Foreign Omnibridge. The mediator uses transferFrom to pull the amount and sends the bridge request through the AMB. That is two transactions unless an existing allowance covers the amount.

With an ERC-677 token, call transferAndCall(omnibridge, amount, data) on the token. The token transfers the amount to the mediator, then calls its onTokenTransfer(from, value, data) callback. The mediator processes the deposit and sends the same kind of bridging request through the AMB. No allowance is involved, and the deposit takes one transaction.

For a quick reference while tracing Gnosis Bridge contracts, the GNO token bridge is a related route to keep in view. The relevant distinction here is the token interface: many Ethereum ERC-20s support only the approval-and-pull path, while Omnibridge-minted tokens on Gnosis Chain support transferAndCall.

Where does the receiver go?

In relayTokens(token, receiver, value), the receiver is a separate argument. With transferAndCall, the receiver is encoded in data: Omnibridge reads the first 20 bytes as the destination address. If data is empty, the destination defaults to the sender’s address. That can send tokens to the wrong place when a contract is the sender, so encode the intended receiver explicitly.

For a withdrawal of bridged USDC from Gnosis Chain to Ethereum, call transferAndCall on the Gnosis-side USDC token, targeting the Home Omnibridge. Put the Ethereum recipient address in the first 20 bytes of data. The callback lets the mediator burn the bridged tokens and start the AMB message to release tokens on Ethereum.

Before submitting, inspect the token contract’s ABI and confirm which path it exposes. Then check that the receiver argument or encoded address matches the destination you intend; that gives the AMB request the right recipient.

More stories