Skip to content

Commit

Permalink
Update keystore api doc
Browse files Browse the repository at this point in the history
Signed-off-by: Ashutosh Tripathi <[email protected]>
  • Loading branch information
ashucoder9 authored Nov 21, 2024
1 parent 6f02873 commit 3456526
Showing 1 changed file with 64 additions and 104 deletions.
168 changes: 64 additions & 104 deletions api/keystore/service.md
Original file line number Diff line number Diff line change
@@ -1,71 +1,45 @@
---
tags: [AvalancheGo APIs]
title: Keystore API
description: This page is an overview of the Keystore API associated with AvalancheGo.
sidebar_label: Keystore API
pagination_label: Keystore API
---

# Keystore API
<Callout type="warn">
Because the node operator has access to your plain-text password, you should only create a keystore user on a node that you operate. If that node is breached, you could lose all your tokens. Keystore APIs are not recommended for use on Mainnet.
</Callout>

:::warning
Because the node operator has access to your plain-text password, you should only create a
keystore user on a node that you operate. If that node is breached, you could lose all your tokens.
Keystore APIs are not recommended for use on Mainnet.
:::
Every node has a built-in keystore. Clients create users on the keystore, which act as identities to be used when interacting with blockchains. A keystore exists at the node level, so if you create a user on a node it exists _only_ on that node. However, users may be imported and exported using this API.

Every node has a built-in keystore. Clients create users on the keystore, which act as identities to
be used when interacting with blockchains. A keystore exists at the node level, so if you create a
user on a node it exists _only_ on that node. However, users may be imported and exported using this
API.
For validation and cross-chain transfer on the Mainnet, you should issue transactions through [AvalancheJS](/tooling/avalanche-js). That way control keys for your funds won't be stored on the node, which significantly lowers the risk should a computer running a node be compromised. See following docs for details:

For validation and cross-chain transfer on the Mainnet, you should issue transactions through
[AvalancheJS](/tooling/avalanchejs-overview). That way control keys for your funds won't be stored on
the node, which significantly lowers the risk should a computer running a node be compromised. See
following docs for details:

- Transfer AVAX Tokens Between Chains:

