github.com/MetalBlockchain/metalgo@v1.11.9/api/keystore/service.md (about) 1 --- 2 tags: [AvalancheGo APIs] 3 description: This page is an overview of the Keystore API associated with AvalancheGo. 4 sidebar_label: Keystore API 5 pagination_label: Keystore API 6 --- 7 8 # Keystore API 9 10 :::warning 11 Because the node operator has access to your plain-text password, you should only create a 12 keystore user on a node that you operate. If that node is breached, you could lose all your tokens. 13 Keystore APIs are not recommended for use on Mainnet. 14 ::: 15 16 Every node has a built-in keystore. Clients create users on the keystore, which act as identities to 17 be used when interacting with blockchains. A keystore exists at the node level, so if you create a 18 user on a node it exists _only_ on that node. However, users may be imported and exported using this 19 API. 20 21 For validation and cross-chain transfer on the Mainnet, you should issue transactions through 22 [AvalancheJS](/tooling/avalanchejs-overview). That way control keys for your funds won't be stored on 23 the node, which significantly lowers the risk should a computer running a node be compromised. See 24 following docs for details: 25 26 - Transfer AVAX Tokens Between Chains: 27 28 - C-Chain: [export](https://github.com/ava-labs/avalanchejs/blob/master/examples/c-chain/export.ts) and 29 [import](https://github.com/ava-labs/avalanchejs/blob/master/examples/c-chain/import.ts) 30 - P-Chain: [export](https://github.com/ava-labs/avalanchejs/blob/master/examples/p-chain/export.ts) and 31 [import](https://github.com/ava-labs/avalanchejs/blob/master/examples/p-chain/import.ts) 32 - X-Chain: [export](https://github.com/ava-labs/avalanchejs/blob/master/examples/x-chain/export.ts) and 33 [import](https://github.com/ava-labs/avalanchejs/blob/master/examples/x-chain/import.ts) 34 35 - [Add a Node to the Validator Set](/nodes/validate/add-a-validator) 36 37 :::info 38 39 This API set is for a specific node, it is unavailable on the [public server](/tooling/rpc-providers.md). 40 41 ::: 42 43 ## Format 44 45 This API uses the `json 2.0` API format. For more information on making JSON RPC calls, see 46 [here](/reference/standards/guides/issuing-api-calls.md). 47 48 ## Endpoint 49 50 ```text 51 /ext/keystore 52 ``` 53 54 ## Methods 55 56 ### keystore.createUser 57 58 :::caution 59 60 Deprecated as of [**v1.9.12**](https://github.com/ava-labs/avalanchego/releases/tag/v1.9.12). 61 62 ::: 63 64 Create a new user with the specified username and password. 65 66 **Signature:** 67 68 ```sh 69 keystore.createUser( 70 { 71 username:string, 72 password:string 73 } 74 ) -> {} 75 ``` 76 77 - `username` and `password` can be at most 1024 characters. 78 - Your request will be rejected if `password` is too weak. `password` should be at least 8 79 characters and contain upper and lower case letters as well as numbers and symbols. 80 81 **Example Call:** 82 83 ```sh 84 curl -X POST --data '{ 85 "jsonrpc":"2.0", 86 "id" :1, 87 "method" :"keystore.createUser", 88 "params" :{ 89 "username":"myUsername", 90 "password":"myPassword" 91 } 92 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/keystore 93 ``` 94 95 **Example Response:** 96 97 ```json 98 { 99 "jsonrpc": "2.0", 100 "id": 1, 101 "result": {} 102 } 103 ``` 104 105 ### keystore.deleteUser 106 107 :::caution 108 109 Deprecated as of [**v1.9.12**](https://github.com/ava-labs/avalanchego/releases/tag/v1.9.12). 110 111 ::: 112 113 Delete a user. 114 115 **Signature:** 116 117 ```sh 118 keystore.deleteUser({username: string, password:string}) -> {} 119 ``` 120 121 **Example Call:** 122 123 ```sh 124 curl -X POST --data '{ 125 "jsonrpc":"2.0", 126 "id" :1, 127 "method" :"keystore.deleteUser", 128 "params" : { 129 "username":"myUsername", 130 "password":"myPassword" 131 } 132 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/keystore 133 ``` 134 135 **Example Response:** 136 137 ```json 138 { 139 "jsonrpc": "2.0", 140 "id": 1, 141 "result": {} 142 } 143 ``` 144 145 ### keystore.exportUser 146 147 :::caution 148 149 Deprecated as of [**v1.9.12**](https://github.com/ava-labs/avalanchego/releases/tag/v1.9.12). 150 151 ::: 152 153 Export a user. The user can be imported to another node with 154 [`keystore.importUser`](/reference/avalanchego/keystore-api.md#keystoreimportuser). The user’s password 155 remains encrypted. 156 157 **Signature:** 158 159 ```sh 160 keystore.exportUser( 161 { 162 username:string, 163 password:string, 164 encoding:string //optional 165 } 166 ) -> { 167 user:string, 168 encoding:string 169 } 170 ``` 171 172 `encoding` specifies the format of the string encoding user data. Can only be `hex` when a value is 173 provided. 174 175 **Example Call:** 176 177 ```sh 178 curl -X POST --data '{ 179 "jsonrpc":"2.0", 180 "id" :1, 181 "method" :"keystore.exportUser", 182 "params" :{ 183 "username":"myUsername", 184 "password":"myPassword" 185 } 186 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/keystore 187 ``` 188 189 **Example Response:** 190 191 ```json 192 { 193 "jsonrpc": "2.0", 194 "id": 1, 195 "result": { 196 "user": "7655a29df6fc2747b0874e1148b423b954a25fcdb1f170d0ec8eb196430f7001942ce55b02a83b1faf50a674b1e55bfc00000000", 197 "encoding": "hex" 198 } 199 } 200 ``` 201 202 ### keystore.importUser 203 204 :::caution 205 206 Deprecated as of [**v1.9.12**](https://github.com/ava-labs/avalanchego/releases/tag/v1.9.12). 207 208 ::: 209 210 Import a user. `password` must match the user’s password. `username` doesn’t have to match the 211 username `user` had when it was exported. 212 213 **Signature:** 214 215 ```sh 216 keystore.importUser( 217 { 218 username:string, 219 password:string, 220 user:string, 221 encoding:string //optional 222 } 223 ) -> {} 224 ``` 225 226 `encoding` specifies the format of the string encoding user data. Can only be `hex` when a value is 227 provided. 228 229 **Example Call:** 230 231 ```sh 232 curl -X POST --data '{ 233 "jsonrpc":"2.0", 234 "id" :1, 235 "method" :"keystore.importUser", 236 "params" :{ 237 "username":"myUsername", 238 "password":"myPassword", 239 "user" :"0x7655a29df6fc2747b0874e1148b423b954a25fcdb1f170d0ec8eb196430f7001942ce55b02a83b1faf50a674b1e55bfc000000008cf2d869" 240 } 241 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/keystore 242 ``` 243 244 **Example Response:** 245 246 ```json 247 { 248 "jsonrpc": "2.0", 249 "id": 1, 250 "result": {} 251 } 252 ``` 253 254 ### keystore.listUsers 255 256 :::caution 257 258 Deprecated as of [**v1.9.12**](https://github.com/ava-labs/avalanchego/releases/tag/v1.9.12). 259 260 ::: 261 262 List the users in this keystore. 263 264 **Signature:** 265 266 ```sh 267 keystore.ListUsers() -> {users:[]string} 268 ``` 269 270 **Example Call:** 271 272 ```sh 273 curl -X POST --data '{ 274 "jsonrpc":"2.0", 275 "id" :1, 276 "method" :"keystore.listUsers" 277 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/keystore 278 ``` 279 280 **Example Response:** 281 282 ```json 283 { 284 "jsonrpc": "2.0", 285 "id": 1, 286 "result": { 287 "users": ["myUsername"] 288 } 289 } 290 ```