Bridging from Solana to Chiliz Chain

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

Note that LayerZero provide their own QuickStart for OFT contracts:

Prerequisites

Bridging from Solana (Non-EVM) to Chiliz Chain (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:

Step 1: Contract Development

The "Shared Decimals" Challenge

Because the Ethereum Virtual Machine (EVM) handles token mathematics differently than Solana, we must align their decimal precision before tokens cross the bridge:

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

  • Chiliz Chain (Destination): Standard ERC-20 tokens (and your new destination OFT) typically use 18 decimals.

If you sent a 9-decimal payload from Solana directly to Chiliz without conversion, the EVM contract would misinterpret the amount, resulting in a microscopic fraction of a token being minted 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 SPL token from Solana, the Solana Adapter scales the number down to 6 decimals (treating the lowest 3 decimals of the SPL token as "dust" and leaving them safely in the user's wallet).

  • The 6-decimal message payload is sent across the bridge.

  • The Chiliz Chain Native OFT receives the 6-decimal number and scales it up to its local 18 decimals before minting the ERC-20 token into the user's EVM wallet.

Learn more here.

Solana Program Development

Because your token already exists on Solana, you do not need to create a new token contract. Instead, you will deploy a Solana OFT Adapter Program written in Rust. This program will act as a decentralized lockbox, securely holding your SPL tokens when users bridge them to Chiliz Chain, and releasing them when users bridge back.

LayerZero provides an Anchor workspace with pre-built, audited contracts so you do not have to write the Rust logic from scratch.

1. Cloning the LayerZero Solana SDK

Start by cloning the official LayerZero developer tools repository, which contains the Solana OFT Adapter example.

Open your terminal and run:

2. Building the Solana Adapter Program

This directory is an Anchor workspace containing both Native OFT and OFT Adapter implementations. You need to build the Rust program to generate your unique Solana Program ID.

After the build completes, retrieve your new Program ID by running:

3. Deploying to Solana Mainnet

Ensure your Solana CLI is configured for Mainnet and that your local wallet has enough $SOL to cover the deployment size and storage rent.

4. Initializing the OFT Adapter

Unlike the Native OFT (which requires creating a new Mint), initializing the Adapter simply links your newly deployed Program ID to your existing SPL Token Mint Address.

The LayerZero SDK provides Hardhat tasks to handle this initialization from the command line. Ensure your Solana LayerZero Endpoint (30168) is configured, then run:

There are crucial parameters here:

  • --mint: This must be the exact Base58 Mint Address of the SPL token you want to bridge. The Adapter will create an escrow account specifically for this token.

  • --shared-decimals 6: This dictates how the Adapter scales the payload before sending it to the EVM. If your Solana token has 9 decimals, leaving 6 shared decimals here ensures it translates safely across the bridge without overflow issues.

Once this initialization transaction is confirmed on Solana, your Adapter is live and ready to securely lock your SPL tokens!

Chiliz Contract Development

Because your Solana SPL token does not yet exist on the Chiliz Chain, you must deploy a standard Native OFT contract. This contract will act as the minter. When it receives a verified message from your Solana Adapter, it will mint the corresponding ERC-20 tokens; when a user bridges back to Solana, it will burn them.

As we discussed in "The Shared Decimals Challenge", your Solana Adapter scales the payload down to 6 decimals before sending it.

LayerZero's EVM implementation is such that you do not need to write custom scaling logic. By default, the OFT.sol contract uses 18 local decimals and 6 shared decimals. It will automatically detect the 6-decimal payload arriving from Solana and scale it up to the standard 18-decimal format () before minting the ERC-20 token to the user's wallet.

Deploying the OFT on Chiliz Chain

Create a new file named ChilizNativeOFT.sol in your Hardhat project's contracts/ folder:

Do not deploy yet! But keep this in mind:

  • Make sure that the _name and _symbol parameters match your original Solana SPL token exactly to provide a unified experience for your users.

  • When deploying to Chiliz Mainnet, you will pass the Chiliz Endpoint V2 address (0x6F475642a6e85809B1c36Fa62763669b1b48DD5B) as the _lzEndpoint.

Step 2: LayerZero Configuration

Now that you have your Solana Adapter initialized and your Chiliz Native OFT ready for deployment, you must configure the connection between them.

The main challenge here is address formatting. LayerZero’s cross-chain messaging requires all peer addresses to be formatted as bytes32. The LayerZero V2 Hardhat toolbox handles this automatically by decoding your Base58 Solana Adapter Program ID and padding it to the standard EVM format.

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 generator handles the automatic conversion of your Solana Base58 address into the EVM bytes32 padding required by the Chiliz smart contract.

Step 3: Deployment Workflow

At this stage, your Solana Adapter is already compiled, deployed, and initialized (as covered in Step 1). Now, you need to deploy the EVM side of the bridge—the Native OFT—to the Chiliz Chain.

You will use Hardhat to push this contract to the Chiliz Mainnet.

1. The Chiliz Native OFT Deployment Script

In your Hardhat project, create a deployment script in your deploy/ directory named 01_deploy_chiliz_native_oft.ts. This script will initialize the new ERC-20 token on Chiliz.

2. The Solana Program Deployment

As a quick reminder, your Solana Adapter does not use Hardhat for its initial deployment. You should have already:

  1. Run anchor build and anchor deploy to push the Rust program to Solana Mainnet.

  2. Executed the lz:oft-adapter-solana:init task to link your Adapter to your existing SPL Token Mint.

  3. Copied the resulting Base58 Program ID into your layerzero.config.ts file.

3. Executing the Chiliz Deployment

Ensure your hardhat.config.ts file has the RPC URL and private key properly configured for the chiliz network.

Run the following command in your terminal to deploy the Native OFT:

Once the deployment finishes, Hardhat will save the newly minted Chiliz contract address in the deployments/ folder. You now have live contracts on both Solana (SVM) and Chiliz Chain (EVM), but they are not yet authorized to speak to one another.

Step 4: Wiring & Peering

At this point, you have a Rust Adapter Program on Solana and a Native EVM OFT on Chiliz Chain. To allow them to communicate securely, you must "wire" them together as trusted peers.

Just like bridging in the opposite direction, we are dealing with two completely different Virtual Machines (SVM and EVM). Because of this, configuring the Enforced Options (Gas Limits) correctly is critical to ensuring your transactions don't stall on the destination chain.

The "Enforced Options" for Chiliz (EVM)

When a user bridges their SPL token from Solana to Chiliz, the LayerZero Executor needs EVM gas to call the lzReceive function on your Chiliz contract to mint the ERC-20 tokens.

Conversely, for the return trip (Chiliz back to Solana), the Executor will need Solana Compute Units and Lamports to unlock the SPL tokens and potentially pay the rent for an Associated Token Account (ATA).

Updating the Configuration

To guarantee the Executor has enough gas for both directions, you must define these limits in your layerzero.config.ts file before wiring.

Update the connections array in your config file to include the following enforcedOptions:

Executing the Wire Task

Once your configuration is saved, the LayerZero V2 toolbox automates the peering process. It decodes your Base58 Solana address, pads it to the required bytes32 EVM format, and submits the configuration transactions to both the Solana Mainnet and the Chiliz Mainnet.

Run the following command in your terminal:

The CLI will prompt you to confirm the transactions. It will use your configured Solana wallet to submit the source transaction (costing $SOL) and Hardhat to submit the Chiliz destination transaction (costing $CHZ).

On the Chiliz side, the LayerZero Hardhat toolbox will automatically generate and execute 6 required configuration transactions:

  1. setSendLibrary: Assigns the V2 MessageLib for sending messages.

  2. setReceiveLibrary: Assigns the MessageLib for receiving messages.

  3. setConfig (Send Library): Configures the DVNs and Executor.

  4. setConfig (Receive Library): Configures the DVNs for inbound verification.

  5. setEnforcedOptions: Ensures consistent execution parameters (specifically ensuring enough Solana Compute Units are paid for the return trip).

  6. setPeer: Cryptographically links the Chiliz EID to your Solana Adapter's Base58 Program ID (converted to bytes32).

The Solana SDK handles the equivalent programmatic instructions for the SVM side under the hood.

Once both transactions confirm, your Solana-to-Chiliz bridge is officially live and securely permissioned!

Step 5: Operation & Testing

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

1) Preparing Your Solana Wallet

Unlike the EVM where you must execute a separate, prior approve() transaction to grant an Adapter an allowance, Solana handles token approvals and transfers within the same transaction instructions.

However, you must ensure that your local Solana wallet (the one configured in your project) actually holds a balance of the SPL tokens you intend to bridge, as well as enough $SOL to pay for the source transaction fee and the LayerZero cross-chain message fee.

2) Sending the Cross-Chain Message to Chiliz