- C-Chain: [export](https://github.com/ava-labs/avalanchejs/blob/master/examples/c-chain/export.ts) and
[import](https://github.com/ava-labs/avalanchejs/blob/master/examples/c-chain/import.ts)
- P-Chain: [export](https://github.com/ava-labs/avalanchejs/blob/master/examples/p-chain/export.ts) and
[import](https://github.com/ava-labs/avalanchejs/blob/master/examples/p-chain/import.ts)
- X-Chain: [export](https://github.com/ava-labs/avalanchejs/blob/master/examples/x-chain/export.ts) and
[import](https://github.com/ava-labs/avalanchejs/blob/master/examples/x-chain/import.ts)

- [Add a Node to the Validator Set](/nodes/validate/add-a-validator)

:::info

This API set is for a specific node, it is unavailable on the [public server](/tooling/rpc-providers.md).

:::
1. Transfer AVAX Tokens Between Chains:
- C-Chain: [export](https://github.com/ava-labs/avalanchejs/blob/master/examples/c-chain/export.ts) and [import](https://github.com/ava-labs/avalanchejs/blob/master/examples/c-chain/import.ts)
- P-Chain: [export](https://github.com/ava-labs/avalanchejs/blob/master/examples/p-chain/export.ts) and [import](https://github.com/ava-labs/avalanchejs/blob/master/examples/p-chain/import.ts)
- X-Chain: [export](https://github.com/ava-labs/avalanchejs/blob/master/examples/x-chain/export.ts) and [import](https://github.com/ava-labs/avalanchejs/blob/master/examples/x-chain/import.ts)
2. [Add a Node to the Validator Set](/nodes/validate/node-validator)

<Callout title="Note">
This API set is for a specific node, it is unavailable on the [public server](/tooling/rpc-providers).
</Callout>

## Format

This API uses the `json 2.0` API format. For more information on making JSON RPC calls, see
[here](/reference/standards/guides/issuing-api-calls.md).
This API uses the `json 2.0` API format. For more information on making JSON RPC calls, see [here](/api-reference/standards/guides/issuing-api-calls).

## Endpoint

```text
```
/ext/keystore
```

## Methods

### keystore.createUser

:::caution

Deprecated as of [**v1.9.12**](https://github.com/ava-labs/avalanchego/releases/tag/v1.9.12).

:::

Create a new user with the specified username and password.

**Signature:**
**Signature**:

```sh
```
keystore.createUser(
{
username:string,
Expand All @@ -75,12 +49,11 @@ keystore.createUser(
```

- `username` and `password` can be at most 1024 characters.
- Your request will be rejected if `password` is too weak. `password` should be at least 8
characters and contain upper and lower case letters as well as numbers and symbols.
- Your request will be rejected if `password` is too weak. `password` should be at least 8 characters and contain upper and lower case letters as well as numbers and symbols.

**Example Call:**
**Example Call**:

```sh
```
curl -X POST --data '{
"jsonrpc":"2.0",
"id" :1,
Expand All @@ -92,9 +65,9 @@ curl -X POST --data '{
}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/keystore
```

**Example Response:**
**Example Response**:

```json
```
{
"jsonrpc": "2.0",
"id": 1,
Expand All @@ -104,23 +77,21 @@ curl -X POST --data '{

### keystore.deleteUser

:::caution

Deprecated as of [**v1.9.12**](https://github.com/ava-labs/avalanchego/releases/tag/v1.9.12).

:::
<Callout type="warn">
Deprecated as of [v1.9.12](https://github.com/ava-labs/avalanchego/releases/tag/v1.9.12).
</Callout>

Delete a user.

**Signature:**
**Signature**:

```sh
```
keystore.deleteUser({username: string, password:string}) -> {}
```

**Example Call:**
**Example Call**:

```sh
```
curl -X POST --data '{
"jsonrpc":"2.0",
"id" :1,
Expand All @@ -132,9 +103,9 @@ curl -X POST --data '{
}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/keystore
```

**Example Response:**
**Example Response**:

```json
```
{
"jsonrpc": "2.0",
"id": 1,
Expand All @@ -144,19 +115,15 @@ curl -X POST --data '{

### keystore.exportUser

:::caution

Deprecated as of [**v1.9.12**](https://github.com/ava-labs/avalanchego/releases/tag/v1.9.12).
<Callout type="warn">
Deprecated as of [v1.9.12](https://github.com/ava-labs/avalanchego/releases/tag/v1.9.12).
</Callout>

:::
Export a user. The user can be imported to another node with [`keystore.importUser`](/api-reference/keystore-api#keystoreimportuser). The user's password remains encrypted.

Export a user. The user can be imported to another node with
[`keystore.importUser`](/reference/avalanchego/keystore-api.md#keystoreimportuser). The user’s password
remains encrypted.
**Signature**:

**Signature:**

```sh
```
keystore.exportUser(
{
username:string,
Expand All @@ -169,12 +136,11 @@ keystore.exportUser(
}
```

`encoding` specifies the format of the string encoding user data. Can only be `hex` when a value is
provided.
`encoding` specifies the format of the string encoding user data. Can only be `hex` when a value is provided.

**Example Call:**
**Example Call**:

```sh
```
curl -X POST --data '{
"jsonrpc":"2.0",
"id" :1,
Expand All @@ -186,9 +152,9 @@ curl -X POST --data '{
}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/keystore
```

**Example Response:**
**Example Response**:

```json
```
{
"jsonrpc": "2.0",
"id": 1,
Expand All @@ -201,18 +167,15 @@ curl -X POST --data '{

### keystore.importUser

:::caution

Deprecated as of [**v1.9.12**](https://github.com/ava-labs/avalanchego/releases/tag/v1.9.12).

:::
<Callout type="warn">
Deprecated as of [v1.9.12](https://github.com/ava-labs/avalanchego/releases/tag/v1.9.12).
</Callout>

Import a user. `password` must match the user’s password. `username` doesn’t have to match the
username `user` had when it was exported.
Import a user. `password` must match the user's password. `username` doesn't have to match the username `user` had when it was exported.

**Signature:**
**Signature**:

```sh
```
keystore.importUser(
{
username:string,
Expand All @@ -223,12 +186,11 @@ keystore.importUser(
) -> {}
```

`encoding` specifies the format of the string encoding user data. Can only be `hex` when a value is
provided.
`encoding` specifies the format of the string encoding user data. Can only be `hex` when a value is provided.

**Example Call:**
**Example Call**:

```sh
```
curl -X POST --data '{
"jsonrpc":"2.0",
"id" :1,
Expand All @@ -241,9 +203,9 @@ curl -X POST --data '{
}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/keystore
```

**Example Response:**
**Example Response**:

```json
```
{
"jsonrpc": "2.0",
"id": 1,
Expand All @@ -253,33 +215,31 @@ curl -X POST --data '{

### keystore.listUsers

:::caution

Deprecated as of [**v1.9.12**](https://github.com/ava-labs/avalanchego/releases/tag/v1.9.12).

:::
<Callout type="warn">
Deprecated as of [v1.9.12](https://github.com/ava-labs/avalanchego/releases/tag/v1.9.12).
</Callout>

List the users in this keystore.

**Signature:**
**Signature**:

```sh
```
keystore.ListUsers() -> {users:[]string}
```

**Example Call:**
**Example Call**:

```sh
```
curl -X POST --data '{
"jsonrpc":"2.0",
"id" :1,
"method" :"keystore.listUsers"
}' -H 'content-type:application/json;' 127.0.0.1:9650/ext/keystore
```

**Example Response:**
**Example Response**:

```json
```
{
"jsonrpc": "2.0",
"id": 1,
Expand Down

0 comments on commit 3456526

Please sign in to comment.