LogoLogo
  • LINE's Mini Dapp & Dapp Portal
    • Join Us
    • How to build successful Mini Dapp
  • Mini Dapp
    • Overview
      • Sample Mini Dapp
    • LINE Integration
      • LINE Developers
      • LINE Front-end Framework (LIFF)
        • Essential Settings
      • Official Account
      • Invite Friends
    • Mini Dapp SDK
      • How to Get SDK Authorization
      • Wallet Provider
      • Payment Provider
        • Settlement
        • Policy
          • Payment
          • Refund
          • Cancellation
        • Flow
      • Release Note
        • v1.2.12
        • v1.2.11
        • v1.2.10
        • v1.2.9
        • v1.2.8
        • v1.2.6
        • v1.2.5
        • v1.2.4
        • v1.2.3
        • v1.2.2
        • v1.2.1
        • v1.2.0
    • Integration Guide for Game Engine
      • for Unity
      • for Cocos Creator
    • Design Guide
  • Dapp Portal
    • Mini Dapp Information
    • Collection & Drops
      • Collection Information
      • Upload NFT Information
      • Drops Information
      • Fungible Token Information
      • How to mint NFT
    • Reward
      • Reward System Flow
      • Launching Promotion
  • Extra Packages
    • Gas Fee Delegation
    • Growth Competition
      • Playbook for Teams
      • Historical Data
  • Review Guidelines
  • Update Note
  • Contact Us
Powered by GitBook
On this page
  • Initiate SDK
  • Connect Wallet
  • Send Transaction
  • class WalletProvider
  • Compatible Libraries
  1. Mini Dapp
  2. Mini Dapp SDK

Wallet Provider

Initiate SDK

1. Initialize SDK via clientId and Get WalletProvider

import DappPortalSDK from '@linenext/dapp-portal-sdk'
 
const sdk = await DappPortalSDK.init({ clientId: '<CLIENT_ID>' });
const provider = sdk.getWalletProvider()

Initialize SDK as below code if you want to connect testnet. (Default of chainId is '8217', mainnet)

const sdk = await DappPortalSDK.init({
  clientId: '<CLIENT_ID>',
  chainId: '1001',
});

Connect Wallet

1. Initiate SDK

2. Verify the address of the connected wallet via sending kaia_requestAccounts request to the wallet. In this process, Users can see a screen to select the type of wallet and check whether wallet is connected.

const accounts = await provider.request({ method: 'kaia_requestAccounts' });
const accountAddress = accounts[0]

2. Create message to get sign from user

const message = 'Welcome to Mini Dapp';

3. Request a message signature to verify the ownership of the Address.

const signature = await provider.request({method: 'personal_sign', params: [message, accountAddress]});

4. You can also use the kaia_connectAndSign method to execute from Wallet Connect to Signature in a single call.

const message = 'Welcome to Mini Dapp';
const [account, signature] = (await walletProvider.request({
    method: "kaia_connectAndSign",
    params: [message],
})) as string[];

5. You can get the connected wallet using the kaia_accounts method. when requesting kaia_accounts with no connected wallet, the Client can get response with [] without showing the wallet connection screen.

const accounts = await provider.request({ method: 'kaia_accounts' });
const accountAddress = accounts[0]

Send Transaction

1. Initiate SDK

2. It creates a transaction that requires the user’s signature. At this time, the address in from must be matched with address in the wallet connected in the previous step.

const tx = {
  from: accountAddress,
  to: '0xBBBBBBBBBBBB',
  value: '0x10',
  gas: '0x5208',
};

3. Request kaia_sendTransaction to connected Wallet. Pop up will be opened for verifying transaction to sign in this step. If success, Transaction hash will be returned.

const txHash = await provider.request({method: 'kaia_sendTransaction', params: [tx]});

class WalletProvider

WalletProvider provides compatible interface with EIP-1193 which can easily link Dapp Portal Wallet and various Kaia Wallets.

The list of wallets which can be integrated via WalletProvider is below if users use web browser.

  • Dapp Portal Wallet (Web)

  • Kaia Wallet (Mobile App)

  • Kaia Wallet (Chrome Extenstion) ; if Kaia Wallet extension is installed on browser.

WalletProvider choose Dapp Portal Wallet (LIFF) automatically if user uses LINE Messenger.

a. getWalletType(): WalletType | null

It returns wallet type which is connected.

  • null : Status before wallet is connected.

  • WalletType.Web : Status wallet is connected (https://wallet.dappportal.io)

  • WalletType.Liff : Status opened from LINE Messenger (Android/iOS)

  • WalletType.Extension : Status opened from chrome extension

  • WalletType.Mobile : Status opened from Kaia Wallet mobile App

  • WalletType.OKX : Status opened from OKX Wallet

b. async request(requestArgs: RequestArguments): Promise

It sends request to connected wallet. This function provides JSON-RPC API format on request. You can send request to retrieve healthy status of chain and sign transaction with wallet. If you send it before wallet connection, user will see a screen to select wallet type to connect.

The requests and responses available in this function are shown in the following table.

(W : wallet connection required / U : wallet unlocked required)

Codition
RPC method

kaia_accounts

klay_accounts

eth_accounts

W

kaia_requestAccounts

W

klay_requestAccounts

W

eth_requestAccounts

W/U

W/U

W/U

W/U

kaia_sendTransaction

W/U

klay_sendTransaction

W/U

eth_sendTransaction

W/U

kaia_signTransaction

W/U

klay_signTransaction

We recommend to use personal_sign to get compatibility with various wallets including OKX Wallet.

Error

{code: -32001, message: 'User canceled'}
Code
Description

-32001

User canceled request - Closed popup - Clicked cancel button from wallet

-32005

User logged out due to incorrect password input

c. async disconnectWallet(): Promise

  • Disconnect connected wallet

  • Provide option to choose and connect walletType

await walletProvider.disconnectWallet()
window.location.reload();

d. Event

  • WalletProvider supports EventEmitter interface as EIP-1193.

Compatible Libraries

PreviousHow to Get SDK AuthorizationNextPayment Provider

Last updated 4 days ago

kaia_signLegacy ()

personal_sign ()

kaia_connectAndSign (sign follows )

RPC methods that are not included in the table will be requested directly to the chain node and please refer to Kaia docs' .

RPC API Reference
https://docs.kaia.io/ko/references/sdk/ethers-ext/getting-started/
https://docs.kaia.io/ko/references/sdk/web3js-ext/getting-started/
https://docs.kaia.io/ko/references/sdk/caver-js/
KIP-97
EIP-191
EIP-191