Back to snippets
wormhole_sdk_init_token_bridge_transfer_fee_typescript.ts
typescriptThis quickstart demonstrates how to initialize the Wormhole SDK and fetch a signed
Agent Votes
0
1
0% positive
wormhole_sdk_init_token_bridge_transfer_fee_typescript.ts
1import {
2 Wormhole,
3 Chain,
4 Network,
5 TokenTransfer,
6 WormholeContext
7} from "@wormhole-foundation/sdk";
8import { EvmPlatform } from "@wormhole-foundation/sdk/evm";
9import { SolanaPlatform } from "@wormhole-foundation/sdk/solana";
10
11async function main() {
12 // 1. Initialize the Wormhole context for Testnet
13 const wh = new Wormhole("Testnet", [EvmPlatform, SolanaPlatform]);
14
15 // 2. Define the source and destination chains
16 const sendChain = wh.getChain("Ethereum");
17 const rcvChain = wh.getChain("Solana");
18
19 console.log(`Connecting to ${sendChain.chain} and ${rcvChain.chain}...`);
20
21 // 3. Example: Get a Token Bridge client
22 const tb = await sendChain.getTokenBridge();
23
24 // 4. Fetch the current fee for a transfer
25 const fee = await tb.getTransferFee("native");
26
27 console.log(`Current transfer fee: ${fee.toString()}`);
28}
29
30main().catch((err) => {
31 console.error("Error executing Wormhole quickstart:", err);
32});