Dev integration
Welcome to KasWare's integration documentation. This documentation is for learning to integrate KasWare wallet with your applications. Please note : The integration API may be modified if relevant standards are officially released by kaspa core team one day in the future.
Getting Started
First of all, install KasWare Wallet on your development machine. Once KasWare Wallet is installed and running, you should find that new browser tabs have a window.kasware object available in the developer console. This is how your website will interact with KasWare Wallet.
Browser Detection
To verify if the browser is running KasWare Wallet, copy and paste the code snippet below in the developer console of your web browser:
You can review the full API for the window.kasware object here.
Connecting to KasWare Wallet
"Connecting" or "logging in" to KasWare Wallet effectively means "to access the user's Kaspa account(s)".
You should only initiate a connection request in response to direct user action, such as clicking a button. You should always disable the "connect" button while the connection request is pending. You should never initiate a connection request on page load.
We recommend that you provide a button to allow the user to connect KasWare Wallet to your dapp. Clicking this button should call the following method:
Demo
Methods
requestAccounts
Connect the current account.
Parameters
none
Returns
Promise returns string[] : Address of current account.
Example
getAccounts
Get address of current account
Parameters
none
Returns
Promise - string: address of current account
Example
getVersion
get wallet version
Parameters
none
Returns
Promise - string: wallet version
Example
getNetwork
get network
Parameters
none
Returns
Promise - string: the network. livenet and testnet
Example
switchNetwork
switch network
Parameters
network - string: the network. mainnet/testnet/devnet
Returns
none
Example
disconnect
disconnect kasware wallet
Parameters
origin - string: website origin url
Returns
none
Example
getPublicKey
Get publicKey of current account.
Parameters
none
Returns
Promise - string: publicKey
Example
getBalance
Get KAS balance
Parameters
none
Returns
Promise - Object:
confirmed - number : the confirmed sompi
unconfirmed - number : the unconfirmed sompi
total - number : the total sompi
Example
getKRC20Balance
Get KRC20 token balance
Parameters
none
Returns
Promise - Array of Object:
balance: string;
dec: string;
locked: string;
opScoreMod: string;
tick: string;
Example
sendKaspa
Send KAS
Parameters
toAddress - string: the address to send
sompi - number: the sompi to send
options - object: (optional)
priorityFee - number: the network prioity fee. default is 0. Unit is sompi
Returns
Promise - string: txid
Example
signMessage
sign message
Parameters
msg - string: a string to sign
type - string: (Optional) "ecdsa" | "bip322-simple". default is "ecdsa"
Returns
Promise - string: the signature.
Example
signKRC20Transaction
Sign KRC20 Transaction
Parameters
inscribeJsonString - string: stringified json object
type - number: 2 for deployment, 3 for mint, 4 for transfer
destAddr - string:(optional) the address to transfer. it's an optional parameter. only used for transfer
priorityFee - number:(optional) the network prioity fee. default is 0. Unit is kas.
Returns
Promise - string: txid
Example-1: deploy a KRC20 token
Example-2: mint a KRC20 token
Example-3: transfer a KRC20 token
Events
accountsChanged
The accountsChanged will be emitted whenever the user's exposed account address changes.
networkChanged
The networkChanged will be emitted whenever the user's network changes.
balanceChanged
The balaneChanged will be emitted whenever the user's balance changes.
Example
transactionReplacementResponse
The transactionReplacementResponse will be emitted whenever the user pushes a rbf transaction.
Example
Last updated