Klaytn Account Migration

This document is a reference for those who want to migrate their BApps from their individual ENs to KAS. It will mainly deal with the differences between using EN and KAS.

Steps for Migration

  1. Sign up on KAS, generate authentication key: Before you can use KAS, you have to sign up and generate an API authentication key. For more information, please refer to this link: Sign Up, Auth, Permission, SDK

    Note) Using this authentication key directly in the frontend code can be very risky in terms of security. Use it on a backend server with limited access.

  2. Add the authentication key to the existing codes: All APIs on KAS can be called via HTTP. And these calls must contain authentication data in the headers. Once that call is made, it will look something like this with caver.js:

    const accessKeyId = "{{your_accessKeyId}}";
    const secretAccessKey = "{{your_secretAccessKey}}";
    
    const option = {
        headers: [
          {name: 'Authorization', value: 'Basic ' +  Buffer.from(accessKeyId + ':' + secretAccessKey).toString('base64')},
          {name: 'x-chain-id', value: '8217'},
        ]
    }
    const caver = new Caver(new Caver.providers.HttpProvider("https://node-api.klaytnapi.com/v1/klaytn", option))
  3. Migrate the old key: If you have been using EN as a keystore instead of an individual wallet, you may also have to migrate your old key. In order to use your old key on KAS, you need a separate Wallet API, which also contains the API for migrating old keys. Please contact support@klaytnapi.com.

  4. Additional modifications: There are certain JSON RPC APIs supported by an average EN but not on KAS. If you are using any of these APIs, you may have to make certain modifications to the API. You can find out whether your JSON RPC API is supported or not in this link: JSON-RPC API

For any other issues or inquiries, you can visit our KAS Forum, or contact us by email at support@klaytnapi.com.

Migrating with KAS SDK

To migrate your Klaytn accounts to KAS, you can either use KAS SDK or write your own migration code.

The below example demonstrates how you can use KAS SDK.

Migrating with REST API

Creating a Public Key

In order to migrate your Klaytn accounts to KAS, you need to update the accounts using the public key managed by KAS. To generate a public key to be managed by KAS, use Create Key API. You can create up to 100 public keys at a time. Pass the desired number of keys as size parameter.

API Request

API Response

The response for Create Key API is shown below:

Creating Account Update Transaction

You have to create an account update transaction with the key from your old account.

If you wish to use multisig account, first complete the procedures for migration and then make the changes using Wallet API's Multisig Account Update API.

API Request

Account Migration

You can run the account migration process based on the account update transaction results from the previous section. For a quick reminder before calling the API:

API Request

API Response

For more details regarding this API, please refer to here. For any inquiries regarding this document or KAS in general, please visit KAS Developers Forum.

Last updated

Was this helpful?