# Mint from Destination 2 - Base Sepolia

We will demonstrate how you can send messages & mint tokens across <mark style="color:purple;">multiple chains</mark> using Chainlink CCIP

We will demonstrate how you can send messages & mint tokens across multiple chains using Chainlink CCIP

{% embed url="<https://github.com/solangegueiros/chainlink-bootcamp-2024/blob/main/CrossSourceMinterMumbai.sol>" %}
Workshop Source Code
{% endembed %}

We will be using Base Sepolia instead, since Polygon Mumbai was deprecated in April 2024.

<figure><img src="https://62720068-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNQrWPKDHvXg0HQjwzHbY%2Fuploads%2Fagh80fUawvwabqVLuggz%2FScreenshot%202024-04-30%20at%203.31.02%E2%80%AFAM.png?alt=media&#x26;token=27502608-bd87-4d59-a538-f4d4ddf7b47b" alt=""><figcaption><p>A screengrab from the Link Token Contracts Documentation for Base Sepolia Testnet</p></figcaption></figure>

Follow this link to switch your <mark style="color:red;">Metamask</mark> wallet to the <mark style="color:purple;">Base Sepolia network</mark> - Make sure the Chain ID is <mark style="color:purple;">84532</mark>

{% embed url="<https://chainlist.org/?testnets=true&search=base+sepolia>" %}
Base Sepolia Network
{% endembed %}

Use the Faucet to receive some LINK and ETH on the Base Sepolia Network

{% embed url="<https://faucets.chain.link/base-sepolia>" %}
You can acquire Base Sepolia Testnet Link and Ethereum here\\
{% endembed %}

{% embed url="<https://docs.chain.link/resources/link-token-contracts?parent=ccip#base-sepolia-testnet>" %}
This link directs you to the exact spot from that screengrab above
{% endembed %}

Make sure you add the LINK token to your wallet by importing it as per the above links. You can either do that by copying the Link token address and manually importing it, or by clicking the button provided.

***

Now that we have our important prerequisites taken care of, lets dive into the code. Make a new file in Remix, <mark style="color:blue;">`CrossSourceMinterBaseSepolia.sol`</mark> and copy the following in there.

```solidity
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

// Deploy this contract on Base Sepolia

import {IRouterClient} from "@chainlink/contracts-ccip/src/v0.8/ccip/interfaces/IRouterClient.sol";
import {Client} from "@chainlink/contracts-ccip/src/v0.8/ccip/libraries/Client.sol";
import {LinkTokenInterface} from "@chainlink/contracts/src/v0.8/interfaces/LinkTokenInterface.sol";

/**
 * THIS IS AN EXAMPLE CONTRACT THAT USES HARDCODED VALUES FOR CLARITY.
 * THIS IS AN EXAMPLE CONTRACT THAT USES UN-AUDITED CODE.
 * DO NOT USE THIS CODE IN PRODUCTION.
 */
contract CrossSourceMinterBaseSepolia {

    // Custom errors to provide more descriptive revert messages.
    error NotEnoughBalance(uint256 currentBalance, uint256 calculatedFees); // Used to make sure contract has enough balance to cover the fees.
    error NothingToWithdraw(); // Used when trying to withdraw but there's nothing to withdraw.

    IRouterClient public router;
    LinkTokenInterface public linkToken;
    uint64 public destinationChainSelector;
    address public owner;
    address public destinationMinter;

    event MessageSent(bytes32 messageId);

    constructor(address destMinterAddress) {
        owner = msg.sender;

        // https://docs.chain.link/ccip/supported-networks/testnet

        // from Base Sepolia
        address routerAddressBaseSepolia = 0xD3b06cEbF099CE7DA4AcCf578aaebFDBd6e88a93;
        router = IRouterClient(routerAddressBaseSepolia);
        linkToken = LinkTokenInterface(0xE4aB69C077896252FAFBD49EFD26B5D171A32410);
        linkToken.approve(routerAddressBaseSepolia, type(uint256).max);

        // to Sepolia
        destinationChainSelector = 16015286601757825753;
        destinationMinter = destMinterAddress;
    }

    function mintOnEthSepolia() external {
        // Mint from Base Sepolia network = chain[2]
        Client.EVM2AnyMessage memory message = Client.EVM2AnyMessage({
            receiver: abi.encode(destinationMinter),
            data: abi.encodeWithSignature("mintFrom(address,uint256)", msg.sender, 2),
            tokenAmounts: new Client.EVMTokenAmount[](0),
            extraArgs: Client._argsToBytes(
                Client.EVMExtraArgsV1({gasLimit: 980_000})
            ),
            feeToken: address(linkToken)
        });        

        // Get the fee required to send the message
        uint256 fees = router.getFee(destinationChainSelector, message);

        if (fees > linkToken.balanceOf(address(this)))
            revert NotEnoughBalance(linkToken.balanceOf(address(this)), fees);

        bytes32 messageId;
        // Send the message through the router and store the returned message ID
        messageId = router.ccipSend(destinationChainSelector, message);
        emit MessageSent(messageId);
    }

    modifier onlyOwner() {
        require(msg.sender == owner);
        _;
    }

    function linkBalance (address account) public view returns (uint256) {
        return linkToken.balanceOf(account);
    }

    function withdrawLINK(
        address beneficiary
    ) public onlyOwner {
        uint256 amount = linkToken.balanceOf(address(this));
        if (amount == 0) revert NothingToWithdraw();
        linkToken.transfer(beneficiary, amount);
    }
}
```