The LayerZero V2 toolbox includes a Hardhat task for sending OFT transfers directly from the command line, even when the source chain is Solana.

Unlike Solana-to-Solana transfers, your destination here is a standard EVM hexadecimal wallet address (e.g., 0x123...). The LayerZero CLI handles the padding and byte conversion for the payload automatically.

Run the following command in your terminal:

What happens here?

  1. The script quotes the cross-chain fee in $SOL.

  2. It constructs a transaction that transfers 10 SPL tokens from your wallet into the Solana Adapter's escrow account.

  3. The Adapter scales the 9-decimal SPL token amount down to the 6 shared decimals.

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

3) Tracking the Packet on LayerZero Scan

Because bridging from Solana involves translating between two entirely different consensus mechanisms and finalizing the transaction on the SVM before executing on the EVM, 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:

The Chiliz Native OFT will have automatically scaled the 6-decimal payload back up to the EVM-standard 18 decimals, so you receive exactly 10 full tokens

4) Troubleshooting Stuck Messages

If your transaction is marked as confirmed on Solana but fails to execute on Chiliz, the most common culprit is an EVM Out-of-Gas error.

  • If the gas parameter in your enforcedOptions (configured in Step 5) was set too low for the Chiliz network to process the lzReceive minting function, the LayerZero Executor will fail to deliver the message.

  • Fix: You do not lose your tokens. You can manually push a stuck message through via the LayerZero Scan UI. Simply connect your EVM wallet to Chiliz Chain, click the "Force Resume" or "Execute" button on the block explorer, and pay the Chiliz gas fee yourself to finalize the minting.

Last updated

Was this helpful?