Quick Start

Install Kaikas

To develop using Kaikas, you’re first going to want to get Kaikas installed on your development machine.

  • You can download Kaikas for Chrome here

Once you have it running, you should find that new browser tabs have window.klaytn object available in the console. Via klaytn object, you can interact with Kaikas.

Basic Interactions

Caver Browser Detection

The first thing your app will want to do is to verify whether the user is using Kaikas or not, which can be done by following typeof window.klaytn !== 'undefined'

Running a Test Network

In the top left menu, you can select the network that you are currently connected to. By choosing Baobab Testnet you can connect to Klaytn's test network.

You can use test network for free. You get free test KLAY from Baobab Klaytn Wallet, by clicking on the KLAY Faucet menu.

Detecting Kaikas

If you want to differentiate Kaikas from other Klaytn-compatible browsers, you can use klaytn.isKaikas.

Connecting to Kaikas

"Connecting" or "logging in" to Kaikas means you can get access to user's Klaytn accounts. You should only initiate a connection request in response to direct user action, such as clicking a button. You should never initiate a connection request on page load.

We recommend that you provide a button to allow the user to connect Kaikas to your BApp. Clicking this button should call the following method.

klaytn.enable() //or window.klaytn.enable()

This will trigger the following pop-up. If the user hits the connect button, the method will resolve.

This promise-returning function resolves with an array of hex-prefixed Klaytn addresses, which can be used as general account references when sending transactions.

Over time, this method is intended to grow to include various additional parameters to help your site request all the setup it needs from the user during setup.

Since it returns a promise, if you’re in an async function, you may log in like this:

const accounts = await klaytn.enable()
const account = accounts[0] // We currently only ever provide a single account,
// but the array gives us some room to grow.

Getting User State

Users can choose which network to connect. klaytn.networkVersion tells you which network the user is currently connected to, (main network: 8217, test network: 1001) and klaytn.selectedAddress gives you the account address the user is logged in.

Accessing Accounts

Once the user has connected to Kaikas, you can access the user's account via klaytn.selectedAddress. Also, if you’d like to be notified when the address changes, you can subscribe via

klaytn.on('accountsChanged', function(accounts) {
  // Your code
})

Now you are ready to make transactions.

Last updated