Copy this code into your new <mark style="color:blue;">CrossSourceMinterBase.sol File</mark>

Go to the <mark style="color:orange;">Deployment tab</mark> and include your <mark style="color:yellow;">`CrossDestinationMinter.sol`</mark><mark style="color:yellow;">'s address</mark> as the parameter (this is the same contract we deployed on Ethereum Sepolia)&#x20;

<figure><img src="https://62720068-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNQrWPKDHvXg0HQjwzHbY%2Fuploads%2FsMKBfQASPNanIuyr9JZ5%2FScreenshot%202024-04-30%20at%205.57.46%E2%80%AFAM.png?alt=media&#x26;token=c7ad6ba4-16a6-4ef9-bee1-5fe8bd88a4e1" alt=""><figcaption><p>Example of the Deployment Tab</p></figcaption></figure>

Now send the newly created <mark style="color:blue;">`CrossSourceMinterBaseSepolia`</mark> contract 5 LINK so it can pay for operations.

<figure><img src="https://62720068-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNQrWPKDHvXg0HQjwzHbY%2Fuploads%2FbbZU9JIRM5EMyscUdHZv%2FScreenshot%202024-04-30%20at%205.58.44%E2%80%AFAM.png?alt=media&#x26;token=64e537fe-2ead-4da7-bc3e-dc57ba84c41c" alt=""><figcaption><p>Example of Link transfer</p></figcaption></figure>

Once LINK is in the contract you should confirm that it is there by clicking the <mark style="color:blue;">`linkBalance`</mark> button and pass the <mark style="color:yellow;">`CrossSourceMinterBaseSepolia`</mark> address as the input parameter.

<figure><img src="https://62720068-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNQrWPKDHvXg0HQjwzHbY%2Fuploads%2F2o7r49dtR9YjjFwQAYr2%2FScreenshot%202024-05-03%20at%207.28.45%E2%80%AFPM.png?alt=media&#x26;token=166e609b-b64a-425c-bd82-4e27790238c3" alt=""><figcaption><p>Example of Checking the Link Balance</p></figcaption></figure>

<figure><img src="https://62720068-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNQrWPKDHvXg0HQjwzHbY%2Fuploads%2FSJPFluHuXDHFxyjdQwly%2FScreenshot%202024-05-03%20at%207.25.49%E2%80%AFPM.png?alt=media&#x26;token=211a162c-7d41-4685-9b61-b629fc001661" alt=""><figcaption><p>Example Of mintOnEthSepolia</p></figcaption></figure>

<figure><img src="https://62720068-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNQrWPKDHvXg0HQjwzHbY%2Fuploads%2FOtp6fCmFV9Q7eBlNMmhr%2FScreenshot%202024-04-30%20at%206.00.34%E2%80%AFAM.png?alt=media&#x26;token=f5fbe8a6-6fde-4c9a-aee2-80c564897cdc" alt=""><figcaption><p>Confirm the transaction</p></figcaption></figure>

<figure><img src="https://62720068-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNQrWPKDHvXg0HQjwzHbY%2Fuploads%2FMh4H7kcNTqeqccbI4nNk%2FScreenshot%202024-04-30%20at%206.06.05%E2%80%AFAM.png?alt=media&#x26;token=8b119c48-a8a9-4589-95e0-bf29c92f5ccc" alt=""><figcaption><p>This transaction may take a little bit of time</p></figcaption></figure>

Have patience, this transaction may take some time as it works [towards finality on the Source & Destination Chain](https://docs.chain.link/ccip/architecture#ccip-execution-latency).

If done correctly the outcome should look something like this

<figure><img src="https://62720068-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNQrWPKDHvXg0HQjwzHbY%2Fuploads%2F7KMLX5yfUTNV7HxJhCBZ%2FScreenshot%202024-04-30%20at%206.30.00%E2%80%AFAM.png?alt=media&#x26;token=68d67dec-92d2-4dbd-90c4-933175d01bf0" alt=""><figcaption></figcaption></figure>

CONGRATULATIONS 🥳

Celebrate by tweeting about #chainlink and share your screenshots!
