Quickstart

This guide will get you all set up and ready to use Klever Wallet in your application. We’ll cover how to get started using vanilla JavaScript and how to make your first method call.

Verify installation

The presence of the Klever Wallet provider object, window.klever, in a user's browser indicates an Klever user. Is extremelly recommend this step for better user experience and error handling.

index.js

if (typeof window.klever !== 'undefined') {
  console.log('Klever Wallet is installed!')
}

User's account

To access user's account information is necessary to request to user and validate the access.

When acessing a user's accounts:

  • Only initiate a connection request in response to direct user action, such as selecting a connect button.
  • Always disable the connect button while the connection request is pending.

index.js

  await window.klever.initialize();
  const address = await window.klever.getWalletAddress();
  if (!address || address.length === 0) {
    throw new Error("Session not properly initialized");
  }

Secure your application

To increase security of your application and trying to verify integrity of user's wallet, you can add more one step in account validation, a message verification through a signed value.

After retrieve user's address, you can request a signed value to user and validate it.

index.js

// ...

const messageToSign = 'Validate this message to proceed.'
const signedMessage = await window.klever.signMessage(messageToSign)
const isValid = await window.klever.validateSignature(
  messageToSign,
  signedMessage,
  address,
)
if (!isValid) {
  throw new Error('Invalid signature')
}

What's next?

Great, you're now make a secure connection with Klever Wallet. Here are a few links that might be handy as you venture further into Klever Wallet:

Was this page helpful?