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/5e248e65451335d27df99246533415c2 to your computer and use it in GitHub Desktop.

Select an option

Save nazreen/5e248e65451335d27df99246533415c2 to your computer and use it in GitHub Desktop.
ApeCoin OFT expansion instructions - HyperEVM

This is instructions set 2 of 3.

hyperEVM

  1. You have already uploaded the deployments, so this step is done.

  2. Amend hardhat.config.ts

    • Note: https://rpc.hyperliquid-mainnet.xyz/evm might not work anymore. Either replace it or set an env var for RPC_URL_HYPEREVM_MAINNET. https://hyperliquid.drpc.org seems to be working at time of writing.
    • 2b. 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,
    },
    
  3. Create layerzero.base.config.ts and paste the following contents:

    import { EndpointId } from '@layerzerolabs/lz-definitions'
    import { ExecutorOptionType } from '@layerzerolabs/lz-v2-utilities'
    
    import type { OAppEnforcedOption, OAppOmniGraphHardhat, OmniPointHardhat } from '@layerzerolabs/toolbox-hardhat'
    
    enum MsgType {
        SEND = 1,
    }
    const hyperliquidMainnetContract: OmniPointHardhat = {
        eid: EndpointId.HYPERLIQUID_V2_MAINNET,
        contractName: 'ApeCoin',
    }
    
    const baseMainnetContract: OmniPointHardhat = {
        eid: EndpointId.BASE_V2_MAINNET,
        contractName: 'ApeOFT',
    }
    
    const receiveEnforcedOptions: OAppEnforcedOption[] = [
        {
            msgType: MsgType.SEND,
            optionType: ExecutorOptionType.LZ_RECEIVE,
            gas: 100_000,
        },
    ]
    
    const config: OAppOmniGraphHardhat = {
        contracts: [
            {
                contract: hyperliquidMainnetContract,
            },
            {
                contract: baseMainnetContract,
            },
        ],
        connections: [
            {
                from: baseMainnetContract,
                to: hyperliquidMainnetContract,
                config: {
                    enforcedOptions: receiveEnforcedOptions,
                    sendLibrary: '0xB5320B0B3a13cC860893E2Bd79FCd7e13484Dda2',
                    receiveLibraryConfig: {
                        receiveLibrary: '0xc70AB6f32772f59fBfc23889Caf4Ba3376C84bAf',
                        gracePeriod: BigInt(0),
                    },
                    sendConfig: {
                        executorConfig: {
                            maxMessageSize: 10_000,
                            executor: '0x2CCA08ae69E0C44b18a57Ab2A87644234dAebaE4',
                        },
                        ulnConfig: {
                            confirmations: BigInt(0),
                            requiredDVNs: [
                                '0x9e059a54699a285714207b43b055483e78faac25', // LayerZero Labs
                                '0xa7b5189bca84cd304d8553977c7c614329750d99', // Horizen
                            ],
                        },
                    },
                    receiveConfig: {
                        ulnConfig: {
                            confirmations: BigInt(0),
                            requiredDVNs: [
                                '0x9e059a54699a285714207b43b055483e78faac25', // LayerZero Labs
                                '0xa7b5189bca84cd304d8553977c7c614329750d99', // Horizen
                            ],
                        },
                    },
                },
            },
        ],
    }
    
    export default config
    
  4. Create layerzero.bnb.config.ts and paste the following contents:

    import { EndpointId } from '@layerzerolabs/lz-definitions'
    import { ExecutorOptionType } from '@layerzerolabs/lz-v2-utilities'
    
    import type { OAppEnforcedOption, OAppOmniGraphHardhat, OmniPointHardhat } from '@layerzerolabs/toolbox-hardhat'
    
    enum MsgType {
        SEND = 1,
    }
    const hyperliquidMainnetContract: OmniPointHardhat = {
        eid: EndpointId.HYPERLIQUID_V2_MAINNET,
        contractName: 'ApeCoin',
    }
    
    const bnbMainnetContract: OmniPointHardhat = {
        eid: EndpointId.BSC_V2_MAINNET,
        contractName: 'ApeOFT',
    }
    
    const receiveEnforcedOptions: OAppEnforcedOption[] = [
        {
            msgType: MsgType.SEND,
            optionType: ExecutorOptionType.LZ_RECEIVE,
            gas: 100_000,
        },
    ]
    
    const config: OAppOmniGraphHardhat = {
        contracts: [
            {
                contract: hyperliquidMainnetContract,
            },
            {
                contract: bnbMainnetContract,
            },
        ],
        connections: [
            {
                from: bnbMainnetContract,
                to: hyperliquidMainnetContract,
                config: {
                    enforcedOptions: receiveEnforcedOptions,
                    sendLibrary: '0x9F8C645f2D0b2159767Bd6E0839DE4BE49e823DE',
                    receiveLibraryConfig: {
                        receiveLibrary: '0xB217266c3A98C8B2709Ee26836C98cf12f6cCEC1',
                        gracePeriod: BigInt(0),
                    },
                    sendConfig: {
                        executorConfig: {
                            maxMessageSize: 10_000,
                            executor: '0x3ebD570ed38B1b3b4BC886999fcF507e9D584859',
                        },
                        ulnConfig: {
                            confirmations: BigInt(0),
                            requiredDVNs: [
                                '0xfd6865c841c2d64565562fcc7e05e619a30615f0', // LayerZero Labs
                                '0x247624e2143504730aec22912ed41f092498bef2', // Horizen
                            ],
                        },
                    },
                    receiveConfig: {
                        ulnConfig: {
                            confirmations: BigInt(0),
                            requiredDVNs: [
                                '0xfd6865c841c2d64565562fcc7e05e619a30615f0', // LayerZero Labs
                                '0x247624e2143504730aec22912ed41f092498bef2', // Horizen
                            ],
                        },
                    },
                },
            },
        ],
    }
    
    export default config
    
  5. Edit layerzero.hyperliquid.config.ts:

    5a. Declare contract variables:

    const baseMainnetContract: OmniPointHardhat = {
        eid: EndpointId.BASE_V2_MAINNET,
        contractName: 'ApeOFT',
    }
    const bnbMainnetContract: OmniPointHardhat = {
        eid: EndpointId.BSC_V2_MAINNET,
        contractName: 'ApeOFT',
    }
    

    5b. Insert into config.contracts array:

        {
            contract: baseMainnetContract,
        },
        {
            contract: bnbMainnetContract,
        },
    

    5c. Insert into config.connections:

     ```
        {
         from: hyperliquidMainnetContract,
         to: baseMainnetContract,
         config: {
             enforcedOptions: EnforcedOptionsL2,
             sendLibrary: '0xfd76d9CB0Bac839725aB79127E7411fe71b1e3CA',
             receiveLibraryConfig: {
                 receiveLibrary: '0x7cacBe439EaD55fa1c22790330b12835c6884a91',
                 gracePeriod: BigInt(0),
             },
             sendConfig: {
                 executorConfig: {
                     maxMessageSize: 10_000,
                     executor: '0x41Bdb4aa4A63a5b2Efc531858d3118392B1A1C3d',
                 },
                 ulnConfig: {
                     confirmations: BigInt(0),
                     requiredDVNs: [
                         '0xc097ab8cd7b053326dfe9fb3e3a31a0cce3b526f', // LayerZero Labs
                         '0xbb83ecf372cbb6daa629ea9a9a53bec6d601f229', // Horizen
                         '0xc7423626016bc40375458bc0277f28681ec91c8e', // P2P
                     ],
                 },
             },
             receiveConfig: {
                 ulnConfig: {
                     confirmations: BigInt(0),
                     requiredDVNs: [
                         '0xc097ab8cd7b053326dfe9fb3e3a31a0cce3b526f', // LayerZero Labs
                         '0xbb83ecf372cbb6daa629ea9a9a53bec6d601f229', // Horizen
                         '0xc7423626016bc40375458bc0277f28681ec91c8e', // P2P
                     ],
                 },
             },
         },
     },
     {
         from: hyperliquidMainnetContract,
         to: bnbMainnetContract,
         config: {
             enforcedOptions: EnforcedOptionsL2,
             sendLibrary: '0xfd76d9CB0Bac839725aB79127E7411fe71b1e3CA',
             receiveLibraryConfig: {
                 receiveLibrary: '0x7cacBe439EaD55fa1c22790330b12835c6884a91',
                 gracePeriod: BigInt(0),
             },
             sendConfig: {
                 executorConfig: {
                     maxMessageSize: 10_000,
                     executor: '0x41Bdb4aa4A63a5b2Efc531858d3118392B1A1C3d',
                 },
                 ulnConfig: {
                     confirmations: BigInt(0),
                     requiredDVNs: [
                         '0xc097ab8cd7b053326dfe9fb3e3a31a0cce3b526f', // LayerZero Labs
                         '0xbb83ecf372cbb6daa629ea9a9a53bec6d601f229', // Horizen
                         '0xc7423626016bc40375458bc0277f28681ec91c8e', // P2P
                     ],
                 },
             },
             receiveConfig: {
                 ulnConfig: {
                     confirmations: BigInt(0),
                     requiredDVNs: [
                         '0xc097ab8cd7b053326dfe9fb3e3a31a0cce3b526f', // LayerZero Labs
                         '0xbb83ecf372cbb6daa629ea9a9a53bec6d601f229', // Horizen
                         '0xc7423626016bc40375458bc0277f28681ec91c8e', // P2P
                     ],
                 },
             },
         },
     },
     ```
    

    Note: All the addresses are the same for all connections as they are referring to the same instances on HyperEVM Mainnet.

  6. Given that the BNB OFT is still owned by your EOA, ensure you set that EOA's private key or mnemonic in the .env

  7. Run the wiring command for Base - npx hardhat lz:oapp:wire --oapp-config layerzero.base.config.ts. Submit the txns.

  8. Run the wiring command for BNB - npx hardhat lz:oapp:wire --oapp-config layerzero.bnb.config.ts. Submit the txns.

  9. Get the wiring txns for Hyperliquid - npx hardhat lz:oapp:wire --oapp-config layerzero.hyperliquid.config.ts --output-filename hyperliquid-wire-txns.json

    • When asked to preview txns, you can choose Y or just terminate the process immediately, as at this point, the JSON file would have already been generated. If asked " Would you like to submit the required transactions?", respond with 'N' to terminate the process.
    • View the generated JSON at hyperliquid-wire-txns.json to view the txns data that needs execution
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment