Developer Docs


A contract that implements sgReceive() can perform powerful logic on the receiving chain.
This interface should be implemented by contracts that receive a swap():
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.7.6;
interface IStargateReceiver {
function sgReceive(
uint16 _srcChainId, // the remote chainId sending the tokens
bytes memory _srcAddress, // the remote Bridge address
uint256 _nonce,
address _token, // the token contract on the local chain
uint256 amountLD, // the qty of local _token contract tokens
bytes memory payload
) external;
This is a very powerful feature of Stargate, because with it you can perform additional logic upon receiving tokens on the destination chain!
As an example of something the LayerZero team built using IStargateReceiver, we used an AMM to swapExactTokensForTokens() using the Stargate swap()'ed USDC into native token on the destination chain.