@kasplex/kiwi-web
Advanced tools
| export declare const errorMsg: { | ||
| WALLET_NOT_FOUND: (walletName: string) => string; | ||
| WALLET_NOT_INITIALIZED: string; | ||
| WALLET_OBJECT_NOT_INITIALIZED: string; | ||
| FUNCTION_NAME_REQUIRED: string; | ||
| METHOD_NOT_FUNCTION: (functionName: string) => string; | ||
| WALLET_PROVIDER_NOT_INITIALIZED: string; | ||
| }; |
| export * from './walletDetector'; | ||
| export * from './walletApi'; |
| /** | ||
| * A unified wallet API interface for interacting with various cryptocurrency wallets. | ||
| * Provides standardized methods for account management, transactions, and wallet operations. | ||
| */ | ||
| declare class WalletApi { | ||
| private walletObj; | ||
| private initialized; | ||
| walletName: string; | ||
| private constructor(); | ||
| /** | ||
| * Initializes the wallet instance with the specified wallet provider | ||
| * @param walletName - Name of the wallet provider (e.g., 'kasware', 'unisat') | ||
| * @throws Error if wallet is not found or invalid | ||
| */ | ||
| private initWallet; | ||
| /** | ||
| * Factory method to create a new WalletApi instance | ||
| * @param walletName - Name of the wallet provider | ||
| * @returns Promise<WalletApi> - Initialized wallet instance | ||
| */ | ||
| static create(walletName: string): Promise<WalletApi>; | ||
| /** | ||
| * Validates that the wallet instance is properly initialized | ||
| * @throws Error if instance is not initialized | ||
| */ | ||
| private ensureInitialized; | ||
| /** | ||
| * Validates and returns a wallet method | ||
| * @param functionName - Name of the wallet method to call | ||
| * @returns Function - Bound wallet method | ||
| * @throws Error if method is invalid or unavailable | ||
| */ | ||
| checkFun(functionName: string): Promise<any>; | ||
| /** | ||
| * Performs wallet-specific authorization flow | ||
| * @returns Promise<string> - Authorization result (varies by wallet) | ||
| */ | ||
| authorize(): Promise<string | void | string[]>; | ||
| /** | ||
| * Validates wallet object is initialized | ||
| * @private | ||
| * @throws {Error} When wallet object is not available | ||
| */ | ||
| private validateWalletObject; | ||
| /** | ||
| * Registers a handler for the 'accountsChanged' event. | ||
| * @param handler - Callback function to handle the event. | ||
| */ | ||
| onAccountsChanged(handler: (accounts: string[]) => void): Promise<void>; | ||
| /** | ||
| * Removes a handler for the 'accountsChanged' event. | ||
| * @param handler - Callback function to remove. | ||
| */ | ||
| offAccountsChanged(handler: (accounts: string[]) => void): Promise<void>; | ||
| /** | ||
| * Registers a callback for network change events | ||
| * @param handler - Callback function that receives new network identifier | ||
| * @throws {Error} When wallet is not initialized | ||
| * @example | ||
| * wallet.onNetworkChanged((network) => { | ||
| * console.log('Network changed to:', network); | ||
| * }); | ||
| */ | ||
| onNetworkChanged(handler: (network: string) => void): Promise<void>; | ||
| /** | ||
| * Unregisters a network change callback | ||
| * @param handler - Previously registered callback function to remove | ||
| * @throws {Error} When wallet is not initialized | ||
| */ | ||
| offNetworkChanged(handler: (network: string) => void): Promise<void>; | ||
| /** | ||
| * Requests access to wallet accounts | ||
| * @returns Promise<string[]> - Array of authorized account addresses | ||
| */ | ||
| requestAccounts(): Promise<string[]>; | ||
| /** | ||
| * Gets currently connected accounts | ||
| * @returns Promise<string> - Primary account address | ||
| */ | ||
| getAccounts(): Promise<string>; | ||
| /** | ||
| * Gets currently connected accounts | ||
| * @returns Promise<string> - Primary account address | ||
| */ | ||
| getAccount(): Promise<string>; | ||
| /** | ||
| * Gets current network version | ||
| * @returns Promise<string> - Network version identifier | ||
| */ | ||
| getVersion(): Promise<string>; | ||
| /** | ||
| * Gets current network information | ||
| * @returns Promise<string> - Network name/identifier | ||
| */ | ||
| getNetwork(): Promise<string>; | ||
| /** | ||
| * Switches wallet to specified network | ||
| * @param network - Target network identifier | ||
| * @returns Promise<string> - Operation result | ||
| */ | ||
| switchNetwork(network: string): Promise<string>; | ||
| /** | ||
| * Disconnects from wallet | ||
| * @param origin - Optional origin identifier | ||
| * @returns Promise<string> - Disconnection result | ||
| */ | ||
| disconnect(orgin?: string): Promise<string>; | ||
| /** | ||
| * Retrieves the public key from the wallet. | ||
| * @returns {Promise<string>} - Public key. | ||
| */ | ||
| getPublicKey(): Promise<string>; | ||
| /** | ||
| * Gets current account balance | ||
| * @returns Promise<Object> - Balance information | ||
| */ | ||
| getBalance(): Promise<Object>; | ||
| /** | ||
| * Retrieves the KRC20 token balance. | ||
| * @returns {Promise<Array<any> | Object>} - KRC20 token balance. | ||
| */ | ||
| getKRC20Balance(): Promise<Array<any> | Object>; | ||
| /** | ||
| * Retrieves the UTXO entries from the wallet. | ||
| * @returns {Promise<Array<any> | Object>} - UTXO entries. | ||
| */ | ||
| getUtxoEntries(): Promise<Array<any> | Object>; | ||
| /** | ||
| * Sends Kaspa transaction | ||
| * @param toAddress - Recipient address | ||
| * @param sompi - Amount in sompi | ||
| * @param options - Additional transaction options | ||
| * @returns Promise<string> - Transaction hash | ||
| */ | ||
| sendKaspa(toAddress: string, sompi: number, options?: object): Promise<string>; | ||
| /** | ||
| * Signs a PSKT transaction | ||
| * @param txJsonString - Transaction data in JSON format | ||
| * @param options - Signing options | ||
| * @returns Promise<string> - Signed transaction | ||
| */ | ||
| signPskt({ txJsonString, options }: { | ||
| txJsonString: string; | ||
| options: object; | ||
| }): Promise<string>; | ||
| /** | ||
| * Builds a script for a transaction. | ||
| * @param {Object} params - Script parameters. | ||
| * @param {string} params.type - Script type. | ||
| * @param {string} params.data - Script data. | ||
| * @returns {Promise<string>} - Built script. | ||
| */ | ||
| buildScript({ type, data }: { | ||
| type: string; | ||
| data: string; | ||
| }): Promise<string>; | ||
| /** | ||
| * Submits a commit-reveal transaction. | ||
| * @param {object} commit - Commit transaction. | ||
| * @param {object} reveal - Reveal transaction. | ||
| * @param {any} script - Script data. | ||
| * @param {string} networkId - Network ID. | ||
| * @returns {Promise<any>} - Transaction result. | ||
| */ | ||
| submitCommitReveal(commit: object, reveal: object, script: any, networkId: string): Promise<any>; | ||
| /** | ||
| * Creates a KRC20 order. | ||
| * @param {Object} params - Order parameters. | ||
| * @param {string} params.krc20Tick - KRC20 ticker. | ||
| * @param {number | string} params.krc20Amount - KRC20 amount. | ||
| * @param {number} params.kasAmount - Kaspa amount. | ||
| * @param {Array<{ address: string; amount: number }>} params.psktExtraOutput - Extra outputs. | ||
| * @param {number} params.priorityFee - Priority fee. | ||
| * @returns {Promise<any>} - Order result. | ||
| */ | ||
| createKRC20Order({ krc20Tick, krc20Amount, kasAmount, psktExtraOutput, priorityFee }: { | ||
| krc20Tick: string; | ||
| krc20Amount: number | string; | ||
| kasAmount: number; | ||
| psktExtraOutput: { | ||
| address: string; | ||
| amount: number; | ||
| }[]; | ||
| priorityFee: number; | ||
| }): Promise<any>; | ||
| /** | ||
| * Buys a KRC20 token. | ||
| * @param {Object} params - Transaction parameters. | ||
| * @param {string} params.txJsonString - Transaction JSON string. | ||
| * @param {Array<{ address: string; amount: number }>} params.extraOutput - Extra outputs. | ||
| * @param {number} params.priorityFee - Priority fee. | ||
| * @returns {Promise<any>} - Transaction result. | ||
| */ | ||
| buyKRC20Token({ txJsonString, extraOutput, priorityFee }: { | ||
| txJsonString: string; | ||
| extraOutput: { | ||
| address: string; | ||
| amount: number; | ||
| }[]; | ||
| priorityFee: number; | ||
| }): Promise<any>; | ||
| /** | ||
| * Cancels a KRC20 order. | ||
| * @param {Object} params - Order parameters. | ||
| * @param {string} params.krc20Tick - KRC20 ticker. | ||
| * @param {string} params.txJsonString - Transaction JSON string. | ||
| * @param {string} params.sendCommitTxId - Commit transaction ID. | ||
| * @returns {Promise<string>} - Cancellation result. | ||
| */ | ||
| cancelKRC20Order({ krc20Tick, txJsonString, sendCommitTxId }: { | ||
| krc20Tick: string; | ||
| txJsonString: string; | ||
| sendCommitTxId: string; | ||
| }): Promise<string>; | ||
| /** | ||
| * Signs a message. | ||
| * @param {string} msg - Message to sign. | ||
| * @param {string} type - Signature type. | ||
| * @returns {Promise<string>} - Signed message. | ||
| */ | ||
| signMessage(msg: string, type: string): Promise<string>; | ||
| /** | ||
| * Signs a KRC20 transaction. | ||
| * @param {string} inscribeJsonString - Inscription JSON string. | ||
| * @param {number} type - Transaction type. | ||
| * @param {string} destAddr - Destination address. | ||
| * @param {number} priorityFee - Priority fee. | ||
| * @returns {Promise<any>} - Signed transaction. | ||
| */ | ||
| signKRC20Transaction(inscribeJsonString: string, type: number, destAddr: string, priorityFee: number): Promise<any>; | ||
| /** | ||
| * Retrieves the current chain. | ||
| * @returns {Promise<Object>} - Current chain. | ||
| */ | ||
| getChain(): Promise<Object>; | ||
| /** | ||
| * Switches the wallet to the specified blockchain network | ||
| * @param chain - Chain ID/number to switch to | ||
| * @returns Promise<Object> - Result object containing network switch details | ||
| * @throws Error if chain switching fails or unsupported chain | ||
| */ | ||
| switchChain(chain: number): Promise<Object>; | ||
| /** | ||
| * Retrieves a paginated list of digital inscriptions (NFTs/BRC-20 tokens) | ||
| * @param cursor - Starting index for pagination (default: 0) | ||
| * @param size - Number of items per page (default: 10) | ||
| * @returns Promise<Object> - Paginated inscription data { list, total, cursor } | ||
| */ | ||
| getInscriptions(cursor?: number, size?: number): Promise<Object>; | ||
| /** | ||
| * Sends Bitcoin transaction to specified address | ||
| * @param toAddress - Recipient Bitcoin address | ||
| * @param satoshis - Amount to send in satoshis | ||
| * @param options - Additional transaction options { feeRate, memo, etc. } | ||
| * @returns Promise<string> - Resulting transaction hash | ||
| */ | ||
| sendBitcoin(toAddress: string, satoshis: number, options: object): Promise<string>; | ||
| /** | ||
| * Transfers Runes protocol tokens | ||
| * @param address - Recipient address | ||
| * @param runeid - Rune ID/identifier | ||
| * @param amount - Amount to transfer | ||
| * @param options - Additional transfer options | ||
| * @returns Promise<Object> - Transfer result { txId, status } | ||
| */ | ||
| sendRunes(address: string, runeid: string, amount: string, options: object): Promise<Object>; | ||
| /** | ||
| * Transfers a single inscription (NFT/BRC-20) | ||
| * @param address - Recipient address | ||
| * @param inscriptionId - ID of the inscription to transfer | ||
| * @param options - Transfer options { feeRate, etc. } | ||
| * @returns Promise<Object> - Transfer confirmation data | ||
| */ | ||
| sendInscription(address: string, inscriptionId: string, options: object): Promise<Object>; | ||
| /** | ||
| * Creates a transfer inscription for specified token | ||
| * @param ticker - Token ticker symbol (e.g., 'ordi') | ||
| * @param amount - Amount to inscribe | ||
| * @returns Promise<void> - Resolves when inscription is initiated | ||
| */ | ||
| inscribeTransfer(ticker: string, amount: string): Promise<void>; | ||
| /** | ||
| * Broadcasts a raw transaction to the network | ||
| * @param options - Transaction data { hex, network, etc. } | ||
| * @returns Promise<string> - Broadcast transaction ID | ||
| */ | ||
| pushTx(options: object): Promise<string>; | ||
| /** | ||
| * Signs a Partially Signed Bitcoin Transaction (PSBT) | ||
| * @param psbtHex - PSBT in hex format | ||
| * @param options - Signing options { autoFinalize, etc. } | ||
| * @returns Promise<string> - Signed PSBT hex | ||
| */ | ||
| signPsbt(psbtHex: string, options: object): Promise<string>; | ||
| /** | ||
| * Batch signs multiple PSBTs | ||
| * @param psbtHexs - Array of PSBT hex strings | ||
| * @param options - Array of signing options per PSBT | ||
| * @returns Promise<string[]> - Array of signed PSBT hex strings | ||
| */ | ||
| signPsbts(psbtHexs: string[], options: object[]): Promise<string[]>; | ||
| /** | ||
| * Pushes a signed PSBT to the network | ||
| * @param psbtHex - Signed PSBT in hex format | ||
| * @returns Promise<string> - Broadcast transaction ID | ||
| */ | ||
| pushPsbt(psbtHex: string): Promise<string>; | ||
| /** | ||
| * Establishes connection with wallet provider | ||
| * @returns Promise<void> - Resolves when connection is established | ||
| * @throws Error if connection fails | ||
| */ | ||
| connect(): Promise<void>; | ||
| /** | ||
| * Initializes wallet state and required parameters | ||
| * @returns Promise<any> - Wallet initialization data | ||
| */ | ||
| initialize(): Promise<any>; | ||
| /** | ||
| * Opens wallet UI for KRC-20 token deployment | ||
| * @returns Promise<any> - Deployment interface response | ||
| */ | ||
| openDeployKrc20View(): Promise<any>; | ||
| /** | ||
| * Opens wallet UI for KRC-20 token minting | ||
| * @returns Promise<any> - Minting interface response | ||
| */ | ||
| openMintKrc20View(): Promise<any>; | ||
| /** | ||
| * Verifies a signed message against current account | ||
| * @returns Promise<any> - Verification result | ||
| */ | ||
| verifyMessage(): Promise<any>; | ||
| } | ||
| export { WalletApi }; |
| declare class BrowerWallet { | ||
| static walletList: string[]; | ||
| /** | ||
| * Retrieves a list of installed browser wallets by checking their global variables. | ||
| * This method iterates through the `WALLET_ID_LIST` and checks if each wallet's global variable | ||
| * exists on the `window` object. | ||
| * | ||
| * @returns {Promise<string[]>} A promise that resolves to an array of wallet keys for installed wallets. | ||
| */ | ||
| static getBrowerWalletList(): Promise<string[]>; | ||
| /** | ||
| * Detects whether specified browser extensions are installed by checking their global variables. | ||
| * This method takes an array of extension names and checks if each extension's global variable | ||
| * | ||
| * @param {string[]} extensionNames - An array of extension names to check. | ||
| * @returns {Promise<Record<string, boolean>>} A promise that resolves to an object mapping extension names to their installation status. | ||
| */ | ||
| static detectBrowserExtensions(extensionNames: string[]): Promise<Record<string, boolean>>; | ||
| /** | ||
| * Checks if a specific browser extension is installed by verifying its global variable. | ||
| * This method attempts to detect the extension by checking if the corresponding global variable | ||
| * might be loaded asynchronously. | ||
| * | ||
| * @param {string} extensionName - The name of the extension to check. | ||
| * @param {number} retries - The number of retry attempts (default: 1). | ||
| * @param {number} delay - The delay (in milliseconds) between retries (default: 300). | ||
| * @returns {Promise<boolean>} A promise that resolves to `true` if the extension is installed, otherwise `false`. | ||
| */ | ||
| static isExtInstalled(extensionName: string, retries?: number, delay?: number): Promise<boolean>; | ||
| /** | ||
| * Retrieves the wallet instance for the specified wallet name. | ||
| * This method checks if the wallet extension is installed by verifying its global variable on the `window` object. | ||
| * If the wallet is installed, it returns the wallet instance; otherwise, it returns `null`. | ||
| * | ||
| * @param {string} walletName - The name of the wallet to retrieve. | ||
| * @returns {Promise<Window[keyof Window] | null>} A promise that resolves to the wallet instance if installed, otherwise `null`. | ||
| */ | ||
| static getWallet(walletName: string): Promise<Window[keyof Window] | null>; | ||
| } | ||
| export { BrowerWallet }; |
| # Wallet Extension SDK | ||
| A unified wallet API interface for interacting with various cryptocurrency wallets. This SDK provides standardized methods for account management, transactions, and wallet operations. | ||
| ## Quick Start | ||
| ```typescript | ||
| import { WalletApi } from '@kasplex/kiwi-web'; | ||
| // Create and initialize wallet instance | ||
| const wallet = await WalletApi.create('kasware'); | ||
| // Request account access | ||
| const accounts = await wallet.authorize(); | ||
| console.log('Connected accounts:', accounts); | ||
| // Send KAS | ||
| const txId = await wallet.sendKaspa( | ||
| 'kaspatest:qrxh35ysr2hchag9gtam5vlkvpmn89ph78t6nqvg44yj3xf8rpeg2ttgg7a5t', | ||
| 100000000, | ||
| ) | ||
| console.log('Transaction ID Info:', txId); | ||
| ``` | ||
| ## Supported Wallets | ||
| - Kasware | ||
| - Kaskeeper | ||
| - Kastle | ||
| ## Core Features | ||
| - Account Management | ||
| - Transaction Operations | ||
| - Network Management | ||
| - Event Handling | ||
| - KRC20 Token Operations | ||
| - Message Signing | ||
| - PSBT Operations | ||
| ### Account Management | ||
| #### `authorize()` | ||
| Requests access to wallet accounts. | ||
| ```typescript | ||
| const accounts = await wallet.authorize(); | ||
| ``` | ||
| #### `getAccounts()` | ||
| Get currently connected accounts. | ||
| ```typescript | ||
| const account = await wallet.getAccounts(); | ||
| ``` | ||
| ## Wallet Method Support Comparison | ||
| | Method Name | KasKeeper | Kastle | KasWare | | ||
| |------------------------|-----------|--------|---------| | ||
| | **Authorization & Connection** | | | | | ||
| | authorize | Yes | Yes | Yes | | ||
| | connect | Yes | Yes | No | | ||
| | requestAccounts | Yes | | Yes | | ||
| | getAccounts | Yes | | Yes | | ||
| | getAccount | No | Yes | No | | ||
| | **Network & Version** | | | | | ||
| | getVersion | Yes | | Yes | | ||
| | getNetwork | Yes | | Yes | | ||
| | switchNetwork | Yes | | Yes | | ||
| | disconnect | Yes | | Yes | | ||
| | **Account Info** | | | | | ||
| | getPublicKey | Yes | | Yes | | ||
| | getBalance | Yes | | Yes | | ||
| | getKRC20Balance | Yes | | Yes | | ||
| | getUtxoEntries | No | | Yes | | ||
| | **Transaction Operations** | | | | | ||
| | sendKaspa | Yes | | Yes | | ||
| | signPskt | No | | Yes | | ||
| | buildScript | No | | Yes | | ||
| | submitCommitReveal | No | | Yes | | ||
| | createKRC20Order | No | | Yes | | ||
| | buyKRC20Token | No | | Yes | | ||
| | cancelKRC20Order | No | | Yes | | ||
| | signMessage | Yes | | Yes | | ||
| | signKRC20Transaction | No | | Yes | | ||
| | **Chain & Inscriptions** | | | | | ||
| | getChain | No | | No | | ||
| | switchChain | No | | No | | ||
| | getInscriptions | No | | No | | ||
| | sendBitcoin | No | | No | | ||
| | sendRunes | No | | No | | ||
| | inscribeTransfer | No | | No | | ||
| | **PSBT Operations** | | | | | ||
| | pushTx | Yes | | Yes | | ||
| | signPsbt | Yes | | No | | ||
| | signPsbts | Yes | | No | | ||
| | pushPsbt | Yes | | No | | ||
| | **Other Features** | | | | | ||
| | initialize | Yes | | Yes | | ||
| | openDeployKrc20View | Yes | | No | | ||
| | openMintKrc20View | Yes | | No | | ||
| | verifyMessage | Yes | | No | | ||
| ## Reference Connection | ||
| - **[Kasware Documentation](https://docs.kasware.xyz/wallet/dev-base/dev-integration#requestaccounts)**: Official documentation for integrating with the Kasware wallet. | ||
| ## Best Practices | ||
| 1. Always initialize wallet using `WalletApi.create()` | ||
| 2. Handle wallet events appropriately | ||
| 3. Implement proper error handling | ||
| 4. Check network compatibility before operations | ||
| 5. Verify transaction parameters before sending | ||
| ## TypeScript Support | ||
| The SDK is written in TypeScript and provides full type definitions for all methods and parameters. | ||
| ## Contributing | ||
| Contributions are welcome! Please read our contributing guidelines before submitting pull requests. | ||
| ## License | ||
| MIT License |
| # Kasplex Wallet SDK for web - Kiwi | ||
| **Kasplex Wallet SDK for web - Kasplex in Wallet Integration (Kiwi) is a powerful and easy-to-use SDK designed to simplify the management of Kaspa wallet assets. It provides seamless integration with Kaspa nodes, KRC20 tokens, and essential wallet functionalities, enabling developers to build robust Kaspa-based applications effortlessly.. | ||
| ## Features | ||
| - **Mnemonic Support**: Generate and restore wallets securely using industry-standard mnemonics. | ||
| - **Wallet Generation & Derivation**: Create hierarchical deterministic (HD) wallets and derive multiple addresses. | ||
| - **KRC20 Protocol Implementation & API Integration**: Easily interact with **KRC20 tokens** using built-in API functions. | ||
| - **Kaspa API & Node Connectivity**: Connect to Kaspa nodes for real-time blockchain data and transaction processing. | ||
| - **Multi-Signature Wallet Support**: Implement enhanced security with multi-signature wallet functionality. | ||
| - **Message Subscription**: Subscribe to blockchain events, transaction updates, and real-time notifications. | ||
| ## Installation | ||
| Node.js Version Requirement: This SDK requires Node.js version 20.13.1 or higher. You can check your Node.js version by running: | ||
| ## Getting Started | ||
| To integrate **Kasplex Wallet SDK - Kiwi** into your project, follow these steps: | ||
| 1. **Install the SDK**: | ||
| ```sh | ||
| npm install @kasplex/kiwi-web | ||
| ``` | ||
| 2. **Set up networkType and init rpc client for use**: | ||
| ```typescript | ||
| import { Kiwi, Rpc, Wasm, initialize } from '@kasplex/kiwi-web' | ||
| await initialize("path to kaspa_bg.wasm"); // you can find kaspa_bg.wasm in @kasplex-web/dist | ||
| await Kiwi.setNetwork(Wasm.NetworkType.Mainnet) // NetworkType.Testnet for test net | ||
| await Rpc.setInstance(Wasm.NetworkType.Mainnet).connect(); // connect kaspa node for fetch information from the node if needed | ||
| ``` | ||
| 2. **Generate a new wallet**: | ||
| ```typescript | ||
| import { Mnemonic, Wallet } from "@kasplex/kiwi-web"; | ||
| const mnemonic = Mnemonic.random(12); | ||
| console.log("Generated Mnemonic:", mnemonic); | ||
| let wallet = Wallet.fromMnemonic(mnemonic) | ||
| ``` | ||
| 4. **send kas**: | ||
| ```typescript | ||
| import { Kaspa } from "@kasplex/kiwi-web"; | ||
| const resp = await Kaspa.transferKas(privateKey, toAddress, 130000000n, 10000n) | ||
| ``` | ||
| 5. **KRC20**: | ||
| ```typescript | ||
| import { Kaspa, Enum, Utils, KRC20 } from "@kasplex/kiwi-web"; | ||
| const krc20data = Utils.createKrc20Data({ | ||
| p: "krc-20", | ||
| op: Enum.OP.Mint, | ||
| tick: 'TCKFE', | ||
| }) | ||
| let txid = await KRC20.mint(_privateKey, krc20data, 100000n) | ||
| console.log("Mint txid", txid) | ||
| ``` | ||
| 6. **Browser Extension Integration**: | ||
| ```typescript | ||
| import { BrowerWallet, WalletApi } from "@kasplex/kiwi-web"; | ||
| const walletList = await BrowerWallet.getBrowerWalletList(); | ||
| console.log("walletList", walletList); | ||
| // Create and initialize wallet instance | ||
| const wallet = await WalletApi.create('kasware'); | ||
| // Request account access | ||
| const accounts = await wallet.requestAccounts(); | ||
| console.log('Connected accounts:', accounts); | ||
| // Get wallet balance | ||
| const balance = await wallet.getBalance(); | ||
| console.log('Wallet balance:', balance); | ||
| ``` | ||
| For detailed browser extension integration guide, please refer to our [Browser Extension Documentation](./README-WalletExt.md) | ||
| ## More Examples | ||
| - For more detailed usage examples, check out our [Examples Directory](./examples/) | ||
| - For usage of node, check out our [Kiwi for NODE](./README.md) | ||
| ## Contribution | ||
| We welcome contributions from the community! Feel free to submit issues, feature requests, or pull requests to improve the **Kasplex Wallet SDK - Kiwi**. | ||
| ## License | ||
| This project is licensed under the **MIT License**. | ||
| 🚀 **Start building with Kasplex Wallet SDK - Kiwi today and unlock the full potential of the Kaspa ecosystem!** |
@@ -36,2 +36,11 @@ import { Params } from '../types/interface'; | ||
| /** | ||
| * Retrieves paginated full transaction details for a specific Kaspa address. | ||
| * This is useful when dealing with large transaction histories that need pagination. | ||
| * | ||
| * @param address - The Kaspa wallet address to query | ||
| * @param param - Optional query parameters for pagination (e.g., limit, before,after,fields,resolve_previous_outpoints) | ||
| * @returns Promise containing the paginated transaction data | ||
| */ | ||
| static getFullTransactionPage(address: string, param?: Record<string, string>): Promise<unknown>; | ||
| /** | ||
| * Get transaction count for a specific Kaspa address. | ||
@@ -38,0 +47,0 @@ * @param kaspaAddress The Kaspa wallet address |
+1
-0
@@ -13,3 +13,4 @@ export * as Wasm from './wasm'; | ||
| export * from "./utils/index"; | ||
| export * from "./browerExtend/index"; | ||
| export * as Modules from "./types/index"; | ||
| export * as Tx from "./tx"; |
@@ -20,1 +20,15 @@ export declare const BASE_URL_TEST = "https://tn10api.kasplex.org"; | ||
| export declare const KASPLEX = "kasplex"; | ||
| export declare const WALLET_AUTH_METHODS: { | ||
| readonly kastle: "connect"; | ||
| readonly kasware: "requestAccounts"; | ||
| readonly unisat: "requestAccounts"; | ||
| readonly kaskeeper: "disconnect"; | ||
| readonly kasperia: "requestAccounts"; | ||
| }; | ||
| export declare const WALLET_ID_LIST: { | ||
| Kaskeeper: string; | ||
| Kaspian: string; | ||
| kasware: string; | ||
| kastle: string; | ||
| kasperia: string; | ||
| }; |
+3
-2
| { | ||
| "name": "@kasplex/kiwi-web", | ||
| "version": "1.0.12", | ||
| "version": "1.0.13", | ||
| "type": "module", | ||
@@ -27,3 +27,4 @@ "sideEffects": false, | ||
| "dist", | ||
| "README-WEB.md" | ||
| "README-WEB.md", | ||
| "README-WalletExt.md" | ||
| ], | ||
@@ -30,0 +31,0 @@ "keywords": [ |
+15
-16
@@ -1,4 +0,4 @@ | ||
| # Kasplex Wallet SDK for web - Kiwi | ||
| # Kasplex Wallet SDK - Kiwi | ||
| **Kasplex Wallet SDK for web - Kasplex in Wallet Integration (Kiwi) is a powerful and easy-to-use SDK designed to simplify the management of Kaspa wallet assets. It provides seamless integration with Kaspa nodes, KRC20 tokens, and essential wallet functionalities, enabling developers to build robust Kaspa-based applications effortlessly.. | ||
| **Kasplex Wallet SDK - Kasplex in Wallet Integration (Kiwi) is a powerful and easy-to-use SDK designed to simplify the management of Kaspa wallet assets. It provides seamless integration with Kaspa nodes, KRC20 tokens, and essential wallet functionalities, enabling developers to build robust Kaspa-based applications effortlessly. | ||
@@ -10,3 +10,3 @@ ## Features | ||
| - **KRC20 Protocol Implementation & API Integration**: Easily interact with **KRC20 tokens** using built-in API functions. | ||
| - **Kaspa API & Node Connectivity**: Connect to Kaspa nodes for real-time blockchain data and transaction processing. | ||
| - **Kaspa API & Node Connectivity**: Connect to Kaspa nodes for real-time blockchain data and transaction process. | ||
| - **Multi-Signature Wallet Support**: Implement enhanced security with multi-signature wallet functionality. | ||
@@ -16,3 +16,3 @@ - **Message Subscription**: Subscribe to blockchain events, transaction updates, and real-time notifications. | ||
| ## Installation | ||
| Node.js Version Requirement: This SDK requires Node.js version 20.13.1 or higher. You can check your Node.js version by running: | ||
| Node.js Version Requirement: This SDK requires Node.js version 20.13.1 or higher. You can check the version of Node.js while it is running. | ||
@@ -25,11 +25,7 @@ ## Getting Started | ||
| ```sh | ||
| npm install @kasplex/kiwi-web | ||
| npm install @kasplex/kiwi | ||
| ``` | ||
| 2. **Set up networkType and init rpc client for use**: | ||
| ```typescript | ||
| import { Kiwi, Rpc, Wasm, initialize } from '@kasplex/kiwi-web' | ||
| await initialize("path to kaspa_bg.wasm"); // you can find kaspa_bg.wasm in @kasplex-web/dist | ||
| await Kiwi.setNetwork(Wasm.NetworkType.Mainnet) // NetworkType.Testnet for test net | ||
| import { Kiwi, Rpc, Wasm } from "@kasplex/kiwi"; | ||
| await Rpc.setInstance(Wasm.NetworkType.Mainnet).connect(); // connect kaspa node for fetch information from the node if needed | ||
@@ -40,3 +36,3 @@ ``` | ||
| ```typescript | ||
| import { Mnemonic, Wallet } from "@kasplex/kiwi-web"; | ||
| import { Mnemonic, Wallet } from "@kasplex/kiwi"; | ||
| const mnemonic = Mnemonic.random(12); | ||
@@ -47,5 +43,5 @@ console.log("Generated Mnemonic:", mnemonic); | ||
| 4. **send kas**: | ||
| 4. **send $KAS**: | ||
| ```typescript | ||
| import { Kaspa } from "@kasplex/kiwi-web"; | ||
| import { Kaspa } from "@kasplex/kiwi"; | ||
| const resp = await Kaspa.transferKas(privateKey, toAddress, 130000000n, 10000n) | ||
@@ -56,3 +52,3 @@ ``` | ||
| ```typescript | ||
| import { Kaspa, Enum, Utils, KRC20 } from "@kasplex/kiwi-web"; | ||
| import { Kaspa, Enum, Utils, KRC20 } from "@kasplex/kiwi"; | ||
| const krc20data = Utils.createKrc20Data({ | ||
@@ -68,5 +64,8 @@ p: "krc-20", | ||
| ## More Examples | ||
| - For more detailed usage examples, check out our [Examples Directory](./example/) | ||
| - For usage of node, check out our [Kiwi for NODE](./README.md) | ||
| - For more detailed usage examples, check out our [Examples Directory](./examples/) | ||
| - For web usage, check out our [Kiwi for WEB](./README-WEB.md) | ||
| ## Integrated wallet method | ||
| - Please refer to the details for the method of providing a wallet in the [WalletExt](./README-WalletExt.md) | ||
| ## Contribution | ||
@@ -73,0 +72,0 @@ |
Sorry, the diff of this file is too big to display
12774273
0.27%42
16.67%35641
2.03%73
-1.35%