Bridging from Chiliz Chain to Solana

To bridge an existing token from Chiliz Chain to Solana, you need to write and deploy two separate smart contracts: an OFT Adapter on the chain where the token already exists (Chiliz Chain), and a Native OFT on the destination chain (Solana).

Note that LayerZero provide their own QuickStart for OFT contracts:

Prerequisites

Bridging from Chiliz Chain (EVM) to Solana (Non-EVM) requires dual-stack development. You will need environments and wallets set up for both ecosystems.

You will therefore need the following environments:

This guide requires the following:

  • A token contract address on Chiliz Chain. You do not need to own it.

  • A Web3 wallet for each chain (MetaMask does not support non-EVM chains):

  • Enough gas tokens on each chain to pay for the contract deployments as well as the gas fees for sending messages.

    • On Chiliz Chain: CHZ tokens.

    • On Solana: SOL tokens.

Step 1: Contract Development

The "Shared Decimals" Challenge

Because Solana handles token mathematics differently than the Ethereum Virtual Machine (EVM), we must handle decimals correctly:

  • Chiliz Chain (EVM): Standard ERC-20 tokens typically have 18 decimals of precision.

  • Solana: Native SPL Tokens typically have 9 decimals of precision.

If you send units from Chiliz to Solana, the Solana contract would misinterpret the amount, resulting in a massive inflation of the token on the destination chain.

To normalize the math, LayerZero uses a sharedDecimals configuration. By default, the LayerZero V2 OFT standard sets sharedDecimals to 6.

  • When a user bridges 1.00 token from Chiliz, the Adapter drops the lowest 12 decimals (treating them as "dust") to scale the number down to 6 decimals.

  • The message is sent across the bridge.

  • The Solana program receives the 6-decimal number and scales it up to its local 9 decimals before minting.

Learn more here.

Preparing the OFTAdapter on Chiliz Chain

The OFTAdapter contract acts as a lockbox for your existing token. When users bridge their tokens away from Chiliz Chain, this contract locks the original ERC20 tokens.

Because LayerZero's OFTAdapter sets sharedDecimals to 6 by default, you can use the standard implementation. If you ever need to change this (e.g., to 8), you would override the sharedDecimals() function.

Create a new file named ChilizTokenAdapter.sol in your contracts folder:

As you can see this contract extends the LayerZero OFT Adapter contract, as well as a standard Ownable.sol contract to give the administrative keys. You need both so that you, and only you, can safely wire the chains together.

Preparing and Deploying the OFT on Solana

Unlike Chiliz Chain, Solana does not use the Ethereum Virtual Machine (EVM) or Solidity language. Solana smart contracts (called "Programs") are written in Rust.

To bridge your token, you need to deploy an OFT program on Solana. When this program receives a verified message from your Chiliz-deployed OFTAdapter, it will mint the corresponding SPL token into the user's Solana wallet.

LayerZero provides a ready-to-use Anchor example so you do not have to write the Rust bridge logic from scratch.

1. Clone the LayerZero OFT Solana example:

2. Build the Rust program

This will also generate your unique Solana Program ID (equivalent to a contract address in the EVM):

After the build completes, Anchor will generate a new keypair in target/deploy/oft_solana-keypair.json. You can retrieve your new Program ID by running:

3. Deploy to Solana Mainnet

Make sure that your Solana CLI is configured for Mainnet and your local wallet has enough $SOL for the deployment and storage rent. Don't forget to update the Anchor.toml file and the lib.rs declare_id! macro with this new Program ID before deploying.

4. Initialize the OFT and the SPL Mint

On Solana, a token's logic and its ledger are separated. You must initialize a new Mint Account (the SPL Token) and assign your newly deployed OFT Program as the Mint Authority. This ensures only the LayerZero bridge can mint new tokens on Solana.

The LayerZero SDK provides Hardhat/TypeScript tasks to handle this initialization directly from the command line. In your oft-solana project, configure your LayerZero Endpoint for Solana (30168) and run the initialization script:

Crucial Parameters:

  • --mint-decimals 9: Sets the standard SPL token precision on Solana.

  • --shared-decimals 6: Must match the shared decimals you configured (or the default) on your Chiliz Chain OFTAdapter. This is what guarantees 1 Chiliz token = 1 Solana token.

Once this initialization transaction is confirmed on the Solana blockchain, your native OFT program is fully set up and ready to be wired to the Chiliz OFTAdapter!

Step 2: LayerZero Configuration

With your Chiliz Adapter deployed and your Solana OFT program initialized, you must now configure their connection. This is where the difference between EVM and non-EVM networks becomes highly visible.

Address Formatting:

  • Chiliz Chain (EVM): Uses standard 20-byte hexadecimal addresses (e.g., 0x123...).

  • Solana: Uses Base58 encoded addresses (e.g., YourProgramId111111111111111111111111111111).

LayerZero’s cross-chain messaging requires all peer addresses to be formatted as bytes32. Fortunately, the LayerZero V2 Hardhat tooling automatically handles the Base58-to-Bytes32 conversion for you, as long as you define the endpoints correctly in your config.

The Simple Config Generator is the recommended way to generate wiring configuration, as it automates bidirectional wiring and applies recommended security configurations under the hood.

Create or update your layerzero.config.ts file in the root of your Hardhat project:

The LayerZero wire task will read this, decode the Base58 string, pad it to 32 bytes, and pass it securely into the Chiliz OFTAdapter's setPeer function.

