Skip to content

Instantly share code, notes, and snippets.

@nazreen
Last active October 13, 2025 13:40
Show Gist options
  • Select an option

  • Save nazreen/e8395a10c0ef30df856d5cee396660c3 to your computer and use it in GitHub Desktop.

Select an option

Save nazreen/e8395a10c0ef30df856d5cee396660c3 to your computer and use it in GitHub Desktop.
ApeCoin OFT expansion instructions - Solana

This is instructions set 1 of 3.

ape-solana

  1. Upload Base and BNB deployments folders into /deployments in the ape-solana repo (only base-mainnet and bsc-mainnet are needed)
  2. In hardhat.config.ts, add the following into config.networks:
'base-mainnet': {
    eid: EndpointId.BASE_V2_MAINNET,
    url: process.env.RPC_URL_BASE_MAINNET || 'https://base.gateway.tenderly.co',
    accounts,
},
'bsc-mainnet': {
    eid: EndpointId.BSC_V2_MAINNET,
    url: process.env.RPC_URL_BSC_MAINNET || 'https://bsc.drpc.org',
    accounts,
},
  1. In layerzero.config.ts, add the following,

    3a - contract instances:

    const bnbContract: OmniPointHardhat = {
        eid: EndpointId.BSC_V2_MAINNET,
        contractName: 'ApeOFT',
    }
    const baseContract: OmniPointHardhat = {
        eid: EndpointId.BASE_V2_MAINNET,
        contractName: 'ApeOFT',
    }
    

    3b - Enforced Options variables:

    const TO_BNB_MAINNET_ENFORCED_OPTIONS: OAppEnforcedOption[] = [
        {
            msgType: 1,
            optionType: ExecutorOptionType.LZ_RECEIVE,
            gas: 100_000,
            value: 0,
        },
    ]
    const TO_BASE_MAINNET_ENFORCED_OPTIONS: OAppEnforcedOption[] = [
        {
            msgType: 1,
            optionType: ExecutorOptionType.LZ_RECEIVE,
            gas: 100_000,
            value: 0,
        },
    ]
    

    3c generateConnectionsConfig's connections:

    // then in generateConnectionsConfig, add the following into the array
            [
                bnbContract, // Chain A contract
                solanaContract, // Chain B contract
                [['LayerZero Labs', 'Horizen'], []], // [ requiredDVN[], [ optionalDVN[], threshold ] ]
                [20, 32], // [A to B confirmations, B to A confirmations]
                [TO_SOLANA_ENFORCED_OPTIONS, TO_BNB_MAINNET_ENFORCED_OPTIONS], // Chain B enforcedOptions, Chain A enforcedOptions
            ],
            [
                baseContract, // Chain A contract
                solanaContract, // Chain B contract
                [['LayerZero Labs', 'Horizen'], []], // [ requiredDVN[], [ optionalDVN[], threshold ] ]
                [10, 32], // [A to B confirmations, B to A confirmations]
                [TO_SOLANA_ENFORCED_OPTIONS, TO_BASE_MAINNET_ENFORCED_OPTIONS], // Chain B enforcedOptions, Chain A enforcedOptions
            ],
    
    

    3d - generateConnectionsConfig's contracts array:

    { contract: bnbContract },
    { contract: baseContract },
    
  2. In the repo root, create a new file named convertTxnData.ts and paste the following as its content:

    import fs from 'fs'
    
    import bs58 from 'bs58'
    
    // Get filename from command line argument
    const [, , fileName] = process.argv
    
    if (!fileName) {
        console.error('❌ Usage: pnpm ts-node convertTxnData.ts <JSON_FILENAME>')
        process.exit(1)
    }
    
    // Read and parse JSON file
    const input = JSON.parse(fs.readFileSync(fileName, 'utf8'))
    
    // Loop through entries
    for (const entry of input) {
        const { point, data } = entry
    
        if (point?.eid === 30168 && typeof data === 'string') {
            const hex = data.startsWith('0x') ? data.slice(2) : data
    
            if (hex.length % 2 !== 0) {
                throw new Error(`Invalid hex string for eid ${point.eid}`)
            }
    
            const bytes = Uint8Array.from(hex.match(/.{2}/g)!.map((b) => parseInt(b, 16)))
    
            entry.data = bs58.encode(bytes)
        }
    }
    
    // Write to output file (same name with `_converted.json`)
    const outputFile = fileName.replace(/\.json$/, '') + '_converted.json'
    fs.writeFileSync(outputFile, JSON.stringify(input, null, 2))
    
    console.log(`✅ Converted entries with eid 30168 to Base58 and saved as ${outputFile}`)
    

    We will use this script to convert the txn data (to base58) for Solana transactions as devtools outputs all txn data in hex format but Squads expects them in base58.

  3. Run init-config - npx hardhat lz:oft:solana:init-config --oapp-config layerzero.config.ts --multisig-key GPuMML3FeJXTr948CvTwSYANHm74RSW5iUibw5T6vSfa --output-filename base-bnb-init-config-txns.json

    • When asked to preview txns, you can choose Y or just terminate the process immediately, as at this point, base-bnb-init-config-txns.json would have already been generated. If asked " Would you like to submit the required transactions?", just respond with 'N' to terminate the process as you should proceed with manually pasting in the txn data into the Squads UI.
    • Note: the txn data are in Hex, but we need them to be in base58 in order to import into Squads UI.
    • 5a. Now, run pnpm ts-node convertTxnData.ts base-bnb-init-config-txns.json
    • 5b. Open up base-bnb-init-config-txns_converted.json to view the 2 txns.
    • 5c. Copy the data, import into the Squads UI and execute the txn.
  4. Run wire - npx hardhat lz:oapp:wire --oapp-config layerzero.config.ts --multisig-key GPuMML3FeJXTr948CvTwSYANHm74RSW5iUibw5T6vSfa --output-filename base-bnb-wire-txns.json

    • Note: for the txns that are for Solana (eid: 30168), the txn data are in Hex, but we need them to be in base58 in order to import into Squads UI.
    • When asked to preview txns, you can choose Y or just terminate the process immediately, as at this point, base-bnb-wire-txns.json would have already been generated. If asked " Would you like to submit the required transactions?", just respond with 'N' to terminate the process as you should proceed with manually pasting in the txn data into the Squads UI.
    • 6a. Now, run pnpm ts-node convertTxnData.ts base-bnb-wire-txns.json
    • 6b. Open up base-bnb-wire-txns_converted.json to view the txns.
    • 6c. Identify the Solana txns, they are the ones with eid value of 30168 - copy the data, import into the Squads UI and execute the txn.
    • 6d. Identify the Ape txns, they are the ones with eid value of 30312 - execute them via the Safe Multisig UI.
    • 6e. Identify the Arbitrum txns, they are the ones with eid value of 30110 - execute them via the Safe Multisig UI.
    • 6f. Identify the Base txns, they are the ones with eid value of 30184 - execute them via the Safe Multisig UI.
    • 6g. Identify the BNB txns, they are the ones with eid value of 30102 - execute them via the Safe Multisig UI.
    • 6h. Identify the Hyperliquid txns, they are the ones with eid value of 30367 - execute them via the Safe Multisig UI.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment