Wallet Provider
Initiate SDK
1. Initialize SDK via clientId and Get WalletProvider
Initialize SDK as below code if you want to connect testnet. (Default of chainId is '8217', mainnet)
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.
2. Create message to get sign from user
3. Request a message signature to verify the ownership of the Address.
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.
4. 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.
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)
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.
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.
Error
-32001
User canceled request - Closed popup - Clicked cancel button from wallet
-32005
User logged out due to incorrect password input
c. Event
WalletProvider supports EventEmitter interface as EIP-1193.
d. disconnectWallet
Disconnect connected wallet.
Provide option to choose and connect walletType
Compatible Libraries
Last updated