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

0.1.8 • 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={['Aptos', 'Celo', 'Polygon', 'Sui']}
      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';

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

  const handleUnsignedTx = async (unsignedTx: any): Promise<void> => {
    // To execute the transaction,
    // send the unsigned transaction to the wallet.
  };

  const handleConfirm = async () => {
    try {
      const tx = await api.buildTransferTx({
        sender: { chain: 'Sui', address: '0x....' },
        receiver: {
          chain: 'Aptos,
          address: '0x....',
        },
        amount: '1.2',
      });
      handleUnsignedTx(tx);
    } 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

92

Version

0.1.8

License

ISC

Unpacked Size

121 kB

Total Files

98

Last publish

Collaborators

  • daoauth