Inspect SDK

Installation

We recommend switching to Node.js Version 16 to make sure common crypto dependencies works.

Then run:

npm install @oneid-xyz/inspect
yarn add @oneid-xyz/inspect

Getting Started

Quick Start:

import { OneID } from '@oneid-xyz/inspect';

const oneid = new OneID()
await oneid.systemConfig.initConfig()

oneid.getWalletsByID('oneidtest.c98')

By default, this will apply our public RPC. In case you need to use another RPC, please apply format below

import { OneID } from './oneid';

const oneId = new OneID({
  rpcUrl: string,
  //or
  provider: provider,
 
})

Parameters:

Just input one of 2 options below.

  • provider: when using WebsocketProvider or CustomHttpsProvider

  • rpcUrl: when using httpProvider or other rpc

    • HTTP Web3 Provider

Functions

Init Configuration

initConfig() allows to init base configuration from OneID SDK

Interface:

await oneid.systemConfig.initConfig()

Note:

  • Inspect & Core SDK are using same system config, developer shall only need to init once.

Get Wallet by ID Name

getWalletsByID will return the Linked Wallet of an ID Name.

Linked Wallet is the wallet address that user actually interacts with when Dapps/Wallets integrated our ONEID SDK

  • For example, when you transfer assets to ID Name test.c98 on C98 Wallet, the assets are transferred to the Linked Wallet address.

Interface:

getWalletsByID(id: string, chainId?: CHAIN_TYPE): Promise<LinkedWallet[]>

Parameters:

  • chainId is optional

    • If null, OneID will return 100+ chains & its address.

    • If developers have included chainId, then OneID will return address of that chain.

  • chainId has been defined in SDK to be managed easier. In case, the chain does not have public chainID, CHAIN_TYPE will support to get the chain's address

  • Refer the Supported Chains in Linked Wallet to get mapping of chainID

Example:

const wallets = await oneid.getWalletsByID(“test.c98”, CHAIN_TYPE.BINANCE_SMART) // BSC

Returns:

[
  { 
    chain: "binanceSmart", 
    address: "0x123..." 
  }
]

Get Primary Name

getPrimaryName will return the Primary Name of the wallet address.

Primary Name is using as main interacting with DAPPs when the wallet address has multiple ID names. For example, in the OneID website, user shall be able to see their Primary Name on the top right corner.

Note: OneID Primary Name offers multi-chains, hence Developer can use address of any chain to get Primary Name even if it's Solana, Cosmos or EVM

Interface:

getPrimaryName(walletAddress: string): Promise<string>

Parameters

  • walletAddress

Example:

const id = await oneid.getPrimaryName('0x123...') 

Returns:

id: "test.c98"

Get Linked ID Names

getLinkedIDs will return all the ID Names that linked to the wallets.

Note: this function support EVM address only

Interface:

getLinkedIDs(walletAddress: string): Promise<LinkedID[]>

Parameters

  • walletAddress

Example:

const ids = await oneid.getLinkedIDs('0x123...') 

Returns:

[
  {
    "walletName": "",
    "isPrimary": false,
    "node": "0xzxc...",
    "code": "123...",
    "linked": [
        {
            "chain": "bitcoin",
            "address": "bc...",
        },
        ...
    ],
    "registar": "0xzxc...",
    "expires": 1725437071,
    "id": "123...",
    "name": "test.c98"
  },
  ...
]

Get Controller Permission

getPermission will return the address that has permission to edit Records of ID Name.

Interface:

getPermission(ids: string[]): Promise<ResponseExecuteTransaction<string[]>>

Parameters

  • ids

Example:

const owners = await oneid.getPermission(['test.c98']) 

Returns:

owners: ['0x123...', ...]

Get Node

getNode() will validate and generate node of an ID Name, then this node shall be used to interact with contract.

Interface:

getNode(id: string): string

Parameters

  • id

Example:

const node = await oneid.getNode(['test.c98']) 

Returns:

node: '0xzxc...'

Supported Chains in Linked Wallet

Last updated