Last active
May 10, 2024 03:26
-
-
Save QingyangKong/902b1bf992f6eb09d26a1e5e7a313671 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
pragma solidity 0.8.19; | |
import {IRouterClient} from "@chainlink/contracts-ccip/src/v0.8/ccip/interfaces/IRouterClient.sol"; | |
import {OwnerIsCreator} from "@chainlink/contracts-ccip/src/v0.8/shared/access/OwnerIsCreator.sol"; | |
import {Client} from "@chainlink/contracts-ccip/src/v0.8/ccip/libraries/Client.sol"; | |
import {CCIPReceiver} from "@chainlink/contracts-ccip/src/v0.8/ccip/applications/CCIPReceiver.sol"; | |
import {IERC20} from "@chainlink/contracts-ccip/src/v0.8/vendor/openzeppelin-solidity/v4.8.3/contracts/token/ERC20/IERC20.sol"; | |
import {SafeERC20} from "@chainlink/contracts-ccip/src/v0.8/vendor/openzeppelin-solidity/v4.8.3/contracts/token/ERC20/utils/SafeERC20.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. | |
*/ | |
interface INFT { | |
function safeMint(address to) external; | |
} | |
/// @title - A simple messenger contract for transferring/receiving tokens and data across chains. | |
contract DestChainReceiver is CCIPReceiver, OwnerIsCreator { | |
using SafeERC20 for IERC20; | |
INFT public nft; | |
address public routerEthSepolia = 0x0BF3dE8c5D3e8A2B34D2BEeB17ABfCeBaf363A59; | |
address public BnMToken = 0xFd57b4ddBf88a4e07fF4e34C487b99af2Fe82a05; | |
/// @notice Constructor initializes the contract with the router address. | |
constructor(address nftAddr) CCIPReceiver(routerEthSepolia) { | |
nft = INFT(nftAddr); | |
} | |
/// handle a received message | |
function _ccipReceive( | |
Client.Any2EVMMessage memory any2EvmMessage | |
) | |
internal | |
override | |
{ | |
(bool success, ) = address(nft).call(any2EvmMessage.data); | |
require(success, "mint failed"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment