Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

warn on Keystore API usage #811

Merged
merged 1 commit into from
Jun 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions docs/apis/avalanchego/apis/keystore.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ sidebar_position: 13

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.

_**You should only create a keystore user on a node that you operate, as the node operator has access to your plaintext password.**_
:::warning
You should only create a keystore user on a node that you operate, as the node operator has access to your plaintext password.
:::

For validation and delegation on the mainnet, you should issue transactions through [the wallet](../../../nodes/validate/staking.md). 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.
For validation and delegation on the mainnet, you should issue transactions through [AvalancheJS](../../avalanchejs/README.md) or [the wallet](../../../nodes/validate/staking.md). 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.

## Format

Expand Down
39 changes: 33 additions & 6 deletions docs/quickstart/fund-a-local-test-network.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,28 @@

In [Create a Local Test Network](create-a-local-test-network.md), we showed you how to launch a 5 node local test network. Once you have a local network the next step is to fund an address so that you can begin creating transactions and interacting with smart-contracts.

We'll show you how to leverage a pre-funded private key to access funds on the X-Chain, C-Chain and P-Chain. **NOTE** this same private key, `PrivateKey-ewoqjP7PxY4yr3iLTpLisriqt94hdyDFNgchSxGGztUrTXtNN`, can be used to sign txs locally using [AvalancheJS](../apis/avalanchejs/README.md). You don't need to import the key into the local keystore in order to access those funds. They are in the genesis vertex and block for each respective chain.
We'll show you how to leverage a pre-funded private key to access funds on the X-Chain, C-Chain and P-Chain.


:::info
This same private key, `PrivateKey-ewoqjP7PxY4yr3iLTpLisriqt94hdyDFNgchSxGGztUrTXtNN`, can be used to sign txs locally using [AvalancheJS](../apis/avalanchejs/README.md). You don't need to import the key into the local keystore in order to access those funds. They are in the genesis vertex and block for each respective chain.


The port in this tutorial uses 9650. Depending on how you start your local network, it could be different. If you are using Avalanche Network Runner, please check [here](./create-a-local-test-network.md#retrieve-all-nodes) to see how to retrieve the port numbers.

:::

:::warning
Keystore APIs are used in this tutorial, as warned in [Keystore API](../apis/avalanchego/apis/keystore.md): you should only create a keystore user on a node that you operate, as the node operator has access to your plaintext password.
:::

## Create a User

First run `keystore.createUser` to create a user in the local keystore.
:::tip
This step can be skipped if you are only interesting in how to check the fund balance on X/P/C Chain.
:::

First run [`keystore.createUser`](../apis/avalanchego/apis/keystore.md#keystorecreateuser) to create a user in the local keystore.

```text
curl --location --request POST '127.0.0.1:9650/ext/keystore' \
Expand All @@ -38,11 +49,16 @@ curl --location --request POST '127.0.0.1:9650/ext/keystore' \
}
```

Next you can import the pre-funded private key, `PrivateKey-ewoqjP7PxY4yr3iLTpLisriqt94hdyDFNgchSxGGztUrTXtNN`aka `ewoq`, into any of the 3 blockchains on the default subnet. After importing the key you can check the balance to confirm that it worked.
Next you can import the pre-funded private key, `PrivateKey-ewoqjP7PxY4yr3iLTpLisriqt94hdyDFNgchSxGGztUrTXtNN`, aka `ewoq`, into any of the 3 blockchains on the default subnet. After importing the key you can check the balance to confirm that it worked.

## X-Chain

Import `ewoq` into the [X-Chain](../apis/avalanchego/apis/x-chain.md).
### Import Key
:::tip
This step can be skipped if you are only interesting in how to check the fund balance on X Chain. It shows how to get the correct address.
:::

Import `ewoq` into the [X-Chain via avm.importKey API](../apis/avalanchego/apis/x-chain.md#avmimportkey).

```text
curl --location --request POST '127.0.0.1:9650/ext/bc/X' \
Expand Down Expand Up @@ -101,7 +117,12 @@ curl --location --request POST '127.0.0.1:9650/ext/bc/X' \

## C-Chain

Import `ewoq` into the [C-Chain](../apis/avalanchego/apis/c-chain.md).
### Import Key
:::tip
This step can be skipped if you are only interesting in how to check the fund balance on C Chain. It just shows how to get the correct address.
:::

Import `ewoq` into the [C-Chain via avax.importKey API](../apis/avalanchego/apis/c-chain.md#avaximportkey).

```text
curl --location --request POST '127.0.0.1:9650/ext/bc/C/avax' \
Expand Down Expand Up @@ -171,7 +192,13 @@ To see this account on Metamask, follow these steps:

## P-Chain

Import `ewoq` into the [P-Chain](../apis/avalanchego/apis/p-chain.md).
### Import Key
:::tip
This step can be skipped if you are only interesting in how to check the fund balance on P Chain. It just shows how to get the correct address.
:::


Import `ewoq` into the [P-Chain via platform.importKey API](../apis/avalanchego/apis/p-chain.md#platformimportkey).

```text
curl --location --request POST '127.0.0.1:9650/ext/bc/P' \
Expand Down