# Inspect SDK

### Installation

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

Then run:

```javascript
npm install @oneid-xyz/inspect
```

```javascript
yarn add @oneid-xyz/inspect
```

### Getting Started

**Quick Start:**

```javascript
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

<pre class="language-javascript"><code class="lang-javascript"><strong>import { OneID } from './oneid';
</strong>
const oneId = new OneID({
  rpcUrl: string,
  //or
  provider: provider,
 
})
</code></pre>

**Parameters**:

Just input one of 2 options below.

* `provider`: when using **WebsocketProvider** or **CustomHttpsProvider**
  * <https://web3js.readthedocs.io/>
* `rpcUrl`: when using **httpProvider** or other rpc
  * HTTP Web3 Provider

### Functions

#### Init Configuration

`initConfig()` allows to init base configuration from OneID SDK

*Interface:*

```javascript
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**:*

```javascript
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](https://docs.oneid.xyz/developer-guide/oneid-sdk/inspect-sdk#supported-chains-in-linked-wallet) to get mapping of `chainID`&#x20;

*Example:*

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

***Returns**:*

```javascript
[
  { 
    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**:*

```javascript
getPrimaryName(walletAddress: string): Promise<string>
```

**Parameters**

* `walletAddress`&#x20;

*Example:*

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

***Returns**:*

```json
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

\
\&#xNAN;***Interface**:*

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

**Parameters**

* `walletAddress`&#x20;

*Example:*

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

***Returns**:*

```json
[
  {
    "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.<br>

***Interface**:*

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

**Parameters**

* `ids`&#x20;

*Example:*

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

***Returns**:*

```javascript
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**:*

```javascript
getNode(id: string): string
```

**Parameters**

* `id`&#x20;

*Example:*

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

***Returns**:*

```javascript
node: '0xzxc...'
```

### Supported Chains in Linked Wallet

| ChainType                    | ChainID       | ChainKey       |
| ---------------------------- | ------------- | -------------- |
| CHAIN\_TYPE.PLATON           | 210425        | platon         |
| CHAIN\_TYPE.MOONBEAM         | 1284          | moonbeam       |
| CHAIN\_TYPE.APTOSLABS        | aptoslabs     | aptoslabs      |
| CHAIN\_TYPE.INJECTIVE        | injective-1   | injective      |
| CHAIN\_TYPE.OSMOSIS          | osmosis-1     | osmosis        |
| CHAIN\_TYPE.EVMOS            | evmos\_9001-2 | evmos          |
| CHAIN\_TYPE.JUNO             | juno-1        | juno           |
| CHAIN\_TYPE.AGORIC           | agoric-3      | agoric         |
| CHAIN\_TYPE.OASIS            | 42262         | oasis          |
| CHAIN\_TYPE.KUJIRA           | kaiyo-1       | kujira         |
| CHAIN\_TYPE.STARGAZE         | stargaze-1    | stargaze       |
| CHAIN\_TYPE.UMEE             | umee-1        | umee           |
| CHAIN\_TYPE.STRIDE           | stride-1      | stride         |
| CHAIN\_TYPE.APTOS            | ait-3         | aptos          |
| CHAIN\_TYPE.SUI\_MAINNET     | sui           | suiMainnet     |
| CHAIN\_TYPE.SEI\_MAINNET     | pacific-1     | seiMainnet     |
| CHAIN\_TYPE.ARCHWAY          | constantine-1 | archway        |
| CHAIN\_TYPE.TOMO             | 88            | tomo           |
| CHAIN\_TYPE.ARCHWAY\_MAINNET | archway-1     | archwayMainnet |
| CHAIN\_TYPE.CHILIZ           | 88880         | chiliz         |
| CHAIN\_TYPE.NAUTILUS         | 22222         | nautilus       |
| CHAIN\_TYPE.MANTLE           | 5000          | mantle         |
| CHAIN\_TYPE.SCROLL           | 534352        | scroll         |
| CHAIN\_TYPE.BITCOIN          | bitcoin       | bitcoin        |
| CHAIN\_TYPE.ETHER            | 1             | ether          |
| CHAIN\_TYPE.ETHERPOW         | 10001         | etherPow       |
| CHAIN\_TYPE.BINANCE\_SMART   | 56            | binanceSmart   |
| CHAIN\_TYPE.HECO             | 128           | heco           |
| CHAIN\_TYPE.OKEX             | 66            | okex           |
| CHAIN\_TYPE.TERRA\_2         | phoenix-1     | terra2         |
| CHAIN\_TYPE.GATE             | 86            | gate           |
| CHAIN\_TYPE.KUCOIN           | 321           | kucoin         |
| CHAIN\_TYPE.SOLANA           | solana        | solana         |
| CHAIN\_TYPE.NEAR             | near          | near           |
| CHAIN\_TYPE.AVAX             | 43114         | avax           |
| CHAIN\_TYPE.AVAX\_X          | avaxX         | avaxX          |
| CHAIN\_TYPE.TRON             | tron          | tron           |
| CHAIN\_TYPE.POLYGON          | 137           | matic          |
| CHAIN\_TYPE.FANTOM           | 250           | fantom         |
| CHAIN\_TYPE.XDAI             | 100           | xdai           |
| CHAIN\_TYPE.POLKADOT         | polkadot      | polkadot       |
| CHAIN\_TYPE.KUSAMA           | kusama        | kusama         |
| CHAIN\_TYPE.COSMOS           | cosmoshub-4   | cosmos         |
| CHAIN\_TYPE.THOR             | thor          | thor           |
| CHAIN\_TYPE.AURA             | aura          | aura           |
| CHAIN\_TYPE.BAND             | columbus-5    | terra          |
| CHAIN\_TYPE.BAND             | band          | band           |
| CHAIN\_TYPE.KAVA             | kava          | kava           |
| CHAIN\_TYPE.SECRET\_NETWORK  | secret-4      | secretNetwork  |
| CHAIN\_TYPE.PERSISTENCE      | core-1        | persistence    |
| CHAIN\_TYPE.BINANCE          | binance       | binance        |
| CHAIN\_TYPE.FUNCTION\_X      | fxcore        | functionX      |
| CHAIN\_TYPE.ELROND           | elrond        | elrond         |
| CHAIN\_TYPE.TEZOS            | tezos         | tezos          |
| CHAIN\_TYPE.CELO             | 42220         | celo           |
| CHAIN\_TYPE.ALGORAND         | algorand      | algorand       |
| CHAIN\_TYPE.CASPER           | casper        | casper         |
| CHAIN\_TYPE.KARDIA           | 24            | kardia         |
| CHAIN\_TYPE.RONIN            | 2020          | ronin          |
| CHAIN\_TYPE.KLAYTN           | 8217          | klaytn         |
| CHAIN\_TYPE.HARMONY          | 1666600000    | harmony        |
| CHAIN\_TYPE.CONFLUX          | conflux       | conflux        |
| CHAIN\_TYPE.OPTIMISM         | 10            | optimism       |
| CHAIN\_TYPE.BOBA             | 288           | boba           |
| CHAIN\_TYPE.ZKSYNC\_POLYGON  | 1101          | zksyncPolygon  |
| CHAIN\_TYPE.ZKSYNC\_ERA      | 324           | zksyncEra      |
| CHAIN\_TYPE.ARBITRUM         | 42161         | arbitrum       |
| CHAIN\_TYPE.ARBITRUM\_XDAI   | 200           | arbitrumXdai   |
| CHAIN\_TYPE.AURORA           | 1313161554    | aurora         |
| CHAIN\_TYPE.TON              | ton           | ton            |
| CHAIN\_TYPE.CRONOS           | 25            | cronos         |
| CHAIN\_TYPE.BITTORRENT       | 199           | bittorrent     |
| CHAIN\_TYPE.THETA            | theta         | theta          |
| CHAIN\_TYPE.THETAFUEL        | 361           | thetafuel      |
