1.3.4 • Published 6 months ago

@linenext/dapp-portal-sdk v1.3.4

Weekly downloads
-
License
UNLICENSED
Repository
-
Last release
6 months ago

Dapp Portal SDK

Quick start

Create a Project

Prepare the provided clientId. The SDK operates only on pre-approved host addresses.

Install the SDK

Add the Dapp Portal SDK to your project by entering the following command:

npm install @linenext/dapp-portal-sdk

or

yarn add @linenext/dapp-portal-sdk

Sign a Transaction

Initialize the SDK with the clientId confirmed during the project creation step, and obtain a WalletProvider.

import DappPortalSDK from '@linenext/dapp-portal-sdk'

const sdk = await DappPortalSDK.init({ clientId: '<CLIENT_ID>' });
const provider = sdk.getWalletProvider()

If you wish to use the testnet, initialize the SDK like this:

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

Send a kaia_requestAccounts request to the wallet to check the address of the connected wallet. During this process, the user will see a screen to select the wallet type and confirm the connection.

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

Create a transaction that requires the user's signature. The address used in the from field should match the wallet address obtained in the previous step.

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

Send a kaia_sendTransaction request to the wallet. During this process, a popup will open for the user to verify the transaction to be signed. If successful, it returns the Tx hash.

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

Connect and Sign a Message

You can use the kaia_connectAndSign method to connect to a wallet and sign a message in a single step. This method simplifies the process by combining wallet connection and message signing.

const [address, signature] = await provider.request({method: 'kaia_connectAndSign', params: [someMessage]});

Compatible Libraries

1.3.4

6 months ago

1.3.3

6 months ago

1.3.2

6 months ago

1.3.1

6 months ago

1.3.0

6 months ago

1.2.14

6 months ago

1.2.13

6 months ago

1.2.12

7 months ago

1.2.11

8 months ago

1.2.10

8 months ago

1.2.9

9 months ago

1.2.8

9 months ago

1.2.7

9 months ago

1.2.6

10 months ago

1.2.5

10 months ago

1.2.4

10 months ago

1.2.3

10 months ago

1.2.2

10 months ago

1.2.1

10 months ago

1.2.0

10 months ago

1.1.0

11 months ago

0.9.1

12 months ago