This project implements an Omnichain Non-Fungible Token (ONFT) on the Solana blockchain using LayerZero's cross-chain messaging protocol. Unlike the Ethereum implementation which uses contract inheritance, this Solana version utilizes LayerZero's Endpoint Cross Program Invocation (CPI) Helper to achieve cross-chain functionality.
The Solana program is structured to work with LayerZero's messaging interface, allowing for sending and receiving arbitrary data between different blockchain networks. Here's an overview of the key components:
- Location:
programs/zealot_nft/src/lib.rs
- This file defines the program's entry points and interactions with the LayerZero Endpoint.
- Location:
programs/zealot_nft/src/instructions/
- These files contain the logic for various operations:
init_oft.rs
andinit_adapter_oft.rs
: Initialize the ONFTsend.rs
: Handles sending tokens to other chainslz_receive.rs
: Processes incoming messages from other chainsmint_to.rs
: Mints new tokensset_mint_authority.rs
: Sets the minting authority
- Location:
programs/zealot_nft/src/state/
- These files define the program's state:
onft.rs
: ONFT configurationpeer.rs
: Manages cross-chain peer information
The Solana program implements the following core functionalities:
-
Initialization:
- Sets up the ONFT configuration and LayerZero endpoint interaction
- Implemented in
init_oft.rs
andinit_adapter_oft.rs
-
Cross-Chain Operations:
- Sending:
send.rs
prepares and sends messages through the LayerZero Endpoint - Receiving:
lz_receive.rs
handles incoming messages from other chains
- Sending:
-
Token Management:
- Minting:
mint_to.rs
handles token creation - Authority Management:
set_mint_authority.rs
controls minting permissions
- Minting:
-
Administrative Functions:
- Various files in
instructions/
handle admin operations like setting peers and enforcing options
- Various files in
Unlike the Ethereum version which inherits from an OApp Standard, the Solana program directly interacts with the LayerZero Endpoint:
- The program uses LayerZero's Endpoint CPI Helper for cross-chain messaging
send.rs
andlz_receive.rs
are key files that interact with the LayerZero Endpoint- The program handles account management required for Solana's CPI model
The test file tests/zealot_nft.ts
covers basic operations:
- Initializing the ONFT
- Sending tokens cross-chain
- Receiving tokens from other chains
These tests ensure that the program correctly interacts with the LayerZero Endpoint for cross-chain operations.