Step 3: Deployment Workflow

With your contracts written and your layerzero.config.ts prepared, it is time to deploy the Chiliz OFTAdapter. Since you already built and deployed the Solana native OFT program using Anchor in Step 1, this step focuses on deploying the EVM side of the bridge using Hardhat.

Deploying The Chiliz OFTAdapter contract

In your Hardhat project, create a deployment script in your deploy/ directory named 01_deploy_chiliz_solana_adapter.ts. This script passes your existing token address and the Chiliz Endpoint V2 address (EID) into the constructor.

Deploying the Chiliz OFTAdapter

Before proceeding, make sure that:

  • you have copied the resulting Base58 Program ID into your layerzero.config.ts file.

  • your hardhat.config.ts has the RPC URL and private key properly configured for Chiliz Chain Mainnet.

Run the following command in your terminal to deploy the EVM Adapter:

Once the deployment is complete, Hardhat will save the Chiliz contract address in the deployments/ folder.

At this point, you have live contracts on both Chiliz Chain (EVM) and Solana (SVM), but they do not yet trust each other. Time to make them meet!

Step 4: Wiring & Peering

To allow your OFTAdapter contract and OFT program to communicate, you must "wire" them together as trusted peers.

Because we are bridging across two entirely different Virtual Machines (EVM and SVM), configuring requires special attention.

EVM gas vs Solana compute units

When a user bridges a token from Chiliz Chain to another EVM chain (like Base), the LayerZero Executor needs EVM gas to call lzReceive.

However, when bridging from Chiliz Chain to Solana, the target chain does not use EVM gas. It uses Compute Units and Lamports (fractions of $SOL). Furthermore, if a user bridges tokens to a Solana wallet that does not yet hold your token, the Executor must pay Solana's "rent exemption" fee to create an Associated Token Account (ATA) for them. This requires dropping actual $SOL value on the destination.

To guarantee the Executor has enough Compute Units and Lamports to mint tokens and create ATAs on Solana, you must define these limits in your layerzero.config.ts file before wiring.

Run the automated wire command in your terminal:

This will prepare the 6 required configuration transactions:

  1. setSendLibrary: Assigns the MessageLib for outbound packets.

  2. setReceiveLibrary: Assigns the MessageLib for inbound packets.

  3. setConfig: Configures the DVNs and Executor.

  4. setConfig : Configures the DVNs for inbound verification.

  5. setEnforcedOptions: Ensures consistent execution parameters (crucial for ensuring the user pays enough upfront to cover Solana Compute Units and Lamport rent).

  6. setPeer: Links the Solana EID to your destination Base58 Program ID.

The LayerZero V2 toolbox automates the heavy lifting: it will decode the Base58 Solana address, pad it to the required bytes32 EVM format, and submit the setPeer and setEnforcedOptions transactions to both chains.

Once the wiring transactions confirm, your EVM-to-Solana bridge is live and securely permissioned.

Your token is officially ready to cross the EVM/SVM divide!

Step 5: Operation & Testing

With your Chiliz Adapter deployed, your Solana Native OFT initialized, and the two properly wired together, your token is officially ready to cross the EVM/SVM divide. The final step is to execute and track a test transfer from Chiliz Chain to Solana.

1) Sending the Cross-Chain Message to Solana

The LayerZero V2 toolbox includes a Hardhat task for sending OFT transfers directly from the command line.

Unlike EVM-to-EVM transfers where your destination is a standard hexadecimal string, your destination here is a Base58 Solana wallet address. The LayerZero CLI handles the Base58-to-Bytes32 conversion for the message payload automatically.

Run the following command in your terminal:

What happens here?

  1. The script quotes the cross-chain fee in $CHZ (which covers the EVM gas, the verifier network fees, and the Solana destination fees).

  2. It calls the send() function on your Chiliz Adapter.

  3. The Adapter locks 10 tokens (18 decimals). It drops the lowest 12 decimals as "dust" (leaving them in your Chiliz wallet) to scale the payload down to the 6 sharedDecimals.

  4. The LayerZero Endpoint emits the packet toward the Solana Mainnet.

2) Tracking the Packet on LayerZero Scan

Because bridging to Solana involves translating between two entirely different consensus mechanisms and waiting for SVM finality, an asynchronous delay is normal.

To track this journey in real-time, click the LayerZero Scan link that appears in the CLI output.

Learn more about this tool here:

Decimal Translation

The Solana Native OFT will have automatically scaled the 6-decimal payload coming from the bridge up to the standard SPL 9 decimals, so your Solana wallet receives exactly 10 full tokens.

4) Troubleshooting Stuck Messages

If your transaction is marked as confirmed on Chiliz but fails to execute on Solana, the most common culprit is an Insufficient Lamports, or Compute Units error.

  • If the destination Solana wallet did not already have an Associated Token Account (ATA) for your specific token, the LayerZero Executor had to pay the Solana "rent exemption" fee to create it.

  • If the value parameter (Lamports) in your enforcedOptions was set too low to cover this rent, or if the gas (Compute Units) was insufficient, the Executor will refuse to pay out of pocket, and the message will stall.

  • Fix: You do not lose your tokens. You can manually push a stuck message through via the LayerZero Scan UI. Connect your Solana wallet, click the "Force Resume" or "Execute" button on the block explorer, and pay the local destination fee (Compute Units + ATA Rent in $SOL) yourself to finalize the minting.

Last updated

Was this helpful?