Skip to content

Commit ab00a78

Browse files
0xLuccadawnkelly09
andauthored
Apply suggestions from code review
Co-authored-by: Dawn Kelly <[email protected]>
1 parent 40b3e11 commit ab00a78

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

develop/toolkit/api-libraries/subxt.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,21 @@ description: Subxt is a Rust library for type-safe interaction with Polkadot SDK
77

88
## Introduction
99

10-
subxt is a Rust library designed to interact with Polkadot SDK-based blockchains. It provides a type-safe interface for submitting transactions, querying on-chain state, and performing other blockchain interactions. By leveraging Rusts strong type system, subxt ensures that your code is validated at compile time, reducing runtime errors and improving reliability.
10+
subxt is a Rust library designed to interact with Polkadot SDK-based blockchains. It provides a type-safe interface for submitting transactions, querying on-chain state, and performing other blockchain interactions. By leveraging Rust's strong type system, subxt ensures that your code is validated at compile time, reducing runtime errors and improving reliability.
1111

1212
## Prerequisites
1313

1414
Before using subxt, ensure you have the following requirements:
1515

1616
- Rust and Cargo installed on your system. You can install them using [Rustup](https://rustup.rs/){target=\_blank}
17-
- A Rust project initialized. If you dont have one, create it with:
17+
- A Rust project initialized. If you don't have one, create it with:
1818
```bash
1919
cargo new my_project && cd my_project
2020
```
2121

2222
## Installation
2323

24-
To use subxt in your project, you need to install the necessary dependencies. Each plays a specific role in enabling interaction with the blockchain:
24+
To use subxt in your project, you must install the necessary dependencies. Each plays a specific role in enabling interaction with the blockchain:
2525

2626
1. **Install the subxt CLI** - [`subxt-cli`](https://crates.io/crates/subxt-cli){target=\_blank} is a command-line tool that provides utilities for working with Polkadot SDK metadata. In the context of subxt, it is essential to download chain metadata, which is required to generate type-safe Rust interfaces for interacting with the blockchain. Install it using:
2727

@@ -43,7 +43,7 @@ To use subxt in your project, you need to install the necessary dependencies. Ea
4343
cargo add subxt-signer
4444
```
4545

46-
- **[tokio](https://crates.io/crates/tokio){target=\_blank}** - an asynchronous runtime for Rust. Since blockchain operations are async, Tokio enables efficient handling of network requests. The `rt` feature enables Tokios runtime, including the current-thread single-threaded scheduler, necessary for async execution. The `macros` feature provides procedural macros like `#[tokio::main]` to simplify runtime setup
46+
- **[tokio](https://crates.io/crates/tokio){target=\_blank}** - an asynchronous runtime for Rust. Since blockchain operations are async, Tokio enables the efficient handling of network requests. The `rt` feature enables Tokio's runtime, including the current-thread single-threaded scheduler, which is necessary for async execution. The `macros` feature provides procedural macros like `#[tokio::main]` to simplify runtime setup
4747
4848
```bash
4949
cargo add tokio --features rt,macros
@@ -59,23 +59,23 @@ To use subxt in your project, you need to install the necessary dependencies. Ea
5959
6060
This guide will walk you through the fundamental operations of subxt, from setting up your environment to executing transactions and querying blockchain state.
6161
62-
### Downloading Chain Metadata
62+
### Download Chain Metadata
6363
6464
Before interacting with a blockchain, you need to retrieve its metadata. This metadata defines storage structures, extrinsics, and other runtime details. Use the `subxt-cli` tool to download the metadata, replacing `INSERT_NODE_URL` with the URL of the node you want to interact with:
6565
6666
```bash
6767
subxt metadata --url INSERT_NODE_URL > polkadot_metadata.scale
6868
```
6969
70-
### Generating Type-Safe Interfaces
70+
### Generate Type-Safe Interfaces
7171
7272
Use the `#[subxt::subxt]` macro to generate a type-safe Rust interface from the downloaded metadata:
7373
7474
```rust
7575
--8<-- 'code/develop/toolkit/api-libraries/subxt/subxt.rs:6:8'
7676
```
7777
78-
Once subxt interfaces are generated, you can interact with your node in the following ways:
78+
Once subxt interfaces are generated, you can interact with your node in the following ways. You can use the links below to view the related subxt documentation:
7979
8080
- **[Transactions](https://docs.rs/subxt/latest/subxt/book/usage/transactions/index.html){target=\_blank}** - builds and submits transactions, monitors their inclusion in blocks, and retrieves associated events
8181
- **[Storage](https://docs.rs/subxt/latest/subxt/book/usage/storage/index.html){target=\_blank}** - enables querying of node storage data
@@ -86,7 +86,7 @@ Once subxt interfaces are generated, you can interact with your node in the foll
8686
- **[Custom values](https://docs.rs/subxt/latest/subxt/book/usage/custom_values/index.html){target=\_blank}** - accesses "custom values" contained within metadata
8787
- **[Raw RPC calls](https://docs.rs/subxt/latest/subxt/book/usage/rpc/index.html){target=\_blank}** - facilitates raw RPC requests to compatible nodes
8888
89-
### Initializing the Subxt client
89+
### Initialize the Subxt client
9090
9191
To interact with a blockchain node using subxt, create an asynchronous main function and initialize the client. Replace `INSERT_NODE_URL` with the URL of your target node:
9292
@@ -96,7 +96,7 @@ To interact with a blockchain node using subxt, create an asynchronous main func
9696
--8<-- 'code/develop/toolkit/api-libraries/subxt/subxt.rs:73:75'
9797
```
9898
99-
### Reading Chain Data
99+
### Read Chain Data
100100
101101
subxt provides multiple ways to access on-chain data:
102102
@@ -116,14 +116,14 @@ subxt provides multiple ways to access on-chain data:
116116
--8<-- 'code/develop/toolkit/api-libraries/subxt/subxt.rs:26:42'
117117
```
118118
119-
### Submitting Transasctions
119+
### Submit Transactions
120120
121-
To submit a transaction, you need to construct an extrinsic, sign it with your private key, and send it to the blockchain. Replace `INSERT_DEST_ADDRESS` with the recipients address, `INSERT_AMOUNT` with the amount to transfer, and `INSERT_SECRET_PHRASE` with the senders mnemonic phrase:
121+
To submit a transaction, you must construct an extrinsic, sign it with your private key, and send it to the blockchain. Replace `INSERT_DEST_ADDRESS` with the recipient's address, `INSERT_AMOUNT` with the amount to transfer, and `INSERT_SECRET_PHRASE` with the sender's mnemonic phrase:
122122
123123
```rust
124124
--8<-- 'code/develop/toolkit/api-libraries/subxt/subxt.rs:44:72'
125125
```
126126
127127
## Where to Go Next
128128
129-
Now that you've covered the basics, dive into the official [subxt documentation](https://docs.rs/subxt/latest/subxt/book/index.html){target=\_blank} for comprehensive reference materials and advanced features.
129+
Now that you've covered the basics dive into the official [subxt documentation](https://docs.rs/subxt/latest/subxt/book/index.html){target=\_blank} for comprehensive reference materials and advanced features.

0 commit comments

Comments
 (0)