1.3.4 • Published 9 months ago

@linenext/dapp-portal-sdk v1.3.4

Weekly downloads
-
License
UNLICENSED
Repository
-
Last release
9 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

9 months ago

1.3.3

9 months ago

1.3.2

9 months ago

1.3.1

9 months ago

1.3.0

9 months ago

1.2.14

9 months ago

1.2.13

9 months ago

1.2.12

10 months ago

1.2.11

11 months ago

1.2.10

11 months ago

1.2.9

12 months ago

1.2.8

1 year ago

1.2.7

1 year ago

1.2.6

1 year ago

1.2.5

1 year ago

1.2.4

1 year ago

1.2.3

1 year ago

1.2.2

1 year ago

1.2.1

1 year ago

1.2.0

1 year ago

1.1.0

1 year ago

0.9.1

1 year ago