@zktx.io/wormhole-kit-core
Installation
bash
npm install @zktx.io/wormhole-kit-core
bash
yarn add @zktx.io/wormhole-kit-core
Usage
First, instantiate the WhCoreProvider
component.
typescript
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']}
>
<App />
</WhCoreProvider>
</StrictMode>,
);
Next, use the WhCoreProvider
context in the Modal to create unsigned transactions.
typescript
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