For the complete documentation index, see llms.txt. This page is also available as Markdown.

Kastle Wallet API

Integrate your dApp with Kastle Wallet.

Each API method is available in two styles:

  • Direct method: kastle.methodName(...)

  • KIP-style generic request: kastle.request('kas:method_name', args)


1. Detect Kastle

if (window.kastle) {
  console.log("Kastle Wallet detected!");
} else {
  alert("Please install Kastle Wallet.");
}

2. Connect

Opens the permission popup and requests wallet access.

const isSuccess = await kastle.connect();
console.log("Connected:", isSuccess); // true

3. Get Version

Available since: Extension 2.48.0 Β· Mobile 1.19.0

Returns the current wallet version in SemVer format. The build metadata suffix identifies the platform:

Suffix
Platform

+extension

Browser extension

+mobile

Mobile app


4. Get Account


5. Get Network

Returns the currently active network ID.


6. Switch Network

Prompts the user to switch to a different network.


7. Get Balance

Available since: Extension 2.47.0 Β· Mobile 1.19.0

Returns the current account balance in sompi.


8. Get UTXO Entries

Available since: Extension 2.47.0 Β· Mobile 1.19.0

Returns all UTXOs for the current account.


9. Send KAS

Builds, signs, and broadcasts a KAS transfer in one call. No RPC or WASM needed.

Parameters

Parameter
Type
Required
Description

toAddress

string

βœ…

Recipient Kaspa address

sompi

number

βœ…

Amount in sompi (minimum 0.2 KAS = 20,000,000 sompi)

options.priorityFee

number

❌

Priority fee in sompi (default: 0)

options.payload

string

❌

Transaction payload as a hex string (even length, 0-9 a-f only). Returns an error if the format is invalid.


10. Build Transaction

Available since: Extension 2.47.0 Β· Mobile 1.19.0

Builds one or more transactions from the current account's UTXOs. Returns serialized txJson ready for signing. No RPC or WASM needed.

amount and priorityFee are strings (sompi) to avoid JS BigInt precision loss. May return multiple transactions when UTXO compounding is needed.

Parameters

Parameter
Type
Required
Description

outputs

{ address: string; amount: string }[]

βœ…

Recipient addresses and amounts (in sompi)

options.priorityFee

string

❌

Priority fee in sompi (default: "0")

options.payload

string

❌

Transaction payload as a hex string (even length, 0-9 a-f only). Returns an error if the format is invalid.

options.inputs

IUtxoEntry[]

❌

to use as inputs. If omitted, all UTXOs of the current account are used automatically.

IUtxoEntry schema


11. Sign & Broadcast Transaction

Signs a transaction and broadcasts it to the network. Opens a confirmation popup.

To build txJson manually using Kaspa WASM and an RPC client, see docs/index.js.


12. Sign Transaction

Signs a transaction without broadcasting it. Returns the signed transaction as a JSON string. Useful for marketplace flows (e.g. SingleAnyOneCanPay).

With a custom script (e.g. for P2SH spend):


13. Sign Message

Signs an arbitrary message string.


14. KRC-20: Transfer Token

KRC-20 operations use a commit-reveal pattern. Kastle handles both steps β€” no WASM needed.


15. Compound UTXOs

Available since: Extension 2.52.0 Β· Mobile 1.20.0

Consolidates all UTXOs in the current account into a single UTXO by sending the full balance back to the sender's own address. Opens a confirmation popup.

Useful for reducing future transaction fees caused by having many small UTXOs.

Parameter
Type
Required
Description

options.priorityFee

string

❌

Priority fee in sompi (default: "0")

16. Events

Listen to wallet state changes. Events are emitted in both KasWare-compatible and KIP-style formats simultaneously.


API Reference

Direct Method

KIP-style (kastle.request)

Returns

kastle.connect()

kas:connect

boolean

kastle.getVersion()

kas:get_version

string (e.g. 2.47.0+extension, 1.19.0+mobile)

kastle.getAccount()

kas:get_account

{ address, publicKey }

kastle.getNetwork()

kas:get_network

string

kastle.switchNetwork(networkId)

kas:switch_network

string

kastle.getBalance()

kas:get_balance

{ balance: string }

kastle.getUtxoEntries()

kas:get_utxo_entries

{ entries[] }

kastle.sendKaspa(toAddress, sompi, opts?)

kas:send_sompi

string (txId)

kastle.buildTransaction(outputs, opts?)

kas:build_transaction

{ networkId, transactions[] }

kastle.signAndBroadcastTx(networkId, txJson, scripts?)

kas:sign_and_broadcast_tx

string (txId)

kastle.signTx(networkId, txJson, scripts?)

kas:sign_tx

string (signed txJson)

kastle.signMessage(message)

kas:sign_message

string (signature)

kastle.commitReveal(networkId, namespace, data, opts?)

kas:commit_reveal

{ commitTxId, revealTxId }

kastle.compoundUtxos(opts?)

kas:compound_utxos

string (txId)


Full Working Example

See the interactive demo for a complete, runnable reference:

Last updated