This smart contract implements an NFT-based flight ticketing and resale marketplace with cross-chain capabilities. It leverages Chainlink services for dynamic pricing and secure cross-chain messaging.
- NFT flight tickets (ERC721)
- Dynamic pricing using Chainlink Price Feeds
- Resale marketplace for tickets
- Cross-chain ticket transfers using Chainlink CCIP
- Admin controls for allowlisting and pausing
- Purpose: Fetches real-time AVAX/USD price to set ticket prices dynamically.
- Where Used:
- Declared as
AggregatorV3Interface internal priceFeed; - Initialized in the constructor:
priceFeed = AggregatorV3Interface(FUJI_AVAX_USD);
- Used in
mintFlightTicket()to determine the current ticket price:uint256 currentPrice = getCurrentPrice();
- The
getCurrentPrice()function fetches the latest price:(, int256 price, , , ) = priceFeed.latestRoundData(); return uint256(price) * 10**10; // Convert to 18 decimals
- Declared as
- Type: Price Feed
- Purpose: Enables secure cross-chain NFT transfers and message passing.
- Where Used:
- The contract inherits from
CCIPReceiver:contract FlightBookingNFT is ... CCIPReceiver
- Initialized in the constructor:
CCIPReceiver(_router) - Sending cross-chain messages in
transferTicketCrossChain():Client.EVM2AnyMessage memory evm2AnyMessage = Client.EVM2AnyMessage({...}); IRouterClient router = IRouterClient(this.getRouter()); uint256 fees = router.getFee(destinationChainSelector, evm2AnyMessage); router.ccipSend{value: fees}(destinationChainSelector, evm2AnyMessage);
- Receiving cross-chain messages in
_ccipReceive():function _ccipReceive(Client.Any2EVMMessage memory any2EvmMessage) internal override
- The contract inherits from
- Type: CCIP (Cross-Chain Messaging)
- Install dependencies (OpenZeppelin, Chainlink).
- Deploy with router address and initial owner.
- Mint tickets using
mintFlightTicket. - List for resale or transfer cross-chain as needed.
- Only allowlisted chains and senders can interact cross-chain.
- Tickets cannot be resold or transferred after use or after flight departure.
MIT