From 1df8252f80b985c5c129a93138baacebe6544fbf Mon Sep 17 00:00:00 2001 From: mfahampshire Date: Tue, 27 Aug 2024 18:01:21 +0200 Subject: [PATCH] first pass developers structure --- .../new_docs/pages/developers/_meta.json | 5 + .../new_docs/pages/developers/concepts.mdx | 1 + .../pages/developers/concepts/_meta.json | 5 + .../developers/concepts/abstractions.mdx | 1 + .../pages/developers/concepts/messages.mdx | 1 + .../pages/developers/concepts/overview.mdx | 1 + .../pages/developers/integrations/todo.md | 0 .../new_docs/pages/developers/tools.mdx | 3 + .../pages/developers/tools/_meta.json | 4 + .../pages/developers/tools/cli-wallet.md | 8 + .../pages/developers/tools/nym-cli.md | 339 ++++++++++++++++++ 11 files changed, 368 insertions(+) create mode 100644 documentation/new_docs/pages/developers/_meta.json create mode 100644 documentation/new_docs/pages/developers/concepts.mdx create mode 100644 documentation/new_docs/pages/developers/concepts/_meta.json create mode 100644 documentation/new_docs/pages/developers/concepts/abstractions.mdx create mode 100644 documentation/new_docs/pages/developers/concepts/messages.mdx create mode 100644 documentation/new_docs/pages/developers/concepts/overview.mdx create mode 100644 documentation/new_docs/pages/developers/integrations/todo.md create mode 100644 documentation/new_docs/pages/developers/tools.mdx create mode 100644 documentation/new_docs/pages/developers/tools/_meta.json create mode 100644 documentation/new_docs/pages/developers/tools/cli-wallet.md create mode 100644 documentation/new_docs/pages/developers/tools/nym-cli.md diff --git a/documentation/new_docs/pages/developers/_meta.json b/documentation/new_docs/pages/developers/_meta.json new file mode 100644 index 0000000000..a7218243c5 --- /dev/null +++ b/documentation/new_docs/pages/developers/_meta.json @@ -0,0 +1,5 @@ +{ + "concepts": "Core Concepts", + "integrations": "Integrations", + "tools": "Tools" +} diff --git a/documentation/new_docs/pages/developers/concepts.mdx b/documentation/new_docs/pages/developers/concepts.mdx new file mode 100644 index 0000000000..39802f6428 --- /dev/null +++ b/documentation/new_docs/pages/developers/concepts.mdx @@ -0,0 +1 @@ +stub diff --git a/documentation/new_docs/pages/developers/concepts/_meta.json b/documentation/new_docs/pages/developers/concepts/_meta.json new file mode 100644 index 0000000000..0a5c5e2a93 --- /dev/null +++ b/documentation/new_docs/pages/developers/concepts/_meta.json @@ -0,0 +1,5 @@ +{ + "overview": "Overview", + "messages": "Message Based Paradigm", + "abstractions": "Connection Abstractions" +} diff --git a/documentation/new_docs/pages/developers/concepts/abstractions.mdx b/documentation/new_docs/pages/developers/concepts/abstractions.mdx new file mode 100644 index 0000000000..39802f6428 --- /dev/null +++ b/documentation/new_docs/pages/developers/concepts/abstractions.mdx @@ -0,0 +1 @@ +stub diff --git a/documentation/new_docs/pages/developers/concepts/messages.mdx b/documentation/new_docs/pages/developers/concepts/messages.mdx new file mode 100644 index 0000000000..39802f6428 --- /dev/null +++ b/documentation/new_docs/pages/developers/concepts/messages.mdx @@ -0,0 +1 @@ +stub diff --git a/documentation/new_docs/pages/developers/concepts/overview.mdx b/documentation/new_docs/pages/developers/concepts/overview.mdx new file mode 100644 index 0000000000..39802f6428 --- /dev/null +++ b/documentation/new_docs/pages/developers/concepts/overview.mdx @@ -0,0 +1 @@ +stub diff --git a/documentation/new_docs/pages/developers/integrations/todo.md b/documentation/new_docs/pages/developers/integrations/todo.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/documentation/new_docs/pages/developers/tools.mdx b/documentation/new_docs/pages/developers/tools.mdx new file mode 100644 index 0000000000..f31dc44c3b --- /dev/null +++ b/documentation/new_docs/pages/developers/tools.mdx @@ -0,0 +1,3 @@ +# Tools + +There are a few tools available to developers for chain interaction: the `nym-cli` tool, which operates as an easier-to-use wrapper around `nyxd`, and the CLI wallet. diff --git a/documentation/new_docs/pages/developers/tools/_meta.json b/documentation/new_docs/pages/developers/tools/_meta.json new file mode 100644 index 0000000000..fb605b8b02 --- /dev/null +++ b/documentation/new_docs/pages/developers/tools/_meta.json @@ -0,0 +1,4 @@ +{ + "nym-cli": "NYM-CLI tool", + "cli-wallet": "CLI wallet" +} diff --git a/documentation/new_docs/pages/developers/tools/cli-wallet.md b/documentation/new_docs/pages/developers/tools/cli-wallet.md new file mode 100644 index 0000000000..a619564672 --- /dev/null +++ b/documentation/new_docs/pages/developers/tools/cli-wallet.md @@ -0,0 +1,8 @@ +# CLI Wallet + +If you have already read our validator setup and maintenance [documentation](https://nymtech.net/operators/nodes/validator-setup.html) you will have seen that we compile and use the `nyxd` binary primarily for our validators. This binary can however be used for many other tasks, such as creating and using keypairs for wallets, or automated setups that require the signing and broadcasting of transactions. + +### Using `nyxd` binary as a CLI wallet +You can use the `nyxd` as a minimal CLI wallet if you want to set up an account (or multiple accounts). Just compile the binary as per the documentation, **stopping after** the [building your validator](https://nymtech.net/operators/nodes/validator-setup.html#building-your-validator) step is complete. You can then run `nyxd keys --help` to see how you can set up and store different keypairs with which to interact with the Nyx blockchain. + +For more on interacting with the chain, see the [Interacting with Nyx Chain and Smart Contracts](../nyx/interacting-with-chain.md) page. diff --git a/documentation/new_docs/pages/developers/tools/nym-cli.md b/documentation/new_docs/pages/developers/tools/nym-cli.md new file mode 100644 index 0000000000..b6ed36bfa7 --- /dev/null +++ b/documentation/new_docs/pages/developers/tools/nym-cli.md @@ -0,0 +1,339 @@ +# Nym-CLI + +## What is this tool for? +This is a CLI tool for interacting with: + +* the Nyx blockchain (account management, querying the chain state, etc) +* the smart contracts deployed on Nyx (bonding and un-bonding mixnodes, collecting rewards, etc) + +It provides a convenient wrapper around the `nymd` client, and has similar functionality to the `nyxd` binary for querying the chain or executing smart contract methods. + +## Building +The `nym-cli` binary can be built by running `cargo build --release` in the `nym/tools/nym-cli` directory. + +### Usage +You can see all available commands with: + +``` +./nym-cli --help +``` + +~~~admonish example collapsible=true title="Console output" +``` + +nym-cli +A client for interacting with Nym smart contracts and the Nyx blockchain + +USAGE: + nym-cli [OPTIONS] + +OPTIONS: + --config-env-file + Overrides configuration as a file of environment variables. Note: individual env vars + take precedence over this file. + + -h, --help + Print help information + + --mixnet-contract-address + Overrides the mixnet contract address provided either as an environment variable or in a + config file + + --mnemonic + Provide the mnemonic for your account. You can also provide this is an env var called + MNEMONIC. + + --nymd-url + Overrides the nymd URL provided either as an environment variable NYMD_VALIDATOR or in a + config file + + --validator-api-url + Overrides the validator API URL provided either as an environment variable API_VALIDATOR + or in a config file + + --vesting-contract-address + Overrides the vesting contract address provided either as an environment variable or in + a config file + +subcommands: + account Query and manage Nyx blockchain accounts + block Query chain blocks + cosmwasm Manage and execute WASM smart contracts + generate-fig Generates shell completion + help Print this message or the help of the given subcommand(s) + mixnet Manage your mixnet infrastructure, delegate stake or query the directory + signature Sign and verify messages + tx Query for transactions + vesting-schedule Create and query for a vesting schedule +``` +~~~ + +## Example Usage +Below we have listed some example commands for some of the features listed above. + +If ever in doubt what you need to type, or if you want to see alternative parameters for a command, use the `nym-cli --help` to view all available options. + +``` +./nym-cli account create --help +``` + +~~~admonish example collapsible=true title="Console output" +``` + +Create a new mnemonic - note, this account does not appear on the chain until the account id is used in a transaction + +USAGE: + nym-cli account create [OPTIONS] + +OPTIONS: + --config-env-file + Overrides configuration as a file of environment variables. Note: individual env vars take precedence over this file. + +-h, --help + Print help information + + --mixnet-contract-address + Overrides the mixnet contract address provided either as an environment variable or in a + config file + + --mnemonic + Provide the mnemonic for your account. You can also provide this is an env var called + MNEMONIC. + + --nymd-url + Overrides the nymd URL provided either as an environment variable NYMD_VALIDATOR or in a + config file + + --validator-api-url + Overrides the validator API URL provided either as an environment variable API_VALIDATOR + or in a config file + + --vesting-contract-address + Overrides the vesting contract address provided either as an environment variable or in + a config file + + --word-count +``` +~~~ + +### Create account + +Creates an account with a random Mnemonic and a new address. + +``` +./nym-cli account create + +# Result: +# 1. Mnemonic +assist jungle spoil domain saddle energy box carpet toy resist castle faith talent note outdoor inform cage lecture syrup trigger dress oppose slender museum +# 2. Address +n132tpw4kkfas7ah0vmq78dwurhxljf2f869tlf5 +``` +> NEVER share your mnemonic with anyone. Keep it stored in a safe and secure location. + +### Check the current balance of an account + +Queries the existing balance of an account. + +``` +# Using adddress below for example purposes. +./nym-cli account balance n1hzn28p2c6pzr98r85jp3h53fy8mju5w7ndd5vh + +# Result: +2022-11-10T10:28:54.009Z INFO nym_cli_commands::validator::account::balance > Getting balance for n1hzn28p2c6pzr98r85jp3h53fy8mju5w7ndd5vh... + +# Balance for each token will be listed here +0.264 nym +1921.995 nyx +``` + +You can also query an accounts balance by using its mnemonic: + +``` +./nym-cli account balance --mnemonic +``` + +### Send tokens to an account + +Sends tokens to an account using an address. + +``` +./nym-cli account send
+``` + +### Get the current block height + +Queries the specified blockchain (Nyx chain by default) for the current block height. + +``` +./nym-cli block current-height --mnemonic + +# Result: +Current block height: + +``` + +### Query for a mix node + +Query a mix node on the mixnet. + +``` +./nym-cli mixnet query mixnodes --mnemonic +``` + + +### Bond a mix node + +Bonding a mix node is a process that takes a few steps due to the need to sign a transaction with your nym address for replay attack protection. + +* generate a signature payload: +``` +./nym-cli mixnet operators mixnode create-mixnode-bonding-sign-payload + +# returns something like +97GEhgMrPTmQVZgHqJeqWmgQ154GLKqy8xNGtLkV8xy5xc1SuwsEnqjhtZVshBYK74n53fFkKbSrS6kxkBE3vUikbU76JZmLMFmfR7aaU2NdBnfTPPHP2nwb2hJiEueq4SvvtDtQckxv7ZJzdxyXHxUeDPhzbprxTff78U3NGNk4cg6Q2K4EFqishdaqToedsXAPvVCWNbC1iWVjEq8nJ95Eb3NJyi3KmXcNDy4i8ZXgZHu4v8F4htXq2vZUdBSbizdkNr1NRvEg6PGVQdTseyuN8JxD3yuvrqprPY2kvJaT2YiYLPgWxoQtbfwcpkX4PP1PvwuMg4W8EXhitMpM2WHqLDP5vgfDGxdDCmRS44pM8ya4hcQ4g3McHWxduGWdbCzNNEsX6oQw4LVFcWn4mhbXSgqHwNQMm2TQW6LatYZSwCczdhEwV2CXe36UGCUzozmm4nj9qfUtXqDzMrHAAS8kjbKaVNaVaRRKgauQrHnK7QGg1QpVnnaxCs14wvUb62sio8XZmMzP2SjVaRJFCyJB3UwZ6L4oXMGMXSRsiKe8ZNTaa6iX69tx54CAAHBHoiReiq7E5T2VuR5v +``` + +* sign this payload: +``` +./nym-mixnode sign --id upgrade_test --contract-msg 97GEhgMrPTmQVZgHqJeqWmgQ154GLKqy8xNGtLkV8xy5xc1SuwsEnqjhtZVshBYK74n53fFkKbSrS6kxkBE3vUikbU76JZmLMFmfR7aaU2NdBnfTPPHP2nwb2hJiEueq4SvvtDtQckxv7ZJzdxyXHxUeDPhzbprxTff78U3NGNk4cg6Q2K4EFqishdaqToedsXAPvVCWNbC1iWVjEq8nJ95Eb3NJyi3KmXcNDy4i8ZXgZHu4v8F4htXq2vZUdBSbizdkNr1NRvEg6PGVQdTseyuN8JxD3yuvrqprPY2kvJaT2YiYLPgWxoQtbfwcpkX4PP1PvwuMg4W8EXhitMpM2WHqLDP5vgfDGxdDCmRS44pM8ya4hcQ4g3McHWxduGWdbCzNNEsX6oQw4LVFcWn4mhbXSgqHwNQMm2TQW6LatYZSwCczdhEwV2CXe36UGCUzozmm4nj9qfUtXqDzMrHAAS8kjbKaVNaVaRRKgauQrHnK7QGg1QpVnnaxCs14wvUb62sio8XZmMzP2SjVaRJFCyJB3UwZ6L4oXMGMXSRsiKe8ZNTaa6iX69tx54CAAHBHoiReiq7E5T2VuR5v +``` + +* bond the node using the signature: +``` +./nym-cli --mnemonic mixnet operators mixnode bond --amount 100000000 --mix-port 1789 --version "1.1.13" --host "85.163.111.99" --identity-key "B6pWscxYb8sPAdKTci8zPy5AgMzn5Zx8KpWwQNCyUSU7" --location "nym-town" --sphinx-key "o6MmKHzRewpNzVwaV37ZX9G3BfK4AmfYvsQfyoyAFRk" --signature "2TujBZfer8r5QM639Yb8coD9xH6f5eXzjAT5dD7wMom9fH8D1u36d7UpPdVaaZrWsCynmYpobwMWqiMKr5kM6CprD" +``` + +### Bond a gateway +Bonding a mix node is a process that takes a few steps due to the need to sign a transaction with your nym address for replay attack protection. + +* generate a signature payload: +``` +./nym-cli mixnet operators gateway create-gateway-bonding-sign-payload + +# returns something like +97GEhgMrPTmQVZgHq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tXqDzMrHAAS8kjbKaVNaVaRRKgauQrHnK7QGg1QpVnnaxCs14wvUb62sio8XZmMzP2SjVaRJFCyJB3UwZ6L4oXMGMXSRsiKe8ZNTaa6iX69tx54CAAHBHoiReiq7E5T2VuR5v +``` + +* bond the node using this signature: +``` +./nym-cli --mnemonic mixnet operators gateway bond --amount 100000000 --mix-port 1789 --version "1.1.13" --host "85.163.111.99" --identity-key "B6pWscxYb8sPAdKTci8zPy5AgMzn5Zx8KpWwQNCyUSU7" --location "nym-town" --sphinx-key "o6MmKHzRewpNzVwaV37ZX9G3BfK4AmfYvsQfyoyAFRk" --signature "2TujBZfer8r5QM639Yb8coD9xH6f5eXzjAT5dD7wMom9fH8D1u36d7UpPdVaaZrWsCynmYpobwMWqiMKr5kM6CprD" +``` + +### Un-bond a node + +Un-bond a mix node or gateway. +``` +./nym-cli mixnet operators gateway unbound --mnemonic +``` + +> The same command can be applied with a mix node. Just replace `gateway` with `mixnode`. + +### Upgrade a mix node + +Upgrade your node config. +``` +./nym-cli mixnet operators mixnode settings update-config --version +``` + +### Claim a vesting reward for a mixnode + +Claim rewards for a mix node bonded with locked tokens. + +``` +./nym-cli mixnet operators mixnode rewards vesting-claim --mnemonic +``` + +### Claim rewards + +``` +./nym-cli mixnet operators mixnode rewards --mnemonic +``` + +### Manage Mix node Settings + +Manage your mix node settings stored in the directory. + +``` +./nym-cli mixnet operators mixnode settings update-config --version +``` + +### Delegate Stake + +Delegate to a mix node. +``` +./nym-cli mixnet delegators delegate --amount –mix-id --mnemonic +``` + +### Un-delegate Stake + +Remove stake from a mix node. +``` +./nym-cli mixnet delegators undelegate --mix-id --mnemonic +``` + +### Query a reward for a delegator + +Claim rewards accumulated during the delegation of unlocked tokens. +``` +./nym-cli mixnet delegators rewards claim --mix-id --mnemonic +``` + + +### Signature Generation: Sign a message + +Sign a message. +``` +./nym-cli signature sign --mnemonic + +# Result: +{"account_id":,"public_key":{"@type":"/cosmos.crypto.secp256k1.PubKey","key":},"signature":""} +``` + +### Signature Generation: Verify a signature + +Verify a signature. +``` +./nym-cli signature verify --mnemonic +``` + +### Create a Vesting Schedule + +Creates a vesting schedule for an account in the [vesting smart contract](../nyx/vesting-contract.md). + +``` +./nym-cli vesting-schedule create --mnemonic --address
--amount +``` + +### Query a Vesting Schedule + +Query for vesting schedule in the [vesting smart contract](../nyx/vesting-contract.md). + +``` +./nym-cli vesting-schedule query --mnemonic +``` + + +## Staking on someone's behalf (for custodians) + +There is a limitation the staking address can only perform the following actions (and are visible via the Nym Wallet: + +- Bond on the gateway's or mix node's behalf. +- Delegate or Un-delegate (to a mix node in order to begin receiving rewards) +- Claiming the rewards on the account + +```admonish note title="" +The staking address has no ability to withdraw any coins from the parent's account. +``` + +The staking address must maintain the same level of security as the parent mnemonic; while the parent mnemonic's delegations and bonding events will be visible to the parent owner, the staking address will be the only account capable of undoing the bonding and delegating from the mix nodes or gateway. + +Query for staking on behalf of someone else +``` +./nym-cli --mnemonic mixnet delegators delegate --mix-id --identity-key --amount +```