Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Building a Secure Interchain Messaging dApp: A technical Deep Dive

Building a Secure Interchain Messaging dApp: A technical Deep Dive

Building a Secure Interchain Messaging dApp: A technical Deep Dive

Olubisi Idris Ayinde

November 29, 2023
Tweet

More Decks by Olubisi Idris Ayinde

Other Decks in Education

Transcript

  1. Building a Secure
    Interchain
    Messaging dApp
    November, 2023 - Lagos, Nigeria

    View full-size slide

  2. Idris Olubisi
    Developer
    Advocate,Axelar
    @olanetsoft

    View full-size slide

  3. By a show of hands, how many of you have directly
    interacted with a blockchain application before?

    View full-size slide

  4. Have you heard the word “Interchain” or
    “Cross-chain”?

    View full-size slide

  5. The concept of
    blockchain
    Lagos, Nigeria

    View full-size slide

  6. The concept of blockchain
    Blockchain creates a safe and open way of recording transactions with a
    shared and unchangeable digital record, eliminating the need for
    middlemen.

    View full-size slide

  7. Decentralized Applications
    ● Your backend runs on 1000s of computers
    ● Instead of paying Amazon, you pay gas to validators
    ● Immutability
    ● Trade-offs between speed, cost, privacy, and more

    View full-size slide

  8. A brief history of
    blockchain
    Lagos, Nigeria

    View full-size slide

  9. The Beginning, 2009-2017
    1 2 3
    A brief history of blockchain

    View full-size slide

  10. A brief history of blockchain
    New platforms, 2017-2022
    2
    1 3

    View full-size slide

  11. A brief history of blockchain
    Omnichain, 2023- the future
    3
    1 2

    View full-size slide

  12. How do you take advantage of the new world?
    ● What if you didn’t care which chain you were on?
    ● What if you took advantage of chain differences?
    ● What if you could be where your users are?

    View full-size slide

  13. Axelar is
    1. Security & decentralization focused
    2. Integrated into 50+ chains
    3. Simple to use

    View full-size slide

  14. Axelar Tech Stack

    View full-size slide

  15. Send Tokens
    1. Deposit Addresses
    2. sendToken()
    3. Interchain Tokens

    View full-size slide

  16. A deposit address is a temporary special address created and monitored by
    Axelar's Relayer Services on behalf of the requester.
    const sdk = new AxelarAssetTransfer({ environment: "testnet" });
    const depositAddress = await sdk.getDepositAddress({
    fromChain, // source chain name
    toChain, // destination chain name
    destinationAddress, // destination chain address
    Asset // asset to transfer
    });
    Deposit Addresses

    View full-size slide

  17. sendToken is a function in Axelar's gateway EVM contract that facilitates token
    transfers between EVM and Cosmos chains.
    sendToken(
    "avalanche", // destination chain name
    "0xF16DfB26e1FEc993E085092563ECFAEaDa7eD7fD", // destination address
    "USDC", // asset symbol
    100000000 // amount (in atomic units)
    )
    sendToken()

    View full-size slide

  18. Interchain Tokens
    Interchain Tokens allow you to send tokens cross-chain, build your own asset
    bridges, build asset transfers into your interchain dApp and many more.
    How is this different?
    - Create a standardized ERC-20 token on multiple chains via the Interchain
    Portal
    - Build a custom token on every chain with built-in methods for sending
    - Upgrade an existing token by deploying a wrapper on every chain
    - Make Interchain Tokens executable alongside GMP messages for enhanced
    functionality.

    View full-size slide

  19. Send Messages
    1. callContract()
    2. callContractWithToken()

    View full-size slide

  20. Axelar's GMP enables a developer building on one chain to call any function on
    any other connected chain.
    callContract()
    // Src Chain
    function callContract(
    string memory destinationChain,
    string memory contractAddress,
    bytes memory payload
    ) external;
    // Dest Chain
    function _execute(
    string memory sourceChain,
    string memory sourceAddress,
    bytes calldata payload
    ) internal virtual {}

    View full-size slide

  21. Axelar's GMP enables a developer building on one chain to call any function on
    any other connected chain.
    callContractWithToken()
    // Src Chain
    function callContractWithToken(
    string memory destinationChain,
    string memory contractAddress,
    bytes memory payload,
    string memory symbol,
    uint256 amount
    ) external;
    // Dest Chain
    function _executeWithToken(
    string memory sourceChain,
    string memory sourceAddress,
    bytes calldata payload,
    string memory tokenSymbol,
    uint256 amount
    ) internal virtual {}

    View full-size slide

  22. Dapp Dapp
    Source Chain
    (eg Ethereum)
    Destination Chain
    (eg Polygon)
    Gateway
    1. callContract() 4. _execute()
    Gateway
    2. Emit event 3. approveContractCall()
    Axelar Network
    Validators & Consensus

    View full-size slide

  23. Instead of moving assets to compute,
    move compute to where assets are

    View full-size slide

  24. Real-World
    Applications
    Lagos, Nigeria

    View full-size slide

  25. Demo
    1. Clone a simple Next.js UI
    2. Write a smart contract
    3. Deploy the smart contract
    4. Wire/connect the smart
    contract to the frontend
    5. Test the application
    bit.ly/interchain-messaging-dap
    p-workshop

    View full-size slide

  26. Axelar Examples
    github.com/axelarnetwork/axelar-examples

    View full-size slide

  27. Foundry Axelar GMP Examples
    github.com/axelarnetwork/foundry-axelar-gmp-
    example

    View full-size slide

  28. What Next ???
    It’s Easy to Build
    Interchain-Native dApps
    For support, visit #developers on
    Axelar's Discord

    View full-size slide

  29. Idris Olubisi
    Developer
    Advocate,Axelar
    @olanetsoft
    bit.ly/olanetsoft-survey

    View full-size slide