@zktx.io/wormhole-kit-core
TypeScript icon, indicating that this package has built-in type declarations

0.1.12 • Public • Published

@zktx.io/wormhole-kit-core

If you want to utilize only the core features of Wormhole Kit for your excellent UX, you can simply use Wormhole Kit Core.

Getting started

Get started with @zktx.io/wormhole-kit and learn by developer docs

Installation

npm install @zktx.io/wormhole-kit-core
yarn add @zktx.io/wormhole-kit-core

Usage

First, instantiate the WhCoreProvider component.

import {
  WhCoreProvider,
} from '@zktx.io/wormhole-kit-core';

const root = createRoot(document.getElementById('root') as HTMLElement);
root.render(
  <StrictMode>
    <WhCoreProvider
      network="Testnet"
      chains={['Sui', 'Sepolia', 'Solana', 'Aptos', 'Celo', 'Polygon']}
      config={
        {
          chains: {
            Ethereum: {
              rpc: 'https://eth-goerli.public.blastapi.io',
            },
            Polygon: {
              rpc: 'https://polygon-mumbai.api.onfinality.io/public',
            },
          },
        }
      }
    >
      <App />
    </WhCoreProvider>
  </StrictMode>,
);

Next, use the WhCoreProvider context in the Modal to create unsigned transactions.

import { useWormhole } from '@zktx.io/wormhole-kit-core';

import type { IUnsignedTx } from '@zktx.io/wormhole-kit-core';

export const WhTransferModal = () => {
  const api = useWormhole();

  const handleUnsignedTxs = async (unsignedTxs: IUnsignedTx[]): Promise<void> => {
    // To execute the transaction,
    // send the unsigned transaction to the wallet.
  };

  const handleConfirm = async () => {
    try {
      const txs = await api.buildTransferTx({
        sender: { chain: 'Sui', address: '0x....' },
        receiver: {
          chain: 'Aptos,
          address: '0x....',
        },
        amount: '1.2',
      });
      handleUnsignedTxs(txs);
    } catch (error) {
      console.error(error);
    }
  };

  return <>...</>
}

WhCoreProvider Props

  • network: Mainnet, Testnet, and Devnet.
  • chains: Algorand, Aptos, EVMs, Solana, and Sui.
  • config: If needed, you can customize the default configuration to, for example, support a different RPC endpoint. link

Package Sidebar

Install

npm i @zktx.io/wormhole-kit-core

Weekly Downloads

58

Version

0.1.12

License

ISC

Unpacked Size

123 kB

Total Files

98

Last publish

Collaborators

  • daoauth