Multichain
  • Getting Started
    • Introduction
      • Supported Chains
      • Supported Tokens
    • How it works
      • Cross-Chain Bridge
      • Cross-Chain Router
    • Governance Token
      • VeMulti
      • How to Convert ANY to MULTI
    • Security
      • Security model
      • Bug bounty (Immunefi)
      • Bug bounty (alternative)
    • How to Use
      • Fees
    • Road Map
    • FAQ
    • Careers
      • Front-end developer
      • Back-end developer
      • Test Engineer
      • Test Development Engineer
      • Security Engineer (Code Auditing)
      • Blockchain Development Engineer
      • Senior Content Editor
      • Event Manager
  • Listing and Integration
    • Token Listing
      • ERC20 Cross-chain Options
      • Difference between V2&V3
    • Chain Integration
      • EVM Networks Integration
      • Non-EVM Networks Integration
    • FAQ
  • Developer Guide
    • How to Integrate Front-end Router
    • Bridge API (Token list/Tx Status)
    • Scan API (Tx Status/Account History)
    • Token Router Testnet
    • anyCall V7
      • How to integrate anyCall V7?
      • API/Explorer
      • Quickstart (Cross-chain text example)
      • Estimate Fee/Pay Fees on destination chain
    • anyCall V6
      • How to integrate anyCall V6?
      • anyFallback
      • anyCall V6 Testnet Environments
      • Fees Paid on Source Chain
      • Context (Verify msg.sender)
    • $USDC CCTP X anyCall
      • Contract Addresses and example
    • anyCall NFT Bridge
    • Permissionless Token bridging
    • How to develop under Anyswap ERC20 standards
    • Bridge funds and anyCall (Router V7)
      • Mainnet
      • Testnet (Quick Start Example)
    • How to Integrate Front-end Bridges
Powered by GitBook
On this page
  • How to import the context interface
  • Getting Context and Verify Sender
  1. Developer Guide
  2. anyCall V6

Context (Verify msg.sender)

anyCall V6 is permissionless so you need to verify the msg.sender on the source chain because anyone can call your destination contract.

This context function exists inside the AnyCallExecutor contract

contract AnyCallExecutor {
    struct Context {
        address from;
        uint256 fromChainID;
        uint256 nonce;
    }

    Context public context;}

Returned Information

  1. address from: The address on the source chain that called anyCall.

  2. uint256 fromChainID: The source chain id.

  3. uint256 nonce: The total amount of times anyCall has been called.

How to import the context interface

An interface should be created to get the context information, it could be the same interface as the interface for anyCall .

interface CallProxy{
    function anyCall(
        address _to,
        bytes calldata _data,
        address _fallback,
        uint256 _toChainID,
        uint256 _flags

    ) external payable;

    function context() external view returns (address from, uint256 fromChainID, uint256 nonce);
    
    function executor() external view returns (address executor);
}

Getting Context and Verify Sender

Note that the contract address for AnyCallExecutor is different from the address of AnyCallV6Proxy. Use the address of AnyCallExecutor to get Context information.

The address of AnyCallExecutor can be set in constuctor like this

  constructor(){
        anycallExecutor=CallProxy(anycallcontract).executor();
    }

Then context information can be fetched with the following codes and you can use a variable such as verifiedcaller to verify msg.sender on the source chain is authorized.

(address from, uint256 fromChainId,) = IAnycallV6Proxy(anycallExecutor).context();
require(verifiedcaller == from, "AnycallClient: wrong context");

PreviousFees Paid on Source ChainNext$USDC CCTP X anyCall

Last updated 2 years ago

Full Example:

https://testnet.ftmscan.com/address/0xC939EbeedBdF61f839296cF326e9aE2a84C8022C#code