# IStargateReceiver.sol

This interface should be implemented by contracts that receive a swap():

```javascript
// 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!&#x20;

As an [example of something the LayerZero team built](https://stargateprotocol.gitbook.io/stargate/stargate-composability/stargatecomposed.sol) using `IStargateReceiver`, we used an AMM to swapExactTokensForTokens() using the Stargate swap()'ed USDC into native token on the destination chain.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://stargateprotocol.gitbook.io/stargate/interfaces/evm-solidity-interfaces/istargatereceiver.sol.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
