@folks-finance/wormhole-ntt-sdk
v0.1.10
Published
JavaScript SDK for Wormhole NTT Bridge
Readme
@folks-finance/wormhole-ntt-sdk
JavaScript SDK for transferring Wormhole NTT tokens with support for Algorand.
Table of Contents
Getting Started
Installation
Package manager
Using npm:
npm install @folks-finance/wormhole-ntt-sdkUsing yarn:
yarn add @folks-finance/wormhole-ntt-sdkUsing pnpm:
pnpm add @folks-finance/wormhole-ntt-sdkUsing bun:
bun add @folks-finance/wormhole-ntt-sdkSDK Structure and Usage
The Wormhole NTT SDK consists of two main components:
FolksCore: This acts as the central context for the SDK, managing configuration and state that is shared across all modules.FolksBridge: For interacting with API and smart-contracts.
FolksCore
FolksCore is responsible for initializing the SDK and maintaining the global context. It handles:
- Network selection (testnet/mainnet)
- Provider management
- Signer management
Any changes made to FolksCore will affect subsequent calls to the various modules. For example, changing the network or signer will impact how the modules interact with the blockchain.
FolksBridge
FolksBridge used for:
- Reading executor capabilities
- Requesting quotes for transfer execution
- Initiating transfers
- Read operations history
This module use the context provided by FolksCore internally, so they always operate based on the current state of FolksCore.
Basic Usage
To start using the Folks Finance Wormhole NTT SDK:
- Import and initialize
FolksCore:
import { FolksCore, NetworkType } from "@folks-finance/xchain-sdk";
const folksConfig = {
network: NetworkType.TESTNET, // or NetworkType.MAINNET
provider: {
evm: {
// Add your EVM provider configuration here (optional)
// If not provided, default providers will be used
},
},
};
FolksCore.init(folksConfig);
// For operations that require signing - set signer
const evmSigner = getEVMSigner(network, chain); // or getAVMSigner()
FolksCore.setFolksSigner({
signer: evmSigner,
folksChainId: TESTNET_FOLKS_CHAIN_ID.AVALANCHE_FUJI,
chainType: ChainType.EVM,
});- Use
FolksBridgemodule to transfer tokens:
const feePaymentToken = {
tokenType: TokenType.GAS,
tokenSymbol: "",
tokenDecimals: 18,
};
const sourceChain = TESTNET_FOLKS_CHAIN_ID.AVALANCHE_FUJI;
const destChain = TESTNET_FOLKS_CHAIN_ID.ALGORAND_TESTNET;
const capabilities = await FolksBridge.read.capabilities();
const quote = await FolksBridge.read.quote(sourceChain, destChain, feePaymentToken);
const prepareCall = await FolksBridge.prepare.transfer(
TESTNET_NTT_TOKEN_ID.FOLKS_TESTNET,
1_000_000n,
destChain,
convertToGenericAddress("5F3UPPGBWR2KBH3B3TJYJXQYIRVVNOVGOJLOVY6ALHCIMDW2SWS4FA7VLU" as AVMAddress, ChainType.AVM),
capabilities,
quote,
feePaymentToken,
);
const txHash = await FolksBridge.write.transfer(prepareCall);
console.log(txHash);More examples provided in ./examples folder.
