diff --git a/pages/developers/_meta.json b/pages/developers/_meta.json index efad1ef..1eb8603 100644 --- a/pages/developers/_meta.json +++ b/pages/developers/_meta.json @@ -5,6 +5,7 @@ }, "blueprints": "Blueprints", "services": "Use Cases", + "cli": "Tangle CLI", "-- gadget-tutorial": { "type": "separator", "title": "Blueprint (AVS) Tutorials" diff --git a/pages/developers/cli/_meta.json b/pages/developers/cli/_meta.json new file mode 100644 index 0000000..665e36d --- /dev/null +++ b/pages/developers/cli/_meta.json @@ -0,0 +1,5 @@ +{ + "installation": "Installation", + "quickstart": "Quickstart", + "reference": "Reference" +} \ No newline at end of file diff --git a/pages/developers/cli/installation.mdx b/pages/developers/cli/installation.mdx new file mode 100644 index 0000000..c6f7907 --- /dev/null +++ b/pages/developers/cli/installation.mdx @@ -0,0 +1,33 @@ +--- +title: Installation +--- + +# Tangle CLI Installation + +There are multiple sources to install the CLI from: + +1. Using the installation script (stable) + +> The script supports Linux, MacOS, and Windows (WSL2) + +```shell +$ curl --proto '=https' --tlsv1.2 -LsSf https://github.com/tangle-network/gadget/releases/download/cargo-tangle/v0.1.1-beta.7/cargo-tangle-installer.sh | sh +``` + +2. From [crates.io](https://crates.io) (stable) + +```shell +$ cargo install cargo-tangle --force +``` + +3. From source (nightly) + +```shell +$ cargo install cargo-tangle --git https://github.com/tangle-network/gadget --force +``` + +You can verify your installation with: + +```shell +$ cargo tangle --version +``` \ No newline at end of file diff --git a/pages/developers/cli/quickstart.mdx b/pages/developers/cli/quickstart.mdx new file mode 100644 index 0000000..8508aa8 --- /dev/null +++ b/pages/developers/cli/quickstart.mdx @@ -0,0 +1,48 @@ +--- +title: Quickstart +--- + +# Tangle CLI Quickstart + +## Pre-requisites + +* [git](https://git-scm.org) +* Tangle CLI, see [installation](./installation) + +## Creating a New Project + +1. Open your terminal and run: + +```shell +$ cargo tangle blueprint create --name +``` + +2. Follow the prompts to set up your project. + +{/* TODO: Add a GIF */} + +### Project Structure + +After creation, your project will have the following structure: + +``` +/ +├── src/ +│ ├── lib.rs +│ └── main.rs +├── Cargo.toml +├── README.md +└── ... +``` + +## Deploying your Blueprint + +Once you're ready to deploy your blueprint, simply: + +```shell +export SIGNER="//Alice" +export EVM_SIGNER="0xcb6df9de1efca7a3998a8ead4e02159d5fa99c3e0d4fd6432667390bb4726854" +cargo tangle blueprint deploy +``` + +See [deploy command reference](./reference#deploy) for all options. \ No newline at end of file diff --git a/pages/developers/cli/reference.mdx b/pages/developers/cli/reference.mdx new file mode 100644 index 0000000..d561318 --- /dev/null +++ b/pages/developers/cli/reference.mdx @@ -0,0 +1,75 @@ +--- +title: Reference +--- + +# Tangle CLI Reference + +## Blueprint + +The primary subcommand, used for building, testing, and deploying blueprints. + +- Aliases: `bp` + +Usage: +```shell +$ cargo tangle blueprint +``` + +### Subcommands + +Note that unless specified, all arguments are optional. + +#### Create + +Creates a new blueprint + +- Name: `create` +- Aliases: `c` +- Options: + - `--name` (**required**): The name of the blueprint + - `--repo`: The repo to pull the template from, by default this uses the hello world [blueprint template](https://github.com/tangle-network/blueprint-template) + - `--path`: The path to copy a template from, no default value + +Usage: + +Create a blueprint using the default template +```shell +$ cargo tangle blueprint create --name +``` + +Create a blueprint using another template from git +```shell +$ cargo tangle blueprint create --name --repo +``` + +#### Deploy + +Deploy a blueprint to Tangle + +- Name: `deploy` +- Aliases: `d` +- Options: + - `rpc-url`: The tangle RPC URL to use (default: `wss://rpc.tangle.tools`) + - `package`: The package to deploy, useful when using workspaces +- Environment Variables: + - `SIGNER` (**required**): The SURI of the Subtrate signer account + - `EVM_SIGNER` (**required**): The SURI of the EVM signer account + +Usage: + +Deploy a blueprint to a local Tangle node: +```bash +export SIGNER="//Alice" +export EVM_SIGNER="0xcb6df9de1efca7a3998a8ead4e02159d5fa99c3e0d4fd6432667390bb4726854" +cargo tangle blueprint deploy --rpc-url +``` +Where `` will likely be `ws://localhost:9944`. + +#### Generate Keys + +- Name: `generate-keys` +- Options: + - `key-type` (alias: `k`) (**required**): The key type to generate (sr25519, ecdsa, bls_bn254, ed25519, bls381) + - `path` (alias: `p`): The path to write the generated keypair to. If not provided, the keypair will be written solely to stdout + - `seed` (alias: `s`): The SURI/seed to generate the keypair from. If not provided, a random keypair will be generated + - `show-secret`: Denotes that the Private Key should also be printed to stdout. If not provided, only the public key will be printed \ No newline at end of file diff --git a/pages/developers/getting-started.mdx b/pages/developers/getting-started.mdx index e492f92..73ab888 100644 --- a/pages/developers/getting-started.mdx +++ b/pages/developers/getting-started.mdx @@ -13,47 +13,15 @@ Before you begin, ensure you have the following installed: - [Rust](https://www.rust-lang.org/tools/install) - [Forge](https://getfoundry.sh) - [Tangle](https://github.com/tangle-network/tangle?tab=readme-ov-file#-getting-started-) -- `cargo-tangle` CLI tool +- [`cargo-tangle`](./cli/installation) CLI tool -To install the Tangle CLI, run: +## Creating my First Blueprint -```bash -curl --proto '=https' --tlsv1.2 -LsSf https://github.com/tangle-network/gadget/releases/download/cargo-tangle/v0.1.1-beta.7/cargo-tangle-installer.sh | sh -``` - -Alternatively, install from source: - -```bash -cargo install cargo-tangle --git https://github.com/tangle-network/gadget --force -``` - -## Creating a New Project - -1. Open your terminal and run: - - ```bash - cargo tangle blueprint create --name hello-world-blueprint - ``` - -2. Follow the prompts to set up your project. +See the [CLI Quickstart](./cli/quickstart) for instructions on creating a [blueprint](./blueprints). -## Project Structure +### Key Files -After creation, your project will have the following structure: - -``` -hello-world-blueprint/ -├── src/ -│ ├── lib.rs -│ └── main.rs -├── Cargo.toml -├── README.md -└── -``` - -Let's look at the key files: - -### src/lib.rs +#### src/lib.rs This file contains the core logic of your Blueprint, including job definitions, report structures, and event listeners. Here's an example of a simple "Hello World" job: @@ -82,7 +50,7 @@ pub fn say_hello(who: Option) -> Result { This job takes an optional `who` parameter and returns a greeting. -### src/main.rs +#### src/main.rs This file serves as the entry point for your Actively Validated Service (AVS) node. It sets up the runtime environment, initializes the necessary components, and starts the event watcher. Here's a breakdown of its key responsibilities: @@ -151,15 +119,9 @@ cargo build This command compiles your Rust code and checks for any errors. -## Deploying Your Blueprint - -To deploy your Blueprint to the Tangle network, use: - -```bash -cargo tangle gadget deploy -``` +### Deploying Your Blueprint -This command will package your Blueprint and deploy it to the Tangle network test environment. +See [deploying your blueprint](./cli/quickstart#deploying-your-blueprint). ## Next Steps