From a313bc0599a939e0961f783efff765b35bf1a9da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20Blanchemain?= Date: Tue, 19 Nov 2024 18:10:46 -0800 Subject: [PATCH 1/7] Feat: add "Using Stylus CLI" draft --- arbitrum-docs/stylus/using-stylus-cli.mdx | 115 ++++++++++++++++++++++ website/sidebars.js | 5 + 2 files changed, 120 insertions(+) create mode 100644 arbitrum-docs/stylus/using-stylus-cli.mdx diff --git a/arbitrum-docs/stylus/using-stylus-cli.mdx b/arbitrum-docs/stylus/using-stylus-cli.mdx new file mode 100644 index 000000000..156d9daf6 --- /dev/null +++ b/arbitrum-docs/stylus/using-stylus-cli.mdx @@ -0,0 +1,115 @@ +--- +id: using-stylus-cli +title: 'Using Stylus CLI' +description: 'Get started with Stylus CLI, a Rust toolkit for developing Stylus contracts' +author: 'anegg0' +sme: 'anegg0' +sidebar_position: 2 +target_audience: Developers writing Stylus contracts in Rust using Stylus +--- + +This guide will get you started with Stylus' basics. We'll cover the following steps: + +## Setting up your development environment + +### Prerequisites + +
+Rust toolchain + +Follow the instructions on [Rust Lang's installation page](https://www.rust-lang.org/tools/install) to install a complete Rust toolchain (v1.81 or older, v1.82 is currently not supported) on your system. After installation, ensure you can access the programs `rustup`, `rustc`, and `cargo` from your preferred terminal application. + +
+ +
+VS Code + +We recommend [VSCode](https://code.visualstudio.com/) as the IDE of choice for its excellent Rust support, but feel free to use another text editor or IDE if you're comfortable with those. + +Some helpful VS Code extensions for Rust development: + +- [rust-analyzer](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer): Provides advanced features like smart code completion and on-the-fly error checks +- [Error Lens](https://marketplace.visualstudio.com/items?itemName=usernamehw.errorlens): Immediately highlights errors and warnings in your code +- [Even Better TOML](https://marketplace.visualstudio.com/items?itemName=tamasfe.even-better-toml): Improves syntax highlighting and other features for TOML files, often used in Rust projects +- [Dependi](https://marketplace.visualstudio.com/items?itemName=fill-labs.dependi): Helps manage Rust crate versions directly from the editor + +
+ +
+Docker + +The testnode we will use as well as some `cargo stylus` commands require Docker to operate. + +You can download Docker from [Docker's website](https://www.docker.com/products/docker-desktop). + +
+ +
+Foundry's Cast + +[Foundry's Cast](https://book.getfoundry.sh/cast/) is a command-line tool that allows you to interact with your EVM contracts. + +
+ +
+Nitro devnode + +Stylus is available on Arbitrum Sepolia, but we'll use nitro devnode which has a pre-funded wallet saving us the effort of wallet provisioning or running out of tokens to send transactions. + +```shell title="Install your devnode" +git clone https://github.com/OffchainLabs/nitro-devnode.git +cd nitro-devnode +``` + +```shell title="Launch your devnode" +./run-dev-node.sh +``` + +
+ +[cargo stylus](https://github.com/OffchainLabs/cargo-stylus/blob/main/main/VALID_WASM.md) is a CLI toolkit built to facilitate the development of Stylus contracts. + +It is available as a plugin to the standard cargo tool used for developing Rust programs. + +### Installing cargo stylus + +In your terminal, run: + +```shell +cargo install --force cargo-stylus +``` + +Add WASM ([WebAssembly](https://webassembly.org/)) as a build target for the specific Rust toolchain you are using. The below example sets your default Rust toolchain to 1.80 as well as adding the WASM build target: + +```shell +rustup default 1.80 +rustup target add wasm32-unknown-unknown --toolchain 1.80 +``` + +You can verify that cargo stylus is installed by running `cargo stylus --help` in your terminal, which will return a list of helpful commands, we will use some of them in this guide: + +```shell title="cargo stylus --help returns:" +Cargo command for developing Stylus projects + +Usage: cargo stylus + +Commands: + new Create a new Stylus project + init Initializes a Stylus project in the current directory + export-abi Export a Solidity ABI + activate Activate an already deployed contract [aliases: a] + cache Cache a contract using the Stylus CacheManager for Arbitrum chains + check Check a contract [aliases: c] + deploy Deploy a contract [aliases: d] + verify Verify the deployment of a Stylus contract [aliases: v] + cgen Generate c code bindings for a Stylus contract + replay Replay a transaction in gdb [aliases: r] + trace Trace a transaction [aliases: t] + help Print this message or the help of the given command(s) + +Options: + -h, --help Print help + -V, --version Print version +``` + +Feel free to explore the [Stylus Rust SDK reference](./reference/overview) for more information on using Stylus in your Arbitrum projects. diff --git a/website/sidebars.js b/website/sidebars.js index d28e48219..88a5913a7 100644 --- a/website/sidebars.js +++ b/website/sidebars.js @@ -515,6 +515,11 @@ const sidebars = { }, ], }, + { + type: 'doc', + id: 'stylus/using-stylus-cli', + label: 'Using Stylus CLI', + }, { type: 'category', label: 'Concepts', From 3de1c1b656b043e76825e7d61788b44504417259 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20Blanchemain?= Date: Wed, 20 Nov 2024 14:46:54 -0800 Subject: [PATCH 2/7] feat: add command table --- arbitrum-docs/stylus/using-stylus-cli.mdx | 55 +++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/arbitrum-docs/stylus/using-stylus-cli.mdx b/arbitrum-docs/stylus/using-stylus-cli.mdx index 156d9daf6..ec6e66c26 100644 --- a/arbitrum-docs/stylus/using-stylus-cli.mdx +++ b/arbitrum-docs/stylus/using-stylus-cli.mdx @@ -112,4 +112,59 @@ Options: -V, --version Print version ``` + +Cargo Stylus Commands + +| Command | Description | Options | +|---------|-----------------------------|---------------------------------| +| new | Create a new Stylus project | • name: Project name (required) | +• --minimal: Create a minimal contract | +| init | Initialize a Stylus project in current directory | • --minimal: Create a minimal contract | +| export-abi | Export a Solidity ABI | • --output: Output file (defaults to stdout) +• --json: Write JSON ABI using solc | +| activate | Activate an already deployed contract | • --address: Contract address to activate +• --data-fee-bump-percent: Percent to bump estimated fee (default 20%) +• --estimate-gas: Only estimate gas without sending tx | +| cache | Cache contract using Stylus CacheManager | Subcommands: +• bid: Place bid on contract +• status: Check contract status +• suggest-bid: Get suggested minimum bid | +| check | Check a contract | • --wasm-file: WASM to check +• --contract-address: Deploy address | +| deploy | Deploy a contract | • --estimate-gas: Only perform estimation +• --no-verify: Skip reproducible container +• --cargo-stylus-version: Version for Docker image | +| verify | Verify contract deployment | • --deployment-tx: Hash of deployment tx +• --no-verify: Skip reproducible container +• --cargo-stylus-version: Version for Docker image | +| cgen | Generate C code bindings | • input: Input file path +• out_dir: Output directory path | +| replay | Replay transaction in gdb | • --stable-rust: Use stable Rust +• --child: Child process flag | +| trace | Trace a transaction | • --endpoint: RPC endpoint +• --tx: Transaction hash +• --project: Project path +• --use-native-tracer: Use native tracer | + + +Common Options +These options are available across multiple commands: +| Option | Description | +|--------|-------------| +| --endpoint | Arbitrum RPC endpoint (default: http://localhost:8547) | +| --verbose | Print debug info | +| --source-files-for-project-hash | Paths to source files for project hash | +| --max-fee-per-gas-gwei | Optional max fee per gas in gwei | +Authentication Options +Available for commands that interact with the blockchain: + +| Option | Description | +|--------|-------------| +| --private-key-path | Path to file containing hex-encoded private key | +| --private-key | Private key as hex string (exposes to shell history) | +| --keystore-path | Path to Ethereum wallet keystore file | +| --keystore-password-path | Keystore password file path | + + + Feel free to explore the [Stylus Rust SDK reference](./reference/overview) for more information on using Stylus in your Arbitrum projects. From 1a8023a1fe1552ced6b2293bf583dbc6efa285d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20Blanchemain?= Date: Wed, 20 Nov 2024 20:06:43 -0800 Subject: [PATCH 3/7] feat: Draft CLI article --- arbitrum-docs/stylus/using-stylus-cli.mdx | 216 ++++++++++------------ 1 file changed, 100 insertions(+), 116 deletions(-) diff --git a/arbitrum-docs/stylus/using-stylus-cli.mdx b/arbitrum-docs/stylus/using-stylus-cli.mdx index ec6e66c26..3cd85439d 100644 --- a/arbitrum-docs/stylus/using-stylus-cli.mdx +++ b/arbitrum-docs/stylus/using-stylus-cli.mdx @@ -8,163 +8,147 @@ sidebar_position: 2 target_audience: Developers writing Stylus contracts in Rust using Stylus --- -This guide will get you started with Stylus' basics. We'll cover the following steps: +This guide will get you started using [cargo stylus](https://github.com/OffchainLabs/cargo-stylus) is a CLI toolkit built to facilitate the development of Stylus contracts. -## Setting up your development environment +It is available as a plugin to the standard cargo tool used for developing Rust programs. + + + +### Installing cargo stylus -### Prerequisites +#### Prerequisites -
-Rust toolchain +Rust toolchain Follow the instructions on [Rust Lang's installation page](https://www.rust-lang.org/tools/install) to install a complete Rust toolchain (v1.81 or older, v1.82 is currently not supported) on your system. After installation, ensure you can access the programs `rustup`, `rustc`, and `cargo` from your preferred terminal application. -
+#### Installation -
-VS Code +In your terminal, run: -We recommend [VSCode](https://code.visualstudio.com/) as the IDE of choice for its excellent Rust support, but feel free to use another text editor or IDE if you're comfortable with those. +```shell +cargo install --force cargo-stylus +``` -Some helpful VS Code extensions for Rust development: +Add WASM ([WebAssembly](https://webassembly.org/)) as a build target for the specific Rust toolchain you are using. The below example sets your default Rust toolchain to 1.80 as well as adding the WASM build target: -- [rust-analyzer](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer): Provides advanced features like smart code completion and on-the-fly error checks -- [Error Lens](https://marketplace.visualstudio.com/items?itemName=usernamehw.errorlens): Immediately highlights errors and warnings in your code -- [Even Better TOML](https://marketplace.visualstudio.com/items?itemName=tamasfe.even-better-toml): Improves syntax highlighting and other features for TOML files, often used in Rust projects -- [Dependi](https://marketplace.visualstudio.com/items?itemName=fill-labs.dependi): Helps manage Rust crate versions directly from the editor +```shell +rustup default 1.80 +rustup target add wasm32-unknown-unknown --toolchain 1.80 +``` -
+You can verify that cargo stylus is installed by running `cargo stylus -V` in your terminal, returning something like:`stylus 0.5.6` -
-Docker +### Using cargo stylus -The testnode we will use as well as some `cargo stylus` commands require Docker to operate. +#### Cargo Stylus Commands -You can download Docker from [Docker's website](https://www.docker.com/products/docker-desktop). +| Command | Description | Options | +|---------|-------------|----------| +| new | Create a new Stylus project | • name: Project name (required)
• --minimal: Create a minimal contract | +| init | Initialize a Stylus project in current directory | • --minimal: Create a minimal contract | +| export-abi | Export a Solidity ABI | • --output: Output file (defaults to stdout)
• --json: Write JSON ABI using solc | +| activate | Activate an already deployed contract | • --address: Contract address to activate
• --data-fee-bump-percent: Percent to bump estimated fee (default 20%)
• --estimate-gas: Only estimate gas without sending tx | +| cache | Cache contract using Stylus CacheManager | Subcommands:
• bid: Place bid on contract
• status: Check contract status
• suggest-bid: Get suggested minimum bid | +| check | Check a contract | • --wasm-file: WASM to check
• --contract-address: Deploy address | +| deploy | Deploy a contract | • --estimate-gas: Only perform estimation
• --no-verify: Skip reproducible container
• --cargo-stylus-version: Version for Docker image | +| verify | Verify contract deployment | • --deployment-tx: Hash of deployment tx
• --no-verify: Skip reproducible container
• --cargo-stylus-version: Version for Docker image | +| cgen | Generate C code bindings | • input: Input file path
• out_dir: Output directory path | +| replay | Replay transaction in gdb | • --stable-rust: Use stable Rust
• --child: Child process flag | +| trace | Trace a transaction | • --endpoint: RPC endpoint
• --tx: Transaction hash
• --project: Project path
• --use-native-tracer: Use native tracer | -
+##### Common Options -
-Foundry's Cast + These options are available across multiple commands: -[Foundry's Cast](https://book.getfoundry.sh/cast/) is a command-line tool that allows you to interact with your EVM contracts. +| Option | Description | +|--------|-------------| +| --endpoint | Arbitrum RPC endpoint (default: http://localhost:8547) | +| --verbose | Print debug info | +| --source-files-for-project-hash | Paths to source files for project hash | +| --max-fee-per-gas-gwei | Optional max fee per gas in gwei | -
+##### Authentication Options -
-Nitro devnode +Available for commands involving transactions: -Stylus is available on Arbitrum Sepolia, but we'll use nitro devnode which has a pre-funded wallet saving us the effort of wallet provisioning or running out of tokens to send transactions. +| Option | Description | +|--------|-------------| +| --private-key-path | Path to file containing hex-encoded private key | +| --private-key | Private key as hex string (exposes to shell history) | +| --keystore-path | Path to Ethereum wallet keystore file | +| --keystore-password-path | Keystore password file path | -```shell title="Install your devnode" -git clone https://github.com/OffchainLabs/nitro-devnode.git -cd nitro-devnode -``` -```shell title="Launch your devnode" -./run-dev-node.sh -``` +### Example Usage -
+#### Create a new Stylus project -[cargo stylus](https://github.com/OffchainLabs/cargo-stylus/blob/main/main/VALID_WASM.md) is a CLI toolkit built to facilitate the development of Stylus contracts. +```shell +cargo stylus new my_project +``` -It is available as a plugin to the standard cargo tool used for developing Rust programs. +#### Initialize a Stylus project in the current directory -### Installing cargo stylus +```shell +cargo stylus init +``` -In your terminal, run: +#### Export a Solidity ABI ```shell -cargo install --force cargo-stylus +cargo stylus export-abi --output abi.json ``` -Add WASM ([WebAssembly](https://webassembly.org/)) as a build target for the specific Rust toolchain you are using. The below example sets your default Rust toolchain to 1.80 as well as adding the WASM build target: +#### Activate an already deployed contract ```shell -rustup default 1.80 -rustup target add wasm32-unknown-unknown --toolchain 1.80 +cargo stylus activate --address 0x1234567890123456789012345678901234567890 ``` -You can verify that cargo stylus is installed by running `cargo stylus --help` in your terminal, which will return a list of helpful commands, we will use some of them in this guide: - -```shell title="cargo stylus --help returns:" -Cargo command for developing Stylus projects - -Usage: cargo stylus - -Commands: - new Create a new Stylus project - init Initializes a Stylus project in the current directory - export-abi Export a Solidity ABI - activate Activate an already deployed contract [aliases: a] - cache Cache a contract using the Stylus CacheManager for Arbitrum chains - check Check a contract [aliases: c] - deploy Deploy a contract [aliases: d] - verify Verify the deployment of a Stylus contract [aliases: v] - cgen Generate c code bindings for a Stylus contract - replay Replay a transaction in gdb [aliases: r] - trace Trace a transaction [aliases: t] - help Print this message or the help of the given command(s) - -Options: - -h, --help Print help - -V, --version Print version +#### Deploy a contract + +```shell +cargo stylus deploy --RPC-endpoint http://localhost:8547 --private-key-path /path/to/private-key --max-fee-per-gas-gwei 100 ``` -Cargo Stylus Commands +#### Cache a contract using the Stylus CacheManager for Arbitrum chains -| Command | Description | Options | -|---------|-----------------------------|---------------------------------| -| new | Create a new Stylus project | • name: Project name (required) | -• --minimal: Create a minimal contract | -| init | Initialize a Stylus project in current directory | • --minimal: Create a minimal contract | -| export-abi | Export a Solidity ABI | • --output: Output file (defaults to stdout) -• --json: Write JSON ABI using solc | -| activate | Activate an already deployed contract | • --address: Contract address to activate -• --data-fee-bump-percent: Percent to bump estimated fee (default 20%) -• --estimate-gas: Only estimate gas without sending tx | -| cache | Cache contract using Stylus CacheManager | Subcommands: -• bid: Place bid on contract -• status: Check contract status -• suggest-bid: Get suggested minimum bid | -| check | Check a contract | • --wasm-file: WASM to check -• --contract-address: Deploy address | -| deploy | Deploy a contract | • --estimate-gas: Only perform estimation -• --no-verify: Skip reproducible container -• --cargo-stylus-version: Version for Docker image | -| verify | Verify contract deployment | • --deployment-tx: Hash of deployment tx -• --no-verify: Skip reproducible container -• --cargo-stylus-version: Version for Docker image | -| cgen | Generate C code bindings | • input: Input file path -• out_dir: Output directory path | -| replay | Replay transaction in gdb | • --stable-rust: Use stable Rust -• --child: Child process flag | -| trace | Trace a transaction | • --endpoint: RPC endpoint -• --tx: Transaction hash -• --project: Project path -• --use-native-tracer: Use native tracer | - - -Common Options -These options are available across multiple commands: -| Option | Description | -|--------|-------------| -| --endpoint | Arbitrum RPC endpoint (default: http://localhost:8547) | -| --verbose | Print debug info | -| --source-files-for-project-hash | Paths to source files for project hash | -| --max-fee-per-gas-gwei | Optional max fee per gas in gwei | -Authentication Options -Available for commands that interact with the blockchain: +```shell +cargo stylus cache bid --address 0x1234567890123456789012345678901234567890 +``` -| Option | Description | -|--------|-------------| -| --private-key-path | Path to file containing hex-encoded private key | -| --private-key | Private key as hex string (exposes to shell history) | -| --keystore-path | Path to Ethereum wallet keystore file | -| --keystore-password-path | Keystore password file path | +#### Verify a contract deployment +```shell +cargo stylus verify --deployment-tx 0x1234567890123456789012345678901234567890 +``` Feel free to explore the [Stylus Rust SDK reference](./reference/overview) for more information on using Stylus in your Arbitrum projects. + + + + + + + + + + + + + + + + + + + + + + + + + From 39b80e1a8abbb2bc41ffcfc8a4f4e7c65bcba9ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20Blanchemain?= Date: Thu, 21 Nov 2024 21:48:32 -0800 Subject: [PATCH 4/7] fix: reformat --- arbitrum-docs/stylus/using-stylus-cli.mdx | 62 +++++++++++------------ 1 file changed, 30 insertions(+), 32 deletions(-) diff --git a/arbitrum-docs/stylus/using-stylus-cli.mdx b/arbitrum-docs/stylus/using-stylus-cli.mdx index 3cd85439d..0123dac92 100644 --- a/arbitrum-docs/stylus/using-stylus-cli.mdx +++ b/arbitrum-docs/stylus/using-stylus-cli.mdx @@ -12,8 +12,6 @@ This guide will get you started using [cargo stylus](https://github.com/Offchain It is available as a plugin to the standard cargo tool used for developing Rust programs. - - ### Installing cargo stylus #### Prerequisites @@ -43,42 +41,41 @@ You can verify that cargo stylus is installed by running `cargo stylus -V` in yo #### Cargo Stylus Commands -| Command | Description | Options | -|---------|-------------|----------| -| new | Create a new Stylus project | • name: Project name (required)
• --minimal: Create a minimal contract | -| init | Initialize a Stylus project in current directory | • --minimal: Create a minimal contract | -| export-abi | Export a Solidity ABI | • --output: Output file (defaults to stdout)
• --json: Write JSON ABI using solc | -| activate | Activate an already deployed contract | • --address: Contract address to activate
• --data-fee-bump-percent: Percent to bump estimated fee (default 20%)
• --estimate-gas: Only estimate gas without sending tx | -| cache | Cache contract using Stylus CacheManager | Subcommands:
• bid: Place bid on contract
• status: Check contract status
• suggest-bid: Get suggested minimum bid | -| check | Check a contract | • --wasm-file: WASM to check
• --contract-address: Deploy address | -| deploy | Deploy a contract | • --estimate-gas: Only perform estimation
• --no-verify: Skip reproducible container
• --cargo-stylus-version: Version for Docker image | -| verify | Verify contract deployment | • --deployment-tx: Hash of deployment tx
• --no-verify: Skip reproducible container
• --cargo-stylus-version: Version for Docker image | -| cgen | Generate C code bindings | • input: Input file path
• out_dir: Output directory path | -| replay | Replay transaction in gdb | • --stable-rust: Use stable Rust
• --child: Child process flag | -| trace | Trace a transaction | • --endpoint: RPC endpoint
• --tx: Transaction hash
• --project: Project path
• --use-native-tracer: Use native tracer | +| Command | Description | Options | +| ---------- | ------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| new | Create a new Stylus project | • name: Project name (required)
• --minimal: Create a minimal contract | +| init | Initialize a Stylus project in current directory | • --minimal: Create a minimal contract | +| export-abi | Export a Solidity ABI | • --output: Output file (defaults to stdout)
• --json: Write JSON ABI using solc | +| activate | Activate an already deployed contract | • --address: Contract address to activate
• --data-fee-bump-percent: Percent to bump estimated fee (default 20%)
• --estimate-gas: Only estimate gas without sending tx | +| cache | Cache contract using Stylus CacheManager | Subcommands:
• bid: Place bid on contract
• status: Check contract status
• suggest-bid: Get suggested minimum bid | +| check | Check a contract | • --wasm-file: WASM to check
• --contract-address: Deploy address | +| deploy | Deploy a contract | • --estimate-gas: Only perform estimation
• --no-verify: Skip reproducible container
• --cargo-stylus-version: Version for Docker image | +| verify | Verify contract deployment | • --deployment-tx: Hash of deployment tx
• --no-verify: Skip reproducible container
• --cargo-stylus-version: Version for Docker image | +| cgen | Generate C code bindings | • input: Input file path
• out_dir: Output directory path | +| replay | Replay transaction in gdb | • --stable-rust: Use stable Rust
• --child: Child process flag | +| trace | Trace a transaction | • --endpoint: RPC endpoint
• --tx: Transaction hash
• --project: Project path
• --use-native-tracer: Use native tracer | ##### Common Options - These options are available across multiple commands: +These options are available across multiple commands: -| Option | Description | -|--------|-------------| -| --endpoint | Arbitrum RPC endpoint (default: http://localhost:8547) | -| --verbose | Print debug info | -| --source-files-for-project-hash | Paths to source files for project hash | -| --max-fee-per-gas-gwei | Optional max fee per gas in gwei | +| Option | Description | +| ------------------------------- | ------------------------------------------------------ | +| --endpoint | Arbitrum RPC endpoint (default: http://localhost:8547) | +| --verbose | Print debug info | +| --source-files-for-project-hash | Paths to source files for project hash | +| --max-fee-per-gas-gwei | Optional max fee per gas in gwei | ##### Authentication Options Available for commands involving transactions: -| Option | Description | -|--------|-------------| -| --private-key-path | Path to file containing hex-encoded private key | -| --private-key | Private key as hex string (exposes to shell history) | -| --keystore-path | Path to Ethereum wallet keystore file | -| --keystore-password-path | Keystore password file path | - +| Option | Description | +| ------------------------ | ---------------------------------------------------- | +| --private-key-path | Path to file containing hex-encoded private key | +| --private-key | Private key as hex string (exposes to shell history) | +| --keystore-path | Path to Ethereum wallet keystore file | +| --keystore-password-path | Keystore password file path | ### Example Usage @@ -112,7 +109,6 @@ cargo stylus activate --address 0x1234567890123456789012345678901234567890 cargo stylus deploy --RPC-endpoint http://localhost:8547 --private-key-path /path/to/private-key --max-fee-per-gas-gwei 100 ``` - #### Cache a contract using the Stylus CacheManager for Arbitrum chains ```shell @@ -125,11 +121,10 @@ cargo stylus cache bid --address 0x1234567890123456789012345678901234567890 cargo stylus verify --deployment-tx 0x1234567890123456789012345678901234567890 ``` - Feel free to explore the [Stylus Rust SDK reference](./reference/overview) for more information on using Stylus in your Arbitrum projects. - + @@ -149,6 +144,9 @@ Feel free to explore the [Stylus Rust SDK reference](./reference/overview) for m + + + From 5e6c3a1ff92e3b46fb53b198ac60c1950d2df58f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20Blanchemain?= Date: Thu, 21 Nov 2024 22:18:56 -0800 Subject: [PATCH 5/7] fix: content re-shuffle --- arbitrum-docs/stylus/using-stylus-cli.mdx | 74 ++++++++++------------- 1 file changed, 33 insertions(+), 41 deletions(-) diff --git a/arbitrum-docs/stylus/using-stylus-cli.mdx b/arbitrum-docs/stylus/using-stylus-cli.mdx index 0123dac92..344a5bbaf 100644 --- a/arbitrum-docs/stylus/using-stylus-cli.mdx +++ b/arbitrum-docs/stylus/using-stylus-cli.mdx @@ -8,9 +8,11 @@ sidebar_position: 2 target_audience: Developers writing Stylus contracts in Rust using Stylus --- -This guide will get you started using [cargo stylus](https://github.com/OffchainLabs/cargo-stylus) is a CLI toolkit built to facilitate the development of Stylus contracts. +This guide will get you started using [cargo stylus](https://github.com/OffchainLabs/cargo-stylus), a CLI toolkit to help developers manage, compile, and optimize their Stylus contracts efficiently. -It is available as a plugin to the standard cargo tool used for developing Rust programs. +This overview is meant to help discover cargo stylus' tools and learn to use them effectively. + +Cargo stylus is available as a plugin to the standard cargo tool used for developing Rust programs. ### Installing cargo stylus @@ -39,7 +41,7 @@ You can verify that cargo stylus is installed by running `cargo stylus -V` in yo ### Using cargo stylus -#### Cargo Stylus Commands +#### Cargo Stylus commands reference | Command | Description | Options | | ---------- | ------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | @@ -55,7 +57,7 @@ You can verify that cargo stylus is installed by running `cargo stylus -V` in yo | replay | Replay transaction in gdb | • --stable-rust: Use stable Rust
• --child: Child process flag | | trace | Trace a transaction | • --endpoint: RPC endpoint
• --tx: Transaction hash
• --project: Project path
• --use-native-tracer: Use native tracer | -##### Common Options +##### Common options These options are available across multiple commands: @@ -66,7 +68,7 @@ These options are available across multiple commands: | --source-files-for-project-hash | Paths to source files for project hash | | --max-fee-per-gas-gwei | Optional max fee per gas in gwei | -##### Authentication Options +##### Authentication options Available for commands involving transactions: @@ -77,7 +79,7 @@ Available for commands involving transactions: | --keystore-path | Path to Ethereum wallet keystore file | | --keystore-password-path | Keystore password file path | -### Example Usage +### Example usage #### Create a new Stylus project @@ -97,56 +99,46 @@ cargo stylus init cargo stylus export-abi --output abi.json ``` -#### Activate an already deployed contract +#### Cache a contract using the Stylus CacheManager for Arbitrum chains ```shell -cargo stylus activate --address 0x1234567890123456789012345678901234567890 +cargo stylus cache bid --address 0x1234567890123456789012345678901234567890 ``` -#### Deploy a contract +#### Additional resources -```shell -cargo stylus deploy --RPC-endpoint http://localhost:8547 --private-key-path /path/to/private-key --max-fee-per-gas-gwei 100 -``` +For more advanced usage and detailed guides, refer to the following resources: -#### Cache a contract using the Stylus CacheManager for Arbitrum chains +##### Optimize WASM binaries -```shell -cargo stylus cache bid --address 0x1234567890123456789012345678901234567890 -``` +The `cargo-stylus` tool allows you to optimize WebAssembly (WASM) binaries, ensuring that your contracts are as efficient as possible. -#### Verify a contract deployment +###### [Learn how to optimize WASM binaries](https://docs.arbitrum.io/stylus/how-tos/optimizing-binaries) -```shell -cargo stylus verify --deployment-tx 0x1234567890123456789012345678901234567890 -``` +##### Debug Stylus transactions + +Gain insights into your Stylus contracts by debugging transactions. + +###### [Debug Stylus transactions](https://docs.arbitrum.io/stylus/how-tos/debug-stylus-transactions) + +A guide to debugging transactions, helping you identify and fix issues. -Feel free to explore the [Stylus Rust SDK reference](./reference/overview) for more information on using Stylus in your Arbitrum projects. +##### Verify contracts - +Ensure that your Stylus contracts are correctly verified. - +###### [Verify contracts](https://docs.arbitrum.io/stylus/how-tos/verify-contracts) - +Step-by-step instructions on how to verify your contracts using `cargo-stylus`. - - - - - - - - - - - - - +###### [Optimize WASM binaries](https://docs.arbitrum.io/stylus/how-tos/optimizing-binaries) +###### [Troubleshooting](https://docs.arbitrum.io/stylus/troubleshooting-building-stylus) +###### [Run a Stylus dev node](https://docs.arbitrum.io/run-arbitrum-node/run-local-dev-node) - +This overview page serves as the starting point for mastering the CLI tools available for Stylus development. From optimizing your contracts to debugging and verifying them, the `cargo-stylus` toolset is integral to a smooth development experience. - +#### Source code repository - +The source code for `cargo-stylus` is available on GitHub. Explore the code, contribute, or use it as a reference. - +###### [cargo-stylus repository](https://github.com/OffchainLabs/stylus):** Visit the GitHub repository for more information. From a1e6143dab3e714429a7e2ba9a3e97572b8434d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20Blanchemain?= Date: Thu, 21 Nov 2024 22:24:59 -0800 Subject: [PATCH 6/7] fix: re-format + simplify --- arbitrum-docs/stylus/using-stylus-cli.mdx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/arbitrum-docs/stylus/using-stylus-cli.mdx b/arbitrum-docs/stylus/using-stylus-cli.mdx index 344a5bbaf..05d7cd3e8 100644 --- a/arbitrum-docs/stylus/using-stylus-cli.mdx +++ b/arbitrum-docs/stylus/using-stylus-cli.mdx @@ -8,14 +8,14 @@ sidebar_position: 2 target_audience: Developers writing Stylus contracts in Rust using Stylus --- -This guide will get you started using [cargo stylus](https://github.com/OffchainLabs/cargo-stylus), a CLI toolkit to help developers manage, compile, and optimize their Stylus contracts efficiently. +This guide will get you started using [cargo stylus](https://github.com/OffchainLabs/cargo-stylus), a CLI toolkit to help developers manage, compile, and optimize their Stylus contracts efficiently. This overview is meant to help discover cargo stylus' tools and learn to use them effectively. -Cargo stylus is available as a plugin to the standard cargo tool used for developing Rust programs. - ### Installing cargo stylus +Cargo stylus is available as a plugin to the standard cargo tool used for developing Rust programs. + #### Prerequisites Rust toolchain @@ -132,7 +132,9 @@ Ensure that your Stylus contracts are correctly verified. Step-by-step instructions on how to verify your contracts using `cargo-stylus`. ###### [Optimize WASM binaries](https://docs.arbitrum.io/stylus/how-tos/optimizing-binaries) + ###### [Troubleshooting](https://docs.arbitrum.io/stylus/troubleshooting-building-stylus) + ###### [Run a Stylus dev node](https://docs.arbitrum.io/run-arbitrum-node/run-local-dev-node) This overview page serves as the starting point for mastering the CLI tools available for Stylus development. From optimizing your contracts to debugging and verifying them, the `cargo-stylus` toolset is integral to a smooth development experience. @@ -141,4 +143,4 @@ This overview page serves as the starting point for mastering the CLI tools avai The source code for `cargo-stylus` is available on GitHub. Explore the code, contribute, or use it as a reference. -###### [cargo-stylus repository](https://github.com/OffchainLabs/stylus):** Visit the GitHub repository for more information. +###### [cargo-stylus repository](https://github.com/OffchainLabs/stylus):\*\* Visit the GitHub repository for more information. From fc20392c1e40f5b38f6429db9c173620e1787c1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20Blanchemain?= Date: Thu, 21 Nov 2024 22:43:48 -0800 Subject: [PATCH 7/7] fix: re-format --- arbitrum-docs/stylus/using-stylus-cli.mdx | 72 +++++------------------ 1 file changed, 16 insertions(+), 56 deletions(-) diff --git a/arbitrum-docs/stylus/using-stylus-cli.mdx b/arbitrum-docs/stylus/using-stylus-cli.mdx index 05d7cd3e8..ab2b3fe1b 100644 --- a/arbitrum-docs/stylus/using-stylus-cli.mdx +++ b/arbitrum-docs/stylus/using-stylus-cli.mdx @@ -79,68 +79,28 @@ Available for commands involving transactions: | --keystore-path | Path to Ethereum wallet keystore file | | --keystore-password-path | Keystore password file path | -### Example usage +### Examples usage -#### Create a new Stylus project +| Description | Command | +|--------------------------------------------------------------------|-------------------------------------------------------------------------------| +| Create a new Stylus project | `cargo stylus new my_project` | +| Initialize a Stylus project in the current directory | `cargo stylus init` | +| Export a Solidity ABI | `cargo stylus export-abi --output abi.json` | +| Cache a contract using the Stylus CacheManager for Arbitrum chains | `cargo stylus cache bid --address 0x1234567890123456789012345678901234567890` | -```shell -cargo stylus new my_project -``` - -#### Initialize a Stylus project in the current directory - -```shell -cargo stylus init -``` +#### How-tos -#### Export a Solidity ABI - -```shell -cargo stylus export-abi --output abi.json -``` - -#### Cache a contract using the Stylus CacheManager for Arbitrum chains - -```shell -cargo stylus cache bid --address 0x1234567890123456789012345678901234567890 -``` +| Topic | Description | +|----------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------| +| [Learn how to optimize WASM binaries](https://docs.arbitrum.io/stylus/how-tos/optimizing-binaries) | The `cargo-stylus` tool allows you to optimize WebAssembly (WASM) binaries, ensuring that your contracts are as efficient as possible. | +| [Debug Stylus transactions](https://docs.arbitrum.io/stylus/how-tos/debug-stylus-transactions) | A guide to debugging transactions, helping you identify and fix issues. Gain insights into your Stylus contracts by debugging transactions. | +| [Verify contracts](https://docs.arbitrum.io/stylus/how-tos/verify-contracts) | Ensure that your Stylus contracts are correctly verified. Step-by-step instructions on how to verify your contracts using `cargo-stylus`. | +|[Run a Stylus dev node](https://docs.arbitrum.io/run-arbitrum-node/run-local-dev-node) | Learn how to run a local Arbitrum dev node to test your Stylus contracts. | #### Additional resources -For more advanced usage and detailed guides, refer to the following resources: - -##### Optimize WASM binaries - -The `cargo-stylus` tool allows you to optimize WebAssembly (WASM) binaries, ensuring that your contracts are as efficient as possible. +#### [Troubleshooting](https://docs.arbitrum.io/stylus/troubleshooting-building-stylus): solve the most common issues. -###### [Learn how to optimize WASM binaries](https://docs.arbitrum.io/stylus/how-tos/optimizing-binaries) - -##### Debug Stylus transactions - -Gain insights into your Stylus contracts by debugging transactions. - -###### [Debug Stylus transactions](https://docs.arbitrum.io/stylus/how-tos/debug-stylus-transactions) - -A guide to debugging transactions, helping you identify and fix issues. - -##### Verify contracts - -Ensure that your Stylus contracts are correctly verified. - -###### [Verify contracts](https://docs.arbitrum.io/stylus/how-tos/verify-contracts) - -Step-by-step instructions on how to verify your contracts using `cargo-stylus`. - -###### [Optimize WASM binaries](https://docs.arbitrum.io/stylus/how-tos/optimizing-binaries) - -###### [Troubleshooting](https://docs.arbitrum.io/stylus/troubleshooting-building-stylus) - -###### [Run a Stylus dev node](https://docs.arbitrum.io/run-arbitrum-node/run-local-dev-node) +#### [cargo-stylus repository](https://github.com/OffchainLabs/stylus): consult cargo stylus' source code. This overview page serves as the starting point for mastering the CLI tools available for Stylus development. From optimizing your contracts to debugging and verifying them, the `cargo-stylus` toolset is integral to a smooth development experience. - -#### Source code repository - -The source code for `cargo-stylus` is available on GitHub. Explore the code, contribute, or use it as a reference. - -###### [cargo-stylus repository](https://github.com/OffchainLabs/stylus):\*\* Visit the GitHub repository for more information.