diff --git a/.gitignore b/.gitignore
index d0a971f87..c9de686e2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -38,11 +38,4 @@ yarn-error.log*
next-env.d.ts
# vscode
-.vscode/
-
-# pagefind
-public/_pagefind
-
-# sitemap
-public/sitemap.xml
-public/sitemap-0.xml
\ No newline at end of file
+.vscode/
\ No newline at end of file
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 7554e5336..2e8d145cc 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -1,14 +1,13 @@
# Contribution Guidelines
-All pull requests and issues
+The Documentation team at Avail are the primary maintainers of the Avail Documentation and will review all issues and pull requests created in this repository.
> ℹ️ Please make sure to create an issue outlining your feedback/content request for the docs before creating a PR.
> PRs created without approval will be closed. We are open to technical articles on a wide variety of topics related to Avail and Web3 in general. If you have something in mind, please feel free to jump in with an issue on the repo.
-
-Contribute Changes directly from the Avail Documentation Website
+## How to Contribute Changes via the Avail Documentation Website
-Contributing to the Avail Documentation using Github's UIis simple. You'll need a GitHub account and a basic understanding of Markdown syntax to get started.
+Contributing to the Avail Documentation is simple. You'll need a GitHub account and a basic understanding of Markdown syntax to get started.
1. **Locate the Page**: Visit the [Avail Documentation page](https://docs.availproject.org/) you wish to edit.
2. **Edit Link**: Click on the **Edit this page** link. This will redirect you to the corresponding Markdown file on GitHub.
@@ -21,19 +20,15 @@ Contributing to the Avail Documentation using Github's UIis simple. You'll need
> See [GitHub Docs on Linking a Pull Request to an Issue](https://docs.github.com/en/free-pro-team@latest/github/managing-your-work-on-github/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword) for guidance.
8. **Additional Information**: Provide a concise summary of the changes you've made. Include screenshots or references if applicable.
-
9. **Submit**: Click **Propose changes** to finalize your pull request. This will create a new branch in your fork.
-
-
-
-
-Contribute Changes by setting up a local development environment
+## How to Locally Run the Avail Documentation
> **Prerequisites**:
>
-> - [Node.js](https://nodejs.org/en/download/) (version >= 22 is recommended)
-> - [pnpm](https://pnpm.io/installation)
+> - [Node.js](https://nodejs.org/en/download/) (version >= 16.14.1)
+> - [pnpm](https://pnpm.io/installation)
+> **Note for macOS Users**: Xcode and Command Line Tools are required.
1. **Fork the repository**
@@ -42,7 +37,7 @@ Contributing to the Avail Documentation using Github's UIis simple. You'll need
2. **Clone your fork**
```bash
- git clone https://github.com//docs.git
+ git clone https://github.com/availproject/docs.git
```
This will create a repo named `docs` in your current directory.
@@ -53,8 +48,25 @@ Contributing to the Avail Documentation using Github's UIis simple. You'll need
cd docs
```
+4. **Add Upstream Remote**
+
+ > Refer to [GitHub Docs: Configuring a remote for a fork](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/configuring-a-remote-for-a-fork).
+
+ ```bash
+ git remote add upstream https://github.com/availproject/docs
+ ```
+
> ℹ️ You can check if the upstream was added correctly by running `git remote -v`
+5. **Sync Your Fork**
+
+ > See [GitHub Docs: Syncing a fork](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/syncing-a-fork).
+
+ ```bash
+ git checkout main
+ git fetch upstream
+ git merge upstream/main
+ ```
6. **Install Dependencies**
@@ -62,6 +74,8 @@ Contributing to the Avail Documentation using Github's UIis simple. You'll need
pnpm install
```
+ The site is built using Nextra.
+
7. **Run the Docs Locally**
```bash
@@ -92,10 +106,8 @@ Once you are done with all the changes, save all you files and run:
git push origin main
```
- Now you can use the Github UI to create a PR from your forked repository to the `main` branch of the `availproject/docs` repository.
-
-
+ Now you can use the Github UI to create a PR from your forked repository to the `staging` branch of the upstream repository.
## License
-The Avail Project Developer Documentation is licensed under the [MIT License](./LICENSE) free software license.
+The Avail Project Developer Documentation is licensed under the [MIT License](./LICENSE) free software license.### How to Contribute Changes via the Avail Documentation Website.
diff --git a/README.md b/README.md
index 9fc76464b..09900c071 100644
--- a/README.md
+++ b/README.md
@@ -2,46 +2,100 @@
-# Avail Documentation
+
+
Avail Project Developer Documentation
+
-> The Unification Layer for Web3
+[](#contributors-)
-This is the official documentation repository for Avail.
-You can find the latest documentation at [docs.availproject.org](https://docs.availproject.org/).
+
+
The Essential Platform for Modern Blockchains
-## Development
+
-- Avail's docs are built using [Nextra V4](https://nextra.site/docs)
-- Nextra V4 in turn is based on [Next JS 15](https://nextjs.org/docs), which means this repo's directory structure is based on the app router.
+> ℹ️ We are in the process of putting out a comprehensive README following a docs migration. For contribution guidelines, check out the [Contributing Guide](./CONTRIBUTING.md)
-### Set up the project locally
-
-1. Clone the repository locally:
-
-```bash
-git clone https://github.com/availproject/docs.git
-```
-
-2. Install the dependencies:
-
-```bash
-pnpm install
-```
-
-3. Run the development server:
-
-```bash
-pnpm dev
-```
+
+ Welcome to the Avail Project Developer Documentation, your go-to resource for all things related to data availability and modular blockchain development. Designed with a focus on community collaboration, this repository aims to provide the most accurate, comprehensive, and up-to-date information for anyone interested in learning about, contributing to, or maintaining projects within the Avail ecosystem.
+
-4. By default, the docs will be available at [http://localhost:3000](http://localhost:3000).
+
+
+- [Key Repositories](#key-repositories)
+- [Configuration Guide](#configuration-guide)
+ - [Static-Site Generator](#static-site-generator)
+- [Contributing](#contributing)
+- [License](#license)
+
+
+
+Avail provides a secure, trust-minimized base layer designed for high data availability, forming the cornerstone of next-generation, scalable applications. Its core features include:
+
+- **Data Blob Indexing**: Streamlines data indexing by associating transaction data with specific application IDs.
+- **Erasure Encoding**: Enhances data resilience, making it more challenging for nodes to withhold information.
+- **KZG Polynomial Commitments**: Guarantees data presence in the block header.
+- **Decentralized Network of Validators**: Targets a network of up to 1,000 external validators to minimize centralization risks.
+- **Validity Proofs**: Enables light clients to instantly confirm state correctness and data availability upon finalization.
+
+Leveraging Data Availability Sampling, Avail's light client network ensures robust data availability. With an increasing number of light clients, Avail supports larger blocks, thereby unlocking substantial scaling capabilities for blockchain technologies.
+
+Start learning about Avail [here](https://docs.availproject.org/about/introduction/).
+
+## Key Repositories
+
+Below is a curated list of GitHub Repositories part of the Avail Project.
+
+
+Get Started
+
+| Repository Name & Link | Description |
+| ----------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
+| [Reference Document](https://github.com/availproject/data-availability/blob/93c547ce4efce3e992b573179a8d22b3657fdcee/reference%20document/Avail%20Reference%20Paper%20v2.1%206%20Nov%202024.pdf) | Comprehensive document outlining the rationale, design decisions, and theoretical foundations. |
+| [Avail Node](https://github.com/availproject/avail) | Repository for the Avail node implementation, built using Substrate. |
+| [Light Client](https://github.com/availproject/avail-light) | Light client designed for verifying data availability proofs on Avail. |
+| [Explorer](https://github.com/availproject/avail-apps) | Implementation repository for the Avail explorer, built using PolkadotJS Apps. |
+| [Tests](https://github.com/availproject/avail-test) | Repository for end-to-end tests designed to validate Avail's functionalities. |
+
+
+
+
+All Repos
+
+| Category | Repository Name | Description |
+| ------------------- | ------------------------------------------------------------------------------------------------ | -------------------------------------------------------- |
+| **Core Components** | [Avail](https://github.com/availproject/avail) | Main DA Node for the Avail project. |
+| | [Avail Core](https://github.com/availproject/avail-core) | Core components for Avail's DA layer. |
+| **Light Client** | [Avail Light](https://github.com/availproject/avail-light) | Light client for Avail. |
+| Relay for Avail Light client. |
+| | [Light Client Web](https://github.com/availproject/light-client-web) | Web version of Avail's light client. |
+| | [Avail light client Flutter App](https://github.com/availproject/avail-light-client-flutter-app) | Flutter app for Avail's light client. |
+| | [Avail LC Android Lib](https://github.com/availproject/avail-lc-android-lib) | Android library for Avail light client. |
+| **Applications** | [Avail Apps](https://github.com/availproject/avail-apps) | Repository for applications built on Avail. |
+| | [Avail JS](https://github.com/availproject/avail-js) | JavaScript library for Avail; Fork of PolkadotJS |
+| | [Avail Staking Dashboard](https://github.com/availproject/avail-staking-dashboard) | Dashboard for staking on Avail. |
+| | [MetaMask Snap Avail](https://github.com/availproject/metamask-snap-avail) | MetaMask Snap plugin for Avail. |
+| **Substrate** | [Go Substrate RPC Client](https://github.com/availproject/go-substrate-rpc-client) | RPC client for Substrate integration. |
+| | [Substrate](https://github.com/availproject/substrate) | Fork of Substrate for Avail. |
+| **Explorations** | [Avail Uncharted](https://github.com/availproject/avail-explorations) | Experimental features and research. |
+| | [Validium Node](https://github.com/availproject/validium-node) | Polygon zkEVM Node implementation for Validium on Avail. |
+| | [Validium Contracts](https://github.com/availproject/validium-contracts) | Polygon zkEVM Contracts for Validium on Avail. |
+| | [Validium Bridge Service](https://github.com/availproject/validium-bridge-service) | Bridge service for Polygon zkEVM Validium on Avail. |
+| | [Op EVM](https://github.com/availproject/op-evm) | OpEVM implementation on Avail. |
+| | [Op EVM Contracts](https://github.com/availproject/op-evm-contracts) | OpEVM contracts on Avail. |
+| | [Avail OP Stack Adapter](https://github.com/availproject/avail-op-stack-adapter) | DA Adapter for OP Stack. |
+| | [Avail Sovereign DA Adapter](https://github.com/availproject/avail-sovereign-da-adapter) | DA adapter for Sovereign SDK. |
+| | [Sovereign SDK](https://github.com/availproject/sovereign-sdk) | SDK for Sovereign Rollups on Avail. |
+| | [Nomad Config](https://github.com/availproject/nomad-config) | Configuration for Nomad in the Avail ecosystem. |
+| | [Nomad Agents](https://github.com/availproject/nomad-agents) | Agents for Nomad in the Avail ecosystem. |
+| | [ZkNFT](https://github.com/availproject/zknft) | Zero-Knowledge NFTs on Avail. |
+| **Tooling** | [CLI](https://github.com/availproject/cli) | CLI tool for Avail. |
+| | [AvailUp](https://github.com/availproject/availup) | Standalone script for easy Avail network setup via CLI. |
+| | [Avail Indexer](https://github.com/availproject/avail-indexer) | Indexer for the Avail network. |
+| **Documents** | [RFCs](https://github.com/availproject/RFCs) | Repository for Avail Request for Comments and proposals. |
+| | [Incident Reports](https://github.com/availproject/incident-reports) | Repository for incident reports in the Avail ecosystem. |
+
+
## Contributing
-We welcome community contributions to Avail's docs!
-
Please check out the [Contributing Guide](./CONTRIBUTING.md) for a detailed primer on how to contribute to the Avail documentation.
-
-## License
-
-The Avail Project Developer Documentation is licensed under the [MIT License](./LICENSE) free software license.
diff --git a/app/_meta.ts b/app/_meta.ts
index cfb6fd72c..f56995af9 100644
--- a/app/_meta.ts
+++ b/app/_meta.ts
@@ -19,16 +19,6 @@ export default {
title: "API Reference",
},
- 'Versions': {
- type: 'menu',
- title: 'Versions',
- items: {
- _1:{
- title: 'Avail old API docs',
- href: 'http://old-api.docs.availproject.org/',
- },
- },
- },
};
diff --git a/app/api-reference/_meta.ts b/app/api-reference/_meta.ts
index 904a9ec61..b27ce11bd 100644
--- a/app/api-reference/_meta.ts
+++ b/app/api-reference/_meta.ts
@@ -8,34 +8,21 @@ export default {
display: "hidden",
},
- "avail-node-api": "Avail Node API",
+ "avail-node-api": "Avail node API reference",
"---": {
type: "separator",
},
- "avail-lc-api": "Avail Light Client API",
+ "avail-lc-api": "Avail light client API reference",
"----": {
type: "separator",
},
- "avail-bridge-api": "Avail Bridge API",
+ "avail-bridge-api": "Avail bridge API reference",
"------": {
type: "separator",
},
-
- "avail-nexus-sdk": "Avail Nexus SDK API",
-
- "-------": {
- type: "separator",
- },
-
- "avail-turbo-da-api": "Turbo DA API",
-
- "--------": {
- type: "separator",
- }
-
};
diff --git a/app/api-reference/avail-bridge-api/avail-head/page.mdx b/app/api-reference/avail-bridge-api/avail-head/page.mdx
index 764346959..20a89d5d5 100644
--- a/app/api-reference/avail-bridge-api/avail-head/page.mdx
+++ b/app/api-reference/avail-bridge-api/avail-head/page.mdx
@@ -1,6 +1,3 @@
----
-image: '/img/docs-link-preview.png'
----
import { Tabs } from 'nextra/components'
import { Callout } from 'nextra/components'
@@ -18,7 +15,7 @@ import { Callout } from 'nextra/components'
-```bash filename="CURL"
+```sh
curl https://turing-bridge-api.avail.so/avl/head
```
@@ -34,4 +31,4 @@ curl https://turing-bridge-api.avail.so/avl/head
"start":488581
}
}
-```
+```
\ No newline at end of file
diff --git a/app/api-reference/avail-bridge-api/eth-head/page.mdx b/app/api-reference/avail-bridge-api/eth-head/page.mdx
index 5774f426c..7738862f0 100644
--- a/app/api-reference/avail-bridge-api/eth-head/page.mdx
+++ b/app/api-reference/avail-bridge-api/eth-head/page.mdx
@@ -1,7 +1,3 @@
----
-image: '/img/docs-link-preview.png'
----
-
import { Tabs } from 'nextra/components'
import { Callout } from 'nextra/components'
@@ -19,7 +15,7 @@ import { Callout } from 'nextra/components'
-```bash filename="CURL"
+```sh
curl https://turing-bridge-api.avail.so/eth/head
```
@@ -34,4 +30,4 @@ curl https://turing-bridge-api.avail.so/eth/head
"timestamp":1709191840,
"timestampDiff":1716
}
-```
+```
\ No newline at end of file
diff --git a/app/api-reference/avail-bridge-api/info/page.mdx b/app/api-reference/avail-bridge-api/info/page.mdx
index baa3b353d..fdf87058a 100644
--- a/app/api-reference/avail-bridge-api/info/page.mdx
+++ b/app/api-reference/avail-bridge-api/info/page.mdx
@@ -1,7 +1,3 @@
----
-image: '/img/docs-link-preview.png'
----
-
import { Tabs } from 'nextra/components'
import { Callout } from 'nextra/components'
@@ -19,7 +15,7 @@ import { Callout } from 'nextra/components'
-```bash filename="CURL"
+```sh
curl https://turing-bridge-api.avail.so/info
```
@@ -35,4 +31,4 @@ curl https://turing-bridge-api.avail.so/info
"vectorXChainId": "11155111",
"vectorXContractAddress": "0x570f6a1936386a4e060C2Daebbd0b6f5C091e13f"
}
-```
+```
\ No newline at end of file
diff --git a/app/api-reference/avail-bridge-api/liveness/page.mdx b/app/api-reference/avail-bridge-api/liveness/page.mdx
index b01b17d72..17f3b1399 100644
--- a/app/api-reference/avail-bridge-api/liveness/page.mdx
+++ b/app/api-reference/avail-bridge-api/liveness/page.mdx
@@ -1,7 +1,3 @@
----
-image: '/img/docs-link-preview.png'
----
-
import { Tabs } from 'nextra/components'
import { Callout } from 'nextra/components'
@@ -18,7 +14,7 @@ import { Callout } from 'nextra/components'
-```bash filename="CURL"
+```sh
curl https://turing-bridge-api.avail.so/
```
@@ -29,4 +25,4 @@ curl https://turing-bridge-api.avail.so/
```json showLineNumbers filename="Example JSON response"
{"name":"Avail Bridge API"}
-```
+```
\ No newline at end of file
diff --git a/app/api-reference/avail-bridge-api/merkle-proof/page.mdx b/app/api-reference/avail-bridge-api/merkle-proof/page.mdx
index df26b35f4..e2c038ae7 100644
--- a/app/api-reference/avail-bridge-api/merkle-proof/page.mdx
+++ b/app/api-reference/avail-bridge-api/merkle-proof/page.mdx
@@ -1,7 +1,3 @@
----
-image: '/img/docs-link-preview.png'
----
-
import { Tabs } from 'nextra/components'
import { Callout } from 'nextra/components'
@@ -19,7 +15,7 @@ import { Callout } from 'nextra/components'
-```bash filename="CURL"
+```sh
curl "https://turing-bridge-api.avail.so/eth/proof/0x5bc7bd3a4793132007d6d0d9c55dc2ded2fe721a49bd771c1d290e6a3c6ec237?index=5"
```
@@ -67,4 +63,4 @@ curl "https://turing-bridge-api.avail.so/eth/proof/0x5bc7bd3a4793132007d6d0d9c55
},
"rangeHash": "0x21c402a3ccf8df26cb720c6d2fb409f04c809adef7a9a852e463cca83588f4fb"
}
-```
+```
\ No newline at end of file
diff --git a/app/api-reference/avail-bridge-api/page.mdx b/app/api-reference/avail-bridge-api/page.mdx
index 6fff0aed9..3e2d9a13b 100644
--- a/app/api-reference/avail-bridge-api/page.mdx
+++ b/app/api-reference/avail-bridge-api/page.mdx
@@ -1,36 +1,12 @@
---
-image: "/img/docs-link-preview.png"
title: Avail Bridge API reference
asIndexPage: true
---
-
import { Tabs } from 'nextra/components'
import { Callout } from 'nextra/components'
# Avail bridge API reference
-
-**TRANSACTION NESTING LIMITATIONS**
-
-To ensure network stability and security, the Avail network is generally subject to the following limits:
-
-1. **General Transactions**: Transaction nesting is limited to a maximum of 5 levels. Transactions exceeding this limit are not guaranteed to be processed successfully.
-
-2. **Bridge Transactions (Avail to Ethereum)**: For `vector.sendMessage` operations, only direct calls and nesting only with proxy/multisig (up to 2 levels) are supported. Any other combination is not guaranteed to work.
-
-3. **Data Availability Submissions**: `dataAvailability.submitData` operations should only be performed with standard accounts.
-
-4. **Batching Restrictions**:
- - `vector.sendMessage` and `dataAvailability.submitData` calls should not be included in batch calls.
- - `vector.sendMessage` should not be included in schedule calls.
- - Transactions with more than 2 levels of batching are not guaranteed to work.
-
-**Understanding Nesting Levels**:
-- Level 0: Direct call (e.g., `dataAvailability.submitData`)
-- Level 1: One wrapper (e.g., multisig → `dataAvailability.submitData`)
-- Level 2: Two wrappers (e.g., proxy → multisig → `dataAvailability.submitData`)
-
-
**BEFORE WE START**
1. The Avail VectorX bridge can be used to pass messages and tokens between \
@@ -58,7 +34,7 @@ For the sake of simplicity that is what we will be using in this guide.
1. To use the Avail bridge API with `curl`, you just need to have `curl` installed on your system.
You can check if it is installed by running:
-```bash filename="CURL"
+```sh
curl --version
```
@@ -142,4 +118,4 @@ receive_message_contract_address="29190B4d80C409A3DaF743F57379e0453D31C26b"
```
-
+
\ No newline at end of file
diff --git a/app/api-reference/avail-bridge-api/storage-proof/page.mdx b/app/api-reference/avail-bridge-api/storage-proof/page.mdx
index 319254273..9e64aa318 100644
--- a/app/api-reference/avail-bridge-api/storage-proof/page.mdx
+++ b/app/api-reference/avail-bridge-api/storage-proof/page.mdx
@@ -1,7 +1,3 @@
----
-image: '/img/docs-link-preview.png'
----
-
import { Tabs } from 'nextra/components'
import { Callout } from 'nextra/components'
@@ -19,7 +15,7 @@ import { Callout } from 'nextra/components'
-```bash filename="CURL"
+```sh
curl "https://turing-bridge-api.avail.so/avl/proof/0x7963d8403d137cb5560e2436df07c233d18030b5f3f0c61b85083e2a8f2b5e55/1"
```
@@ -47,4 +43,4 @@ curl "https://turing-bridge-api.avail.so/avl/proof/0x7963d8403d137cb5560e2436df0
"0xf8429f31265685397ec9fa17535b5603e86e2b01a583b71373e1b2cbfac2a5bff58fa1a0eb70a047920b4aa1f3a418b52e455694d4e1a2362fd7fbcf16fe53d798311beb"
]
}
-```
+```
\ No newline at end of file
diff --git a/app/api-reference/avail-bridge-api/vector-send-message/page.mdx b/app/api-reference/avail-bridge-api/vector-send-message/page.mdx
index 50de7b009..2f05f57a7 100644
--- a/app/api-reference/avail-bridge-api/vector-send-message/page.mdx
+++ b/app/api-reference/avail-bridge-api/vector-send-message/page.mdx
@@ -191,8 +191,7 @@ let block_num = block.block.header.number;
Ok(())
```
----
-image: "/img/docs-link-preview.png"
+---
- Bringing it all together, we have the following. Inside `src/main.rs`, paste the following code:
```rust
use alloy_network::EthereumWallet;
diff --git a/app/api-reference/avail-bridge-api/vector-send-tokens/page.mdx b/app/api-reference/avail-bridge-api/vector-send-tokens/page.mdx
index 87dcafe97..f569817b2 100644
--- a/app/api-reference/avail-bridge-api/vector-send-tokens/page.mdx
+++ b/app/api-reference/avail-bridge-api/vector-send-tokens/page.mdx
@@ -189,8 +189,7 @@ let contract_address = config.contract_address.parse()?;
println!("Result: {res:?}");
```
----
-image: "/img/docs-link-preview.png"
+---
Bringing it all together, we have the following. Inside `src/main.rs`, paste the following code:
```rust
@@ -537,6 +536,7 @@ let sdk = SDK::new(config.avail_rpc_url.as_str()).await.unwrap();
println!("Executed at block: {:?}", tx_in_block.block_hash());
```
+
----
- Bringing it all together in `src/main.rs`:
diff --git a/app/api-reference/avail-lc-api/page.mdx b/app/api-reference/avail-lc-api/page.mdx
index 0582b3fda..83e2023b4 100644
--- a/app/api-reference/avail-lc-api/page.mdx
+++ b/app/api-reference/avail-lc-api/page.mdx
@@ -1,5 +1,4 @@
---
-image: "/img/docs-link-preview.png"
id: avail-light-client-reference
asIndexPage: true
title: Avail Light Client API reference
@@ -16,6 +15,7 @@ keywords:
- rust
- API
- reference
+image: https://docs.availproject.org/img/avail/AvailDocs.png
---
import { Tabs } from 'nextra/components'
import { Callout } from 'nextra/components'
@@ -44,7 +44,7 @@ Set up your dev environment with `curl` and `Rust`:
1. To use the Avail light client API with `curl`, you just need to have `curl` installed on your system.
You can check if it is installed by running:
-```bash filename="CURL"
+```sh
curl --version
```
@@ -77,4 +77,4 @@ How to run the Rust code snippets:
3. Paste the code snippets into the `main.rs` file, and run the project with `cargo run`.
-
+
\ No newline at end of file
diff --git a/app/api-reference/avail-lc-api/v1-deprecated/page.mdx b/app/api-reference/avail-lc-api/v1-deprecated/page.mdx
index 6e0595cb5..a2370cb4c 100644
--- a/app/api-reference/avail-lc-api/v1-deprecated/page.mdx
+++ b/app/api-reference/avail-lc-api/v1-deprecated/page.mdx
@@ -1,7 +1,3 @@
----
-image: '/img/docs-link-preview.png'
----
-
import { Callout } from 'nextra/components'
@@ -9,4 +5,4 @@ import { Callout } from 'nextra/components'
The Avail light client API has been upgraded, and all the latest methods work under the path `/v2`.
They provide all the features of `V1`, and more.
Please refer to the [Avail light client API reference](/api-reference/avail-lc-api) for detailed information.
-
+
\ No newline at end of file
diff --git a/app/api-reference/avail-lc-api/v2-blocks-header-datafields/page.mdx b/app/api-reference/avail-lc-api/v2-blocks-header-datafields/page.mdx
index cf995c4ee..365f245bf 100644
--- a/app/api-reference/avail-lc-api/v2-blocks-header-datafields/page.mdx
+++ b/app/api-reference/avail-lc-api/v2-blocks-header-datafields/page.mdx
@@ -1,7 +1,3 @@
----
-image: '/img/docs-link-preview.png'
----
-
import { Tabs } from 'nextra/components'
import { Callout } from 'nextra/components'
@@ -10,18 +6,8 @@ import { Callout } from 'nextra/components'
**LOOKING FOR INSTRUCTIONS ON HOW TO RUN YOUR OWN LIGHT CLIENT?**
You can check out [our docs here](/docs/operate-a-node/run-a-light-client/0010-light-client#running-the-light-client) for instructions on how to run your own light client.
-
-**Note:**
-Light client must be running in `app-mode`to retrieve data. [Click here](/docs/operate-a-node/run-a-light-client/0010-light-client#setting-your-identity-using-identitytoml) for instructions on how to run an Avail Light Client in `app-mode`.
-
-
-Gets the block data if available.
-
- Only returns data if the block contains it for the configured `app_id`. If there is no data against the configured `app_id` it returns an empty array.
- Query parameter `fields` specifies whether to return decoded data and encoded extrinsic (with signature). If `fields` parameter is omitted, response contains **hash** and **data**, while **extrinsic** is omitted.
-
-The `data` and `extrinsic` is encoded in `base64` format.
+Gets the block data if available. Query parameter `fields` specifies whether to return decoded data and encoded extrinsic (with signature). If `fields` parameter is omitted, response contains **hash** and **data**, while **extrinsic** is omitted.
@@ -87,7 +73,7 @@ async fn main() {
-
+ Sample Response:
If **block_status = "finished"**, data is available and the response is:
@@ -103,17 +89,10 @@ If **block_status = "finished"**, data is available and the response is:
}
```
-If **block_status** is not **“finished”**, or **`app-mode`** is not enabled, data is not available and the response is:
-
-```yaml
-Not Found
-```
-If no data is available in the block against the configured `app_id` in `app-mode`:
+If **block_status** is not **“finished”**, or **app** mode is not enabled, data is not available and the response is:
```yaml
-{
- "data_transactions": []
-}
+Bad Request
```
@@ -129,4 +108,4 @@ look something like this:
```sh
curl -sL1 avail.sh | bash -s -- --app_id 1 --identity identity.toml --network mainnet
```
-
+
\ No newline at end of file
diff --git a/app/api-reference/avail-lc-api/v2-blocks-header/page.mdx b/app/api-reference/avail-lc-api/v2-blocks-header/page.mdx
index 0bc47854a..d335ae0cf 100644
--- a/app/api-reference/avail-lc-api/v2-blocks-header/page.mdx
+++ b/app/api-reference/avail-lc-api/v2-blocks-header/page.mdx
@@ -1,7 +1,3 @@
----
-image: '/img/docs-link-preview.png'
----
-
import { Tabs } from 'nextra/components'
import { Callout } from 'nextra/components'
@@ -61,13 +57,13 @@ HTTP/1.1 400 Bad Request
-```bash filename="CURL"
+```sh
curl "localhost:7007/v2/blocks/{insert a suitable block number}/header"
```
-```bash filename="CURL"
+```sh
curl "https://api.lightclient.mainnet.avail.so/v2/blocks/{insert a suitable block number}/header"
```
@@ -136,4 +132,4 @@ async fn main() {
}
```
-
+
\ No newline at end of file
diff --git a/app/api-reference/avail-lc-api/v2-blocks/page.mdx b/app/api-reference/avail-lc-api/v2-blocks/page.mdx
index ea6a390ab..f36a8c598 100644
--- a/app/api-reference/avail-lc-api/v2-blocks/page.mdx
+++ b/app/api-reference/avail-lc-api/v2-blocks/page.mdx
@@ -1,7 +1,3 @@
----
-image: '/img/docs-link-preview.png'
----
-
import { Tabs } from 'nextra/components'
import { Callout } from 'nextra/components'
@@ -49,13 +45,13 @@ pushed, similar to case of the frequent polling, so header and confidence will b
-```bash filename="CURL"
+```sh
curl "localhost:7007/v2/blocks/{insert a suitable block number}"
```
-```bash filename="CURL"
+```sh
curl "https://api.lightclient.mainnet.avail.so/v2/blocks/{insert a suitable block number}"
```
@@ -111,7 +107,7 @@ async fn main() {
-
+ Sample Response:
```json
{
@@ -125,4 +121,4 @@ async fn main() {
```yaml
Not Found
-```
+```
\ No newline at end of file
diff --git a/app/api-reference/avail-lc-api/v2-status/page.mdx b/app/api-reference/avail-lc-api/v2-status/page.mdx
index c35b38a76..9a76bfb48 100644
--- a/app/api-reference/avail-lc-api/v2-status/page.mdx
+++ b/app/api-reference/avail-lc-api/v2-status/page.mdx
@@ -1,7 +1,3 @@
----
-image: '/img/docs-link-preview.png'
----
-
import { Tabs } from 'nextra/components'
import { Callout } from 'nextra/components'
@@ -48,13 +44,13 @@ Gets current status and active modes of the light client.
-```bash filename="CURL"
+```sh
curl "localhost:7007/v2/status"
```
-```bash filename="CURL"
+```sh
curl "https://api.lightclient.mainnet.avail.so/v2/status"
```
@@ -126,7 +122,7 @@ async fn main() {
-
+ Sample Response:
```json
{
diff --git a/app/api-reference/avail-lc-api/v2-submit/page.mdx b/app/api-reference/avail-lc-api/v2-submit/page.mdx
index 8653c4970..8d543e965 100644
--- a/app/api-reference/avail-lc-api/v2-submit/page.mdx
+++ b/app/api-reference/avail-lc-api/v2-submit/page.mdx
@@ -1,7 +1,3 @@
----
-image: '/img/docs-link-preview.png'
----
-
import { Tabs } from 'nextra/components'
import { Callout } from 'nextra/components'
@@ -11,11 +7,6 @@ import { Callout } from 'nextra/components'
You can check out [our docs here](/docs/operate-a-node/run-a-light-client/0010-light-client#running-the-light-client) for instructions on how to run your own light client.
-
-**Note:**
-Light client must be running in `app-mode`to retrieve data. [Click here](/docs/operate-a-node/run-a-light-client/0010-light-client#setting-your-identity-using-identitytoml) for instructions on how to run an Avail Light Client in `app-mode`.
-
-
> Submits application data to the avail network
In case of `data` transaction, data transaction is created, signed and submitted.\
@@ -44,7 +35,7 @@ You can use [this website](https://www.base64encode.org/) to encode & decode you
-```bash filename="CURL"
+```sh
curl -XPOST 127.0.0.1:7007/v2/submit --header "Content-Type: application/json" --data '{"data":"dGVzdAo="}'
```
@@ -96,7 +87,7 @@ async fn main() {
-
+ Sample Response:
```yaml
@@ -112,4 +103,4 @@ If app mode is not active (or signing key is not configured and `data` is submit
```yaml
Not found
```
-
+
\ No newline at end of file
diff --git a/app/api-reference/avail-lc-api/v2-subscriptions/page.mdx b/app/api-reference/avail-lc-api/v2-subscriptions/page.mdx
index 4c6424b2d..062852829 100644
--- a/app/api-reference/avail-lc-api/v2-subscriptions/page.mdx
+++ b/app/api-reference/avail-lc-api/v2-subscriptions/page.mdx
@@ -1,7 +1,3 @@
----
-image: '/img/docs-link-preview.png'
----
-
import { Tabs } from 'nextra/components'
import { Callout } from 'nextra/components'
@@ -10,7 +6,7 @@ import { Callout } from 'nextra/components'
The Avail light client WebSocket API allows real-time communication between a client and a server over a
persistent connection. The Web socket API can be used on its own or in combination with HTTP API to enable different pull/push use cases.
-
+ HTTPS vs WSS
`HTTP` and `Websocket` are two different ways of communicating with a server. `HTTP` is a request-response protocol,
where a connection persists for only so long as the request is being processed. In contrast, a websocket connection
@@ -50,7 +46,7 @@ Request:
-```bash filename="CURL"
+```sh
curl -X POST "http://localhost:7007/v2/subscriptions" \
-H "Content-Type: application/json" \
-d '{
@@ -61,7 +57,7 @@ curl -X POST "http://localhost:7007/v2/subscriptions" \
-```bash filename="CURL"
+```sh
curl -X POST "https://api.lightclient.mainnet.avail.so/v2/subscriptions" \
-H "Content-Type: application/json" \
-d '{
@@ -118,7 +114,7 @@ async fn main() {
-
+ Sample Response:
```yaml
diff --git a/app/api-reference/avail-lc-api/v2-version/page.mdx b/app/api-reference/avail-lc-api/v2-version/page.mdx
index 7170271bf..d6aed7430 100644
--- a/app/api-reference/avail-lc-api/v2-version/page.mdx
+++ b/app/api-reference/avail-lc-api/v2-version/page.mdx
@@ -1,7 +1,3 @@
----
-image: '/img/docs-link-preview.png'
----
-
import { Tabs } from 'nextra/components'
import { Callout } from 'nextra/components'
@@ -28,13 +24,13 @@ Gets the version of the light client binary, and the version of the Avail node i
-```bash filename="CURL"
+```sh
curl "localhost:7007/v2/version"
```
-```bash filename="CURL"
+```sh
curl "https://api.lightclient.mainnet.avail.so/v2/version"
```
@@ -79,7 +75,7 @@ async fn main() {
-
+ Sample Response:
```json
{
diff --git a/app/api-reference/avail-lc-api/v2-ws-status/page.mdx b/app/api-reference/avail-lc-api/v2-ws-status/page.mdx
index 40ec07bef..39e1d6b3f 100644
--- a/app/api-reference/avail-lc-api/v2-ws-status/page.mdx
+++ b/app/api-reference/avail-lc-api/v2-ws-status/page.mdx
@@ -1,7 +1,3 @@
----
-image: '/img/docs-link-preview.png'
----
-
import { Tabs } from 'nextra/components'
import { Callout } from 'nextra/components'
@@ -29,4 +25,4 @@ Request current Avail light client status data.
```json
{"topic":"status","request_id":"4a482bb0-3c22-475d-a2b8-af1c27aa2636","message":{"modes":["light","app"],"app_id":13,"genesis_hash":"0xb91746b45e0346cc2f815a520b9c6cb4d5c0902af848db0a80f85932d2e8276a","network":"wss://avail-mainnet.public.blastapi.io/2.2.1-4f0439f4448/39","blocks":{"latest":828832,"available":{"first":828743,"last":828831},"app_data":{"first":828743,"last":828831}}}}
-```
+```
\ No newline at end of file
diff --git a/app/api-reference/avail-lc-api/v2-ws-submit/page.mdx b/app/api-reference/avail-lc-api/v2-ws-submit/page.mdx
index e89d2b75e..9c6b43cc5 100644
--- a/app/api-reference/avail-lc-api/v2-ws-submit/page.mdx
+++ b/app/api-reference/avail-lc-api/v2-ws-submit/page.mdx
@@ -1,7 +1,3 @@
----
-image: '/img/docs-link-preview.png'
----
-
import { Tabs } from 'nextra/components'
import { Callout } from 'nextra/components'
@@ -34,4 +30,4 @@ You can use [this website](https://www.base64encode.org/) to encode & decode you
*Sample Response:*
```json
{"topic":"data-transaction-submitted","request_id":"4a482bb0-3c22-475d-a2b8-af1c27aa2636","message":{"block_number":597725,"block_hash":"0x84803b93bf96aea90fae8fcb21cae70d310783ae8e9c4f4e1d696cec2791c0e3","hash":"0x290efdc7856fd29ec406c610f79aaa3c8079c11f8338093efad739b454bef0ac","index":1}}
-```
+```
\ No newline at end of file
diff --git a/app/api-reference/avail-lc-api/v2-ws-version/page.mdx b/app/api-reference/avail-lc-api/v2-ws-version/page.mdx
index 31030e8db..b55957ac6 100644
--- a/app/api-reference/avail-lc-api/v2-ws-version/page.mdx
+++ b/app/api-reference/avail-lc-api/v2-ws-version/page.mdx
@@ -1,7 +1,3 @@
----
-image: '/img/docs-link-preview.png'
----
-
import { Tabs } from 'nextra/components'
import { Callout } from 'nextra/components'
@@ -28,4 +24,4 @@ Request Avail light client version data.
*Sample Response:*
```json
{"topic":"version","request_id":"4a482bb0-3c22-475d-a2b8-af1c27aa2636","message":{"version":"v1.7.10","network_version":"1.10"}}
-```
+```
\ No newline at end of file
diff --git a/app/api-reference/avail-nexus-sdk/_meta.ts b/app/api-reference/avail-nexus-sdk/_meta.ts
deleted file mode 100644
index c5333f40d..000000000
--- a/app/api-reference/avail-nexus-sdk/_meta.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-export default {
-
- "overview": "Get Started",
- "examples": "Examples",
- "api-reference": "API Reference",
-}
\ No newline at end of file
diff --git a/app/api-reference/avail-nexus-sdk/api-reference/page.mdx b/app/api-reference/avail-nexus-sdk/api-reference/page.mdx
deleted file mode 100644
index 368cbc54e..000000000
--- a/app/api-reference/avail-nexus-sdk/api-reference/page.mdx
+++ /dev/null
@@ -1,806 +0,0 @@
----
-title: 'Avail Nexus SDK API Reference'
-description: 'Complete API reference for the Avail Nexus SDK including initialization, network configuration, bridging, transfers, and utility functions'
-image: '/img/docs-link-preview.png'
----
-
-import { Callout, Steps, Tabs } from 'nextra/components'
-
-# Avail Nexus SDK API Reference
-
-The Avail Nexus SDK provides a comprehensive set of APIs for cross-chain bridging, token transfers, and balance management across multiple EVM chains.
-
-## Quick Start
-
-1. While [this page](/api-reference/avail-nexus-sdk) already contains instructions for getting started with the SDK,
-we also provide two optimized entry points for devs looking to work with specific use cases
-
-
-
-
-
-
-
-
-```bash filename="Terminal"
-npm install @avail-project/nexus/core
-```
-
-
-
-
-```bash filename="Terminal"
-yarn add @avail-project/nexus/core
-```
-
-
-
-
-```bash filename="Terminal"
-pnpm add @avail-project/nexus/core
-```
-
-
-
-
-
-
-
-
-
-
-
-```bash filename="Terminal"
-npm install @avail-project/nexus/ui
-```
-
-
-
-
-```bash filename="Terminal"
-yarn add @avail-project/nexus/ui
-```
-
-
-
-
-```bash filename="Terminal"
-pnpm add @avail-project/nexus/ui
-```
-
-
-
-
-
-
-
-
-
-
-
-```typescript showLineNumbers filename="Typescript"
-import { NexusSDK } from '@avail-project/nexus/core';
-
-// Initialize SDK
-const sdk = new NexusSDK({ network: 'mainnet' });
-await sdk.initialize(provider); // Your wallet provider
-
-// Get unified balances
-const balances = await sdk.getUnifiedBalances();
-console.log('All balances:', balances);
-
-// Bridge tokens
-const bridgeResult = await sdk.bridge({
- token: 'USDC',
- amount: 100,
- chainId: 137, // to Polygon
-});
-
-// Transfer tokens (automatically optimized)
-const transferResult = await sdk.transfer({
- token: 'ETH',
- amount: 0.1,
- chainId: 1, // Uses direct transfer if ETH + gas available on Ethereum
- recipient: '0x742d35Cc6634C0532925a3b8D4C9db96c4b4Db45',
-});
-
-const executeResult = await sdk.execute({
- contractAddress,
- contractAbi: contractAbi,
- functionName: functionName,
- buildFunctionParams: (
- token: SUPPORTED_TOKENS,
- amount: string,
- chainId: SUPPORTED_CHAINS_IDS,
- user: `0x${string}`,
- ) => {
- const decimals = TOKEN_METADATA[token].decimals;
- const amountWei = parseUnits(amount, decimals);
- const tokenAddr = TOKEN_CONTRACT_ADDRESSES[token][chainId];
- return { functionParams: [tokenAddr, amountWei, user, 0] };
- },
- value: ethValue,
- tokenApproval: {
- token: 'USDC',
- amount: '100000000',
- },
-});
-```
-
-
-
-
-```typescript showLineNumbers filename="Typescript"
-import { NexusProvider,
- useNexus,
- BridgeButton,
- TransferButton,
- BridgeAndExecuteButton
-} from '@avail-project/nexus/ui';
-
-// 1. Wrap your app
-function App() {
- return (
- // {network: 'testnet', debug: true} for testnet and debug logs
-
-
- );
-}
-
-// 2. Use components
-function YourComponent() {
- return (
-
- {({ onClick, isLoading }) => (
-
- )}
-
- );
-}
-```
-
-
-
-
-
-## Configuration Options
-
-### Supported Chains
-
-
-
-
-
-| Network | Chain ID | Native Currency | Status |
-| --------- | -------- | --------------- | ------ |
-| Ethereum | 1 | ETH | ✅ |
-| Optimism | 10 | ETH | ✅ |
-| Polygon | 137 | MATIC | ✅ |
-| Arbitrum | 42161 | ETH | ✅ |
-| Avalanche | 43114 | AVAX | ✅ |
-| Base | 8453 | ETH | ✅ |
-| Scroll | 534351 | ETH | ✅ |
-| Sophon | 50104 | SOPH | ✅ |
-| Kaia | 8217 | KAIA | ✅ |
-
-
-
-
-| Network | Chain ID | Native Currency | Status |
-| ---------------- | -------- | --------------- | ------ |
-| Optimism Sepolia | 11155420 | ETH | ✅ |
-| Polygon Amoy | 80002 | MATIC | ✅ |
-| Arbitrum Sepolia | 421614 | ETH | ✅ |
-| Base Sepolia | 84532 | ETH | ✅ |
-
-
-
-
-### Supported Tokens
-
-| Token | Name | Decimals | Networks |
-| ----- | ---------- | -------- | -------------- |
-| ETH | Ethereum | 18 | All EVM chains |
-| USDC | USD Coin | 6 | All supported |
-| USDT | Tether USD | 6 | All supported |
-
-
-How to fetch supported chains from the SDK?
-
-```typescript showLineNumbers filename="Typescript" showLineNumbers filename="Typescript" showLineNumbers filename="Typescript"
-import { SUPPORTED_CHAINS } from @avail-project/nexus/core;
-
-// Mainnet Chain IDs
-SUPPORTED_CHAINS.ETHEREUM; // 1
-SUPPORTED_CHAINS.OPTIMISM; // 10
-SUPPORTED_CHAINS.POLYGON; // 137
-SUPPORTED_CHAINS.ARBITRUM; // 42161
-SUPPORTED_CHAINS.AVALANCHE; // 43114
-SUPPORTED_CHAINS.BASE; // 8453
-SUPPORTED_CHAINS.LINEA; // 59144
-SUPPORTED_CHAINS.SCROLL; // 534351
-```
-
-
-## Headless API Reference
-
-### Initialization
-
-```typescript showLineNumbers filename="Typescript"
-import type { NexusNetwork } from '@avail-project/nexus/core';
-
-// Mainnet (default)
-const sdk = new NexusSDK();
-
-// Testnet
-const sdk = new NexusSDK({ network: 'testnet' as NexusNetwork });
-
-// Initialize with provider (required)
-await sdk.initialize(window.ethereum); // Returns: Promise
-```
-
-### Unified Balance(s)
-
-```typescript showLineNumbers filename="Typescript"
-import type { UserAsset, TokenBalance } from '@avail-project/nexus/core';
-
-// Get all balances across chains
-const balances: UserAsset[] = await sdk.getUnifiedBalances();
-
-// Get balance for specific token
-const usdcBalance: UserAsset | undefined = await sdk.getUnifiedBalance('USDC');
-
-```
-
-### Bridge Operations
-
-```typescript showLineNumbers filename="Typescript"
-import type { BridgeParams, BridgeResult, SimulationResult } from '@avail-project/nexus/core';
-
-// Bridge tokens between chains
-const result: BridgeResult = await sdk.bridge({
- token: 'USDC',
- amount: 100,
- chainId: 137,
-} as BridgeParams);
-
-// Simulate bridge to preview costs
-const simulation: SimulationResult = await sdk.simulateBridge({
- token: 'USDC',
- amount: 100,
- chainId: 137,
-});
-```
-
-### Transfer Operations
-
-```typescript showLineNumbers filename="Typescript"
-import type { TransferParams, TransferResult } from '@avail-project/nexus/core';
-
-// Smart transfer with automatic optimization
-const result: TransferResult = await sdk.transfer({
- token: 'USDC',
- amount: 100,
- chainId: 42161, // Arbitrum
- recipient: '0x...',
-} as TransferParams);
-
-// The SDK automatically:
-// 1. Checks if you have USDC + ETH for gas on Arbitrum
-// 2. Uses direct EVM transfer if available (faster, cheaper)
-// 3. Falls back to chain abstraction if local funds insufficient
-
-// Simulate transfer to preview costs and optimization path
-const simulation: SimulationResult = await sdk.simulateTransfer({
- token: 'USDC',
- amount: 100,
- chainId: 42161,
- recipient: '0x...',
-});
-
-// Check if direct transfer will be used
-console.log('Fees:', simulation.intent.fees);
-// For direct transfers: gasSupplied shows actual native token cost
-// For CA transfers: includes additional CA routing fees
-```
-
-### Execute Operations
-
-```typescript showLineNumbers filename="Typescript"
-import type {
- ExecuteParams,
- ExecuteResult,
- ExecuteSimulation,
- BridgeAndExecuteParams,
- BridgeAndExecuteResult,
- BridgeAndExecuteSimulationResult,
-} from '@avail-project/nexus/core';
-
-// Execute contract functions with dynamic parameter builder - Compound V3 Supply
-const result: ExecuteResult = await sdk.execute({
- toChainId: 1,
- contractAddress: '0xc3d688B66703497DAA19211EEdff47f25384cdc3', // Compound V3 USDC Market
- contractAbi: [
- {
- inputs: [
- { internalType: 'address', name: 'asset', type: 'address' },
- { internalType: 'uint256', name: 'amount', type: 'uint256' },
- ],
- name: 'supply',
- outputs: [],
- stateMutability: 'nonpayable',
- type: 'function',
- },
- ],
- functionName: 'supply',
- buildFunctionParams: (
- token: SUPPORTED_TOKENS,
- amount: string,
- chainId: SUPPORTED_CHAIN_IDS,
- userAddress: `0x${string}`,
- ) => {
- const decimals = TOKEN_METADATA[token].decimals;
- const amountWei = parseUnits(amount, decimals);
- const tokenAddress = TOKEN_CONTRACT_ADDRESSES[token][chainId];
- return {
- functionParams: [tokenAddress, amountWei],
- };
- },
- waitForReceipt: true,
- requiredConfirmations: 3,
- tokenApproval: {
- token: 'USDC',
- amount: '1000000', // Amount in token units
- },
-} as ExecuteParams);
-
-// Simulate execute to preview costs and check for approval requirements
-const simulation: ExecuteSimulation = await sdk.simulateExecute(executeParams);
-if (!simulation.success) {
- console.log('Simulation failed:', simulation.error);
- // Error might indicate missing token approval
-}
-
-// Bridge tokens and execute contract function - Yearn Vault Deposit
-const bridgeAndExecuteResult: BridgeAndExecuteResult = await sdk.bridgeAndExecute({
- token: 'USDC',
- amount: '100000000', // 100 USDC (6 decimals)
- toChainId: 1, // Ethereum
- execute: {
- contractAddress: '0xa354F35829Ae975e850e23e9615b11Da1B3dC4DE', // Yearn USDC Vault
- contractAbi: [
- {
- inputs: [
- { internalType: 'uint256', name: 'assets', type: 'uint256' },
- { internalType: 'address', name: 'receiver', type: 'address' },
- ],
- name: 'deposit',
- outputs: [{ internalType: 'uint256', name: 'shares', type: 'uint256' }],
- stateMutability: 'nonpayable',
- type: 'function',
- },
- ],
- functionName: 'deposit',
- buildFunctionParams: (
- token: SUPPORTED_TOKENS,
- amount: string,
- chainId: SUPPORTED_CHAIN_IDS,
- userAddress: `0x${string}`,
- ) => {
- const decimals = TOKEN_METADATA[token].decimals;
- const amountWei = parseUnits(amount, decimals);
- return {
- functionParams: [amountWei, userAddress],
- };
- },
- tokenApproval: {
- token: 'USDC',
- amount: '100000000',
- },
- },
- waitForReceipt: true,
-} as BridgeAndExecuteParams);
-
-// Comprehensive simulation with detailed step analysis and approval handling
-const simulation: BridgeAndExecuteSimulationResult = await sdk.simulateBridgeAndExecute(params);
-
-// The simulation provides detailed step analysis:
-console.log('Steps:', simulation.steps);
-
-console.log('Total estimated cost:', simulation.totalEstimatedCost);
-
-console.log('Approval required:', simulation.metadata?.approvalRequired);
-console.log('Bridge receive amount:', simulation.metadata?.bridgeReceiveAmount);
-```
-
-### Allowance Management
-
-```typescript showLineNumbers filename="Typescript"
-import type { AllowanceResponse } from '@avail-project/nexus/core';
-
-// Check allowances
-const allowances: AllowanceResponse[] = await sdk.getAllowance(137, ['USDC', 'USDT']);
-
-// Set allowances
-await sdk.setAllowance(137, ['USDC'], 1000000n);
-
-// Revoke allowances
-await sdk.revokeAllowance(137, ['USDC']);
-```
-
-### Intent Management
-
-```typescript showLineNumbers filename="Typescript"
-import type { RequestForFunds } from '@avail-project/nexus/core';
-
-// Get user's transaction intents
-const intents: RequestForFunds[] = await sdk.getMyIntents(1);
-```
-
-### Utilities
-
-All utility functions are available under `sdk.utils`:
-
-```typescript showLineNumbers filename="Typescript"
-import type { ChainMetadata, TokenMetadata, SUPPORTED_TOKENS } from '@avail-project/nexus/core';
-
-// Address utilities
-const isValid: boolean = sdk.utils.isValidAddress('0x...');
-const shortened: string = sdk.utils.truncateAddress('0x...');
-
-// Balance formatting
-const formatted: string = sdk.utils.formatBalance('1000000', 6);
-const units: bigint = sdk.utils.parseUnits('100.5', 6);
-const readable: string = sdk.utils.formatUnits(100500000n, 6);
-
-// Token amount formatting
-const formattedAmount: string = sdk.utils.formatTokenAmount('1000000', 'USDC'); // "1.0 USDC"
-const testnetFormatted: string = sdk.utils.formatTestnetTokenAmount('1000000', 'USDC'); // "1.0 USDC"
-
-// Chain & token info
-const chainMeta: ChainMetadata | undefined = sdk.utils.getChainMetadata(137);
-const tokenMeta: TokenMetadata | undefined = sdk.utils.getTokenMetadata('USDC');
-const mainnetTokenMeta: TokenMetadata | undefined = sdk.utils.getMainnetTokenMetadata('USDC');
-const testnetTokenMeta: TokenMetadata | undefined = sdk.utils.getTestnetTokenMetadata('USDC');
-
-// Chain/token validation
-const isSupported: boolean = sdk.utils.isSupportedChain(137);
-const isSupportedToken: boolean = sdk.utils.isSupportedToken('USDC');
-
-// Get supported chains
-const chains: Array<{ id: number; name: string; logo: string }> = sdk.utils.getSupportedChains();
-
-// Chain ID conversion
-const hexChainId: string = sdk.utils.chainIdToHex(137);
-const decimalChainId: number = sdk.utils.hexToChainId('0x89');
-```
-
-### Event Handling
-
-```typescript showLineNumbers filename="Typescript"
-import type { OnIntentHook, OnAllowanceHook, EventListener } from '@avail-project/nexus/core';
-
-// Intent approval flows
-sdk.setOnIntentHook(({ intent, allow, deny, refresh }: Parameters[0]) => {
- // This is a hook for the dev to show user the intent, the sources and associated fees
-
- // intent: Intent data containing sources and fees for display purpose
-
- // allow(): accept the current intent and continue the flow
-
- // deny(): deny the intent and stop the flow
-
- // refresh(): should be on a timer of 5s to refresh the intent
- // (old intents might fail due to fee changes if not refreshed)
- if (userConfirms) allow();
- else deny();
-});
-
-// Allowance approvals
-sdk.setOnAllowanceHook(({ allow, deny, sources }: Parameters[0]) => {
- // This is a hook for the dev to show user the allowances that need to be setup
- // for the current tx to happen.
-
- // sources: an array of objects with minAllowance, chainID, token symbol, etc.
-
- // allow(allowances): continues the transaction flow with `allowances` array
- // allowances.length === sources.length;
- // valid values are "max" | "min" | string | bigint
-
- // deny(): stops the flow
- allow(['min']); // or ['max'] or custom amounts
-});
-
-// Account/chain changes
-sdk.onAccountChanged((account) => console.log('Account:', account));
-sdk.onChainChanged((chainId) => console.log('Chain:', chainId));
-```
-
-### Progress Events for All Operations
-
-```typescript showLineNumbers filename="Typescript"
-import { NEXUS_EVENTS, ProgressStep } from '@avail-project/nexus/core';
-
-// Bridge & Execute Progress
-const unsubscribeBridgeExecuteExpected = sdk.nexusEvents.on(
- NEXUS_EVENTS.BRIDGE_EXECUTE_EXPECTED_STEPS,
- (steps: ProgressStep[]) => {
- console.log(
- 'Bridge & Execute steps →',
- steps.map((s) => s.typeID),
- );
- },
-);
-
-const unsubscribeBridgeExecuteCompleted = sdk.nexusEvents.on(
- NEXUS_EVENTS.BRIDGE_EXECUTE_COMPLETED_STEPS,
- (step: ProgressStep) => {
- console.log('Bridge & Execute completed →', step.typeID, step.data);
-
- if (step.typeID === 'IS' && step.data.explorerURL) {
- console.log('View transaction:', step.data.explorerURL);
- }
- },
-);
-
-// Transfer & Bridge Progress (optimized operations)
-const unsubscribeTransferExpected = sdk.nexusEvents.on(
- NEXUS_EVENTS.EXPECTED_STEPS,
- (steps: ProgressStep[]) => {
- console.log(
- 'Transfer/Bridge steps →',
- steps.map((s) => s.typeID),
- );
- // For direct transfers: ['CS', 'TS', 'IS'] (3 steps, ~5-15s)
- },
-);
-
-const unsubscribeTransferCompleted = sdk.nexusEvents.on(
- NEXUS_EVENTS.STEP_COMPLETE,
- (step: ProgressStep) => {
- console.log('Transfer/Bridge completed →', step.typeID, step.data);
-
- if (step.typeID === 'IS' && step.data.explorerURL) {
- // Transaction submitted with hash - works for both direct and CA
- console.log('Transaction hash:', step.data.transactionHash);
- console.log('Explorer URL:', step.data.explorerURL);
- }
- },
-);
-
-// Cleanup
-return () => {
- unsubscribeBridgeExecuteExpected();
- unsubscribeBridgeExecuteCompleted();
- unsubscribeTransferExpected();
- unsubscribeTransferCompleted();
-};
-```
-
-The SDK emits consistent event patterns for all operations:
-
-- Bridge & Execute Operations:
-
-`bridge_execute_expected_steps`: once with full ordered array of ProgressSteps
-`bridge_execute_completed_steps`: many; one per finished step with runtime data
-
-- Transfer & Bridge Operations:
-
-`expected_steps`: once; with full ordered array of ProgressSteps
-`step_complete` :many; one per finished step with runtime data
-
-All events include the same `typeID` structure and runtime `data` such as `transactionHash`, `explorerURL`, `confirmations`, `error`, etc.
-This provides consistent progress tracking whether using optimized direct operations or chain abstraction.
-
-### Provider Methods
-
-```typescript showLineNumbers filename="Typescript"
-import type { EthereumProvider, RequestArguments } from '@avail-project/nexus/core';
-
-// Get enhanced provider
-const provider: EthereumProvider = sdk.getEVMProviderWithCA();
-
-// Make EIP-1193 requests
-const result = await sdk.request({
- method: 'eth_accounts',
- params: [],
-} as RequestArguments);
-
-// Cleanup
-await sdk.deinit();
-```
-
-## Usage Examples
-
-### Basic Bridge with Result Handling
-
-```typescript showLineNumbers filename="Typescript"
-import { NexusSDK, type BridgeResult } from '@avail-project/nexus/core';
-
-const sdk = new NexusSDK();
-await sdk.initialize(window.ethereum);
-
-try {
- const result: BridgeResult = await sdk.bridge({
- token: 'USDC',
- amount: 100,
- chainId: 137,
- });
-
- if (result.success) {
- console.log('✅ Bridge successful!');
- if (result.explorerUrl) {
- console.log('View transaction:', result.explorerUrl);
- }
- } else {
- console.error('❌ Bridge failed:', result.error);
- }
-} catch (error) {
- console.error('Bridge error:', error);
-}
-```
-
-### Execute with Receipt Confirmation
-
-```typescript showLineNumbers filename="Typescript"
-import type { ExecuteResult } from '@avail-project/nexus/core';
-
-// MakerDAO DSR (Dai Savings Rate) Deposit
-const result: ExecuteResult = await sdk.execute({
- toChainId: 1,
- contractAddress: '0x373238337Bfe1146fb49989fc222523f83081dDb', // DSR Manager
- contractAbi: [
- {
- inputs: [
- { internalType: 'address', name: 'usr', type: 'address' },
- { internalType: 'uint256', name: 'wad', type: 'uint256' },
- ],
- name: 'join',
- outputs: [],
- stateMutability: 'nonpayable',
- type: 'function',
- },
- ],
- functionName: 'join',
- buildFunctionParams: (
- token: SUPPORTED_TOKENS,
- amount: string,
- chainId: SUPPORTED_CHAIN_IDS,
- userAddress: `0x${string}`,
- ) => {
- const decimals = TOKEN_METADATA[token].decimals;
- const amountWei = parseUnits(amount, decimals);
- return {
- functionParams: [userAddress, amountWei],
- };
- },
- waitForReceipt: true,
- requiredConfirmations: 3,
- tokenApproval: {
- token: 'USDC', // Will be converted to DAI in the bridge
- amount: '1000000',
- },
-});
-
-console.log('Transaction hash:', result.transactionHash);
-console.log('Explorer URL:', result.explorerUrl);
-console.log('Gas used:', result.gasUsed);
-console.log('Confirmations:', result.confirmations);
-```
-
-### Bridge and Execute with Error Handling
-
-```typescript showLineNumbers filename="Typescript"
-import type { BridgeAndExecuteResult } from '@avail-project/nexus/core';
-
-try {
- const result: BridgeAndExecuteResult = await sdk.bridgeAndExecute({
- token: 'USDC',
- amount: '1000',
- toChainId: 1,
- execute: {
- contractAddress: '0xA238Dd80C259a72e81d7e4664a9801593F98d1c5',
- contractAbi: [
- {
- inputs: [
- { internalType: 'address', name: 'asset', type: 'address' },
- { internalType: 'uint256', name: 'amount', type: 'uint256' },
- { internalType: 'address', name: 'onBehalfOf', type: 'address' },
- { internalType: 'uint16', name: 'referralCode', type: 'uint16' },
- ],
- name: 'supply',
- outputs: [],
- stateMutability: 'nonpayable',
- type: 'function',
- },
- ],
- functionName: 'supply',
- buildFunctionParams: (token, amount, chainId, userAddress) => {
- const decimals = TOKEN_METADATA[token].decimals;
- const amountWei = parseUnits(amount, decimals);
- const tokenAddress = TOKEN_CONTRACT_ADDRESSES[token][chainId];
- return {
- functionParams: [tokenAddress, amountWei, userAddress, 0],
- };
- },
- tokenApproval: {
- token: 'USDC',
- amount: '1000000000',
- },
- },
- waitForReceipt: true,
- });
-
- console.log('✅ Bridge and execute completed!');
- if (result.executeTransactionHash) {
- console.log('Execute transaction:', result.executeTransactionHash);
- console.log('View on explorer:', result.executeExplorerUrl);
- }
-} catch (error) {
- if (error.message.includes('User denied')) {
- console.log('User cancelled transaction');
- } else if (error.message.includes('Bridge phase failed')) {
- console.error('Bridge failed:', error);
- } else if (error.message.includes('Execute phase failed')) {
- console.error('Execute failed:', error);
- } else {
- console.error('Operation failed:', error);
- }
-}
-```
-### Complete Portfolio Management
-
-```typescript showLineNumbers filename="Typescript"
-import type { UserAsset, ChainMetadata } from '@avail-project/nexus/core';
-
-// Get complete balance overview
-const balances: UserAsset[] = await sdk.getUnifiedBalances();
-
-for (const asset of balances) {
- console.log(`\n${asset.symbol}: ${asset.balance}`);
- console.log(`Fiat value: $${asset.balanceInFiat || 0}`);
-
- if (asset.breakdown) {
- console.log('Chain breakdown:');
- for (const chainBalance of asset.breakdown) {
- const chain: ChainMetadata | undefined = sdk.utils.getChainMetadata(chainBalance.chain.id);
- console.log(` ${chain?.name}: ${chainBalance.balance}`);
- }
- }
-}
-```
-## Error Handling
-
-```typescript showLineNumbers filename="Typescript"
-import type { BridgeResult } from '@avail-project/nexus/core';
-
-try {
- const result: BridgeResult = await sdk.bridge({ token: 'USDC', amount: 100, chainId: 137 });
-
- if (!result.success) {
- // Handle bridge failure
- console.error('Bridge failed:', result.error);
- }
-} catch (error) {
- if (error.message.includes('User denied')) {
- // User cancelled transaction
- } else if (error.message.includes('Insufficient')) {
- // Insufficient balance
- } else if (error.message.includes('Unsupported')) {
- // Unsupported chain or token
- } else {
- // Other errors
- console.error('Unexpected error:', error);
- }
-}
-```
-## Troubleshooting
-
-### Common Issues
-
-1. **SDK not initialized**: Always call `await sdk.initialize(provider)` before using other methods.
-2. **Unsupported chain/token**: Check supported chains and tokens using `sdk.isSupportedChain()` and `sdk.isSupportedToken()`.
-3. **Insufficient allowance**: Use allowance management methods to check and set appropriate allowances.
-4. **Provider issues**: Ensure your Web3 provider is properly connected and on a supported network.
diff --git a/app/api-reference/avail-nexus-sdk/examples/_meta.ts b/app/api-reference/avail-nexus-sdk/examples/_meta.ts
deleted file mode 100644
index beb02d4f2..000000000
--- a/app/api-reference/avail-nexus-sdk/examples/_meta.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-export default {
-
- "fetch-unified-balances": "Unified Balance",
- "transfer": "Transfer",
- "bridge-tokens": "Bridge",
- "bridge-and-execute": "Bridge & Execute"
-}
\ No newline at end of file
diff --git a/app/api-reference/avail-nexus-sdk/examples/bridge-and-execute/page.mdx b/app/api-reference/avail-nexus-sdk/examples/bridge-and-execute/page.mdx
deleted file mode 100644
index da8f0b182..000000000
--- a/app/api-reference/avail-nexus-sdk/examples/bridge-and-execute/page.mdx
+++ /dev/null
@@ -1,174 +0,0 @@
----
-title: "Bridge and Execute with BridgeAndExecuteButton widget"
----
-
-import { Callout, Tabs } from 'nextra/components'
-
-# ``
-
-
-**SET UP THE SDK BEFORE YOU START:**
-
-You can find the SDK setup instructions in the [Overview](/api-reference/avail-nexus-sdk/overview) page.
-
-
-Use the `BridgeAndExecuteButton` component to provide a pre-built interface that handles bridging tokens to a destination chain and then executing a smart contract function on that chain in a single flow.
-
-The widget automatically manages the bridge + execute flow, UI modals, transaction state, and token approvals. \
-Useful for flows like *“bridge 500 USDC to Base and stake it in a lending pool in a single click.”*
-
-
-**Note:**
-
-1. We made a small demo website that implements the `BridgeAndExecuteButton` widget.
-Check it out here: [nexus-ui-components-demo.vercel.app](https://nexus-ui-components-demo.vercel.app/)
-
-2. If you just want to see an example that uses the `BridgeAndExecuteButton` widget,
-refer to the repo here: [nexus-ui-components-demo](https://github.com/availproject/nexus-ui-components-demo/blob/main/src/components/nexus.tsx#L52)
-
-
-## Props
-
-```typescript showLineNumbers filename="Typescript"
-interface BridgeAndExecuteButtonProps {
- contractAddress: `0x${string}`;
- contractAbi: Abi;
- functionName: string;
- buildFunctionParams: DynamicParamBuilder;
- prefill?: {
- toChainId?: SUPPORTED_CHAINS_IDS;
- token?: SUPPORTED_TOKENS;
- amount?: string;
- };
- children: (props: {
- onClick: () => void;
- isLoading: boolean;
- disabled: boolean;
- }) => ReactNode;
- className?: string;
-}
-
-type DynamicParamBuilder = (
- token: SUPPORTED_TOKENS,
- amount: string,
- chainId: SUPPORTED_CHAINS_IDS,
- userAddress: `0x${string}`
-) => {
- functionParams: readonly unknown[];
- value?: string;
-};
-```
-
-## Example
-
-
-**Note:** \
-Refer to the [API reference](/api-reference/avail-nexus-sdk/api-reference) for a full list of supported tokens and chains,
-as well as more examples of how to use the `BridgeAndExecuteButton` widget.
-
-
-Here are examples of how to use the `BridgeAndExecuteButton` widget:
-
-### Basic Bridge & Execute Button
-
-```tsx showLineNumbers filename="App.tsx"
-import { NexusProvider, BridgeAndExecuteButton, TOKEN_METADATA, TOKEN_CONTRACT_ADDRESSES } from '@avail-project/nexus/ui';
-import { parseUnits } from 'viem';
-
-function App() {
- return (
- {
- const decimals = TOKEN_METADATA[token].decimals;
- const amountWei = parseUnits(amount, decimals);
- const tokenAddr = TOKEN_CONTRACT_ADDRESSES[token][chainId];
- return {
- functionParams: [tokenAddr, amountWei, userAddress, 0],
- value: '0' // No ETH value for ERC-20 token supply
- };
- }}
- >
- {({ onClick, isLoading, disabled }) => (
-
- )}
-
- );
-}
-```
-
-`buildFunctionParams` receives the validated UX input (token, amount, destination chainId) plus the connected wallet address and must return the encoded functionParams
-(and optional ETH value) used in the destination call.
-
-The library then:
-
-- Bridges the asset to toChainId.
-- Sets ERC-20 allowance if required.
-- **Executes** `contractAddress.functionName(functionParams, { value })`.
-
-
-### Pre-filled Bridge & Execute
-
-```tsx showLineNumbers filename="App.tsx"
-import { NexusProvider BridgeAndExecuteButton, TOKEN_METADATA, TOKEN_CONTRACT_ADDRESSES } from '@avail-project/nexus/ui';
-import { parseUnits } from 'viem';
-
-function App() {
- return (
- {
- const decimals = TOKEN_METADATA[token].decimals;
- const amountWei = parseUnits(amount, decimals);
- const tokenAddr = TOKEN_CONTRACT_ADDRESSES[token][chainId];
- return {
- functionParams: [tokenAddr, amountWei, userAddress, 0]
- };
- }}
- prefill={{
- toChainId: 42161, // Arbitrum
- token: 'USDT',
- amount: '100'
- }}
- >
- {({ onClick, isLoading, disabled }) => (
-
- )}
-
- );
-}
-```
\ No newline at end of file
diff --git a/app/api-reference/avail-nexus-sdk/examples/bridge-tokens/page.mdx b/app/api-reference/avail-nexus-sdk/examples/bridge-tokens/page.mdx
deleted file mode 100644
index d974711a0..000000000
--- a/app/api-reference/avail-nexus-sdk/examples/bridge-tokens/page.mdx
+++ /dev/null
@@ -1,95 +0,0 @@
----
-title: "Bridge tokens with BridgeButton widget"
----
-
-import { Callout, Tabs } from 'nextra/components'
-
-# ``
-
-
-**SET UP THE SDK BEFORE YOU START:**
-
-You can find the SDK setup instructions in the [Overview](/api-reference/avail-nexus-sdk/overview) page.
-
-
-Use the `BridgeButton` component to provide a pre-built bridge interface that handles token bridging between supported chains.
-The widget automatically manages the bridge flow, UI modals, and transaction state.
-
-
-**Note:**
-
-1. We made a small demo website that implements the `BridgeButton` widget.
-Check it out here: [nexus-ui-components-demo.vercel.app](https://nexus-ui-components-demo.vercel.app/)
-
-2. If you just want to see an example that uses the `BridgeButton` widget,
-refer to the repo here: [nexus-ui-components-demo](https://github.com/availproject/nexus-ui-components-demo/blob/main/src/components/nexus.tsx#L20)
-
-
-## Props
-
-```typescript showLineNumbers filename="Typescript"
-interface BridgeButtonProps {
- prefill?: BridgeConfig;
- children: (props: { onClick: () => void; isLoading: boolean }) => ReactNode;
- className?: string;
-}
-
-interface BridgeConfig {
- token?: SUPPORTED_TOKENS;
- amount?: number | string;
- chainId?: SUPPORTED_CHAINS_IDS;
- gas?: bigint;
-}
-```
-
-## Example
-
-
-**Note:** \
-Refer to the [API reference](/api-reference/avail-nexus-sdk/api-reference) for a full list of supported tokens and chains,
-as well as more examples of how to use the `BridgeButton` widget.
-
-
-Here are examples of how to use the `BridgeButton` widget:
-
-### Basic Bridge Button
-
-```tsx showLineNumbers filename="App.tsx"
-import {NexusProvider, BridgeButton } from '@avail-project/nexus/ui';
-
-function App() {
- return (
-
- {({ onClick, isLoading }) => (
-
- )}
-
- );
-}
-```
-
-### Pre-filled Bridge Button
-
-```tsx showLineNumbers filename="App.tsx"
-import { NexusProvider, BridgeButton } from '@avail-project/nexus/ui';
-
-function App() {
- return (
-
- {({ onClick, isLoading }) => (
-
- )}
-
- );
-}
-```
\ No newline at end of file
diff --git a/app/api-reference/avail-nexus-sdk/examples/fetch-unified-balances/page.mdx b/app/api-reference/avail-nexus-sdk/examples/fetch-unified-balances/page.mdx
deleted file mode 100644
index 5e509036f..000000000
--- a/app/api-reference/avail-nexus-sdk/examples/fetch-unified-balances/page.mdx
+++ /dev/null
@@ -1,86 +0,0 @@
----
-title: "Fetch unified balance of a user"
----
-
-import { Callout, Steps, Tabs } from 'nextra/components'
-
-# `getUnifiedBalances()` & `getUnifiedBalance()`
-
-
-**SET UP THE SDK BEFORE YOU START:**
-
-You can find the SDK setup instructions in the [Overview](/api-reference/avail-nexus-sdk/overview) page.
-
-
-Use these functions to fetch consolidated token balances across all supported chains.
-This shows users their total available liquidity without needing to check each chain individually.
-
-
-**Note:** Check out the [API reference](/api-reference/avail-nexus-sdk/api-reference) for a full list of supported tokens and chains.
-
-
-## Parameters
-
-### `getUnifiedBalances()`
-
-Fetches the unified balance of all tokens across all chains for a user.
-
-```typescript showLineNumbers filename="Typescript"
-// No parameters required
-await sdk.getUnifiedBalances(): Promise
-```
-
-### `getUnifiedBalance(symbol)`
-
-Fetches the unified balance of a specific token across all chains for a user.
-
-```typescript showLineNumbers filename="Typescript"
-// Takes a token symbol parameter
-await sdk.getUnifiedBalance(symbol: string): Promise
-```
-
-## Example
-
-Here are some minimal examples of how to use the functions to fetch the unified balance of a user:
-
-```typescript showLineNumbers filename="Typescript"
-// Get all balances across chains
-const allBalances = await sdk.getUnifiedBalances();
-console.log('All balances:', allBalances);
-
-// Get balance for specific token
-const usdcBalance = await sdk.getUnifiedBalance('USDC');
-console.log('USDC balance:', usdcBalance);
-```
-
-## Return Value
-
-- `getUnifiedBalances()`: Returns `Promise` - Array of `UserAsset` class instances
-- `getUnifiedBalance(symbol)`: Returns `Promise` - Single `UserAsset` instance or undefined
-
-```typescript showLineNumbers filename="Typescript"
-class UserAsset {
- value: UserAssetDatum; // The actual data
- get balance(): string; // Getter for balance
-}
-
-// The underlying data structure
-interface UserAssetDatum {
- symbol: string; // Token symbol (e.g., 'USDC', 'ETH')
- balance: string; // Total balance across all chains
- balanceInFiat: number; // USD value of the balance
- decimals: number; // Token decimals
- breakdown: { // Per-chain breakdown array
- balance: string; // Balance on this specific chain
- balanceInFiat: number; // USD value on this chain
- chain: {
- id: number; // Chain ID
- logo: string; // Chain logo URL
- name: string; // Chain name
- };
- contractAddress: `0x${string}`; // Token contract address
- decimals: number; // Token decimals on this chain
- isNative?: boolean; // Whether this is native token (optional)
- }[];
-}
-```
\ No newline at end of file
diff --git a/app/api-reference/avail-nexus-sdk/examples/transfer/page.mdx b/app/api-reference/avail-nexus-sdk/examples/transfer/page.mdx
deleted file mode 100644
index c0f8c7f39..000000000
--- a/app/api-reference/avail-nexus-sdk/examples/transfer/page.mdx
+++ /dev/null
@@ -1,95 +0,0 @@
----
-title: "Transfer tokens with TransferButton widget"
----
-
-import { Callout, Tabs } from 'nextra/components'
-
-# ``
-
-
-**SET UP THE SDK BEFORE YOU START:**
-
-You can find the SDK setup instructions in the [Overview](/api-reference/avail-nexus-sdk/overview) page.
-
-
-Use the `TransferButton` component to provide a pre-built transfer interface that handles token transfers to any wallet address on any supported chain.
-The widget automatically manages the transfer flow, UI modals, and transaction state.
-
-
-**Note:**
-1. We made a small demo website that implements the `TransferButton` widget.
-Check it out here: [nexus-ui-components-demo.vercel.app](https://nexus-ui-components-demo.vercel.app/)
-
-2. If you just want to see an example that uses the `TransferButton` widget,
-refer to the repo here: [nexus-ui-components-demo](https://github.com/availproject/nexus-ui-components-demo/blob/main/src/components/nexus.tsx#L34)
-
-
-## Props
-
-```typescript showLineNumbers filename="Typescript"
-interface TransferButtonProps {
- prefill?: TransferConfig;
- children: (props: { onClick: () => void; isLoading: boolean }) => ReactNode;
- className?: string;
-}
-
-interface TransferConfig {
- chainId?: number;
- token?: SUPPORTED_TOKENS;
- amount?: string;
- recipient?: `0x${string}`;
-}
-```
-
-## Example
-
-
-**Note:** \
-Refer to the [API reference](/api-reference/avail-nexus-sdk/api-reference) for a full list of supported tokens and chains,
-as well as more examples of how to use the `TransferButton` widget.
-
-
-Here are examples of how to use the `TransferButton` widget:
-
-### Basic Transfer Button
-
-```tsx showLineNumbers filename="App.tsx"
-import { NexusProvider, TransferButton } from '@avail-project/nexus/ui';
-
-function App() {
- return (
-
- {({ onClick, isLoading }) => (
-
- )}
-
- );
-}
-```
-
-### Pre-filled Transfer Button
-
-```tsx showLineNumbers filename="App.tsx"
-import { NexusProvider, TransferButton } from '@avail-project/nexus/ui';
-
-function App() {
- return (
-
- {({ onClick, isLoading }) => (
-
- )}
-
- );
-}
-```
\ No newline at end of file
diff --git a/app/api-reference/avail-nexus-sdk/overview/page.mdx b/app/api-reference/avail-nexus-sdk/overview/page.mdx
deleted file mode 100644
index bd913579e..000000000
--- a/app/api-reference/avail-nexus-sdk/overview/page.mdx
+++ /dev/null
@@ -1,173 +0,0 @@
----
-title: "Get Started"
----
-
-import { Callout, Steps, Tabs } from 'nextra/components';
-
-# Get Started
-
-
- We built a React demo app that uses the Avail Nexus SDK UI components to implement a unified Web3 experience.
-
- 1. You can use the app here: [`nexus-ui-components-demo.vercel.app`](https://nexus-ui-components-demo.vercel.app/)
- 2. You can find the code for the app here: [`availproject/nexus-ui-components-demo`](https://github.com/availproject/nexus-ui-components-demo)
-
-
-
-The Avail Nexus SDK provides both headless functionality and pre-built React UI components. This guide covers the **React UI components** which offer the fastest way to integrate chain abstraction into your React app.
-
-
-The SDK provides `BridgeButton`, `TransferButton`, and `BridgeAndExecuteButton` components. Each widget is covered in detail in the following pages.
-
-
-
-The Avail Nexus SDK provides some built-in React widgets that make it easier for devs to
-integrate the SDK into their existing React app.
-
-### Get `NexusProvider`
-
-Wrap your app with the `NexusProvider`.
-
-Enable the Nexus SDK functionality by adding the `NexusProvider` to your app's root component. (For e.g.,`layout.tsx` in Next.js or `App.tsx` in Remix, etc.):
-
-```tsx showLineNumbers filename="__root.tsx"
-import { NexusProvider } from '@avail-project/nexus/ui';
-
-export default function Root() {
- return (
-
-
-
- );
-}
-```
-
-
-**FOR EXAMPLE:**
-
-The demo app sets up the `NexusProvider` in the [__root.tsx](https://github.com/availproject/nexus-ui-components-demo/blob/main/src/routes/__root.tsx#L50) file,
-wrapping the entire application with both wallet authentication (Privy) and the Nexus provider.
-
-
-
-
-
-
-### Use UI Components
-
-Forward the user's wallet provider and drop a widget into your UI.
-The UI components handle the SDK initialization for you.
-
-The following example shows how you would use the bridge button, but other widgets are covered in the following pages:
-
-```tsx showLineNumbers filename="WalletBridge.tsx"
-// Complete example showing both wallet provider setup AND widget usage
-import { useEffect } from 'react';
-import { useAccount } from '@wagmi/react';
-import { useNexus, BridgeButton } from '@avail-project/nexus/ui';
-
-function MyApp() {
- const { connector, isConnected } = useAccount();
- const { setProvider } = useNexus();
-
- // Forward wallet provider
- useEffect(() => {
- if (isConnected && connector?.getProvider) {
- connector.getProvider().then(setProvider);
- }
- }, [isConnected, connector, setProvider]);
-
- // Use UI widgets (initialization happens automatically)
- return (
-
- {({ onClick, isLoading }) => (
-
- )}
-
- );
-}
-```
-
-
-**Any wallet library works:** The example shows Wagmi, but you can use Privy, RainbowKit, ConnectKit, or any library that provides an EIP-1193 provider.
-
-The demo app uses Privy and forwards the provider in [connect-wallet.tsx](https://github.com/availproject/nexus-ui-components-demo/blob/main/src/components/connect-wallet.tsx#L16).
-
-
-
-
-
-
-### Manual initialization
-
-You can also manually initialize the SDK instead of leaving it up to the UI components.
-The code snippet below shows how:
-
-
-You still need to wrap your app with the `NexusProvider` before proceeding with the manual initialization.
-
-
-```tsx showLineNumbers filename="App.tsx"
-import { useNexus } from '@avail-project/nexus/ui';
-
-function MyComponent() {
- const { initializeSdk, sdk, isSdkInitialized } = useNexus();
-
- const handleInitialize = async () => {
- const provider = await window.ethereum; // or get from your wallet library
- await initializeSdk(provider); // Initializes both SDK and UI state
-
- // Now you can use SDK methods directly
- const balances = await sdk.getUnifiedBalances();
- console.log('Balances:', balances);
-
- // UI components will already be initialized when used
- };
-
- return (
-
- );
-}
-```
-
-
-**WHAT THIS MEANS?**
-
-1. The `useNexus` hook now shares the initialized SDK instance with the UI components.
-2. You can initialize the SDK manually, and then use the UI components to sign transactions.
-3. With the shared state, just one signature is needed to initialize the SDK and use the UI components.
-
-
-
-
-
-
-
-What do we mean by "unified balance"?
-
-Unified balance shows all the liquidity in a user's EOA account across multiple chains in one view. It lets users transact seamlessly on any chain without needing bridges or pre-provisioning gas for token swaps. Chain abstraction handles all the complexity involved in a cross-chain transaction while enabling better UX through a single intent approval.
-
-For instance, let us take the case where a user intends to spend 18 USDC on Scroll and does not have any balance on Scroll.
-
-- Optimism: 0.1 ETH, O USDT, 0 USDC
-- Arbitrum: 0 ETH, 12 USDT, 0 USDC
-- Base: 0 ETH, 10 USDT, 0 USDC
-- Scroll: 0 ETH, 0 USDT, 0 USDC
-
-To spend 18 USDC on Scroll (destination chain) with the given liquidity fragmentation, it would typically require multiple clicks and steps for swapping or bridging different assets available on the source chains, so that user can convert the assets to the desired token balance on Scroll.
-
-Through chain abstraction and ability to swap cross-chain, users have the convenience to view the consolidated token balance across supported tokens and chains. This simplifies the process of sending 18 USDC on Optimism, as users can sign the intent without the need for bridging, swapping, or considering the optimal routes.
-
-The cross-chain swap enables users to:
-
-- Spend assets on any destination chain without prior liquidity.
-- Collate payable amount by combining multiple supported assets across source chains to address liquidity fragmentation.
-
\ No newline at end of file
diff --git a/app/api-reference/avail-nexus-sdk/page.mdx b/app/api-reference/avail-nexus-sdk/page.mdx
deleted file mode 100644
index ed48d4bca..000000000
--- a/app/api-reference/avail-nexus-sdk/page.mdx
+++ /dev/null
@@ -1,71 +0,0 @@
----
-image: "/img/docs-link-preview.png"
-title: Avail Nexus SDK Reference
-asIndexPage: true
----
-
-import { Callout, Steps, Tabs } from 'nextra/components';
-
-# Avail Nexus
-
-## Prerequisites
-
-
-**BEFORE WE START**
-
-1. The Nexus SDK requires an injected wallet provider (e.g. MetaMask, WalletConnect, etc.)
-2. It is designed for client-side browser environments and **cannot be used** in any server-side environments.
-3. You will need a React-based dev environment to use the SDK UI components.
-4. GitHub: [`availproject/nexus-sdk`](https://github.com/availproject/nexus-sdk)
-5. `npm.js` Package: [`@avail-project/nexus`](https://www.npmjs.com/package/@avail-project/nexus)
-
-
-## Dev Environment Setup
-
-
-
-### Use React Frontend
-
-Set up a React Frontend Project.
-
-Any React-based dev environment works, including React frameworks like Next.js, Remix, Gatsby, or build tools like Vite, Create React App, and Webpack.
-
-### Install SDK
-
-Install the Nexus SDK.
-
-Use any package manager of your choice to install the Nexus SDK:
-
-
-
-
-```bash filename="Terminal"
-npm install @avail-project/nexus
-```
-
-
-
-
-```bash filename="Terminal"
-yarn add @avail-project/nexus
-```
-
-
-
-
-```bash filename="Terminal"
-pnpm add @avail-project/nexus
-```
-
-
-
-
-
- We built a React demo app that uses the Avail Nexus SDK UI components to implement a unified Web3 experience.
-
- 1. You can use the app here: [`nexus-ui-components-demo.vercel.app`](https://nexus-ui-components-demo.vercel.app/)
- 2. You can find the code for the app here: [`availproject/nexus-ui-components-demo`](https://github.com/availproject/nexus-ui-components-demo)
-
-
-
-
diff --git a/app/api-reference/avail-node-api/_meta.ts b/app/api-reference/avail-node-api/_meta.ts
index 8108cd8b8..9bbdb4dea 100644
--- a/app/api-reference/avail-node-api/_meta.ts
+++ b/app/api-reference/avail-node-api/_meta.ts
@@ -1,60 +1,43 @@
export default {
- "Data availability pallet": {
- type: "separator",
- title: "Data availability pallet",
- },
-
- "da-create-application-key": "Create a new App ID on Avail DA",
- "da-submit-data": "Submit new data to Avail DA",
- "da-app-keys": "Fetch App IDs from Avail DA",
- "da-next-app-id": "Fetch the next available App ID on Avail DA",
-
- "Balances pallet": {
- type: "separator",
- title: "Balances pallet",
- },
-
- "balances-transfer-keep-alive":
- "Transfer funds while ensuring min balance for sender",
- "balances-transfer-allow-death":
- "Transfer funds without ensuring min balance for sender",
- "balances-transfer-all": "Transfer all funds from one account to another",
- "system-account": "Fetch balances and other information for an account",
-
- "Staking pallet": {
- type: "separator",
- title: "Staking pallet",
- },
-
- "staking-active-era": "Fetch information on the active era",
- "staking-bond": "Bond AVAIL tokens on Avail DA",
- "staking-nominate": "Nominate staked AVAIL tokens to one or more validators",
- "staking-validate": "Become a validator on Avail DA",
- "staking-chill": "Stop validating on Avail DA",
- "staking-unbond": "Unbond AVAIL tokens from Avail DA",
- "nomination-pools": {
- type: "separator",
- title: "Nomination Pools pallet",
- },
-
- "nomination-pools-join": "Join a nomination pool",
+ "Data availability pallet": {
+ "type": "separator",
+ "title": "Data availability pallet"
+ },
+
+ "da-create-application-key": "Create a new App ID on Avail DA",
+ "da-submit-data": "Submit new data to Avail DA",
+ "da-app-keys": "Fetch App IDs from Avail DA",
+ "da-next-app-id": "Fetch the next available App ID on Avail DA",
+
+ "Balances pallet": {
+ "type": "separator",
+ "title": "Balances pallet"
+ },
+
+ "balances-transfer-keep-alive": "Transfer funds while ensuring min balance for sender",
+ "balances-transfer-allow-death": "Transfer funds without ensuring min balance for sender",
+ "balances-transfer-all": "Transfer all funds from one account to another",
+ "system-account": "Fetch balances and other information for an account",
+
+ "Staking pallet": {
+ "type": "separator",
+ "title": "Staking pallet"
+ },
+
+ "staking-bond": "Bond AVAIL tokens on Avail DA",
+ "staking-nominate": "Nominate staked AVAIL tokens to one or more validators",
+ "staking-unbond": "Unbond AVAIL tokens from Avail DA",
+ "staking-validate": "Become a validator on Avail DA",
+ "staking-chill": "Stop validating on Avail DA",
+ "staking-active-era": "Fetch information on the active era",
+
+ "nomination-pools": {
+ "type": "separator",
+ "title": "Nomination Pools pallet"
+ },
+
"nomination-pools-create": "Create a new nomination pool",
- "nomination-pools-create-with-pool-id":
- "Create a new nomination pool with a specific pool ID",
+ "nomination-pools-create-with-pool-id": "Create a new nomination pool with a specific pool ID",
"nomination-pools-nominate": "Nominate validator(s) for your nomination pool",
-
- "RPC Calls": {
- type: "separator",
- title: "RPC Calls",
- },
-
- "chain-get-block": "Fetch block data using different calls",
-
- "author-submit-extrinsic": {
- display: "hidden",
- },
-
- "author-submit-and-watch-extrinsic": {
- display: "hidden",
- },
+ "nomination-pools-join": "Join a nomination pool",
};
diff --git a/app/api-reference/avail-node-api/author-submit-and-watch-extrinsic/page.mdx b/app/api-reference/avail-node-api/author-submit-and-watch-extrinsic/page.mdx
deleted file mode 100644
index 5c3678ebd..000000000
--- a/app/api-reference/avail-node-api/author-submit-and-watch-extrinsic/page.mdx
+++ /dev/null
@@ -1,21 +0,0 @@
----
-title: "author-submit-and-watch-extrinsic"
-description: "Manually submit an extrinsic to the network and wait for finalization"
-keywords: ["author_submitAndWatchExtrinsic", "submitAndWatchExtrinsic", "submitAndWatch"]
----
-
-import { Callout } from 'nextra/components'
-
-# Manually submit an extrinsic to the network and wait for finalization
-
-
-**`author_submitAndWatchExtrinsic` IS NOT RECOMMENDED FOR USE RIGHT NOW**
-
-1. Avail builds on top of the [Polkadot SDK](https://docs.polkadot.com/develop/parachains/intro-polkadot-sdk/#substrate) (formerly known as Substrate)
-and implements most of it's underlying calls and extrinsics.
-2. The `author_submitAndWatchExtrinsic` RPC call is known to be buggy and unreliable, and as such, not recommended for use.
-3. We recommend most devs [use our dedicated SDKs](/api-reference/avail-node-api) instead of trying to use this RPC call directly.
-4. You can read more about the problem in this Github issue: https://github.com/paritytech/subxt/issues/1668
-5. Since the problem is upstream, we can't fix it directly.
-6. We will keep this page updated with any new information :)
-
\ No newline at end of file
diff --git a/app/api-reference/avail-node-api/author-submit-extrinsic/page.mdx b/app/api-reference/avail-node-api/author-submit-extrinsic/page.mdx
deleted file mode 100644
index fc0a4c495..000000000
--- a/app/api-reference/avail-node-api/author-submit-extrinsic/page.mdx
+++ /dev/null
@@ -1,22 +0,0 @@
----
-title: "author-submit-extrinsic"
-description: "Manually Submit an extrinsic to the network"
-keywords: ["author_submitExtrinsic", "submitExtrinsic"]
----
-
-import { Callout } from 'nextra/components'
-
-# Manually submit an extrinsic to the network
-
-
-**WE RECOMMEND USING THE AVAIL SDKs DIRECTLY**
-1. The `author_submitExtrinsic` RPC call is a low-level API that allows you to manually submit any extrinsic to the Avail network using a signed hash.
-2. We recommend using our dedicated SDKs instead of using this RPC call directly for convenience.
-3. The SDKs themselves use this RPC call internally, and offer a higher level of abstraction for interacting with the network.
-
-
-
-**KNOW THE DIFFERENCE**
-1. `author_submitExtrinsic` & `author_submitAndWatchExtrinsic` are different RPC calls that serve different, but similar purposes.
-2. We recommend not using the latter directly either. You can read about the problems with it [in this page in our docs](/api-reference/avail-node-api/author-submit-and-watch-extrinsic).
-
\ No newline at end of file
diff --git a/app/api-reference/avail-node-api/balances-transfer-all/page.mdx b/app/api-reference/avail-node-api/balances-transfer-all/page.mdx
index cdb695f42..663a6f718 100644
--- a/app/api-reference/avail-node-api/balances-transfer-all/page.mdx
+++ b/app/api-reference/avail-node-api/balances-transfer-all/page.mdx
@@ -1,7 +1,3 @@
----
-image: '/img/docs-link-preview.png'
----
-
import { Callout, Steps, Tabs } from 'nextra/components'
# Transfer all funds from one account to another
@@ -63,64 +59,36 @@ The rest of the code should work as is.
1. Inside `your-file-name.ts`, add the following code:
-```typescript showLineNumbers filename="avail-js" name="cmd1"
-import * as dotenv from 'dotenv';
-import { Account, SDK } from 'avail-js-sdk';
-
-dotenv.config();
-
-export async function transferAll() {
- // Initialize SDK with Turing endpoint
- const sdk = await SDK.New('wss://turing-rpc.avail.so/ws');
-
- // Create account from seed in .env file
- const seed = process.env.SEED;
- if (!seed) {
- throw new Error("SEED environment variable is not set");
- }
-
- // Create account from seed
- const account = Account.new(seed);
- console.log("Sender Address: ", account.address);
-
- // Destination address to send all available AVAIL to
- const destinationAddress = "5DDY2yzh8uCysYFAiRSTeQVwtZSKNF49CkQkyPH852xvrYKk";
- console.log("Recipient Address: ", destinationAddress);
-
- // Setting this value to false will reap your account
- const keepAlive = true;
-
- // Create transfer all transaction
- const tx = sdk.tx.balances.transferAll(destinationAddress, keepAlive);
- console.log("Submitting transfer all transaction...");
-
- // Execute and wait for inclusion
- const res = await tx.executeWaitForInclusion(account, {});
-
- // Check if transaction was successful
- const isOk = res.isSuccessful();
- if (isOk === undefined) {
- throw new Error("Cannot check if transaction was successful");
- }
- else if (!isOk) {
- throw new Error("Transaction failed");
- }
-
- console.log(`Transaction Hash: ${res.txHash}`);
- console.log(`Block Hash: ${res.blockHash}`);
- console.log(`Block Number: ${res.blockNumber}`);
- console.log("Transfer completed successfully");
-
- process.exit(0);
-}
+```typescript showLineNumbers filename="avail-js"
+import { SDK, WaitFor, Keyring, BN } from "avail-js-sdk"
+
+const main = async () => {
+ const providerEndpoint = "wss://turing-rpc.avail.so/ws";
+ const sdk = await SDK.New(providerEndpoint)
+
+ const Alice = 'This is a random seed phrase please replace with your own';
+ const account = new Keyring({ type: "sr25519" }).addFromUri(Alice)
+ const dest = "5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw" // Eve
+ const keepAlive = true
+
+ const result = await sdk.tx.balances.transferAll(dest, keepAlive, WaitFor.BlockInclusion, account)
+ if (result.isErr) {
+ console.log(result.reason)
+ process.exit(1)
+ }
-// Execute the function
-transferAll();
+ console.log("From=" + result.event.from + ", To=" + result.event.to + ", Amount=" + result.event.amount)
+ console.log("MaybeKilled=" + result.event2?.account)
+ console.log("TxHash=" + result.txHash + ", BlockHash=" + result.blockHash)
+
+ process.exit()
+}
+main()
```
2. Run the code using:
-```bash filename="terminal" name="cmd2"
+```bash
ts-node your-file-name.ts
```
@@ -129,54 +97,46 @@ ts-node your-file-name.ts
1. Inside `main.rs`, add the following code:
-```rust showLineNumbers filename="avail-rust" name="cmd3"
-use dotenvy::dotenv;
-use std::env;
-use avail_rust::prelude::*;
+```rust showLineNumbers filename="avail-rust"
+use avail_rust::{Keypair, Nonce, Options, SecretUri, WaitFor, SDK};
use core::str::FromStr;
-
-pub async fn transfer_all() -> Result<(), ClientError> {
-
- // Create a new SDK instance
- let sdk = SDK::new("wss://turing-rpc.avail.so/ws").await?;
-
- // Loading seed phrase and creating an account derived from the seed
- dotenv().ok();
- let seed = env::var("SEED").expect("SEED environment variable is not set");
- let account = account::from_secret_uri(&seed)?;
- println!("Account Address: {}", account.public_key().to_account_id());
-
- // Executing the transaction
- let dest = AccountId::from_str("5DDY2yzh8uCysYFAiRSTeQVwtZSKNF49CkQkyPH852xvrYKk").unwrap();
-
- // Please take note of the `keep_alive` bool parameter
- // If set to true (which is the case right now), the transfer transaction will leave the origin account with a small balance
- // that is above the existential deposit and prevents the account from being reaped
-
- // Set the `keep_alive` parameter to `false` only if you are ok with the origin account being reaped
- let tx = sdk.tx.balances.transfer_all(dest, true);
- let res = tx.execute_and_watch_inclusion(&account, Options::default()).await?;
-
- println!(
- "Block Hash: {:?}, Block Number: {}, Tx Hash: {:?}, Tx Index: {}",
- res.block_hash, res.block_number, res.tx_hash, res.tx_index
- );
-
- Ok(())
-}
-
-// Add a main function to call transfer_all
+
#[tokio::main]
-async fn main() {
- if let Err(e) = transfer_all().await {
- eprintln!("Error: {:?}", e);
- }
+async fn main() -> Result<(), String> {
+ let sdk = SDK::new("wss://turing-rpc.avail.so/ws").await.unwrap();
+
+ let alice = "This is a random seed phrase please replace with your own";
+ let secret_uri = SecretUri::from_str(alice).unwrap();
+ let account = Keypair::from_uri(&secret_uri).unwrap();
+ let dest = "5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw"; // Eve
+ let keep_alive = false;
+ let options = Options::new().nonce(Nonce::BestBlockAndTxPool);
+
+ let result = sdk
+ .tx
+ .balances
+ .transfer_all(dest, keep_alive, WaitFor::BlockInclusion, &account, Some(options))
+ .await?;
+
+ println!(
+ "From={}, To={}, Amount={}",
+ result.event.from, result.event.to, result.event.amount
+ );
+ if let Some(event) = result.event2 {
+ println!("Killed={}", event.account);
+ }
+ println!(
+ "TxHash={:?}, BlockHash={:?}",
+ result.tx_hash, result.block_hash
+ );
+
+ Ok(())
}
```
2. Run the code using:
-```bash filename="terminal" name="cmd4"
+```bash
cargo run
```
@@ -185,89 +145,50 @@ cargo run
1. Inside `main.go`, add the following code:
-```go showLineNumbers filename="avail-go" name="cmd5"
+```go showLineNumbers filename="avail-go"
package main
import (
- "fmt"
- "log"
- "os"
+ "github.com/availproject/avail-go-sdk/src/config"
+ "github.com/availproject/avail-go-sdk/src/sdk"
+ "github.com/availproject/avail-go-sdk/src/sdk/tx"
- "github.com/availproject/avail-go-sdk/primitives"
- SDK "github.com/availproject/avail-go-sdk/sdk"
- "github.com/joho/godotenv"
+ "fmt"
)
func main() {
- // Load environment variables from .env file
- err := godotenv.Load()
- if err != nil {
- log.Fatal("Error loading .env file")
- }
-
- // Make sure the SEED environment variable is set
- seed := os.Getenv("SEED")
- if seed == "" {
- log.Fatal("SEED environment variable is not set")
- }
-
- // Create an account from the SEED environment variable
- acc, err := SDK.Account.NewKeyPair(seed)
- if err != nil {
- log.Fatalf("Failed to create account: %v", err)
- }
- fmt.Println("Your account Address: " + acc.SS58Address(42))
-
- // Initialize an SDK instance
- sdk, err := SDK.NewSDK("https://turing-rpc.avail.so/rpc")
+ config, err := config.LoadConfig()
if err != nil {
- log.Fatalf("Failed to initialize SDK: %v", err)
+ fmt.Printf("cannot load config:%v", err)
}
-
- // Convert the hex string to a MultiAddress
- destAddress, err := primitives.NewAccountIdFromAddress("5DDY2yzh8uCysYFAiRSTeQVwtZSKNF49CkQkyPH852xvrYKk")
+ api, err := sdk.NewSDK(config.ApiURL)
if err != nil {
- log.Fatalf("Failed to convert address: %v", err)
+ fmt.Printf("cannot create api:%v", err)
}
- dest := destAddress.ToMultiAddress()
-
- // Set to false if you don't want to keep the account alive
- keepAlive := true
+ WaitFor := sdk.BlockInclusion
- // Transferring all funds
- tx := sdk.Tx.Balances.TransferAll(dest, keepAlive)
-
- // Execute the transaction
- res, err := tx.ExecuteAndWatchInclusion(acc, SDK.NewTransactionOptions())
+ dest := "5GNJqTPyNqANBkUVMN1LPPrxXnFouWXoe2wNSmmEoLctxiZY"
+ BlockHash, txHash, err := tx.TransferAll(api, config.Seed, WaitFor, dest)
if err != nil {
- log.Fatalf("Transaction failed: %v", err)
+ fmt.Printf("cannot submit Transaction:%v", err)
}
-
- // Check if the transaction was successful
- if !res.IsSuccessful().UnsafeUnwrap() {
- log.Fatal("Transaction was not successful")
- }
-
- fmt.Println("Transaction successful")
-
- // Printing out all the values of the transaction
- fmt.Println(fmt.Sprintf(`Block Hash: %v, Block Index: %v, Tx Hash: %v, Tx Index: %v`, res.BlockHash.ToHexWith0x(), res.BlockNumber, res.TxHash.ToHexWith0x(), res.TxIndex))
+ fmt.Printf("Transaction submitted successfully with block hash: %v\n and ext hash:%v", BlockHash.Hex(), txHash.Hex())
}
```
2. Run the code using:
-```bash filename="terminal" name="cmd6"
+```bash
go run main.go
```
If you receive errors related to missing dependencies while trying to execute your code, run:
-```bash filename="terminal"
+```bash
go mod tidy
```
and try again.
-
+
\ No newline at end of file
diff --git a/app/api-reference/avail-node-api/balances-transfer-allow-death/page.mdx b/app/api-reference/avail-node-api/balances-transfer-allow-death/page.mdx
index 00d9e3b80..756fddce4 100644
--- a/app/api-reference/avail-node-api/balances-transfer-allow-death/page.mdx
+++ b/app/api-reference/avail-node-api/balances-transfer-allow-death/page.mdx
@@ -1,7 +1,3 @@
----
-image: '/img/docs-link-preview.png'
----
-
import { Callout, Steps, Tabs } from 'nextra/components'
# Transfer funds without ensuring min balance for sender
@@ -64,64 +60,36 @@ The rest of the code should work as is.
1. Inside `your-file-name.ts`, add the following code:
-```typescript showLineNumbers filename="avail-js" name="cmd1"
-import * as dotenv from 'dotenv';
-import { Account, SDK, BN } from 'avail-js-sdk';
-
-dotenv.config();
-
-export async function transferAllowDeath() {
- // Initialize SDK with Turing endpoint
- const sdk = await SDK.New('wss://turing-rpc.avail.so/ws');
-
- // Create account from seed in .env file
- const seed = process.env.SEED;
- if (!seed) {
- throw new Error("SEED environment variable is not set");
- }
-
- // Create account from seed
- const account = Account.new(seed);
- console.log("Sender Address: ", account.address);
-
- // Destination address to send AVAIL to
- const destinationAddress = "5DDY2yzh8uCysYFAiRSTeQVwtZSKNF49CkQkyPH852xvrYKk";
- console.log("Recipient Address: ", destinationAddress);
-
- // Amount to transfer: 12.345 AVAIL
- const amount = new BN('12345000000000000000');
-
- // Create transfer transaction
- const tx = sdk.tx.balances.transferAllowDeath(destinationAddress, amount);
- console.log("Submitting transfer transaction...");
-
- // Execute and wait for inclusion
- const res = await tx.executeWaitForInclusion(account, {});
-
- // Check if transaction was successful
- const isOk = res.isSuccessful();
- if (isOk === undefined) {
- throw new Error("Cannot check if transaction was successful");
- }
- else if (!isOk) {
- throw new Error("Transaction failed");
- }
-
- console.log(`Transaction Hash: ${res.txHash}`);
- console.log(`Block Hash: ${res.blockHash}`);
- console.log(`Block Number: ${res.blockNumber}`);
- console.log("Transfer completed successfully");
-
- process.exit(0);
-}
+```typescript showLineNumbers filename="avail-js"
+import { SDK, WaitFor, Keyring, BN } from "avail-js-sdk"
+
+const main = async () => {
+ const providerEndpoint = "wss://turing-rpc.avail.so/ws";
+ const sdk = await SDK.New(providerEndpoint)
+
+ const Alice = 'This is a random seed phrase please replace with your own';
+ const account = new Keyring({ type: "sr25519" }).addFromUri(Alice)
+ const dest = "5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw" // Eve
+ const amount = new BN(12).mul(new BN(10).pow(new BN("18"))) // twelve Avail
+
+ const result = await sdk.tx.balances.transferAllowDeath(dest, amount, WaitFor.BlockInclusion, account)
+ if (result.isErr) {
+ console.log(result.reason)
+ process.exit(1)
+ }
-// Execute the function
-transferAllowDeath();
+ console.log("From=" + result.event.from + ", To=" + result.event.to + ", Amount=" + result.event.amount)
+ console.log("MaybeKilled=" + result.event2?.account)
+ console.log("TxHash=" + result.txHash + ", BlockHash=" + result.blockHash)
+
+ process.exit()
+}
+main()
```
2. Run the code using:
-```bash filename="terminal" name="cmd2"
+```bash
ts-node your-file-name.ts
```
@@ -130,50 +98,46 @@ ts-node your-file-name.ts
1. Inside `main.rs`, add the following code:
-```rust showLineNumbers filename="avail-rust" name="cmd3"
-use dotenvy::dotenv;
-use std::env;
-use avail_rust::prelude::*;
+```rust showLineNumbers filename="avail-rust"
+use avail_rust::{Keypair, Nonce, Options, SecretUri, WaitFor, SDK};
use core::str::FromStr;
-pub async fn transfer_allow_death() -> Result<(), ClientError> {
-
- // Create a new SDK instance
- let sdk = SDK::new("wss://turing-rpc.avail.so/ws").await?;
-
- // Loading seed phrase and creating an account derived from the seed
- dotenv().ok();
- let seed = env::var("SEED").expect("SEED environment variable is not set");
- let account = account::from_secret_uri(&seed)?;
- println!("Account Address: {}", account.public_key().to_account_id());
+#[tokio::main]
+async fn main() -> Result<(), String> {
+ let sdk = SDK::new("wss://turing-rpc.avail.so/ws").await.unwrap();
- // Executing the transaction
- let dest = AccountId::from_str("5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw").unwrap();
- let amount = 12_345_000_000_000_000_000u128; // 12.345 AVAIL being transferred to the destination account
- let tx = sdk.tx.balances.transfer_allow_death(dest, amount);
- let res = tx.execute_and_watch_inclusion(&account, Options::default()).await?;
+ let alice = "This is a random seed phrase please replace with your own";
+ let secret_uri = SecretUri::from_str(alice).unwrap();
+ let account = Keypair::from_uri(&secret_uri).unwrap();
+ let dest = "5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw"; // Eve
+ let amount = 1_000_000_000_000_000_00u128; // 1 Avail
+ let options = Options::new().nonce(Nonce::BestBlockAndTxPool);
- println!(
- "Block Hash: {:?}, Block Number: {}, Tx Hash: {:?}, Tx Index: {}",
- res.block_hash, res.block_number, res.tx_hash, res.tx_index
- );
- println!("Transfer completed successfully");
+ let result = sdk
+ .tx
+ .balances
+ .transfer_allow_death(dest, amount, WaitFor::BlockInclusion, &account, Some(options))
+ .await?;
- Ok(())
-}
+ println!(
+ "From={}, To={}, Amount={}",
+ result.event.from, result.event.to, result.event.amount
+ );
+ if let Some(event) = result.event2 {
+ println!("Killed={}", event.account);
+ }
+ println!(
+ "TxHash={:?}, BlockHash={:?}",
+ result.tx_hash, result.block_hash
+ );
-// Add a main function to call transfer_allow_death
-#[tokio::main]
-async fn main() {
- if let Err(e) = transfer_allow_death().await {
- eprintln!("Error: {:?}", e);
- }
+ Ok(())
}
```
2. Run the code using:
-```bash filename="terminal" name="cmd4"
+```bash
cargo run
```
@@ -182,92 +146,52 @@ cargo run
1. Inside `main.go`, add the following code:
-```go showLineNumbers filename="avail-go" name="cmd5"
+```go showLineNumbers filename="avail-go"
package main
import (
- "fmt"
- "log"
- "os"
+ "math"
+
+ "github.com/availproject/avail-go-sdk/src/config"
+ "github.com/availproject/avail-go-sdk/src/sdk"
+ "github.com/availproject/avail-go-sdk/src/sdk/tx"
+ "github.com/availproject/avail-go-sdk/src/sdk/types"
- "github.com/availproject/avail-go-sdk/metadata"
- "github.com/availproject/avail-go-sdk/primitives"
- SDK "github.com/availproject/avail-go-sdk/sdk"
- "github.com/joho/godotenv"
+ "fmt"
)
func main() {
- // Load environment variables from .env file
- err := godotenv.Load()
- if err != nil {
- log.Fatal("Error loading .env file")
- }
-
- // Make sure the SEED environment variable is set
- seed := os.Getenv("SEED")
- if seed == "" {
- log.Fatal("SEED environment variable is not set")
- }
-
- // Create an account from the SEED environment variable
- acc, err := SDK.Account.NewKeyPair(seed)
+ config, err := config.LoadConfig()
if err != nil {
- log.Fatalf("Failed to create account: %v", err)
+ fmt.Printf("cannot load config:%v", err)
}
- fmt.Println("Your account Address: " + acc.SS58Address(42))
-
- // Initialize an SDK instance
- sdk, err := SDK.NewSDK("https://turing-rpc.avail.so/rpc")
+ api, err := sdk.NewSDK(config.ApiURL)
if err != nil {
- log.Fatalf("Failed to initialize SDK: %v", err)
+ fmt.Printf("cannot create api:%v", err)
}
+ WaitFor := sdk.BlockInclusion
- // Destination address
- destAddress, err := primitives.NewAccountIdFromAddress("5DDY2yzh8uCysYFAiRSTeQVwtZSKNF49CkQkyPH852xvrYKk")
+ amount := uint64(math.Pow(10, 18)) * 10 // send amount 10 AVAIL
+ dest := "5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty"
+ bondAmountUCompact := types.NewUCompactFromUInt(amount)
+ BlockHash, txHash, err := tx.TransferAllowDeath(api, config.Seed, WaitFor, dest, bondAmountUCompact)
if err != nil {
- log.Fatalf("Failed to convert address: %v", err)
+ fmt.Printf("cannot submit Transaction:%v", err)
}
- dest := destAddress.ToMultiAddress()
-
- // Create a Balance from a string
- // The value is 10 AVAIL
- amount, err := metadata.NewBalanceFromString("10000000000000000000")
- if err != nil {
- log.Fatalf("Failed to create balance: %v", err)
- }
-
- // Transferring funds without the
- // necessary checks of keeping the sender's account alive
- tx := sdk.Tx.Balances.TransferAllowDeath(dest, amount)
-
- // Execute the transaction
- res, err := tx.ExecuteAndWatchInclusion(acc, SDK.NewTransactionOptions())
- if err != nil {
- log.Fatalf("Transaction failed: %v", err)
- }
-
- // Check if the transaction was successful
- if !res.IsSuccessful().UnsafeUnwrap() {
- log.Fatal("Transaction was not successful")
- }
-
- fmt.Println("Transaction successful")
-
- // Printing out all the values of the transaction
- fmt.Println(fmt.Sprintf(`Block Hash: %v, Block Index: %v, Tx Hash: %v, Tx Index: %v`, res.BlockHash.ToHexWith0x(), res.BlockNumber, res.TxHash.ToHexWith0x(), res.TxIndex))
- fmt.Println("Transfer completed successfully")
+ fmt.Printf("Transaction submitted successfully with block hash: %v\n and ext hash:%v", BlockHash.Hex(), txHash.Hex())
+ sdk.EventParser(api, BlockHash, "BalanceTransfer")
}
```
2. Run the code using:
-```bash filename="terminal" name="cmd6"
+```bash
go run main.go
```
If you receive errors related to missing dependencies while trying to execute your code, run:
-```bash filename="terminal"
+```bash
go mod tidy
```
and try again.
@@ -275,4 +199,4 @@ and try again.
-
+
\ No newline at end of file
diff --git a/app/api-reference/avail-node-api/balances-transfer-keep-alive/page.mdx b/app/api-reference/avail-node-api/balances-transfer-keep-alive/page.mdx
index 539063e07..defdd4005 100644
--- a/app/api-reference/avail-node-api/balances-transfer-keep-alive/page.mdx
+++ b/app/api-reference/avail-node-api/balances-transfer-keep-alive/page.mdx
@@ -1,7 +1,3 @@
----
-image: '/img/docs-link-preview.png'
----
-
import { Callout, Steps, Tabs } from 'nextra/components'
# Transfer funds while ensuring min balance for sender
@@ -56,65 +52,35 @@ On failure, a reason of failure is returned. On Success, TransferEvent event, tr
1. Inside `your-file-name.ts`, add the following code:
-```typescript showLineNumbers filename="avail-js" name="cmd1"
-import * as dotenv from 'dotenv';
-import { Account, SDK, BN } from 'avail-js-sdk';
-
-dotenv.config();
-
-export async function transferKeepAlive() {
- // Initialize SDK with Turing endpoint
- const sdk = await SDK.New('wss://turing-rpc.avail.so/ws');
-
- // Create account from seed in .env file
- const seed = process.env.SEED;
- if (!seed) {
- throw new Error("SEED environment variable is not set");
- }
-
- // Create account from seed
- const account = Account.new(seed);
- console.log("Sender Address: ", account.address);
-
- // Destination address to send AVAIL to
- const destinationAddress = "5DDY2yzh8uCysYFAiRSTeQVwtZSKNF49CkQkyPH852xvrYKk";
- console.log("Recipient Address: ", destinationAddress);
-
- // Amount to transfer: 12 AVAIL
- const amount = new BN('12000000000000000000'); // 12 with 18 zeroes
- console.log("Transfer Amount: 12 AVAIL");
-
- // Create transfer transaction
- const tx = sdk.tx.balances.transferKeepAlive(destinationAddress, amount);
- console.log("Submitting transfer transaction...");
-
- // Execute and wait for inclusion
- const res = await tx.executeWaitForInclusion(account, {});
-
- // Check if transaction was successful
- const isOk = res.isSuccessful();
- if (isOk === undefined) {
- throw new Error("Cannot check if transaction was successful");
- }
- else if (!isOk) {
- throw new Error("Transaction failed");
- }
-
- console.log(`Transaction Hash: ${res.txHash}`);
- console.log(`Block Hash: ${res.blockHash}`);
- console.log(`Block Number: ${res.blockNumber}`);
- console.log("Transfer completed successfully");
-
- process.exit(0);
-}
+```typescript showLineNumbers filename="avail-js"
+import { SDK, WaitFor, Keyring, BN } from "avail-js-sdk"
+
+const main = async () => {
+ const providerEndpoint = "wss://turing-rpc.avail.so/ws";
+ const sdk = await SDK.New(providerEndpoint)
+
+ const Alice = 'This is a random seed phrase please replace with your own';
+ const account = new Keyring({ type: "sr25519" }).addFromUri(Alice)
+ const dest = "5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw" // Eve
+ const amount = new BN(10).pow(new BN(18)) // one Avail
+
+ const result = await sdk.tx.balances.transferKeepAlive(dest, amount, WaitFor.BlockInclusion, account)
+ if (result.isErr) {
+ console.log(result.reason)
+ process.exit(1)
+ }
-// Execute the function
-transferKeepAlive();
+ console.log("From=" + result.event.from + ", To=" + result.event.to + ", Amount=" + result.event.amount)
+ console.log("TxHash=" + result.txHash + ", BlockHash=" + result.blockHash)
+
+ process.exit()
+}
+main()
```
2. Run the code using:
-```bash filename="terminal" name="cmd2"
+```bash
ts-node your-file-name.ts
```
@@ -123,50 +89,43 @@ ts-node your-file-name.ts
1. Inside `main.rs`, add the following code:
-```rust showLineNumbers filename="avail-rust" name="cmd3"
-use dotenvy::dotenv;
-use std::env;
-use avail_rust::prelude::*;
+```rust showLineNumbers filename="avail-rust" showLineNumbers filename="avail-rust"
+use avail_rust::{Keypair, Nonce, Options, SecretUri, WaitFor, SDK};
use core::str::FromStr;
-pub async fn transfer_keep_alive() -> Result<(), ClientError> {
-
- // Create a new SDK instance
- let sdk = SDK::new("wss://turing-rpc.avail.so/ws").await?;
-
- // Loading seed phrase and creating an account derived from the seed
- dotenv().ok();
- let seed = env::var("SEED").expect("SEED environment variable is not set");
- let account = account::from_secret_uri(&seed)?;
- println!("Account Address: {}", account.public_key().to_account_id());
-
- // Executing the transaction
- let dest = AccountId::from_str("5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw").unwrap();
- let amount = 1_000_000_000_000_000_000u128; // 1 AVAIL being transferred to the destination account
- let tx = sdk.tx.balances.transfer_keep_alive(dest, amount);
- let res = tx.execute_and_watch_inclusion(&account, Options::default()).await?;
+#[tokio::main]
+async fn main() -> Result<(), String> {
+ let sdk = SDK::new("wss://turing-rpc.avail.so/ws").await.unwrap();
- println!(
- "Block Hash: {:?}, Block Number: {}, Tx Hash: {:?}, Tx Index: {}",
- res.block_hash, res.block_number, res.tx_hash, res.tx_index
- );
- println!("Transfer completed successfully");
+ let alice = "This is a random seed phrase please replace with your own";
+ let secret_uri = SecretUri::from_str(alice).unwrap();
+ let account = Keypair::from_uri(&secret_uri).unwrap();
+ let dest: &str = "5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw"; // Eve
+ let amount = 1_000_000_000_000_000_000u128; // 1 Avail
+ let options = Options::new().nonce(Nonce::BestBlockAndTxPool);
+
+ let result = sdk
+ .tx
+ .balances
+ .transfer_keep_alive(dest, amount, WaitFor::BlockInclusion, &account, Some(options))
+ .await?;
- Ok(())
-}
+ println!(
+ "From={}, To={}, Amount={}",
+ result.event.from, result.event.to, result.event.amount
+ );
+ println!(
+ "TxHash={:?}, BlockHash={:?}",
+ result.tx_hash, result.block_hash
+ );
-// Add a main function to call transfer_keep_alive
-#[tokio::main]
-async fn main() {
- if let Err(e) = transfer_keep_alive().await {
- eprintln!("Error: {:?}", e);
- }
+ Ok(())
}
```
2. Run the code using:
-```bash filename="terminal" name="cmd4"
+```bash
cargo run
```
@@ -175,96 +134,56 @@ cargo run
1. Inside `main.go`, add the following code:
-```go showLineNumbers filename="avail-go" name="cmd5"
+```go showLineNumbers filename="avail-go"
package main
import (
- "fmt"
- "log"
- "os"
+ "math"
+
+ "github.com/availproject/avail-go-sdk/src/config"
+ "github.com/availproject/avail-go-sdk/src/sdk"
+ "github.com/availproject/avail-go-sdk/src/sdk/tx"
+ "github.com/availproject/avail-go-sdk/src/sdk/types"
- "github.com/availproject/avail-go-sdk/metadata"
- "github.com/availproject/avail-go-sdk/primitives"
- SDK "github.com/availproject/avail-go-sdk/sdk"
- "github.com/joho/godotenv"
+ "fmt"
)
func main() {
- // Load environment variables from .env file
- err := godotenv.Load()
- if err != nil {
- log.Fatal("Error loading .env file")
- }
-
- // Make sure the SEED environment variable is set
- seed := os.Getenv("SEED")
- if seed == "" {
- log.Fatal("SEED environment variable is not set")
- }
-
- // Create an account from the SEED environment variable
- acc, err := SDK.Account.NewKeyPair(seed)
+ config, err := config.LoadConfig()
if err != nil {
- log.Fatalf("Failed to create account: %v", err)
+ fmt.Printf("cannot load config:%v", err)
}
- fmt.Println("Your account Address: " + acc.SS58Address(42))
-
- // Initialize an SDK instance
- sdk, err := SDK.NewSDK("https://turing-rpc.avail.so/rpc")
+ api, err := sdk.NewSDK(config.ApiURL)
if err != nil {
- log.Fatalf("Failed to initialize SDK: %v", err)
+ fmt.Printf("cannot create api:%v", err)
}
+ WaitFor := sdk.BlockInclusion
- // Destination address
- destAddress, err := primitives.NewAccountIdFromAddress("5DDY2yzh8uCysYFAiRSTeQVwtZSKNF49CkQkyPH852xvrYKk")
+ amount := uint64(math.Pow(10, 18)) * 10 // send amount 10 AVAIL
+ dest := "5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty"
+ bondAmountUCompact := types.NewUCompactFromUInt(amount)
+ BlockHash, txHash, err := tx.TransferKeepAlive(api, config.Seed, WaitFor, dest, bondAmountUCompact)
if err != nil {
- log.Fatalf("Failed to convert address: %v", err)
+ fmt.Printf("cannot submit Transaction:%v", err)
}
- dest := destAddress.ToMultiAddress()
-
- // Create a Balance from a string
- // The value is 10 AVAIL
- amount, err := metadata.NewBalanceFromString("10000000000000000000")
- if err != nil {
- log.Fatalf("Failed to create balance: %v", err)
- }
-
- // Transferring funds while ensuring the sender's account
- // retains a minimum balance
- tx := sdk.Tx.Balances.TransferKeepAlive(dest, amount)
-
- // Execute the transaction
- res, err := tx.ExecuteAndWatchInclusion(acc, SDK.NewTransactionOptions())
- if err != nil {
- log.Fatalf("Transaction failed: %v", err)
- }
-
- // Check if the transaction was successful
- if !res.IsSuccessful().UnsafeUnwrap() {
- log.Fatal("Transaction was not successful")
- }
-
- fmt.Println("Transaction successful")
-
- // Printing out all the values of the transaction
- fmt.Println(fmt.Sprintf(`Block Hash: %v, Block Index: %v, Tx Hash: %v, Tx Index: %v`, res.BlockHash.ToHexWith0x(), res.BlockNumber, res.TxHash.ToHexWith0x(), res.TxIndex))
- fmt.Println("Transfer completed successfully")
+ fmt.Printf("Transaction submitted successfully with block hash: %v\n and ext hash:%v", BlockHash.Hex(), txHash.Hex())
+ sdk.EventParser(api, BlockHash, "BalanceTransfer")
}
```
2. Run the code using:
-```bash filename="terminal" name="cmd6"
+```bash
go run main.go
```
If you receive errors related to missing dependencies while trying to execute your code, run:
-```bash filename="terminal" name="cmd7"
+```bash
go mod tidy
```
and try again.
-
+
\ No newline at end of file
diff --git a/app/api-reference/avail-node-api/chain-get-block/page.mdx b/app/api-reference/avail-node-api/chain-get-block/page.mdx
deleted file mode 100644
index 24c8681e9..000000000
--- a/app/api-reference/avail-node-api/chain-get-block/page.mdx
+++ /dev/null
@@ -1,481 +0,0 @@
----
-image: '/img/docs-link-preview.png'
----
-
-import { Callout, Steps, Tabs } from 'nextra/components'
-
-# Fetch block data from Avail DA using RPC calls
-
-The Avail node supports a variety of RPC calls for fetching block data. This page covers a few
-different calls that are commonly used to fetch block data:
-
-## Fetch block hash using block number [#block-hash-using-block-number]
-
-### Parameters
-
-
-
-
-| parameter | type | optional | description |
-| --------- | ------------- | -------- | ----------------------------------------------------- |
-| blockNumber | number | true | The block number of the block to fetch (fetches hash of latest block if not provided)|
-
-
-
-| parameter | type | optional | description |
-| --------- | ------------- | -------- | ----------------------------------------------------- |
-| blockNumber | number | true | The block number of the block to fetch (fetches hash of latest block if not provided)|
-
-
-
-| parameter | type | optional | description |
-| --------- | ------------- | -------- | ----------------------------------------------------- |
-| blockNumber | number | true | The block number of the block to fetch (fetches hash of latest block if not provided)|
-
-
-
-
-
-### Example
-
-
-
-
-1. Inside `your-file-name.ts`, add the following code:
-
-```typescript showLineNumbers filename="avail-js" name="cmd1"
-import { SDK } from "avail-js-sdk";
-
-export async function chainGetBlockHash() {
-
- // Initialize SDK with Turing endpoint
- const sdk = await SDK.New('wss://turing-rpc.avail.so/ws');
-
- // 1. Gets the block hash for the latest block if no argument is provided
- // 2. Gets the block hash for the block at the given block number if a block number is provided
- const hash = await sdk.client.api.rpc.chain.getBlockHash(1451847)
- console.log("getBlockHash")
- console.log(hash.toJSON())
-
- process.exit(0);
-}
-
-// Execute the function
-chainGetBlockHash()
-```
-
-2. Run the script using the following command:
-
-```bash filename="terminal"
-node your-file-name.ts
-```
-
-
-
-
-1. Inside `main.rs`, add the following code:
-
-```rust showLineNumbers filename="avail-rust" name="cmd3"
-use avail_rust::prelude::*;
-
-pub async fn get_block_hash() -> Result<(), ClientError> {
-
- // Create a new SDK instance
- let sdk = SDK::new("wss://turing-rpc.avail.so/ws").await?;
-
- // 1. Get the block hash for a specific block if argument is provided
- // 2. Get the latest block hash if no argument is provided
- let block_hash = rpc::chain::get_block_hash(&sdk.client, Some(1451847)).await?;
-
- println!("Latest Block Hash: {:?}", block_hash);
-
- Ok(())
-}
-
-#[tokio::main]
-async fn main() -> Result<(), ClientError> {
- get_block_hash().await?;
- Ok(())
-}
-```
-
-2. Run the script using the following command:
-
-```bash filename="terminal" name="cmd4"
-cargo run
-```
-
-
-
-1. Inside `main.go`, add the following code:
-
-```go showLineNumbers filename="avail-go" name="cmd5"
-package main
-
-import (
- "fmt"
- "log"
-
- prim "github.com/availproject/avail-go-sdk/primitives"
- SDK "github.com/availproject/avail-go-sdk/sdk"
-)
-
-func main() {
-
- // Initialize an SDK instance
- sdk, err := SDK.NewSDK("https://turing-rpc.avail.so/rpc")
- if err != nil {
- log.Fatalf("Failed to initialize SDK: %v", err)
- }
-
- // Get the latest block hash by not passing any parameters
- latestBlockHash, err := sdk.Client.Rpc.Chain.GetBlockHash(prim.None[uint32]())
- if err != nil {
- log.Fatalf("Failed to get the leatest block hash: %v", err)
- }
-
- // Print the block hash
- fmt.Println("Latest Block Hash: ", latestBlockHash)
-
- // Get a specific block hash by passing the block number
- specificBlockHash, err := sdk.Client.Rpc.Chain.GetBlockHash(prim.Some[uint32](1451847))
- if err != nil {
- log.Fatalf("Failed to get the specific block hash: %v", err)
- }
-
- // Print the block hash
- fmt.Println("Specific Block Hash: ", specificBlockHash)
-}
-```
-
-2. Run the script using the following command:
-
-```bash filename="terminal" name="cmd6"
-go run main.go
-```
-
-
-
-
-
-## Fetch block header using block hash [#block-header-using-block-hash]
-
-### Parameters
-
-
-
-
-| parameter | type | optional | description |
-| --------- | ------------- | -------- | ----------------------------------------------------- |
-| blockHash | string | true | The hash of the block to fetch (fetches header of latest block if not provided) |
-
-
-
-| parameter | type | optional | description |
-| --------- | ------------- | -------- | ----------------------------------------------------- |
-| blockHash | string | true | The hash of the block to fetch (fetches header of latest block if not provided) |
-
-
-
-| parameter | type | optional | description |
-| --------- | ------------- | -------- | ----------------------------------------------------- |
-| blockHash | string | true | The hash of the block to fetch (fetches header of latest block if not provided) |
-
-
-
-
-### Example
-
-
-
-
-1. Inside `your-file-name.ts`, add the following code:
-
-```typescript showLineNumbers filename="avail-js" name="cmd1"
-import { SDK } from "avail-js-sdk";
-
-export async function chainGetBlockHeader() {
-
- // Initialize SDK with Turing endpoint
- const sdk = await SDK.New('wss://turing-rpc.avail.so/ws');
-
- // 1. Gets the block header for the latest block if no argument is provided
- // 2. Gets the block header for a specific block if a block hash is provided
- const header = await sdk.client.api.rpc.chain.getHeader("0x75a6c54bb5ea904e47fa151956992d7cf543bc7c936d78488e311db8e10397c1")
- console.log("getBlockHeader")
- console.log(header.toJSON())
-
- process.exit(0);
-}
-
-// Execute the function
-chainGetBlockHeader()
-```
-
-2. Run the script using the following command:
-
-```bash filename="terminal"
-node your-file-name.ts
-```
-
-
-
-1. Inside `main.rs`, add the following code:
-
-```rust showLineNumbers filename="avail-rust" name="cmd3"
-use avail_rust::prelude::*;
-
-pub async fn get_block_header() -> Result<(), ClientError> {
-
- // Create a new SDK instance
- let sdk = SDK::new("wss://turing-rpc.avail.so/ws").await?;
-
- // 1. Gets the block header for a specific block if argument is provided
- // 2. Gets the latest block header if no argument is provided
- let block_hash = new_h256_from_hex("0x75a6c54bb5ea904e47fa151956992d7cf543bc7c936d78488e311db8e10397c1")?;
-
- // Get the latest block header
- let latest_block_header = rpc::chain::get_header(&sdk.client, None).await?;
-
- // Get the block header for a specific block
- let block_header = rpc::chain::get_header(&sdk.client, Some(block_hash)).await?;
-
- println!("Latest Block Header: {:?}", latest_block_header);
- println!("Block Header: {:?}", block_header);
-
- Ok(())
-}
-
-#[tokio::main]
-async fn main() -> Result<(), ClientError> {
- get_block_header().await?;
- Ok(())
-}
-```
-
-2. Run the script using the following command:
-
-```bash filename="terminal" name="cmd4"
-cargo run
-```
-
-
-
-1. Inside `main.go`, add the following code:
-
-```go showLineNumbers filename="avail-go" name="cmd5"
-package main
-
-import (
- "fmt"
- "log"
-
- prim "github.com/availproject/avail-go-sdk/primitives"
- SDK "github.com/availproject/avail-go-sdk/sdk"
-)
-
-func main() {
-
- // Initialize an SDK instance
- sdk, err := SDK.NewSDK("https://turing-rpc.avail.so/rpc")
- if err != nil {
- log.Fatalf("Failed to initialize SDK: %v", err)
- }
-
- // Get the latest block hash by not passing any parameters
- latestBlockHeader, err := sdk.Client.Rpc.Chain.GetHeader(prim.None[prim.H256]())
- if err != nil {
- log.Fatalf("Failed to get the latest block header: %v", err)
- }
-
- // Print the block header
- fmt.Println("Latest Block Header: ", latestBlockHeader)
-
- // Get a specific block header by passing the block hash
-
- blockHash, err := prim.NewH256FromHexString("0x75a6c54bb5ea904e47fa151956992d7cf543bc7c936d78488e311db8e10397c1")
- if err != nil {
- log.Fatalf("Failed to create H256 from hex: %v", err)
- }
-
- specificBlockHeader, err := sdk.Client.Rpc.Chain.GetHeader(prim.Some[prim.H256](blockHash))
- if err != nil {
- log.Fatalf("Failed to get the specific block header: %v", err)
- }
-
- // Print the block header
- fmt.Println("Specific Block Header: ", specificBlockHeader)
-}
-```
-
-2. Run the script using the following command:
-
-```bash filename="terminal" name="cmd6"
-go run main.go
-```
-
-
-
-
-## Fetch entire block using block hash [#block-using-block-hash]
-
-### Parameters
-
-
-
-
-| parameter | type | optional | description |
-| --------- | ------------- | -------- | ----------------------------------------------------- |
-| blockHash | string | true | The hash of the block to fetch (fetches block of latest block if not provided) |
-
-
-
-| parameter | type | optional | description |
-| --------- | ------------- | -------- | ----------------------------------------------------- |
-| blockHash | string | true | The hash of the block to fetch (fetches block of latest block if not provided) |
-
-
-
-| parameter | type | optional | description |
-| --------- | ------------- | -------- | ----------------------------------------------------- |
-| blockHash | string | true | The hash of the block to fetch (fetches block of latest block if not provided) |
-
-
-
-
-### Example
-
-
-
-
-1. Inside `your-file-name.ts`, add the following code:
-
-```typescript showLineNumbers filename="avail-js" name="cmd1"
-import { SDK } from "avail-js-sdk";
-
-export async function chainGetBlock() {
-
- // Initialize SDK with Turing endpoint
- const sdk = await SDK.New('wss://turing-rpc.avail.so/ws');
-
- // 1. Gets the block for the latest block if no argument is provided
- // 2. Gets block header and body for a specific block if a block hash is provided
- const block = await sdk.client.api.rpc.chain.getBlock("0x75a6c54bb5ea904e47fa151956992d7cf543bc7c936d78488e311db8e10397c1")
- console.log("getBlock")
- console.log(block.toJSON())
-
- process.exit(0);
-}
-
-// Execute the function
-chainGetBlock()
-```
-
-2. Run the script using the following command:
-
-```bash filename="terminal"
-node your-file-name.ts
-```
-
-
-
-
-1. Inside `main.rs`, add the following code:
-
-```rust showLineNumbers filename="avail-rust" name="cmd3"
-use avail_rust::prelude::*;
-
-pub async fn get_block() -> Result<(), ClientError> {
-
- // Create a new SDK instance
- let sdk = SDK::new("wss://turing-rpc.avail.so/ws").await?;
-
- // 1. Get the block for a specific block if argument is provided
- // 2. Get the latest block if no argument is provided
- let block_hash = new_h256_from_hex("0x75a6c54bb5ea904e47fa151956992d7cf543bc7c936d78488e311db8e10397c1")?;
-
- // Get the latest block
- let latest_block = rpc::chain::get_block(&sdk.client, None).await?;
-
- // Get the block for a specific block
- let specific_block = rpc::chain::get_block(&sdk.client, Some(block_hash)).await?;
-
- println!("Latest Block: {:?}", latest_block);
-
- // println!(" Specific Block: {:?}", block);
-
- Ok(())
-}
-
-#[tokio::main]
-async fn main() -> Result<(), ClientError> {
- get_block().await?;
- Ok(())
-}
-```
-
-2. Run the script using the following command:
-
-```bash filename="terminal" name="cmd4"
-cargo run
-```
-
-
-
-1. Inside `main.go`, add the following code:
-
-```go showLineNumbers filename="avail-go" name="cmd5"
-package main
-
-import (
- "fmt"
- "log"
-
- prim "github.com/availproject/avail-go-sdk/primitives"
- SDK "github.com/availproject/avail-go-sdk/sdk"
-)
-
-func main() {
-
- // Initialize an SDK instance
- sdk, err := SDK.NewSDK("https://turing-rpc.avail.so/rpc")
- if err != nil {
- log.Fatalf("Failed to initialize SDK: %v", err)
- }
-
- // Get the latest block by not passing any parameters
- latestBlock, err := sdk.Client.Rpc.Chain.GetBlock(prim.None[prim.H256]())
- if err != nil {
- log.Fatalf("Failed to get the latest block: %v", err)
- }
-
- // Print the block
- fmt.Println("Latest Block: ", latestBlock)
-
- // Get a specific block by passing the block hash
- blockHash, err := prim.NewH256FromHexString("0x75a6c54bb5ea904e47fa151956992d7cf543bc7c936d78488e311db8e10397c1")
- if err != nil {
- log.Fatalf("Failed to create H256 from hex: %v", err)
- }
- specificBlock, err := sdk.Client.Rpc.Chain.GetBlock(prim.Some(blockHash))
- if err != nil {
- log.Fatalf("Failed to get the specific block: %v", err)
- }
-
- // Print the block
- fmt.Println("Specific Block: ", specificBlock)
-}
-```
-
-2. Run the script using the following command:
-
-```bash filename="terminal" name="cmd6"
-go run main.go
-```
-
-
-
-
-
-
-
diff --git a/app/api-reference/avail-node-api/da-app-keys/page.mdx b/app/api-reference/avail-node-api/da-app-keys/page.mdx
index 83737847c..1c2f44363 100644
--- a/app/api-reference/avail-node-api/da-app-keys/page.mdx
+++ b/app/api-reference/avail-node-api/da-app-keys/page.mdx
@@ -1,7 +1,3 @@
----
-image: '/img/docs-link-preview.png'
----
-
import { Callout, Steps, Tabs } from 'nextra/components'
@@ -9,19 +5,13 @@ import { Callout, Steps, Tabs } from 'nextra/components'
You can check out [our docs for the same](/docs/build-with-avail/interact-with-avail-da/app-id).
-# Fetch an AppID from Avail DA
+# Fetch App IDs from Avail DA
On-chain name of method: `dataAvailability_appKeys`
## Parameters
-
-
-
-| parameter | type | optional | description |
-| --------- | ------------- | -------- | ----------------------------------------------------- |
-| key | string | true | The `app_id` associated with this key will be fetched |
-
+
| parameter | type | optional | description |
@@ -54,102 +44,81 @@ For instructions, [check out our docs here](/api-reference/avail-node-api#settin
The rest of the code should work as is.
-
+
1. Inside `your-file-name.ts`, add the following code:
-```typescript showLineNumbers filename="avail-js" name="cmd1"
-import { SDK, Pallets } from 'avail-js-sdk';
-
-export async function getAppIdByKey() {
- // Initialize SDK with Turing endpoint
- const sdk = await SDK.New('wss://turing-rpc.avail.so/ws');
-
- // Get the current block hash
- const blockHash = await sdk.client.bestBlockHash();
- console.log(`Current block hash: ${blockHash}`);
-
- // Get storage at the current block
- const storageAt = await sdk.client.storageAt(blockHash);
-
- // The key to look up
- const appKey = "my Application Key Name!!!";
-
- // Fetch the app keys entry for this key
- const entry = await Pallets.DataAvailabilityStorage.AppKeys.fetch(storageAt, appKey);
-
- if (entry === null) {
- console.log(`No app ID found for key: "${appKey}"`);
- } else {
- console.log(`App ID: ${entry.value.appId}`);
- console.log(`Owner: ${entry.value.owner.toSS58()}`);
- console.log(`Key: ${appKey}`);
- console.log("App Key fetched successfully");
- }
-
- process.exit(0);
+```typescript showLineNumbers filename="avail-js"
+import { SDK } from "avail-js-sdk"
+
+const main = async () => {
+ const providerEndpoint = "wss://turing-rpc.avail.so/ws"
+ const sdk = await SDK.New(providerEndpoint)
+
+ const key = "Reserved-2"
+ const value = await sdk.api.query.dataAvailability.appKeys(key)
+ console.log(value.toHuman())
+
+ process.exit()
}
-
-// Execute the function
-getAppIdByKey();
+
+main()
```
2. Run the code using:
-```bash filename="terminal" name="cmd2"
+```bash
ts-node your-file-name.ts
```
-
1. Inside `main.rs`, add the following code:
-```rust showLineNumbers filename="avail-rust" name="cmd3"
-use avail_rust::prelude::*;
-use avail::data_availability::storage::types::app_keys::Param0;
-
-pub async fn da_app_keys() -> Result<(), ClientError> {
-
- // Create a new SDK instance
- let sdk = SDK::new("wss://turing-rpc.avail.so/ws").await?;
-
- let key = String::from("My Application Key").as_bytes().to_vec();
- let key = Param0 { 0: key };
-
- let block_hash = sdk.client.best_block_hash().await?;
- let storage = sdk.client.storage().at(block_hash);
- let address = avail::storage().data_availability().app_keys(key);
- let result = storage.fetch(&address).await?;
-
- dbg!(result);
-
- Ok(())
-}
-
-// Add a main function to call da_app_keys
+```rust showLineNumbers filename="avail-rust" showLineNumbers filename="avail-rust"
+use avail_rust::{
+ avail::{self, runtime_types::bounded_collections::bounded_vec::BoundedVec},
+ SDK,
+};
+
#[tokio::main]
-async fn main() {
- if let Err(e) = da_app_keys().await {
- eprintln!("Error: {:?}", e);
- }
- else {
- println!("App Key fetched successfully");
- }
+async fn main() -> Result<(), String> {
+ let sdk = SDK::new("wss://turing-rpc.avail.so/ws").await.unwrap();
+
+ let key = String::from("gohan");
+ let key = BoundedVec(key.as_bytes().to_vec());
+ let storage_query = avail::storage().data_availability().app_keys(key);
+ let best_block_hash = sdk
+ .rpc
+ .chain
+ .get_block_hash(None)
+ .await
+ .map_err(|e| e.to_string())?;
+ let result = sdk
+ .api
+ .storage()
+ .at(best_block_hash)
+ .fetch(&storage_query)
+ .await
+ .map_err(|e| e.to_string())?;
+
+ dbg!(result);
+
+ Ok(())
}
```
2. Run the code using:
-```bash filename="terminal" name="cmd4"
+```bash
cargo run
```
-
+Sample Response:
```json
result = Some(
@@ -205,70 +174,6 @@ addresses in the `AccountId32` format.
-
-
-1. Inside `main.go`, add the following code:
-
-```go showLineNumbers filename="avail-go" name="cmd5"
-package main
-
-import (
- "fmt"
- "log"
-
- daPallet "github.com/availproject/avail-go-sdk/metadata/pallets/data_availability"
- prim "github.com/availproject/avail-go-sdk/primitives"
- SDK "github.com/availproject/avail-go-sdk/sdk"
-)
-
-func main() {
- sdk, err := SDK.NewSDK("https://turing-rpc.avail.so/rpc")
- if err != nil {
- log.Fatalf("Failed to initialize SDK: %v", err)
- }
-
- // Get the latest block hash
- latestBlockHash, err := sdk.Client.BestBlockHash()
- if err != nil {
- log.Fatalf("Failed to get latest block hash: %v", err)
- }
-
- // Initialize the block storage
- blockStorage, err := sdk.Client.StorageAt(prim.Some(latestBlockHash))
- if err != nil {
- log.Fatalf("Failed to get block storage: %v", err)
- }
-
- {
- storage := daPallet.StorageAppKeys{}
- keyString := "Citizen Justice"
- key := []byte(keyString)
-
- val, err := storage.Fetch(&blockStorage, key)
- if err != nil {
- log.Fatalf("Failed to fetch app keys: %v", err)
- }
-
- if val.IsSome() {
- entry := val.Unwrap()
- fmt.Println("App Key Owner: ", entry.Value.Owner.ToHuman())
- fmt.Println("App Key AppId: ", entry.Value.AppId)
- fmt.Println("App Key fetched successfully")
- } else {
- fmt.Println("No app keys found for the given key.")
- }
- }
-}
-```
-
-2. Run the code using:
-
-```bash filename="terminal" name="cmd6"
-go run main.go
-```
-
-
-
## Another example (Fetch all available `app_ids` registered on Avail DA)
@@ -280,55 +185,34 @@ as a mapping of their names to their owner and index.
3. We are however including both scenarios here.
-
+
1. Inside `your-file-name.ts`, add the following code:
-```typescript showLineNumbers filename="avail-js" name="cmd1"
-import { SDK, Pallets } from 'avail-js-sdk';
-
-export async function getAllAppIds() {
- // Initialize SDK with Turing endpoint
- const sdk = await SDK.New('wss://turing-rpc.avail.so/ws');
-
- // Get the current block hash
- const blockHash = await sdk.client.bestBlockHash();
- console.log(`Current block hash: ${blockHash}`);
-
- // Get storage at the current block
- const storageAt = await sdk.client.storageAt(blockHash);
-
- // Fetch all app keys entries
- const entries = await Pallets.DataAvailabilityStorage.AppKeys.fetchAll(storageAt);
-
- console.log(`Total number of app IDs: ${entries.length}`);
-
- // Display all app IDs and their details
- entries.forEach((entry) => {
- console.log(` App ID: ${entry.value.appId}`);
- console.log(` Owner: ${entry.value.owner.toSS58()}`);
-
- let keyString = "";
- try {
- keyString = new TextDecoder().decode(entry.key);
- console.log(` Key (as string): ${keyString}`);
- } catch (e) {
- console.log(` Key (hex): 0x${Buffer.from(entry.key).toString('hex')}`);
- }
- });
-
- process.exit(0);
+```typescript showLineNumbers filename="avail-js"
+import { SDK } from "avail-js-sdk"
+
+const main = async () => {
+ const providerEndpoint = "wss://turing-rpc.avail.so/ws"
+ const sdk = await SDK.New(providerEndpoint)
+
+ const appKeys = await sdk.api.query.dataAvailability.appKeys.entries()
+ for (const [key, value] of appKeys) {
+ console.log(key.toHuman())
+ console.log(value.toHuman())
+ }
+
+ process.exit()
}
-// Execute the function
-getAllAppIds();
+main()
```
2. Run the code using:
-```bash filename="terminal" name="cmd2"
+```bash
ts-node your-file-name.ts
```
@@ -337,105 +221,45 @@ ts-node your-file-name.ts
1. Inside `main.rs`, add the following code:
-```rust showLineNumbers filename="avail-rust" name="cmd3"
-use avail_rust::prelude::*;
-
-pub async fn da_app_keys_iter() -> Result<(), ClientError> {
-
- // Create a new SDK instance
- let sdk = SDK::new("wss://turing-rpc.avail.so/ws").await?;
-
- let block_hash = sdk.client.best_block_hash().await?;
- let storage = sdk.client.storage().at(block_hash);
- let address = avail::storage().data_availability().app_keys_iter();
- let mut results = storage.iter(address).await?;
-
- while let Some(Ok(kv)) = results.next().await {
- let key = (&kv.key_bytes[49..]).to_vec();
- let key = String::from_utf8(key).unwrap();
-
- println!("Key: {:?}", key);
- println!("Value: {:?}", kv.value);
- }
-
- Ok(())
-}
-
-// Add a main function to call da_app_keys_iter
+```rust showLineNumbers filename="avail-rust" showLineNumbers filename="avail-rust"
+use avail_rust::{avail, SDK};
+
#[tokio::main]
-async fn main() {
- if let Err(e) = da_app_keys_iter().await {
- eprintln!("Error: {:?}", e);
- }
+async fn main() -> Result<(), String> {
+ let sdk = SDK::new("wss://turing-rpc.avail.so/ws").await.unwrap();
+
+ let storage_query = avail::storage().data_availability().app_keys_iter();
+ let best_block_hash = sdk
+ .rpc
+ .chain
+ .get_block_hash(None)
+ .await
+ .map_err(|e| e.to_string())?;
+ let mut results = sdk
+ .api
+ .storage()
+ .at(best_block_hash)
+ .iter(storage_query)
+ .await
+ .map_err(|e| e.to_string())?;
+
+ while let Some(Ok(kv)) = results.next().await {
+ let key = (&kv.key_bytes[49..]).to_vec();
+ let key = String::from_utf8(key).unwrap();
+
+ println!("Key: {:?}", key);
+ println!("Value: {:?}", kv.value);
+ }
+
+ Ok(())
}
```
2. Run the code using:
-```bash filename="terminal" name="cmd4"
+```bash
cargo run
```
-
-
-1. Inside `main.go`, add the following code:
-
-```go showLineNumbers filename="avail-go" name="cmd5"
-package main
-
-import (
- "fmt"
- "log"
-
- daPallet "github.com/availproject/avail-go-sdk/metadata/pallets/data_availability"
- prim "github.com/availproject/avail-go-sdk/primitives"
- SDK "github.com/availproject/avail-go-sdk/sdk"
-)
-
-func main() {
- sdk, err := SDK.NewSDK("https://turing-rpc.avail.so/rpc")
- if err != nil {
- log.Fatalf("Failed to initialize SDK: %v", err)
- }
-
- // Get the latest block hash
- latestBlockHash, err := sdk.Client.BestBlockHash()
- if err != nil {
- log.Fatalf("Failed to get latest block hash: %v", err)
- }
-
- // Initialize the block storage
- blockStorage, err := sdk.Client.StorageAt(prim.Some(latestBlockHash))
- if err != nil {
- log.Fatalf("Failed to get block storage: %v", err)
- }
-
- // Fetch all app keys
- {
- storage := daPallet.StorageAppKeys{}
- val, err := storage.FetchAll(&blockStorage)
- if err != nil {
- log.Fatalf("Failed to fetch all app keys: %v", err)
- }
-
- if len(val) == 0 {
- log.Println("No app keys found.")
- } else {
- for i := 0; i < len(val); i++ {
- fmt.Println("App Key Owner: ", val[i].Value.Owner.ToHuman())
- fmt.Println("App Key AppId: ", val[i].Value.AppId)
- }
- }
- }
-}
-```
-
-2. Run the code using:
-
-```bash filename="terminal" name="cmd6"
-go run main.go
-```
-
-
-
+
\ No newline at end of file
diff --git a/app/api-reference/avail-node-api/da-create-application-key/page.mdx b/app/api-reference/avail-node-api/da-create-application-key/page.mdx
index 45128d933..3abad0bfe 100644
--- a/app/api-reference/avail-node-api/da-create-application-key/page.mdx
+++ b/app/api-reference/avail-node-api/da-create-application-key/page.mdx
@@ -1,7 +1,3 @@
----
-image: '/img/docs-link-preview.png'
----
-
import { Callout, Steps, Tabs } from 'nextra/components'
@@ -67,69 +63,34 @@ The rest of the code should work as is.
1. Inside `your-file-name.ts`, add the following code:
-```typescript showLineNumbers filename="avail-js" name="cmd1"
-import * as dotenv from 'dotenv';
-import { Account, SDK, Pallets } from 'avail-js-sdk';
-
-dotenv.config();
-
-export async function createApplicationKey() {
-
- // Initialize SDK with Turing endpoint
- const sdk = await SDK.New('wss://turing-rpc.avail.so/ws');
-
- // Create account from seed in .env file
- const seed = process.env.SEED;
- if (!seed) {
- throw new Error("SEED environment variable is not set");
- }
-
- // Create account from seed
- const account = Account.new(seed);
- console.log("Account Address: ", account.address);
-
- // Use a fixed key string
- const key = "my Application Key Name";
-
- // Create application key transaction
- const tx = sdk.tx.dataAvailability.createApplicationKey(key);
- console.log("Submitting transaction to create application key...");
-
- // Execute and wait for inclusion
- const res = await tx.executeWaitForInclusion(account, {});
-
- // Check if transaction was successful
- const isOk = res.isSuccessful();
- if (isOk === undefined) {
- throw new Error("Cannot check if transaction was successful");
- }
- else if (!isOk) {
- throw new Error("Transaction failed");
- }
-
- // Extract event data
- if (res.events === undefined) throw new Error("No events found");
-
- const event = res.events.findFirst(Pallets.DataAvailabilityEvents.ApplicationKeyCreated);
- if (event === undefined) throw new Error("ApplicationKeyCreated event not found");
-
- const appId = event.id;
- console.log(`Application created successfully:`);
- console.log(`Owner: ${event.owner}`);
- console.log(`Key: ${event.keyToString()}`);
- console.log(`App Id: ${appId}`);
- console.log(`Transaction Hash: ${res.txHash}`);
-
- process.exit(0);
-}
+```typescript showLineNumbers filename="avail-js"
+import { SDK, WaitFor, Keyring } from "avail-js-sdk"
+
+const main = async () => {
+ const providerEndpoint = "wss://turing-rpc.avail.so/ws";
+ const sdk = await SDK.New(providerEndpoint)
+
+ const Alice = 'This is a random seed phrase please replace with your own';
+ const account = new Keyring({ type: "sr25519" }).addFromUri(Alice)
+ const key = "MyAwesomeKey"
+
+ const result = await sdk.tx.dataAvailability.createApplicationKey(key, WaitFor.BlockInclusion, account)
+ if (result.isErr) {
+ console.log(result.reason)
+ process.exit(1)
+ }
+
+ console.log("Key=" + result.event.key + ", Owner=" + result.event.owner + ", Id=" + result.event.id)
+ console.log("TxHash=" + result.txHash + ", BlockHash=" + result.blockHash)
-// Execute the function
-createApplicationKey()
+ process.exit()
+}
+main()
```
2. Run the code using:
-```bash filename="terminal" name="cmd2"
+```bash
ts-node your-file-name.ts
```
@@ -138,56 +99,43 @@ ts-node your-file-name.ts
1. Inside `main.rs`, add the following code:
-```rust showLineNumbers filename="avail-rust" name="cmd3"
-use dotenvy::dotenv;
-use std::env;
-use avail_rust::prelude::*;
-
-type ApplicationKeyCreatedEvent = avail::data_availability::events::ApplicationKeyCreated;
-
-pub async fn create_application_key() -> Result<(), ClientError> {
-
- // Create a new SDK instance
- let sdk = SDK::new("wss://turing-rpc.avail.so/ws").await?;
-
- // Loading seed phrase and creating an account derived from the seed
- dotenv().ok();
- let seed = env::var("SEED").expect("SEED environment variable is not set");
- let account = account::from_secret_uri(&seed)?;
- println!("Account Address: {}", account.public_key().to_account_id());
-
- // Application Key Creation
- // Please note that if an application key with the same `key` already exists, the transaction will fail.
-
- let key = "My Application Key".as_bytes().to_vec();
- let tx = sdk.tx.data_availability.create_application_key(key);
- let res = tx.execute_and_watch_inclusion(&account, Options::default()).await?;
- assert_eq!(res.is_successful(), Some(true), "Transactions must be successful");
-
- let events = res.events.as_ref().unwrap();
- let event = events.find_first::().unwrap();
- let Some(event) = event else {
- return Err("Failed to get Application Key Created Event".into());
- };
- let app_id = event.id.0;
- println!("Application Key Created");
- println!("{}",app_id);
-
- Ok(())
-}
-
-// Add a main function to call create_application_key
+```rust showLineNumbers filename="avail-rust"
+use avail_rust::{Key, Keypair, Nonce, Options, SecretUri, WaitFor, SDK};
+use core::str::FromStr;
+
#[tokio::main]
-async fn main() {
- if let Err(e) = create_application_key().await {
- eprintln!("Error: {:?}", e);
- }
+async fn main() -> Result<(), String> {
+ let sdk = SDK::new("wss://turing-rpc.avail.so/ws").await.unwrap();
+
+ let alice = "This is a random seed phrase please replace with your own";
+ let secret_uri = SecretUri::from_str(alice).unwrap();
+ let account = Keypair::from_uri(&secret_uri).unwrap();
+ let key = String::from("MyAwesome43287oerwhbiwKey").as_bytes().to_vec();
+ let key = Key { 0: key };
+ let options = Options::new().nonce(Nonce::BestBlockAndTxPool);
+
+ let result = sdk
+ .tx
+ .data_availability
+ .create_application_key(key, WaitFor::BlockInclusion, &account, Some(options))
+ .await?;
+
+ println!(
+ "Key={:?}, Owner={}, Id={:?}",
+ result.event.key, result.event.owner, result.event.id
+ );
+ println!(
+ "TxHash={:?}, BlockHash={:?}",
+ result.tx_hash, result.block_hash
+ );
+
+ Ok(())
}
```
2. Run the code using:
-```bash filename="terminal" name="cmd4"
+```bash
cargo run
```
@@ -197,84 +145,47 @@ cargo run
1. Inside `main.go`, add the following code:
-```go showLineNumbers filename="avail-go" name="cmd5"
+```go showLineNumbers filename="avail-go"
package main
import (
- "fmt"
- "log"
- "os"
+ "github.com/availproject/avail-go-sdk/src/config"
+ "github.com/availproject/avail-go-sdk/src/sdk"
+ "github.com/availproject/avail-go-sdk/src/sdk/tx"
- daPallet "github.com/availproject/avail-go-sdk/metadata/pallets/data_availability"
- SDK "github.com/availproject/avail-go-sdk/sdk"
- "github.com/joho/godotenv"
+ "fmt"
)
func main() {
- // Load environment variables from .env file
- err := godotenv.Load()
+ config, err := config.LoadConfig()
if err != nil {
- log.Fatal("Error loading .env file")
+ fmt.Printf("cannot load config:%v", err)
}
-
- // Make sure the SEED environment variable is set
- seed := os.Getenv("SEED")
- if seed == "" {
- log.Fatal("SEED environment variable is not set")
- }
-
- // Create an account from the SEED environment variable
- acc, err := SDK.Account.NewKeyPair(seed)
+ api, err := sdk.NewSDK(config.ApiURL)
if err != nil {
- log.Fatalf("Failed to create account: %v", err)
+ fmt.Printf("cannot create api:%v", err)
}
- fmt.Println("Your account Address: " + acc.SS58Address(42))
- // Initialize an SDK instance
- sdk, err := SDK.NewSDK("https://turing-rpc.avail.so/rpc")
+ fmt.Println("Creating Application key...")
+ WaitFor := sdk.BlockInclusion
+ blockHash, txHash, err := tx.CreateApplicationKey(api, config.Seed, "new Application key created using avail-go....", WaitFor)
if err != nil {
- log.Fatalf("Failed to initialize SDK: %v", err)
+ fmt.Printf("cannot create application key:%v", err)
}
-
- // Generate an application key
- // Please note that the transaction will fail if
- // an AppID with the same key already exists
- key := "My new application key"
- tx := sdk.Tx.DataAvailability.CreateApplicationKey([]byte(key))
-
- // Execute the transaction
- res, err := tx.ExecuteAndWatchInclusion(acc, SDK.NewTransactionOptions())
- if err != nil {
- log.Fatalf("Transaction failed: %v", err)
- }
-
- // Check if the transaction was successful
- if !res.IsSuccessful().UnsafeUnwrap() {
- log.Fatal("Transaction was not successful")
- }
-
- fmt.Println("Application Key Created Successfully")
-
- // Printing out all the values of the event ApplicationKeyCreated
- events := res.Events.UnsafeUnwrap()
- eventMyb := SDK.EventFindFirst(events, daPallet.EventApplicationKeyCreated{})
- event := eventMyb.UnsafeUnwrap().UnsafeUnwrap()
- appId := event.Id
- fmt.Println(fmt.Sprintf(`Owner: %v, Key: %v, AppId: %v`, event.Owner.ToHuman(), string(event.Key), appId))
- fmt.Println(fmt.Sprintf(`Block Hash: %v, Block Index: %v, Tx Hash: %v, Tx Index: %v`, res.BlockHash.ToHexWith0x(), res.BlockNumber, res.TxHash.ToHexWith0x(), res.TxIndex))
- fmt.Println("Application Key Created")
+ fmt.Printf("Application key created successfully with block hash: %v\n and ext hash:%v\n", blockHash.Hex(), txHash.Hex())
+ sdk.EventParser(api, blockHash, "ApplicationKeyCreated")
}
```
2. Run the code using:
-```bash filename="terminal" name="cmd6"
+```bash
go run main.go
```
If you receive errors related to missing dependencies while trying to execute your code, run:
-```bash filename="terminal" name="cmd7"
+```bash
go mod tidy
```
and try again.
diff --git a/app/api-reference/avail-node-api/da-next-app-id/page.mdx b/app/api-reference/avail-node-api/da-next-app-id/page.mdx
index f68f47dab..2ecd0c548 100644
--- a/app/api-reference/avail-node-api/da-next-app-id/page.mdx
+++ b/app/api-reference/avail-node-api/da-next-app-id/page.mdx
@@ -1,7 +1,3 @@
----
-image: '/img/docs-link-preview.png'
----
-
import { Callout, Steps, Tabs } from 'nextra/components'
@@ -20,11 +16,7 @@ You can use this method to fetch the next available `app_id` for your awesome ro
## Parameters
-
-
-
-- None
-
+
- None
@@ -50,47 +42,36 @@ For instructions, [check out our docs here](/api-reference/avail-node-api#settin
The rest of the code should work as is.
-
+
1. Inside `your-file-name.ts`, add the following code:
-```typescript showLineNumbers filename="avail-js" name="cmd1"
-import { SDK, Pallets } from 'avail-js-sdk';
-
-export async function getNextAppId() {
- // Initialize SDK with Turing endpoint
- const sdk = await SDK.New('wss://turing-rpc.avail.so/ws');
-
- // Get the current block hash
- const blockHash = await sdk.client.bestBlockHash();
- console.log(`Current block hash: ${blockHash}`);
-
- // Get storage at the current block
- const storageAt = await sdk.client.storageAt(blockHash);
-
- // Fetch the next available app ID
- const nextAppId = await Pallets.DataAvailabilityStorage.NextAppId.fetch(storageAt);
-
- console.log(`Next available App ID is: ${nextAppId}`);
- console.log("App ID fetched successfully");
-
- process.exit(0);
+```typescript showLineNumbers filename="avail-js"
+import { SDK } from "avail-js-sdk"
+
+const main = async () => {
+ const providerEndpoint = "wss://turing-rpc.avail.so/ws"
+ const sdk = await SDK.New(providerEndpoint)
+
+ const value = await sdk.api.query.dataAvailability.nextAppId()
+ console.log(value.toHuman())
+
+ process.exit()
}
-
-// Execute the function
-getNextAppId();
+
+main()
```
2. Run the code using:
-```bash filename="terminal" name="cmd2"
+```bash
ts-node your-file-name.ts
```
-
+Sample Response:
```json
99
@@ -103,43 +84,42 @@ ts-node your-file-name.ts
1. Inside `main.rs`, add the following code:
-```rust showLineNumbers filename="avail-rust" name="cmd3"
-use avail_rust::prelude::*;
-
-pub async fn da_next_app_id() -> Result<(), ClientError> {
+```rust showLineNumbers filename="avail-rust" showLineNumbers filename="avail-rust"
+use avail_rust::{avail, SDK};
- // Create a new SDK instance
- let sdk = SDK::new("wss://turing-rpc.avail.so/ws").await?;
+#[tokio::main]
+async fn main() -> Result<(), String> {
+ let sdk = SDK::new("wss://turing-rpc.avail.so/ws").await.unwrap();
- let block_hash = sdk.client.best_block_hash().await?;
- let storage = sdk.client.storage().at(block_hash);
- let address = avail::storage().data_availability().next_app_id();
- let result = storage.fetch_or_default(&address).await?;
+ let storage_query = avail::storage().data_availability().next_app_id();
+ let best_block_hash = sdk
+ .rpc
+ .chain
+ .get_block_hash(None)
+ .await
+ .map_err(|e| e.to_string())?;
+ let result = sdk
+ .api
+ .storage()
+ .at(best_block_hash)
+ .fetch(&storage_query)
+ .await
+ .map_err(|e| e.to_string())?;
- println!("Next available App ID is: {:?}", result);
- Ok(())
-}
+ dbg!(result);
-// Add a main function to call da_next_app_id
-#[tokio::main]
-async fn main() {
- if let Err(e) = da_next_app_id().await {
- eprintln!("Error: {:?}", e);
- }
- else {
- println!("App ID fetched successfully");
- }
+ Ok(())
}
```
2. Run the code using:
-```bash filename="terminal" name="cmd4"
+```bash
cargo run
```
-
+Sample Response:
```json
Some(
@@ -152,59 +132,5 @@ Some(
-
-
-1. Inside `main.go`, add the following code:
-
-```go showLineNumbers filename="avail-go" name="cmd5"
-package main
-
-import (
- "fmt"
- "log"
-
- daPallet "github.com/availproject/avail-go-sdk/metadata/pallets/data_availability"
- prim "github.com/availproject/avail-go-sdk/primitives"
- SDK "github.com/availproject/avail-go-sdk/sdk"
-)
-
-func main() {
- sdk, err := SDK.NewSDK("https://turing-rpc.avail.so/rpc")
- if err != nil {
- log.Fatalf("Failed to initialize SDK: %v", err)
- }
-
- // Get the latest block hash
- latestBlockHash, err := sdk.Client.BestBlockHash()
- if err != nil {
- log.Fatalf("Failed to get latest block hash: %v", err)
- }
-
- // Initialize the block storage
- blockStorage, err := sdk.Client.StorageAt(prim.Some(latestBlockHash))
- if err != nil {
- log.Fatalf("Failed to get block storage: %v", err)
- }
-
- // Call the StorageNextAppId function
- storage := daPallet.StorageNextAppId{}
- nextAppId, err := storage.Fetch(&blockStorage)
- if err != nil {
- log.Fatalf("Failed to fetch next app ID: %v", err)
- }
-
- fmt.Printf("Next available App ID is: %v\n", nextAppId)
- fmt.Println("App ID fetched successfully")
-}
-```
-
-2. Run the code using:
-
-```bash filename="terminal" name="cmd6"
-go run main.go
-```
-
-
-
diff --git a/app/api-reference/avail-node-api/da-submit-data/page.mdx b/app/api-reference/avail-node-api/da-submit-data/page.mdx
index 3f11cd7e1..736ba5063 100644
--- a/app/api-reference/avail-node-api/da-submit-data/page.mdx
+++ b/app/api-reference/avail-node-api/da-submit-data/page.mdx
@@ -1,7 +1,3 @@
----
-image: '/img/docs-link-preview.png'
----
-
import { Callout, Steps, Tabs } from 'nextra/components'
# Submit new data to Avail DA
@@ -46,7 +42,8 @@ On-chain name of extrinsic: `dataAvailability_submitData`
On failure, a reason of failure is returned. On Success, DataSubmitted event, transaction data, transaction hash and block hash is returned.
-## Submit data using a specific `app_id`
+
+## Minimal example
1. You will need to set up the dev environment required to run this example.
@@ -56,6 +53,167 @@ For instructions, [check out our docs here](/api-reference/avail-node-api#settin
The rest of the code should work as is.
+
+
+
+
+1. Inside `your-file-name.ts`, add the following code:
+
+```typescript showLineNumbers filename="avail-js"
+import { SDK, WaitFor, Keyring } from "avail-js-sdk"
+
+const main = async () => {
+ const providerEndpoint = "wss://turing-rpc.avail.so/ws";
+ const sdk = await SDK.New(providerEndpoint)
+
+ const Alice = "This is a random seed phrase please replace with your own";
+ const account = new Keyring({ type: "sr25519" }).addFromUri(Alice)
+ const data = "My Awesome Data"
+
+ const result = await sdk.tx.dataAvailability.submitData(data, WaitFor.BlockInclusion, account)
+ if (result.isErr) {
+ console.log(result.reason)
+ process.exit(1)
+ }
+
+ console.log("Data=" + result.txData.data)
+ console.log("Who=" + result.event.who + ", DataHash=" + result.event.dataHash)
+ console.log("TxHash=" + result.txHash + ", BlockHash=" + result.blockHash)
+
+ process.exit()
+}
+main()
+```
+
+2. Run the code using:
+
+```bash
+ts-node your-file-name.ts
+```
+
+
+
+
+1. Inside `src/main.rs`, paste the following code:
+
+```rust showLineNumbers filename="avail-rust"
+use avail_rust::{Data, Keypair, Nonce, Options, SecretUri, WaitFor, SDK};
+use core::str::FromStr;
+
+#[tokio::main]
+async fn main() -> Result<(), String> {
+ let sdk = SDK::new("wss://turing-rpc.avail.so/ws").await.unwrap();
+
+ let alice = "This is a random seed phrase please replace with your own";
+ let secret_uri = SecretUri::from_str(alice).unwrap();
+ let account = Keypair::from_uri(&secret_uri).unwrap();
+ let data = String::from("Sample data being submitted......").as_bytes().to_vec();
+ let data = Data { 0: data };
+
+ let wait_for = WaitFor::BlockInclusion;
+ let options = Options::new().nonce(Nonce::BestBlockAndTxPool);
+
+ let result = sdk
+ .tx
+ .data_availability
+ .submit_data(data, wait_for, &account, Some(options))
+ .await?;
+
+ println!(
+ "Who={}, DataHash={:?}",
+ result.event.who, result.event.data_hash
+ );
+ println!("TxData={:?}", result.tx_data.data);
+ println!(
+ "TxHash={:?}, BlockHash={:?}",
+ result.tx_hash, result.block_hash
+ );
+
+ Ok(())
+}
+```
+
+2. Run the code using:
+
+```bash
+cargo run
+```
+
+
+
+Sample Response:
+```bash
+ Finished dev [unoptimized + debuginfo] target(s) in 13.93s
+ Running `target/debug/da-submit-data`
+Who=5CqgQkrDcdg5QrtuxT3H7WszrqgrBMhdwRbmMVXQzc4VSiEg, DataHash=0xdb10b83f02707eff828e95e4cb534871d6e1ca9fb10eb9ccc12795e9abf6f931
+TxData=BoundedVec([83, 97, 109, 112, 108, 101, 32, 100, 97, 116, 97, 32, 98, 101, 105, 110, 103, 32, 115, 117, 98, 109, 105, 116, 116, 101, 100, 46, 46, 46, 46, 46, 46])
+TxHash=0xbfdf581618f28ef707147ea47a56483c6214dbaa83c53a6cc307073e3b8b578b, BlockHash=0xbee81b96a4e86dbc1a668da466416f6648c0025a7fc0d428ecae71d504290c62
+```
+
+
+
+
+
+
+
+1. Inside `main.go`, paste the following code:
+
+```go showLineNumbers filename="avail-go"
+package main
+
+import (
+ "github.com/availproject/avail-go-sdk/src/config"
+ "github.com/availproject/avail-go-sdk/src/sdk"
+ "github.com/availproject/avail-go-sdk/src/sdk/tx"
+
+ "fmt"
+)
+
+func main() {
+ config, err := config.LoadConfig()
+ if err != nil {
+ fmt.Printf("cannot load config:%v", err)
+ }
+ api, err := sdk.NewSDK(config.ApiURL)
+ if err != nil {
+ fmt.Printf("cannot create api:%v", err)
+ }
+
+ appID := 0
+
+ // if app id is greater than 0 then it must be created before submitting data
+ if config.AppID != 0 {
+ appID = config.AppID
+ }
+ fmt.Println("Submitting data ...")
+ WaitFor := sdk.BlockInclusion
+
+ BlockHash, txHash, err := tx.SubmitData(api, config.Seed, appID, "my happy data", WaitFor)
+ if err != nil {
+ fmt.Printf("cannot submit data:%v", err)
+ }
+ fmt.Printf("Data submitted successfully with block hash: %v\n and ext hash:%v", BlockHash.Hex(), txHash.Hex())
+}
+```
+
+2. Run the code using:
+
+```bash
+go run main.go
+```
+
+
+If you receive errors related to missing dependencies while trying to execute your code, run:
+```bash
+go mod tidy
+```
+and try again.
+
+
+
+
+
+## Submit data using a specific `app_id`
**PLEASE NOTE**
@@ -64,6 +222,8 @@ read more [in our docs here](/api-reference/avail-node-api/da-create-application
2. You can submit data to **ANY** `app_id`, even if you didn't create it. This however does not contitute an
attack vector since the rollups building on top of Avail DA can always filter out DA submissions.
+
+3. If a specific `app_id` is not configured, the default is set to `0`.
@@ -71,74 +231,37 @@ attack vector since the rollups building on top of Avail DA can always filter ou
1. Inside `your-file-name.ts`, paste the following code:
-```typescript showLineNumbers filename="avail-js" name="cmd1"
-import * as dotenv from 'dotenv';
-import { Account, SDK, Pallets } from 'avail-js-sdk';
-
-dotenv.config();
-
-export async function submitData() {
- // Initialize SDK with Turing endpoint
- const sdk = await SDK.New('wss://turing-rpc.avail.so/ws');
-
- // Create account from seed in .env file
- const seed = process.env.SEED;
- if (!seed) {
- throw new Error("SEED environment variable is not set");
- }
-
- // Create account from seed
- const account = Account.new(seed);
- console.log("Account Address: ", account.address);
-
- // Replace with your own AppID
- const appId = 89;
- console.log(`Submitting data to App Id: ${appId}`);
-
- // Create data submission transaction
- const data = "My Data Submission";
- const tx = sdk.tx.dataAvailability.submitData(data);
- console.log("Submitting transaction with data...");
-
- // Execute and wait for inclusion with app_id
- const res = await tx.executeWaitForInclusion(account, { app_id: appId });
-
- // Check if transaction was successful
- const isOk = res.isSuccessful();
- if (isOk === undefined) {
- throw new Error("Cannot check if transaction was successful");
- }
- else if (!isOk) {
- throw new Error("Transaction failed");
+```typescript showLineNumbers filename="avail-js"
+import { SDK, WaitFor, Keyring, TransactionOptions } from "avail-js-sdk"
+
+const main = async () => {
+ const providerEndpoint = "wss://turing-rpc.avail.so/ws";
+ const sdk = await SDK.New(providerEndpoint)
+
+ const Alice = 'This is a random seed phrase please replace with your own';
+ const account = new Keyring({ type: "sr25519" }).addFromUri(Alice)
+ const data = "My Awesome Data"
+ const appId = 89
+ const options = { app_id: appId }
+
+ const result = await sdk.tx.dataAvailability.submitData(data, WaitFor.BlockInclusion, account, options)
+ if (result.isErr) {
+ console.log(result.reason)
+ process.exit(1)
}
-
- // Extract event data
- if (res.events === undefined) throw new Error("No events found");
-
- // Transaction Details
- console.log(
- `Block Hash: ${res.blockHash}, Block Number: ${res.blockNumber}, Tx Hash: ${res.txHash}, Tx Index: ${res.txIndex}`
- );
-
- // Find DataSubmitted event
- const event = res.events.findFirst(Pallets.DataAvailabilityEvents.DataSubmitted);
- if (event === undefined) throw new Error("DataSubmitted event not found");
-
- console.log(`Data submitted successfully:`);
- console.log(`Who: ${event.who}`);
- console.log(`DataHash: ${event.dataHash}`);
-
- console.log("Data submission completed successfully");
- process.exit(0);
+
+ console.log("Data=" + result.txData.data)
+ console.log("Who=" + result.event.who + ", DataHash=" + result.event.dataHash)
+ console.log("TxHash=" + result.txHash + ", BlockHash=" + result.blockHash)
+
+ process.exit()
}
-
-// Execute the function
-submitData();
+main()
```
2. Run the code using:
-```bash filename="terminal" name="cmd2"
+```bash
ts-node your-file-name.ts
```
@@ -146,64 +269,55 @@ ts-node your-file-name.ts
1. Inside `src/main.rs`, paste the following code:
-```rust showLineNumbers filename="avail-rust" name="cmd3"
-use dotenvy::dotenv;
-use std::env;
-use avail_rust::prelude::*;
-
-type DataSubmissionCall = avail::data_availability::calls::types::SubmitData;
-
-pub async fn submit_data() -> Result<(), ClientError> {
-
- // Create a new SDK instance
- let sdk = SDK::new("wss://turing-rpc.avail.so/ws").await?;
+```rust showLineNumbers filename="avail-rust"
+use avail_rust::{Data, Keypair, Nonce, Options, SecretUri, WaitFor, SDK};
+use core::str::FromStr;
- // Loading seed phrase and creating an account derived from the seed
- dotenv().ok();
- let seed = env::var("SEED").expect("SEED environment variable is not set");
- let account = account::from_secret_uri(&seed)?;
- println!("Account Address: {}", account.public_key().to_account_id());
-
- // Please note that the tx will fail if this application key does not exist
- let my_application_key = 1;
-
- // Data Submission
- let data = String::from("My Data").into_bytes();
- let options = Options::new().app_id(my_application_key);
- let tx = sdk.tx.data_availability.submit_data(data);
- let res = tx.execute_and_watch_inclusion(&account, options).await?;
- assert_eq!(res.is_successful(), Some(true), "Transactions must be successful");
-
- println!(
- "Block Hash: {:?}, Block Number: {}, Tx Hash: {:?}, Tx Index: {}",
- res.block_hash, res.block_number, res.tx_hash, res.tx_index
- );
-
- // Decoding
- let decoded = res.decode_as::().await?;
- let Some(decoded) = decoded else {
- return Err("Failed to get Data Submission Call data".into());
- };
-
- let data = to_ascii(decoded.data.0).unwrap();
- println!("Call data: {:?}", data);
-
- println!("Data Submission finished correctly");
-
- Ok(())
-}
-
-// Add a main function to call submit_data
#[tokio::main]
-async fn main() {
- if let Err(e) = submit_data().await {
- eprintln!("Error: {:?}", e);
- }
+async fn main() -> Result<(), String> {
+ let sdk = SDK::new("wss://turing-rpc.avail.so/ws").await.unwrap();
+
+ let alice = "This is a random seed phrase please replace with your own";
+ let secret_uri = SecretUri::from_str(alice).unwrap();
+ let account = Keypair::from_uri(&secret_uri).unwrap();
+ let data = String::from("Sample data being submitted......").as_bytes().to_vec();
+ let data = Data { 0: data };
+
+ let wait_for = WaitFor::BlockInclusion;
+ let options = Options::new().nonce(Nonce::BestBlockAndTxPool);
+
+ let app_id = 89; // You can change this value to your desired app_id
+
+ // Create the options with the app_id included
+ let options = Options {
+ app_id: Some(app_id),
+ mortality: None,
+ nonce: Some(Nonce::BestBlockAndTxPool),
+ tip: None,
+ };
+
+ let result = sdk
+ .tx
+ .data_availability
+ .submit_data(data, wait_for, &account, Some(options))
+ .await?;
+
+ println!(
+ "Who={}, DataHash={:?}",
+ result.event.who, result.event.data_hash
+ );
+ println!("TxData={:?}", result.tx_data.data);
+ println!(
+ "TxHash={:?}, BlockHash={:?}",
+ result.tx_hash, result.block_hash
+ );
+
+ Ok(())
}
```
2. Run the code using:
-```bash filename="terminal" name="cmd4"
+```bash
cargo run
```
@@ -212,72 +326,51 @@ cargo run
1. Inside `main.go`, paste the following code:
-```go showLineNumbers filename="avail-go" name="cmd5"
+```go showLineNumbers filename="avail-go"
package main
import (
- "fmt"
- "log"
- "os"
+ "github.com/availproject/avail-go-sdk/src/config"
+ "github.com/availproject/avail-go-sdk/src/sdk"
+ "github.com/availproject/avail-go-sdk/src/sdk/tx"
- SDK "github.com/availproject/avail-go-sdk/sdk"
- "github.com/joho/godotenv"
+ "fmt"
)
func main() {
- // Load environment variables from .env file
- err := godotenv.Load()
+ config, err := config.LoadConfig()
if err != nil {
- log.Fatal("Error loading .env file")
- }
-
- // Make sure the SEED environment variable is set
- seed := os.Getenv("SEED")
- if seed == "" {
- log.Fatal("SEED environment variable is not set")
+ fmt.Printf("cannot load config:%v", err)
}
-
- // Create an account from the SEED environment variable
- acc, err := SDK.Account.NewKeyPair(seed)
+ api, err := sdk.NewSDK(config.ApiURL)
if err != nil {
- log.Fatalf("Failed to create account: %v", err)
+ fmt.Printf("cannot create api:%v", err)
}
- fmt.Println("Your account Address: " + acc.SS58Address(42))
- // Initialize an SDK instance
- sdk, err := SDK.NewSDK("https://turing-rpc.avail.so/rpc")
- if err != nil {
- log.Fatalf("Failed to initialize SDK: %v", err)
- }
+ // You can your own app id here
+ appID := 0
- // Submit data to Avail
- appId := uint32(89)
- tx := sdk.Tx.DataAvailability.SubmitData([]byte("Submitting some data using avail-go-sdk"))
- res, err := tx.ExecuteAndWatchInclusion(acc, SDK.NewTransactionOptions().WithAppId(appId))
- if err != nil {
- log.Fatalf("Transaction failed: %v", err)
- }
+ fmt.Println("Submitting data ...")
+ WaitFor := sdk.BlockInclusion
- // Check if the transaction was successful
- if !res.IsSuccessful().UnsafeUnwrap() {
- log.Fatal("Transaction was not successful")
+ // submit data
+ BlockHash, txHash, err := tx.SubmitData(api, config.Seed, appID, "my happy data", WaitFor)
+ if err != nil {
+ fmt.Printf("cannot submit data:%v", err)
}
-
- // Printing out all the values of the transaction
- fmt.Println(fmt.Sprintf(`Block Hash: %v, Block Index: %v, Tx Hash: %v, Tx Index: %v`, res.BlockHash.ToHexWith0x(), res.BlockNumber, res.TxHash.ToHexWith0x(), res.TxIndex))
- fmt.Println("Data submission completed successfully")
+ fmt.Printf("Data submitted successfully with block hash: %v\n and ext hash:%v", BlockHash.Hex(), txHash.Hex())
}
```
2. Run the code using:
-```bash filename="terminal" name="cmd6"
+```bash
go run main.go
```
If you receive errors related to missing dependencies while trying to execute your code, run:
-```bash filename="terminal" name="cmd7"
+```bash
go mod tidy
```
and try again.
@@ -288,3 +381,4 @@ and try again.
> This will lead to your data being submitted through a specific `app_id`, which you can verify by looking
> up your transaction on the [Avail explorer](https://explorer.availproject.org/#/explorer).
+
diff --git a/app/api-reference/avail-node-api/nomination-pools-create-with-pool-id/page.mdx b/app/api-reference/avail-node-api/nomination-pools-create-with-pool-id/page.mdx
index b31f78216..d2d2858fc 100644
--- a/app/api-reference/avail-node-api/nomination-pools-create-with-pool-id/page.mdx
+++ b/app/api-reference/avail-node-api/nomination-pools-create-with-pool-id/page.mdx
@@ -1,7 +1,3 @@
----
-image: '/img/docs-link-preview.png'
----
-
import { Callout, Steps, Tabs } from 'nextra/components'
# Create a new nomination pool with a specific pool ID
@@ -10,7 +6,7 @@ On-chain name of method: `nominationPools_createWithPoolId`
## Parameters
-
+
| parameter | type | optional | description |
@@ -38,19 +34,6 @@ On-chain name of method: `nominationPools_createWithPoolId`
| options | Options | true | transaction parameters |
-
-| parameter | type | optional | description |
-| --------- | ----------- | -------- | -------------------------------------------------- |
-| amount | u128 | false | The amount of funds to delegate to the pool |
-| root | &str | false | The account to set as [`PoolRoles::root`] |
-| nominator | &str | false | The account to set as the [`PoolRoles::nominator`] |
-| bouncer | &str | false | The account to set as the [`PoolRoles::bouncer`] |
-| pool id | u32 | false | pool id |
-| waitFor | WaitFor | false | wait for block inclusion or finalization |
-| account | KeyringPair | false | account that will send and sign the transaction |
-| options | Options | true | transaction parameters |
-
-
## Returns
@@ -68,97 +51,56 @@ For instructions, [check out our docs here](/api-reference/avail-node-api#settin
The rest of the code should work as is.
-
-1. The minimum amount of `AVAIL` required to create a nomination pool is `10_000 AVAIL`.
-2. You need to allocate privileges to some accounts while creating the pool.
-
-
-Different roles within a nomination pool
-
-A pool consists of 4 roles, each of which having different responsibilities in managing the running of the pool.
-1. Root: Can change the nominator, bouncer, or itself. Further, it can perform any of the actions the nominator or bouncer can.
-2. Depositor: Creates the pool and is the initial member. The depositor can only leave the pool once all other members have left. Once they leave by withdrawing, the pool is fully removed from the system.
-3. Nominator: Can select the validators the pool nominates.
-4. Bouncer: Can change the pool's state and kick (permissionlessly unbond/withdraw) members if the pool is blocked.
-
-
-
-
-
-
+
1. Inside `your-file-name.ts`, add the following code:
-```typescript showLineNumbers filename="avail-js" name="cmd1"
-import * as dotenv from 'dotenv';
-import { Account, SDK, BN, Pallets } from 'avail-js-sdk';
-
-dotenv.config();
-
-export async function nominationPoolsCreateWithPoolId() {
- // Initialize SDK with Turing endpoint
- const sdk = await SDK.New('wss://turing-rpc.avail.so/ws');
-
- // Create account from seed in .env file
- const seed = process.env.SEED;
- if (!seed) {
- throw new Error("SEED environment variable is not set");
- }
-
- // Create account from seed
- const account = Account.new(seed);
- console.log("Account Address: ", account.address);
-
- // Initial deposit amount: 10,000 AVAIL
- const amount = new BN(10).pow(new BN(18)).mul(new BN(10000)); // 10,000 AVAIL
- console.log("Initial Deposit: 10,000 AVAIL");
-
- // Pool roles - using Alice's address for all roles
- const root = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY"; // Alice
- const nominator = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY"; // Alice
- const bouncer = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY"; // Alice
- const poolId = 0; // Specific pool ID to create
-
- // Create pool with ID transaction
- const tx = sdk.tx.nominationPools.createWithPoolId(amount, root, nominator, bouncer, poolId);
- console.log("Submitting create pool with ID transaction...");
-
- // Execute and wait for inclusion
- const res = await tx.executeWaitForInclusion(account, {});
-
- // Check if transaction was successful
- const isOk = res.isSuccessful();
- if (isOk === undefined) {
- throw new Error("Cannot check if transaction was successful");
- }
- else if (!isOk) {
- throw new Error("Transaction failed");
- }
-
- console.log("\nPool creation with ID completed successfully");
- // Log all transaction details
- console.log("\nTransaction Details:");
- console.log(`Transaction Hash: ${res.txHash}`);
- console.log(`Block Hash: ${res.blockHash}`);
- console.log(`Block Number: ${res.blockNumber}`);
-
- process.exit(0);
+```typescript showLineNumbers filename="avail-js"
+import { SDK, WaitFor, Keyring, BN } from "avail-js-sdk"
+
+const main = async () => {
+ const providerEndpoint = "wss://turing-rpc.avail.so/ws";
+ const sdk = await SDK.New(providerEndpoint);
+
+ const Alice = 'This is a random seed phrase please replace with your own';
+ const account = new Keyring({ type: "sr25519" }).addFromUri(Alice);
+ const amount = new BN(10).pow(new BN(18)).mul(new BN(10000)) // 10_000 Avail
+
+ const root: string = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY" // Alice
+ const nominator: string = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY" // Alice
+ const bouncer: string = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY" // Alice
+ const poolId = 0
+
+ const result = await sdk.tx.nominationPools.createWithPoolId(
+ amount,
+ root,
+ nominator,
+ bouncer,
+ poolId,
+ WaitFor.BlockInclusion,
+ account,
+ )
+ if (result.isErr) {
+ console.log(result.reason)
+ process.exit(1)
+ }
+
+ console.log(JSON.stringify(result, null, 4))
+ process.exit()
}
-
-// Execute the function
-nominationPoolsCreateWithPoolId();
+main()
```
2. Run the code using:
-```bash filename="terminal" name="cmd2"
+```bash
ts-node your-file-name.ts
```
-
+Sample Response:
```js
{
@@ -188,64 +130,56 @@ ts-node your-file-name.ts
1. Inside `main.rs`, add the following code:
-```rust showLineNumbers filename="avail-rust" name="cmd3"
-use dotenvy::dotenv;
-use std::env;
-use avail_rust::prelude::*;
+```rust showLineNumbers filename="avail-rust" showLineNumbers filename="avail-rust"
+use avail_rust::{Keypair, Nonce, Options, SecretUri, WaitFor, SDK};
use core::str::FromStr;
-
-pub async fn nomination_pools_create_with_pool_id() -> Result<(), ClientError> {
-
- // Create a new SDK instance
- let sdk = SDK::new("wss://turing-rpc.avail.so/ws").await?;
-
- // Loading seed phrase and creating an account derived from the seed
- dotenv().ok();
- let seed = env::var("SEED").expect("SEED environment variable is not set");
- let account = account::from_secret_uri(&seed)?;
-
- //Setting the amount to bond and the pool id
- let amount = 10_000_000_000_000_000_000_000u128; // 10_000 Avail tokens
- let pool_id = 1; // You need to use a pool id that is not already in use
-
- //Setting the root, nominator and bouncer
- let root = account.public_key().to_account_id(); //Setting the root to be the account itself
-
- let nominator = AccountId::from_str("5DDY2yzh8uCysYFAiRSTeQVwtZSKNF49CkQkyPH852xvrYKk").unwrap();
- let bouncer = AccountId::from_str("5D7LgWT5J6MVRa6PvTTXUfd9VvggEcguvPnnWAGK44CJKFEq").unwrap();
-
- //Executing the transaction
- let tx = sdk.tx.nomination_pools.create_with_pool_id(amount, root, nominator, bouncer, pool_id);
- let res = tx.execute_and_watch_inclusion(&account, Options::new()).await?;
- assert_eq!(res.is_successful(), Some(true));
-
- println!(
- "Block Hash: {:?}, Block Number: {}, Tx Hash: {:?}, Tx Index: {}",
- res.block_hash, res.block_number, res.tx_hash, res.tx_index
- );
-
- Ok(())
-}
-
-
+
#[tokio::main]
-async fn main() {
- if let Err(e) = nomination_pools_create_with_pool_id().await {
- eprintln!("Error: {:?}", e);
- }
+async fn main() -> Result<(), String> {
+ let sdk = SDK::new("wss://turing-rpc.avail.so/ws").await.unwrap();
+
+ let alice = "This is a random seed phrase please replace with your own";
+ let secret_uri = SecretUri::from_str(alice).unwrap();
+ let account = Keypair::from_uri(&secret_uri).unwrap();
+ let amount = 1_000_000_000_000_000_000_000_000u128; // 1_000_000 Avail tokens
+ let root = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY"; // Alice
+ let nominator = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY"; // Alice
+ let bouncer = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY"; // Alice
+ let pool_id = 0;
+
+ let wait_for = WaitFor::BlockInclusion;
+ let options = Options::new().nonce(Nonce::BestBlockAndTxPool);
+ let result = sdk
+ .tx
+ .nomination_pools
+ .create_with_pool_id(
+ amount,
+ root,
+ nominator,
+ bouncer,
+ pool_id,
+ wait_for,
+ &account,
+ Some(options),
+ )
+ .await?;
+
+ dbg!(result);
+
+ Ok(())
}
```
2. Run the code using:
-```bash filename="terminal" name="cmd4"
+```bash
cargo run
```
-
+Sample Response:
-```rust showLineNumbers filename="avail-rust" name="cmd3"
+```rust showLineNumbers filename="avail-rust"
PoolCreateWithPoolIdTxSuccess {
event: Created {
depositor: AccountId32(...),
@@ -275,100 +209,4 @@ PoolCreateWithPoolIdTxSuccess {
-
-
-1. Inside `main.go`, add the following code:
-
-```go showLineNumbers filename="avail-go" name="cmd5"
-package main
-
-import (
- "fmt"
- "log"
- "os"
-
- "github.com/availproject/avail-go-sdk/metadata"
- "github.com/availproject/avail-go-sdk/primitives"
- SDK "github.com/availproject/avail-go-sdk/sdk"
- "github.com/joho/godotenv"
-)
-
-func main() {
- // Load environment variables from .env file
- err := godotenv.Load()
- if err != nil {
- log.Fatal("Error loading .env file")
- }
-
- // Make sure the SEED environment variable is set
- seed := os.Getenv("SEED")
- if seed == "" {
- log.Fatal("SEED environment variable is not set")
- }
-
- // Create an account from the SEED environment variable
- acc, err := SDK.Account.NewKeyPair(seed)
- if err != nil {
- log.Fatalf("Failed to create account: %v", err)
- }
- fmt.Println("Your account Address: " + acc.SS58Address(42))
-
- // Initialize an SDK instance
- sdk, err := SDK.NewSDK("https://turing-rpc.avail.so/rpc")
- if err != nil {
- log.Fatalf("Failed to initialize SDK: %v", err)
- }
-
- // Set the amount, pool ID, and addresses
- amount, err := metadata.NewBalanceFromString("1000000000000000000000000") // Example amount
- if err != nil {
- log.Fatalf("Failed to create balance: %v", err)
- }
- poolId := uint32(1)
-
- rootAddress, err := primitives.NewAccountIdFromAddress("5DqMavSQikX9eMzwHKiC8xS6VWB2yCd5gGQuQq7KheM2Mgc7")
- if err != nil {
- log.Fatalf("Failed to convert root address: %v", err)
- }
- nominatorAddress, err := primitives.NewAccountIdFromAddress("5FphMk7DhSdq7jXsQCVQthw7XTiCWxdA9ZS6V43rKeJzvya9")
- if err != nil {
- log.Fatalf("Failed to convert nominator address: %v", err)
- }
- bouncerAddress, err := primitives.NewAccountIdFromAddress("5G9fM7DhSdq7jXsQCVQthw7XTiCWxdA9ZS6V43rKeJzvya9")
- if err != nil {
- log.Fatalf("Failed to convert bouncer address: %v", err)
- }
-
- // Convert addresses to MultiAddress
- root := rootAddress.ToMultiAddress()
- nominator := nominatorAddress.ToMultiAddress()
- bouncer := bouncerAddress.ToMultiAddress()
-
- // Create the CreateWithPoolId transaction
- tx := sdk.Tx.NominationPools.CreateWithPoolId(amount, root, nominator, bouncer, poolId)
-
- // Execute the transaction
- res, err := tx.ExecuteAndWatchInclusion(acc, SDK.NewTransactionOptions())
- if err != nil {
- log.Fatalf("Transaction failed: %v", err)
- }
-
- // Check if the transaction was successful
- if !res.IsSuccessful().UnsafeUnwrap() {
- log.Fatal("Transaction was not successful")
- }
-
- fmt.Println("CreateWithPoolId transaction successful")
- fmt.Printf("Block Hash: %v, Block Number: %v, Tx Hash: %v, Tx Index: %v\n", res.BlockHash.ToHexWith0x(), res.BlockNumber, res.TxHash.ToHexWith0x(), res.TxIndex)
-}
-```
-
-2. Run the code using:
-
-```bash filename="terminal" name="cmd6"
-go run main.go
-```
-
-
-
-
+
\ No newline at end of file
diff --git a/app/api-reference/avail-node-api/nomination-pools-create/page.mdx b/app/api-reference/avail-node-api/nomination-pools-create/page.mdx
index a64846cb9..f5ab9c445 100644
--- a/app/api-reference/avail-node-api/nomination-pools-create/page.mdx
+++ b/app/api-reference/avail-node-api/nomination-pools-create/page.mdx
@@ -1,7 +1,3 @@
----
-image: '/img/docs-link-preview.png'
----
-
import { Callout, Steps, Tabs } from 'nextra/components'
# Create a new nomination pool
@@ -10,7 +6,7 @@ On-chain name of method: `nominationPools_create`
## Parameters
-
+
| parameter | type | optional | description |
@@ -36,18 +32,6 @@ On-chain name of method: `nominationPools_create`
| options | Options | true | transaction parameters |
-
-| parameter | type | optional | description |
-| --------- | ----------- | -------- | -------------------------------------------------- |
-| amount | u128 | false | The amount of funds to delegate to the pool |
-| root | &str | false | The account to set as [`PoolRoles::root`] |
-| nominator | &str | false | The account to set as the [`PoolRoles::nominator`] |
-| bouncer | &str | false | The account to set as the [`PoolRoles::bouncer`] |
-| waitFor | WaitFor | false | wait for block inclusion or finalization |
-| account | KeyringPair | false | account that will send and sign the transaction |
-| options | Options | true | transaction parameters |
-
-
## Returns
@@ -65,103 +49,48 @@ For instructions, [check out our docs here](/api-reference/avail-node-api#settin
The rest of the code should work as is.
-
-1. The minimum amount of `AVAIL` required to create a nomination pool is `10_000 AVAIL`.
-2. You need to allocate privileges to some accounts while creating the pool.
+
-
-Different roles within a nomination pool
+
-A pool consists of 4 roles, each of which having different responsibilities in managing the running of the pool.
-1. Root: Can change the nominator, bouncer, or itself. Further, it can perform any of the actions the nominator or bouncer can.
-2. Depositor: Creates the pool and is the initial member. The depositor can only leave the pool once all other members have left. Once they leave by withdrawing, the pool is fully removed from the system.
-3. Nominator: Can select the validators the pool nominates.
-4. Bouncer: Can change the pool's state and kick (permissionlessly unbond/withdraw) members if the pool is blocked.
+1. Inside `your-file-name.ts`, add the following code:
-
+```typescript showLineNumbers filename="avail-js"
+import { SDK, WaitFor, Keyring, BN } from "avail-js-sdk"
-
+const main = async () => {
+ const providerEndpoint = "wss://turing-rpc.avail.so/ws";
+ const sdk = await SDK.New(providerEndpoint);
-
+ const Alice = 'This is a random seed phrase please replace with your own';
+ const account = new Keyring({ type: "sr25519" }).addFromUri(Alice);
+ const amount = new BN(10).pow(new BN(18)).mul(new BN(10000)) // 10_000 Avail
-
+ const root: string = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY" // Alice
+ const nominator: string = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY" // Alice
+ const bouncer: string = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY" // Alice
-1. Inside `your-file-name.ts`, add the following code:
+ const result = await sdk.tx.nominationPools.create(amount, root, nominator, bouncer, WaitFor.BlockInclusion, account)
+ if (result.isErr) {
+ console.log(result.reason)
+ process.exit(1)
+ }
-```typescript showLineNumbers filename="avail-js" name="cmd1"
-import * as dotenv from 'dotenv';
-import { Account, SDK, BN, Pallets } from 'avail-js-sdk';
-
-dotenv.config();
-
-export async function nominationPoolsCreate() {
- // Initialize SDK with Turing endpoint
- const sdk = await SDK.New('wss://turing-rpc.avail.so/ws');
-
- // Create account from seed in .env file
- const seed = process.env.SEED;
- if (!seed) {
- throw new Error("SEED environment variable is not set");
- }
-
- // Create account from seed
- const account = Account.new(seed);
- console.log("Account Address: ", account.address);
-
- // Initial deposit amount: 10,000 AVAIL
- const amount = new BN(10).pow(new BN(18)).mul(new BN(10000)); // 10,000 AVAIL
- console.log("Initial Deposit: 10,000 AVAIL");
-
- // Pool roles - using Alice's address for all roles
- const root = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY"; // Alice
- const nominator = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY"; // Alice
- const bouncer = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY"; // Alice
-
- console.log("Pool Roles:");
- console.log(`Root: ${root}`);
- console.log(`Nominator: ${nominator}`);
- console.log(`Bouncer: ${bouncer}`);
-
- // Create pool transaction
- const tx = sdk.tx.nominationPools.create(amount, root, nominator, bouncer);
-
- console.log("Submitting create pool transaction...");
-
- // Execute and wait for inclusion
- const res = await tx.executeWaitForInclusion(account, {});
-
- // Check if transaction was successful
- const isOk = res.isSuccessful();
- if (isOk === undefined) {
- throw new Error("Cannot check if transaction was successful");
- }
- else if (!isOk) {
- throw new Error("Transaction failed");
- }
-
- console.log("\nPool creation completed successfully");
- // Log all transaction details
- console.log("\nTransaction Details:");
- console.log(`Transaction Hash: ${res.txHash}`);
- console.log(`Block Hash: ${res.blockHash}`);
- console.log(`Block Number: ${res.blockNumber}`);
-
- process.exit(0);
+ console.log(JSON.stringify(result, null, 4))
+ process.exit()
}
-
-// Execute the function
-nominationPoolsCreate();
+main()
```
2. Run the code using:
-```bash filename="terminal" name="cmd2"
+```bash
ts-node your-file-name.ts
```
-
+Sample Response:
```js
{
@@ -196,58 +125,54 @@ ts-node your-file-name.ts
1. Inside `main.rs`, add the following code:
-```rust showLineNumbers filename="avail-rust" name="cmd3"
-use dotenvy::dotenv;
-use std::env;
-use avail_rust::prelude::*;
+```rust showLineNumbers filename="avail-rust" showLineNumbers filename="avail-rust"
+use avail_rust::{Keypair, Nonce, Options, SecretUri, WaitFor, SDK};
use core::str::FromStr;
-
-pub async fn nomination_pools_create() -> Result<(), ClientError> {
-
- // Create a new SDK instance
- let sdk = SDK::new("wss://turing-rpc.avail.so/ws").await?;
-
- // Loading seed phrase and creating an account derived from the seed
- dotenv().ok();
- let seed = env::var("SEED").expect("SEED environment variable is not set");
- let account = account::from_secret_uri(&seed)?;
-
- //Setting the amount to bond and the pool id
- let amount = 10_000_000_000_000_000_000_000u128; // 10_000 Avail tokens
-
- //Setting the root, nominator and bouncer
- let root = account.public_key().to_account_id(); //Setting the root to be the account itself
-
- let nominator = AccountId::from_str("5DDY2yzh8uCysYFAiRSTeQVwtZSKNF49CkQkyPH852xvrYKk").unwrap();
- let bouncer = AccountId::from_str("5D7LgWT5J6MVRa6PvTTXUfd9VvggEcguvPnnWAGK44CJKFEq").unwrap();
-
- //Executing the transaction
- let tx = sdk.tx.nomination_pools.create(amount, root, nominator, bouncer);
- let res = tx.execute_and_watch_inclusion(&account, Options::new()).await?;
- assert_eq!(res.is_successful(), Some(true));
-
- Ok(())
-}
-
-
+
#[tokio::main]
-async fn main() {
- if let Err(e) = nomination_pools_create().await {
- eprintln!("Error: {:?}", e);
- }
+async fn main() -> Result<(), String> {
+ let sdk = SDK::new("wss://turing-rpc.avail.so/ws").await.unwrap();
+
+ let alice = "This is a random seed phrase please replace with your own";
+ let secret_uri = SecretUri::from_str(alice).unwrap();
+ let account = Keypair::from_uri(&secret_uri).unwrap();
+ let amount = 1_600_000_000_000_000_000_000_0u128; // 16_000 Avail tokens
+ let root = "5CqgQkrDcdg5QrtuxT3H7WszrqgrBMhdwRbmMVXQzc4VSiEg"; // Alice
+ let nominator = "5CqgQkrDcdg5QrtuxT3H7WszrqgrBMhdwRbmMVXQzc4VSiEg"; // Alice
+ let bouncer = "5CqgQkrDcdg5QrtuxT3H7WszrqgrBMhdwRbmMVXQzc4VSiEg"; // Alice
+
+ let wait_for = WaitFor::BlockInclusion;
+ let options = Options::new().nonce(Nonce::BestBlockAndTxPool);
+ let result = sdk
+ .tx
+ .nomination_pools
+ .create(
+ amount,
+ root,
+ nominator,
+ bouncer,
+ wait_for,
+ &account,
+ Some(options),
+ )
+ .await?;
+
+ dbg!(result);
+
+ Ok(())
}
```
2. Run the code using:
-```bash filename="terminal" name="cmd4"
+```bash
cargo run
```
-
+Sample Response:
-```rust showLineNumbers filename="avail-rust" name="cmd3"
+```rust showLineNumbers filename="avail-rust"
PoolCreateTxSuccess {
event: Created {
depositor: AccountId32(...),
@@ -277,100 +202,4 @@ PoolCreateTxSuccess {
-
-
-1. Inside `main.go`, add the following code:
-
-```go showLineNumbers filename="avail-go" name="cmd5"
-package main
-
-import (
- "fmt"
- "log"
- "os"
-
- "github.com/availproject/avail-go-sdk/metadata"
- "github.com/availproject/avail-go-sdk/primitives"
- SDK "github.com/availproject/avail-go-sdk/sdk"
- "github.com/joho/godotenv"
-)
-
-func main() {
- // Load environment variables from .env file
- err := godotenv.Load()
- if err != nil {
- log.Fatal("Error loading .env file")
- }
-
- // Make sure the SEED environment variable is set
- seed := os.Getenv("SEED")
- if seed == "" {
- log.Fatal("SEED environment variable is not set")
- }
-
- // Create an account from the SEED environment variable
- acc, err := SDK.Account.NewKeyPair(seed)
- if err != nil {
- log.Fatalf("Failed to create account: %v", err)
- }
- fmt.Println("Your account Address: " + acc.SS58Address(42))
-
- // Initialize an SDK instance
- sdk, err := SDK.NewSDK("https://turing-rpc.avail.so/rpc")
- if err != nil {
- log.Fatalf("Failed to initialize SDK: %v", err)
- }
-
- // Set the amount and addresses
- amount, err := metadata.NewBalanceFromString("1000000000000000000000000") // Example amount
- if err != nil {
- log.Fatalf("Failed to create balance: %v", err)
- }
-
- rootAddress, err := primitives.NewAccountIdFromAddress("5DqMavSQikX9eMzwHKiC8xS6VWB2yCd5gGQuQq7KheM2Mgc7")
- if err != nil {
- log.Fatalf("Failed to convert root address: %v", err)
- }
- nominatorAddress, err := primitives.NewAccountIdFromAddress("5FphMk7DhSdq7jXsQCVQthw7XTiCWxdA9ZS6V43rKeJzvya9")
- if err != nil {
- log.Fatalf("Failed to convert nominator address: %v", err)
- }
- bouncerAddress, err := primitives.NewAccountIdFromAddress("5G9fM7DhSdq7jXsQCVQthw7XTiCWxdA9ZS6V43rKeJzvya9")
- if err != nil {
- log.Fatalf("Failed to convert bouncer address: %v", err)
- }
-
- // Convert addresses to MultiAddress
- root := rootAddress.ToMultiAddress()
- nominator := nominatorAddress.ToMultiAddress()
- bouncer := bouncerAddress.ToMultiAddress()
-
- // Create the Create transaction
- tx := sdk.Tx.NominationPools.Create(amount, root, nominator, bouncer)
-
- // Execute the transaction
- res, err := tx.ExecuteAndWatchInclusion(acc, SDK.NewTransactionOptions())
- if err != nil {
- log.Fatalf("Transaction failed: %v", err)
- }
-
- // Check if the transaction was successful
- if !res.IsSuccessful().UnsafeUnwrap() {
- log.Fatal("Transaction was not successful")
- }
-
- fmt.Println("Create transaction successful")
- fmt.Printf("Block Hash: %v, Block Number: %v, Tx Hash: %v, Tx Index: %v\n", res.BlockHash.ToHexWith0x(), res.BlockNumber, res.TxHash.ToHexWith0x(), res.TxIndex)
-}
-```
-
-2. Run the code using:
-
-```bash filename="terminal" name="cmd6"
-go run main.go
-```
-
-
-
-
diff --git a/app/api-reference/avail-node-api/nomination-pools-join/page.mdx b/app/api-reference/avail-node-api/nomination-pools-join/page.mdx
index 9330867e7..36466292a 100644
--- a/app/api-reference/avail-node-api/nomination-pools-join/page.mdx
+++ b/app/api-reference/avail-node-api/nomination-pools-join/page.mdx
@@ -1,7 +1,3 @@
----
-image: '/img/docs-link-preview.png'
----
-
import { Callout, Steps, Tabs } from 'nextra/components'
# Join a nomination pool
@@ -10,7 +6,7 @@ On-chain name of method: `nominationPools_join`
## Parameters
-
+
| parameter | type | optional | description |
@@ -32,16 +28,6 @@ On-chain name of method: `nominationPools_join`
| options | Options | true | transaction parameters |
-
-| parameter | type | optional | description |
-| --------- | ----------- | -------- | ----------------------------------------------- |
-| amount | u128 | false | The amount of funds to delegate to the pool |
-| pool id | u32 | false | pool id |
-| waitFor | WaitFor | false | wait for block inclusion or finalization |
-| account | KeyringPair | false | account that will send and sign the transaction |
-| options | Options | true | transaction parameters |
-
-
## Returns
@@ -59,84 +45,44 @@ For instructions, [check out our docs here](/api-reference/avail-node-api#settin
The rest of the code should work as is.
-
-1. The minimum amount of `AVAIL` required to join a nomination pool is `100 AVAIL`.
-2. Enter the `poolId` carefully.
-
-
-
+
1. Inside `your-file-name.ts`, add the following code:
```javascript showLineNumbers filename="avail-js"
-import * as dotenv from 'dotenv';
-import { Account, SDK, BN, Pallets } from 'avail-js-sdk';
+import { SDK, WaitFor, Keyring, BN } from "avail-js-sdk"
-dotenv.config();
+const main = async () => {
+ const providerEndpoint = "wss://turing-rpc.avail.so/ws";
+ const sdk = await SDK.New(providerEndpoint);
-export async function nominationPoolsJoin() {
- // Initialize SDK with Turing endpoint
- const sdk = await SDK.New('wss://turing-rpc.avail.so/ws');
-
- // Create account from seed in .env file
- const seed = process.env.SEED;
- if (!seed) {
- throw new Error("SEED environment variable is not set");
- }
-
- // Create account from seed
- const account = Account.new(seed);
- console.log("Account Address: ", account.address);
-
- // Join amount: 1,000 AVAIL
- const amount = new BN(10).pow(new BN(18)).mul(new BN(1000)); // 1,000 AVAIL
- console.log("Join Amount: 1,000 AVAIL");
-
- // Pool ID to join
- // Replace with the actual pool ID you want to join
- const poolId = 1;
- console.log(`Joining Pool ID: ${poolId}`);
-
- // Create join transaction
- const tx = sdk.tx.nominationPools.join(amount, poolId);
- console.log("Submitting join transaction...");
-
- // Execute and wait for inclusion
- const res = await tx.executeWaitForInclusion(account, {});
-
- // Check if transaction was successful
- const isOk = res.isSuccessful();
- if (isOk === undefined) {
- throw new Error("Cannot check if transaction was successful");
- }
- else if (!isOk) {
- throw new Error("Transaction failed");
- }
-
- console.log("Pool join operation completed successfully");
- // Log all transaction details
- console.log("\nTransaction Details:");
- console.log(`Transaction Hash: ${res.txHash}`);
- console.log(`Block Hash: ${res.blockHash}`);
- console.log(`Block Number: ${res.blockNumber}`);
-
- process.exit(0);
-}
+ const Alice = 'This is a random seed phrase please replace with your own';
+ const account = new Keyring({ type: "sr25519" }).addFromUri(Alice);
+ const amount = new BN(10).pow(new BN(18)).mul(new BN(10000)) // 10_000 Avail
+ const poolId = 1
-// Execute the function
-nominationPoolsJoin();
+ const result = await sdk.tx.nominationPools.join(amount, poolId, WaitFor.BlockInclusion, account)
+ if (result.isErr) {
+ console.log(result.reason)
+ process.exit(1)
+ }
+
+ console.log(JSON.stringify(result, null, 4))
+ process.exit()
+}
+main()
```
2. Run the code using:
-```bash filename="terminal" name="cmd2"
+```bash
ts-node your-file-name.ts
```
-
+Sample Response:
```js
{
@@ -161,56 +107,44 @@ ts-node your-file-name.ts
1. Inside `main.rs`, add the following code:
-```rust showLineNumbers filename="avail-rust" name="cmd3"
-use dotenvy::dotenv;
-use std::env;
-use avail_rust::prelude::*;
-
-pub async fn nomination_pools_join() -> Result<(), ClientError> {
-
- // Create a new SDK instance
- let sdk = SDK::new("wss://turing-rpc.avail.so/ws").await?;
-
- // Loading seed phrase and creating an account derived from the seed
- dotenv().ok();
- let seed = env::var("SEED").expect("SEED environment variable is not set");
- let account = account::from_secret_uri(&seed)?;
-
- //Setting the amount to bond and the pool id
- let amount = 1_00_000_000_000_000_000_000_000u128; // 1_000_00 Avail tokens
- let pool_id = 1;
-
- //Executing the transaction
- let tx = sdk.tx.nomination_pools.join(amount, pool_id);
- let res = tx.execute_and_watch_inclusion(&account, Options::new()).await?;
- assert_eq!(res.is_successful(), Some(true));
-
- println!(
- "Block Hash: {:?}, Block Number: {}, Tx Hash: {:?}, Tx Index: {}",
- res.block_hash, res.block_number, res.tx_hash, res.tx_index
- );
-
- Ok(())
-}
-
+```rust showLineNumbers filename="avail-rust" showLineNumbers filename="avail-rust"
+use avail_rust::{Keypair, Nonce, Options, SecretUri, WaitFor, SDK};
+use core::str::FromStr;
+
#[tokio::main]
-async fn main() {
- if let Err(e) = nomination_pools_join().await {
- eprintln!("Error: {:?}", e);
- }
+async fn main() -> Result<(), String> {
+ let sdk = SDK::new("wss://turing-rpc.avail.so/ws").await.unwrap();
+
+ let alice = "This is a random seed phrase please replace with your own";
+ let secret_uri = SecretUri::from_str(alice).unwrap();
+ let account = Keypair::from_uri(&secret_uri).unwrap();
+ let amount = 1_000_000_000_000_000_000_000_000u128; // 1_000_000 Avail tokens
+ let pool_id = 1;
+
+ let wait_for = WaitFor::BlockInclusion;
+ let options = Options::new().nonce(Nonce::BestBlockAndTxPool);
+ let result = sdk
+ .tx
+ .nomination_pools
+ .join(amount, pool_id, wait_for, &account, Some(options))
+ .await?;
+
+ dbg!(result);
+
+ Ok(())
}
```
2. Run the code using:
-```bash filename="terminal" name="cmd4"
+```bash
cargo run
```
-
+Sample Response:
-```rust showLineNumbers filename="avail-rust" name="cmd3"
+```rust showLineNumbers filename="avail-rust"
PoolJoinTxSuccess {
event: Bonded {
member: AccountId32(...),
@@ -236,83 +170,4 @@ PoolJoinTxSuccess {
-
-
-1. Inside `main.go`, add the following code:
-
-```go showLineNumbers filename="avail-go" name="cmd5"
-package main
-
-import (
- "fmt"
- "log"
- "os"
-
- "github.com/availproject/avail-go-sdk/metadata"
- SDK "github.com/availproject/avail-go-sdk/sdk"
- "github.com/joho/godotenv"
-)
-
-func main() {
- // Load environment variables from .env file
- err := godotenv.Load()
- if err != nil {
- log.Fatal("Error loading .env file")
- }
-
- // Make sure the SEED environment variable is set
- seed := os.Getenv("SEED")
- if seed == "" {
- log.Fatal("SEED environment variable is not set")
- }
-
- // Create an account from the SEED environment variable
- acc, err := SDK.Account.NewKeyPair(seed)
- if err != nil {
- log.Fatalf("Failed to create account: %v", err)
- }
- fmt.Println("Your account Address: " + acc.SS58Address(42))
-
- // Initialize an SDK instance
- sdk, err := SDK.NewSDK("https://turing-rpc.avail.so/rpc")
- if err != nil {
- log.Fatalf("Failed to initialize SDK: %v", err)
- }
-
- // Set the amount to bond and the pool ID
- // 1_000_00 Avail tokens
- amount, err := metadata.NewBalanceFromString("1000000000000000000000000")
- if err != nil {
- log.Fatalf("Failed to create balance: %v", err)
- }
- poolId := uint32(1)
-
- // Create the join transaction
- tx := sdk.Tx.NominationPools.Join(amount, poolId)
-
- // Execute the transaction
- res, err := tx.ExecuteAndWatchInclusion(acc, SDK.NewTransactionOptions())
- if err != nil {
- log.Fatalf("Transaction failed: %v", err)
- }
-
- // Check if the transaction was successful
- if !res.IsSuccessful().UnsafeUnwrap() {
- log.Fatal("Transaction was not successful")
- }
-
- fmt.Println("Join transaction successful")
- fmt.Printf("Block Hash: %v, Block Number: %v, Tx Hash: %v, Tx Index: %v\n", res.BlockHash.ToHexWith0x(), res.BlockNumber, res.TxHash.ToHexWith0x(), res.TxIndex)
-}
-```
-
-2. Run the code using:
-
-```bash filename="terminal" name="cmd6"
-go run main.go
-```
-
-
-
-
-
+
\ No newline at end of file
diff --git a/app/api-reference/avail-node-api/nomination-pools-nominate/page.mdx b/app/api-reference/avail-node-api/nomination-pools-nominate/page.mdx
index 6f3004915..d226e779c 100644
--- a/app/api-reference/avail-node-api/nomination-pools-nominate/page.mdx
+++ b/app/api-reference/avail-node-api/nomination-pools-nominate/page.mdx
@@ -1,7 +1,3 @@
----
-image: '/img/docs-link-preview.png'
----
-
import { Callout, Steps, Tabs } from 'nextra/components'
# Nominate validator(s) for your nomination pool
@@ -10,7 +6,7 @@ On-chain name of method: `nominationPools_nominate`
## Parameters
-
+
| parameter | type | optional | description |
@@ -31,15 +27,6 @@ On-chain name of method: `nominationPools_nominate`
| options | Options | true | transaction parameters |
-
-| parameter | type | optional | description |
-| --------- | ----------- | -------- | ----------------------------------------------- |
-| targets | &[String] | false | list of validator addresses to nominate |
-| waitFor | WaitFor | false | wait for block inclusion or finalization |
-| account | KeyringPair | false | account that will send and sign the transaction |
-| options | Options | true | transaction parameters |
-
-
## Returns
@@ -63,74 +50,40 @@ The rest of the code should work as is.
1. Inside `your-file-name.ts`, add the following code:
```javascript showLineNumbers filename="avail-js"
-import * as dotenv from 'dotenv';
-import { Account, SDK, Pallets } from 'avail-js-sdk';
+import { SDK, WaitFor, Keyring } from "avail-js-sdk"
-dotenv.config();
-
-export async function nominationPoolsNominate() {
- // Initialize SDK with Turing endpoint
- const sdk = await SDK.New('wss://turing-rpc.avail.so/ws');
-
- // Create account from seed in .env file
- const seed = process.env.SEED;
- if (!seed) {
- throw new Error("SEED environment variable is not set");
- }
-
- // Create account from seed
- const account = Account.new(seed);
- console.log("Account Address: ", account.address);
-
- // Pool ID to nominate from
- const poolId = 1;
- console.log(`Pool ID: ${poolId}`);
-
- // Validator targets to nominate
- const validators = [
- "5GNJqTPyNqANBkUVMN1LPPrxXnFouWXoe2wNSmmEoLctxiZY", // Alice Stash
- "5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty", // Bob
- ];
-
- // Create nominate transaction
- const tx = sdk.tx.nominationPools.nominate(poolId, validators);
- console.log("Submitting pool nomination transaction...");
-
- // Execute and wait for inclusion
- const res = await tx.executeWaitForInclusion(account, {});
-
- // Check if transaction was successful
- const isOk = res.isSuccessful();
- if (isOk === undefined) {
- throw new Error("Cannot check if transaction was successful");
- }
- else if (!isOk) {
- throw new Error("Transaction failed");
- }
-
- console.log("\nPool nomination completed successfully");
-
- // Log all transaction details
- console.log("\nTransaction Details:");
- console.log(`Transaction Hash: ${res.txHash}`);
- console.log(`Block Hash: ${res.blockHash}`);
- console.log(`Block Number: ${res.blockNumber}`);
-
- process.exit(0);
+const main = async () => {
+ const providerEndpoint = "wss://turing-rpc.avail.so/ws";
+ const sdk = await SDK.New(providerEndpoint);
+
+ const Alice = 'This is a random seed phrase please replace with your own';
+ const account = new Keyring({ type: "sr25519" }).addFromUri(Alice);
+ const validators: string[] = [
+ "5GNJqTPyNqANBkUVMN1LPPrxXnFouWXoe2wNSmmEoLctxiZY",
+ "5DAAnrj7VHTznn2AWBemMuyBwZWs6FNFjdyVXUeYum3PTXFy",
+ ]
+ const poolId = 1
+
+ const result = await sdk.tx.nominationPools.nominate(poolId, validators, WaitFor.BlockInclusion, account)
+ if (result.isErr) {
+ console.log(result.reason)
+ process.exit(1)
+ }
+
+ console.log(JSON.stringify(result, null, 4))
+ process.exit()
}
-
-// Execute the function
-nominationPoolsNominate();
+main()
```
2. Run the code using:
-```bash filename="terminal" name="cmd2"
+```bash
ts-node your-file-name.ts
```
-
+Sample Response:
```js
{
@@ -149,57 +102,46 @@ ts-node your-file-name.ts
1. Inside `main.rs`, add the following code:
-```rust showLineNumbers filename="avail-rust" name="cmd3"
-use dotenvy::dotenv;
-use std::env;
-use avail_rust::prelude::*;
+```rust showLineNumbers filename="avail-rust" showLineNumbers filename="avail-rust"
+use avail_rust::{Keypair, Nonce, Options, SecretUri, WaitFor, SDK};
use core::str::FromStr;
-
-pub async fn nomination_pools_nominate() -> Result<(), ClientError> {
-
- // Create a new SDK instance
- let sdk = SDK::new("wss://turing-rpc.avail.so/ws").await?;
-
- // Loading seed phrase and creating an account derived from the seed
- dotenv().ok();
- let seed = env::var("SEED").expect("SEED environment variable is not set");
- let account = account::from_secret_uri(&seed)?;
-
- //Setting the pool id and the validators to nominate
- let pool_id = 1; // Use your pool id here
-
- //Setting an array of validators to nominate
- let validators = [
- AccountId::from_str("5DqMavSQikX9eMzwHKiC8xS6VWB2yCd5gGQuQq7KheM2Mgc7").expect("Invalid account ID"),
- AccountId::from_str("5FphMk7DhSdq7jXsQCVQthw7XTiCWxdA9ZS6V43rKeJzvya9").expect("Invalid account ID"),
- ];
-
- //Executing the transaction
- let tx = sdk.tx.nomination_pools.nominate(pool_id, validators.to_vec());
- let res = tx.execute_and_watch_inclusion(&account, Options::new()).await?;
- assert_eq!(res.is_successful(), Some(true));
-
- Ok(())
-}
-
+
#[tokio::main]
-async fn main() {
- if let Err(e) = nomination_pools_nominate().await {
- eprintln!("Error: {:?}", e);
- }
+async fn main() -> Result<(), String> {
+ let sdk = SDK::new("wss://turing-rpc.avail.so/ws").await.unwrap();
+
+ let alice = "This is a random seed phrase please replace with your own";
+ let secret_uri = SecretUri::from_str(alice).unwrap();
+ let account = Keypair::from_uri(&secret_uri).unwrap();
+ let targets = [
+ String::from("5GNJqTPyNqANBkUVMN1LPPrxXnFouWXoe2wNSmmEoLctxiZY"), // Alice Stash
+ String::from("5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty"), // Bob;
+ ];
+
+ let wait_for = WaitFor::BlockInclusion;
+ let options = Options::new().nonce(Nonce::BestBlockAndTxPool);
+ let result = sdk
+ .tx
+ .staking
+ .nominate(&targets, wait_for, &account, Some(options))
+ .await?;
+
+ dbg!(result);
+
+ Ok(())
}
```
2. Run the code using:
-```bash filename="terminal" name="cmd4"
+```bash
cargo run
```
-
+Sample Response:
-```rust showLineNumbers filename="avail-rust" name="cmd3"
+```rust showLineNumbers filename="avail-rust"
NominateTxSuccess {
events: ExtrinsicEvents {
ext_hash: 0x6e0ae6fde353974f8b46aace441c49ba7ab135fa3743e0e1331d35c4528dacfb,
@@ -225,87 +167,4 @@ NominateTxSuccess {
-
-
-1. Inside `main.go`, add the following code:
-
-```go showLineNumbers filename="avail-go" name="cmd5"
-package main
-
-import (
- "fmt"
- "log"
- "os"
-
- "github.com/availproject/avail-go-sdk/primitives"
- SDK "github.com/availproject/avail-go-sdk/sdk"
- "github.com/joho/godotenv"
-)
-
-func main() {
- // Load environment variables from .env file
- err := godotenv.Load()
- if err != nil {
- log.Fatal("Error loading .env file")
- }
-
- // Make sure the SEED environment variable is set
- seed := os.Getenv("SEED")
- if seed == "" {
- log.Fatal("SEED environment variable is not set")
- }
-
- // Create an account from the SEED environment variable
- acc, err := SDK.Account.NewKeyPair(seed)
- if err != nil {
- log.Fatalf("Failed to create account: %v", err)
- }
- fmt.Println("Your account Address: " + acc.SS58Address(42))
-
- // Initialize an SDK instance
- sdk, err := SDK.NewSDK("https://turing-rpc.avail.so/rpc")
- if err != nil {
- log.Fatalf("Failed to initialize SDK: %v", err)
- }
-
- // Set the pool ID and validators
- poolId := uint32(1)
- validator1, err := primitives.NewAccountIdFromAddress("5DqMavSQikX9eMzwHKiC8xS6VWB2yCd5gGQuQq7KheM2Mgc7")
- if err != nil {
- log.Fatalf("Failed to convert validator1 address: %v", err)
- }
- validator2, err := primitives.NewAccountIdFromAddress("5FphMk7DhSdq7jXsQCVQthw7XTiCWxdA9ZS6V43rKeJzvya9")
- if err != nil {
- log.Fatalf("Failed to convert validator2 address: %v", err)
- }
- validators := []primitives.AccountId{validator1, validator2}
-
- // Create the nominate transaction
- tx := sdk.Tx.NominationPools.Nominate(poolId, validators)
-
- // Execute the transaction
- res, err := tx.ExecuteAndWatchInclusion(acc, SDK.NewTransactionOptions())
- if err != nil {
- log.Fatalf("Transaction failed: %v", err)
- }
-
- // Check if the transaction was successful
- if !res.IsSuccessful().UnsafeUnwrap() {
- log.Fatal("Transaction was not successful")
- }
-
- fmt.Println("Nominate transaction successful")
- fmt.Printf("Block Hash: %v, Block Number: %v, Tx Hash: %v, Tx Index: %v\n", res.BlockHash.ToHexWith0x(), res.BlockNumber, res.TxHash.ToHexWith0x(), res.TxIndex)
-}
-```
-
-2. Run the code using:
-
-```bash filename="terminal" name="cmd6"
-go run main.go
-```
-
-
-
-
-
+
\ No newline at end of file
diff --git a/app/api-reference/avail-node-api/page.mdx b/app/api-reference/avail-node-api/page.mdx
index ec627a5bb..d900526a7 100644
--- a/app/api-reference/avail-node-api/page.mdx
+++ b/app/api-reference/avail-node-api/page.mdx
@@ -1,5 +1,4 @@
---
-image: "/img/docs-link-preview.png"
title: Avail Node API reference
asIndexPage: true
---
@@ -23,76 +22,40 @@ to eventually be an exhaustive resource for the Avail node API.
-1. Make sure `Node-js` is installed on your system by running the following command in your terminal:
+1. Make sure `Node-js` is installed on your system. You can refer to [Node-js docs](https://nodejs.org/en/download/package-manager) for the same.
-```bash filename="terminal" name="cmd1"
-node --version
-```
-If not installed, you can refer to [Node-js docs](https://nodejs.org/en/download/package-manager) for the same.
-
-2. Create a new Node-js project by running the following command in a directory of your choice:
-
-```bash filename="terminal" name="cmd2"
-pnpm init
-```
+2. Create a new Node-js project by running `npm init -y` in a directory of your choice, and create a new file named `your-file-name.ts`
-3. To install the `avail-js-sdk` run the following command:
+3. To install the `avail-js-sdk` run the following command in the terminal:
-```bash filename="terminal" name="cmd3"
-pnpm add avail-js-sdk@0.4.1
+```bash
+npm install avail-js-sdk@0.3.0
```
4. Make sure to install the `ts-node` package if you haven't already:
-```bash filename="terminal" name="cmd4"
-pnpm add -g ts-node
+```bash
+npm i -g ts-node
```
-5. Create a `tsconfig.json` file in the root of your project by running:
-
-```bash filename="terminal" name="cmd5"
-touch tsconfig.json
-```
+5. Create a `tsconfig.json` file in the root of your project and populate it:
-6. Populate your `tsconfig.json` with the following configuration:
-
-```json showLineNumbers filename="tsconfig.json" name="cmd6"
+```json showLineNumbers filename="tsconfig.json"
{
- "compilerOptions": {
- "target": "es2016",
- "module": "commonjs",
- "outDir": "build",
- "declaration": true,
- "esModuleInterop": true,
- "forceConsistentCasingInFileNames": true,
- "strict": true,
- "skipLibCheck": true,
- "noUnusedParameters": true
- },
- "include": ["**/*.ts", "**/*.js"],
- "exclude": ["node_modules", "build"]
-}
+ "compilerOptions": {
+ "target": "es2016",
+ "module": "commonjs",
+ "outDir": "build",
+ "declaration": true,
+ "esModuleInterop": true,
+ "forceConsistentCasingInFileNames": true,
+ "strict": true,
+ "skipLibCheck": true,
+ "noUnusedParameters": true
+ },
+ "exclude": ["node_modules", "build"]
+}
```
-
-7. Create a `.env` file in the root of your project by running:
-
-```bash filename="terminal" name="cmd7"
-pnpm add dotenv && touch .env
-```
-
-8. Put in the Seed Phrase of the account you want to use into the `.env` file:
-
-```env showLineNumbers filename=".env" name="cmd8"
-SEED="This is a random seed phrase please replace with your own"
-```
-
-
-**IMPORTANT**
-1. Please be **VERY CAREFUL** with your seed phrase.
-2. Make sure to add your `.env` file to your `.gitignore` so that it doesn't get pushed anywhere.
-3. While it is good enough to use an `env` file while testing, try to use better practices while deploying to production.
-
-
@@ -119,15 +82,11 @@ You can use the [networks page](/docs/networks) to find endpoints for mainnet if
1. Make sure `rust` and cargo are installed on your system. You can refer to [Rustlang's docs](https://www.rust-lang.org/tools/install) for the same.
-2. Create a new Rust project by running:
-
-```bash filename="terminal" name="cmd9"
-cargo init
-```
+2. Create a new Rust project by running `cargo init your-project-name`.
3. Paste the following into your `Cargo.toml` file:
-```toml showLineNumbers filename="Cargo.toml" name="cmd10"
+```toml
[workspace]
[package]
@@ -135,95 +94,45 @@ name = "your-project-name"
edition = "2021"
[dependencies]
-# Use avail-rust v0.1.9 from the `avail-rust` repo
-avail-rust = { git = "https://github.com/availproject/avail-rust", tag = "v0.1.9" }
-# Tokio
+avail-rust = { git = "https://github.com/availproject/avail", tag = "v2.2.5.1" }
tokio = { version = "1.38.0", features = ["full"] }
-# dotenvy
-dotenvy = "0.15.7"
-```
-
-
-**Check your rust version**
-1. Run `rustc --version` to check the version of rust installed on your system.
-2. Some features of the `avail-rust` SDK may not work with older versions of rust.
-3. You can update the Rust version on your system by running `rustup update`.
-
-
-4. Create a `.env` file in the root of your project by running the following command:
-
-```bash filename="terminal" name="cmd11"
-touch .env
-```
-
-5. Put in the Seed Phrase of the account you want to use into the `.env` file:
-
-```env showLineNumbers filename=".env" name="cmd12"
-SEED="This is a random seed phrase please replace with your own"
```
-
-
-**IMPORTANT**
-1. Please be **VERY CAREFUL** with your seed phrase.
-2. Make sure to add your `.env` file to your `.gitignore` so that it doesn't get pushed anywhere.
-3. While it is good enough to use an `env` file while testing, try to use better practices while deploying to production.
-
-
1. Make sure `go` is installed on your system by running the following command in your terminal:
-```bash filename="terminal" name="cmd13"
+```bash
go version
```
If not installed, you can refer to [Go's docs](https://golang.org/doc/install) for the same.
2. Create a new Go project by initializing a Go module in a directory of your choice. Run the following command:
-```bash filename="terminal" name="cmd14"
+```bash
go mod init your-project-name
```
3. To install the avail-go-sdk, use the following command to add it to your project:
-```bash filename="terminal" name="cmd15"
-go get github.com/availproject/avail-go-sdk@v0.2.7
+``` bash
+go get github.com/availproject/avail-go-sdk@v0.1.1
```
-4. To install the `godotenv` package, use the following command:
-
-```bash filename="terminal" name="cmd16"
-go get github.com/joho/godotenv
-```
+4. Create a `config.json` file in the root of your project and fill it up like this:
-
-**CHECK YOUR GO VERSION**
-1. Run `go version` to check the version of go installed on your system.
-2. Some features of the `avail-go-sdk` may not work with older versions of go.
-3. Refer to [Golang's docs](https://go.dev/doc/install) for any questions.
-
-
-5. Create a `.env` file in the root of your project by running the following command:
-
-```bash filename="terminal" name="cmd17"
-touch .env
-```
-
-6. Put in the Seed Phrase of the account you want to use into the `.env` file:
+```json showLineNumbers filename="config.json"
+{
+ "seed": "This is a random seed phrase please replace with your own",
+ "api_url": "wss://turing-rpc.avail.so/ws",
+ "size": 1000,
+ "app_id": 0,
+ "dest": "5H3qehpRTFiB3XwyTzYU43SpG7e8jW87vFug95fxdew76Vyi",
+ "amount": 10
+}
-```env showLineNumbers filename=".env" name="cmd18"
-SEED="This is a random seed phrase please replace with your own"
```
-
-
-**IMPORTANT**
-1. Please be **VERY CAREFUL** with your seed phrase.
-2. Make sure to add your `.env` file to your `.gitignore` so that it doesn't get pushed anywhere.
-3. While it is good enough to use an `env` file while testing, try to use better practices while deploying to production.
-
-
-
+
\ No newline at end of file
diff --git a/app/api-reference/avail-node-api/staking-active-era/page.mdx b/app/api-reference/avail-node-api/staking-active-era/page.mdx
index fe40b0858..4adaad6e6 100644
--- a/app/api-reference/avail-node-api/staking-active-era/page.mdx
+++ b/app/api-reference/avail-node-api/staking-active-era/page.mdx
@@ -1,7 +1,3 @@
----
-image: '/img/docs-link-preview.png'
----
-
import { Callout, Steps, Tabs } from 'nextra/components'
# Fetch information on the active era
@@ -10,11 +6,7 @@ On-chain name of method: `staking_activeEra`
## Parameters
-
-
-
-- None
-
+
- None
@@ -41,50 +33,31 @@ For instructions, [check out our docs here](/api-reference/avail-node-api#settin
The rest of the code should work as is.
-
+
1. Inside `your-file-name.ts`, add the following code:
-```typescript showLineNumbers filename="avail-js" name="cmd1"
-import { SDK, Pallets, BN } from "avail-js-sdk";
-
-export async function getActiveEra() {
- // Initialize SDK with Turing endpoint
- const sdk = await SDK.New("wss://turing-rpc.avail.so/ws");
-
- // Get the current block hash
- const blockHash = await sdk.client.bestBlockHash();
- console.log(`Current block hash: ${blockHash}`);
-
- // Get storage at the current block
- const storageAt = await sdk.client.storageAt(blockHash);
+```typescript showLineNumbers filename="avail-js"
+import { SDK } from "avail-js-sdk"
- // Fetch active era information
- const activeEra = await Pallets.StakingStorage.ActiveEra.fetch(storageAt);
+const main = async () => {
+ const providerEndpoint = "wss://turing-rpc.avail.so/ws"
+ const sdk = await SDK.New(providerEndpoint)
- if (!activeEra) {
- console.log("No active era found");
- process.exit(1);
- }
+ const value = await sdk.api.query.staking.activeEra()
+ console.log(value.toHuman())
- // Log all properties of activeEra
- console.log("\nAll Active Era Properties:");
- for (const [key, value] of Object.entries(activeEra)) {
- console.log(`${key}: ${value}`);
- }
-
- process.exit(0);
+ process.exit()
}
-// Execute the function
-getActiveEra();
+main()
```
2. Run the code using:
-```bash filename="terminal" name="cmd2"
+```bash
ts-node your-file-name.ts
```
@@ -94,40 +67,42 @@ ts-node your-file-name.ts
1. Inside `main.rs`, add the following code:
-```rust showLineNumbers filename="avail-rust" name="cmd3"
-use avail_rust::prelude::*;
-
-pub async fn staking_active_era() -> Result<(), ClientError> {
-
- // Create a new SDK instance
- let sdk = SDK::new("wss://turing-rpc.avail.so/ws").await?;
-
- let block_hash = sdk.client.best_block_hash().await?;
- let storage = sdk.client.storage().at(block_hash);
- let address = avail::storage().staking().active_era();
- let result = storage.fetch(&address).await?;
-
- dbg!(result);
-
- Ok(())
-}
-
+```rust showLineNumbers filename="avail-rust" showLineNumbers filename="avail-rust"
+use avail_rust::{avail, SDK};
+
#[tokio::main]
-async fn main() {
- if let Err(e) = staking_active_era().await {
- eprintln!("Error: {:?}", e);
- }
+async fn main() -> Result<(), String> {
+ let sdk = SDK::new("wss://turing-rpc.avail.so/ws").await.unwrap();
+
+ let storage_query = avail::storage().staking().active_era();
+ let best_block_hash = sdk
+ .rpc
+ .chain
+ .get_block_hash(None)
+ .await
+ .map_err(|e| e.to_string())?;
+ let result = sdk
+ .api
+ .storage()
+ .at(best_block_hash)
+ .fetch(&storage_query)
+ .await
+ .map_err(|e| e.to_string())?;
+
+ dbg!(result);
+
+ Ok(())
}
```
2. Run the code using:
-```bash filename="terminal" name="cmd4"
+```bash
cargo run
```
-
+Sample Response:
```json
result = Some(
@@ -142,58 +117,4 @@ result = Some(
-
-
-1. Inside `main.go`, add the following code:
-
-```go showLineNumbers filename="avail-go" name="cmd5"
-package main
-
-import (
- "fmt"
- "log"
-
- staPallet "github.com/availproject/avail-go-sdk/metadata/pallets/staking"
- prim "github.com/availproject/avail-go-sdk/primitives"
- SDK "github.com/availproject/avail-go-sdk/sdk"
-)
-
-func main() {
- sdk, err := SDK.NewSDK("https://turing-rpc.avail.so/rpc")
- if err != nil {
- log.Fatalf("Failed to initialize SDK: %v", err)
- }
-
- // Get the latest block hash
- latestBlockHash, err := sdk.Client.BestBlockHash()
- if err != nil {
- log.Fatalf("Failed to get latest block hash: %v", err)
- }
-
- // Initialize the block storage
- blockStorage, err := sdk.Client.StorageAt(prim.Some(latestBlockHash))
- if err != nil {
- log.Fatalf("Failed to get block storage: %v", err)
- }
-
- // Fetch the active era
- {
- storage := staPallet.StorageActiveEra{}
- val, err := storage.Fetch(&blockStorage)
- if err != nil {
- log.Fatalf("Failed to fetch active era: %v", err)
- }
-
- fmt.Println("Active Era: ", val.Unwrap())
- }
-}
-```
-
-2. Run the code using:
-
-```bash filename="terminal" name="cmd6"
-go run main.go
-```
-
-
-
+
\ No newline at end of file
diff --git a/app/api-reference/avail-node-api/staking-bond/page.mdx b/app/api-reference/avail-node-api/staking-bond/page.mdx
index e17bebc3b..54cd5a31b 100644
--- a/app/api-reference/avail-node-api/staking-bond/page.mdx
+++ b/app/api-reference/avail-node-api/staking-bond/page.mdx
@@ -1,7 +1,3 @@
----
-image: '/img/docs-link-preview.png'
----
-
import { Callout, Steps, Tabs } from 'nextra/components'
# Bond AVAIL tokens on Avail DA
@@ -63,64 +59,35 @@ The rest of the code should work as is.
1. Inside `your-file-name.ts`, add the following code:
-```typescript showLineNumbers filename="avail-js" name="cmd1"
-import * as dotenv from 'dotenv';
-import { Account, SDK, BN, Pallets } from 'avail-js-sdk';
-
-dotenv.config();
-
-export async function stakingBond() {
- // Initialize SDK with Turing endpoint
- const sdk = await SDK.New('wss://turing-rpc.avail.so/ws');
-
- // Create account from seed in .env file
- const seed = process.env.SEED;
- if (!seed) {
- throw new Error("SEED environment variable is not set");
- }
-
- // Create account from seed
- const account = Account.new(seed);
- console.log("Account Address: ", account.address);
-
- // Bond amount: 10,000 AVAIL
- const value = new BN(10_000).mul(new BN(10).pow(new BN(18)));
- console.log("Bond Amount: 10,000 AVAIL");
-
- // Reward destination
- const payee = "Staked";
- console.log("Reward Destination: ", payee);
-
- // Create bond transaction
- const tx = sdk.tx.staking.bond(value, payee);
- console.log("Submitting bond transaction...");
-
- // Execute and wait for inclusion
- const res = await tx.executeWaitForInclusion(account, {});
-
- // Check if transaction was successful
- const isOk = res.isSuccessful();
- if (isOk === undefined) {
- throw new Error("Cannot check if transaction was successful");
- }
- else if (!isOk) {
- throw new Error("Transaction failed");
- }
-
- console.log("Bond completed successfully");
- console.log(`Transaction Hash: ${res.txHash}`);
- console.log(`Block Hash: ${res.blockHash}`);
-
- process.exit(0);
-}
+```typescript showLineNumbers filename="avail-js"
+import { SDK, WaitFor, Keyring, BN } from "avail-js-sdk"
+
+const main = async () => {
+ const providerEndpoint = "wss://turing-rpc.avail.so/ws";
+ const sdk = await SDK.New(providerEndpoint)
+
+ const Alice = 'This is a random seed phrase please replace with your own';
+ const account = new Keyring({ type: "sr25519" }).addFromUri(Alice)
+ const value = new BN(100_000).mul(new BN(10).pow(new BN("18"))) // 100 000 Avail
+ const payee = "Staked"
-// Execute the function
-stakingBond();
+ const result = await sdk.tx.staking.bond(value, payee, WaitFor.BlockInclusion, account)
+ if (result.isErr) {
+ console.log(result.reason)
+ process.exit(1)
+ }
+
+ console.log("Stash=" + result.event.stash + ", Amount=" + result.event.amount)
+ console.log("TxHash=" + result.txHash + ", BlockHash=" + result.blockHash)
+
+ process.exit()
+}
+main()
```
2. Run the code using:
-```bash filename="terminal" name="cmd2"
+```bash
ts-node your-file-name.ts
```
@@ -129,55 +96,43 @@ ts-node your-file-name.ts
1. Inside `src/main.rs`, paste the following code:
-```rust showLineNumbers filename="avail-rust" name="cmd3"
-use dotenvy::dotenv;
-use std::env;
-use avail_rust::{
- prelude::*,
- transactions::staking::RewardDestination,
-};
-
-pub async fn staking_bond() -> Result<(), ClientError> {
-
- // Create a new SDK instance
- let sdk = SDK::new("wss://turing-rpc.avail.so/ws").await?;
-
- // Loading seed phrase and creating an account derived from the seed
- dotenv().ok();
- let seed = env::var("SEED").expect("SEED environment variable is not set");
- let account = account::from_secret_uri(&seed)?;
-
- //Setting amount of AVAIL to be staked
- let value = 1_000_000_000_000_000_000u128 * 1_000_000u128; // 1,000,000 AVAIL
-
- //Setting the payee to be a Validator
- let payee = RewardDestination::Staked;
-
- // Executing the transaction
- let tx = sdk.tx.staking.bond(value, payee);
- let res = tx.execute_and_watch_inclusion(&account, Options::default()).await?;
- assert_eq!(res.is_successful(), Some(true));
-
- println!(
- "Block Hash: {:?}, Block Number: {}, Tx Hash: {:?}, Tx Index: {}",
- res.block_hash, res.block_number, res.tx_hash, res.tx_index
- );
-
- Ok(())
-}
-
-
+```rust showLineNumbers filename="avail-rust"
+use avail_rust::{Keypair, RewardDestination, Nonce, Options, SecretUri, WaitFor, SDK};
+use core::str::FromStr;
+
#[tokio::main]
-async fn main() {
- if let Err(e) = staking_bond().await {
- eprintln!("Error: {:?}", e);
- }
+async fn main() -> Result<(), String> {
+ let sdk = SDK::new("wss://turing-rpc.avail.so/ws").await.unwrap();
+
+ let alice = "This is a random seed phrase please replace with your own";
+ let secret_uri = SecretUri::from_str(alice).unwrap();
+ let account = Keypair::from_uri(&secret_uri).unwrap();
+ let value = 1_000_000_000_000_000_000u128 * 100_000u128; // 100_000 Avail
+ let payee = RewardDestination::Staked;
+ let options = Options::new().nonce(Nonce::BestBlockAndTxPool);
+
+ let result = sdk
+ .tx
+ .staking
+ .bond(value, payee, WaitFor::BlockInclusion, &account, Some(options))
+ .await?;
+
+ println!(
+ "Stash={}, Amount={:?}",
+ result.event.stash, result.event.amount
+ );
+ println!(
+ "TxHash={:?}, BlockHash={:?}",
+ result.tx_hash, result.block_hash
+ );
+
+ Ok(())
}
```
2. Run the code using:
-```bash filename="terminal" name="cmd4"
+```bash
cargo run
```
@@ -186,89 +141,53 @@ cargo run
1. Inside `main.go`, paste the following code:
-```go showLineNumbers filename="avail-go" name="cmd5"
+```go showLineNumbers filename="avail-go"
package main
import (
- "fmt"
- "log"
- "os"
+ "github.com/availproject/avail-go-sdk/src/config"
+ "github.com/availproject/avail-go-sdk/src/sdk"
+ "github.com/availproject/avail-go-sdk/src/sdk/tx"
- "github.com/availproject/avail-go-sdk/metadata"
- SDK "github.com/availproject/avail-go-sdk/sdk"
- "github.com/joho/godotenv"
+ "fmt"
)
func main() {
- // Load environment variables from .env file
- err := godotenv.Load()
+ config, err := config.LoadConfig()
if err != nil {
- log.Fatal("Error loading .env file")
- }
-
- // Make sure the SEED environment variable is set
- seed := os.Getenv("SEED")
- if seed == "" {
- log.Fatal("SEED environment variable is not set")
+ fmt.Printf("cannot load config:%v", err)
}
-
- // Create an account from the SEED environment variable
- acc, err := SDK.Account.NewKeyPair(seed)
+ api, err := sdk.NewSDK(config.ApiURL)
if err != nil {
- log.Fatalf("Failed to create account: %v", err)
+ fmt.Printf("cannot create api:%v", err)
}
- fmt.Println("Your account Address: " + acc.SS58Address(42))
+ WaitFor := sdk.BlockInclusion
+ Payee := sdk.Staked
- // Initialize an SDK instance
- sdk, err := SDK.NewSDK("https://turing-rpc.avail.so/rpc")
- if err != nil {
- log.Fatalf("Failed to initialize SDK: %v", err)
- }
+ bondAmount := int64(1000)
- // Create a Balance from a string
- // The value here is 1000 AVAIL
- amount, err := metadata.NewBalanceFromString("1000000000000000000000")
+ BlockHash, txHash, err := tx.Bond(api, config.Seed, WaitFor, bondAmount, sdk.Payee(Payee))
if err != nil {
- log.Fatalf("Failed to create balance: %v", err)
+ fmt.Printf("cannot submit Transaction:%v", err)
}
-
- // Create a RewardDestination
- payee := metadata.RewardDestination{VariantIndex: 0}
-
- // Call the `Bond` function
- tx := sdk.Tx.Staking.Bond(amount, payee)
-
- // Execute the transaction
- res, err := tx.ExecuteAndWatchInclusion(acc, SDK.NewTransactionOptions())
- if err != nil {
- log.Fatalf("Transaction failed: %v", err)
- }
-
- // Check if the transaction was successful
- if !res.IsSuccessful().UnsafeUnwrap() {
- log.Fatal("Transaction was not successful")
- }
-
- fmt.Println("Transaction successful")
-
- // Printing out all the values of the transaction
- fmt.Println(fmt.Sprintf(`Block Hash: %v, Block Index: %v, Tx Hash: %v, Tx Index: %v`, res.BlockHash.ToHexWith0x(), res.BlockNumber, res.TxHash.ToHexWith0x(), res.TxIndex))
+ fmt.Printf("Transaction submitted successfully with block hash: %v\n and ext hash:%v", BlockHash.Hex(), txHash.Hex())
+ sdk.EventParser(api, BlockHash, "Bond")
}
```
2. Run the code using:
-```bash filename="terminal" name="cmd6"
+```bash
go run main.go
```
If you receive errors related to missing dependencies while trying to execute your code, run:
-```bash filename="terminal"
+```bash
go mod tidy
```
and try again.
-
+
\ No newline at end of file
diff --git a/app/api-reference/avail-node-api/staking-chill/page.mdx b/app/api-reference/avail-node-api/staking-chill/page.mdx
index f4140f9be..c7b493b5d 100644
--- a/app/api-reference/avail-node-api/staking-chill/page.mdx
+++ b/app/api-reference/avail-node-api/staking-chill/page.mdx
@@ -1,7 +1,3 @@
----
-image: '/img/docs-link-preview.png'
----
-
import { Callout, Steps, Tabs } from 'nextra/components'
# Stop validating on Avail DA
@@ -57,56 +53,33 @@ The rest of the code should work as is.
1. Inside `your-file-name.ts`, add the following code:
-```typescript showLineNumbers filename="avail-js" name="cmd1"
-import * as dotenv from 'dotenv';
-import { Account, SDK, Pallets } from 'avail-js-sdk';
-
-dotenv.config();
-
-export async function stakingChill() {
- // Initialize SDK with Turing endpoint
- const sdk = await SDK.New('wss://turing-rpc.avail.so/ws');
-
- // Create account from seed in .env file
- const seed = process.env.SEED;
- if (!seed) {
- throw new Error("SEED environment variable is not set");
- }
-
- // Create account from seed
- const account = Account.new(seed);
- console.log("Account Address: ", account.address);
-
- // Create chill transaction
- const tx = sdk.tx.staking.chill();
- console.log("Submitting chill transaction...");
-
- // Execute and wait for inclusion
- const res = await tx.executeWaitForInclusion(account, {});
-
- // Check if transaction was successful
- const isOk = res.isSuccessful();
- if (isOk === undefined) {
- throw new Error("Cannot check if transaction was successful");
- }
- else if (!isOk) {
- throw new Error("Transaction failed");
- }
-
- console.log("Chill operation completed successfully");
- console.log(`Transaction Hash: ${res.txHash}`);
- console.log(`Block Hash: ${res.blockHash}`);
-
- process.exit(0);
-}
+```typescript showLineNumbers filename="avail-js"
+import { SDK, WaitFor, Keyring, BN } from "avail-js-sdk"
+
+const main = async () => {
+ const providerEndpoint = "wss://turing-rpc.avail.so/ws";
+ const sdk = await SDK.New(providerEndpoint)
+
+ const Alice = 'This is a random seed phrase please replace with your own';
+ const account = new Keyring({ type: "sr25519" }).addFromUri(Alice)
-// Execute the function
-stakingChill();
+ const result = await sdk.tx.staking.chill(WaitFor.BlockInclusion, account)
+ if (result.isErr) {
+ console.log(result.reason)
+ process.exit(1)
+ }
+
+ console.log("Stash=" + result.event.stash)
+ console.log("TxHash=" + result.txHash + ", BlockHash=" + result.blockHash)
+
+ process.exit()
+}
+main()
```
2. Run the code using:
-```bash filename="terminal" name="cmd2"
+```bash
ts-node your-file-name.ts
```
@@ -115,44 +88,41 @@ ts-node your-file-name.ts
1. Inside `src/main.rs`, paste the following code:
-```rust showLineNumbers filename="avail-rust" name="cmd3"
-use dotenvy::dotenv;
-use std::env;
-use avail_rust::prelude::*;
-
-pub async fn staking_chill() -> Result<(), ClientError> {
-
- // Create a new SDK instance
- let sdk = SDK::new("wss://turing-rpc.avail.so/ws").await?;
-
- // Loading seed phrase and creating an account derived from the seed
- dotenv().ok();
- let seed = env::var("SEED").expect("SEED environment variable is not set");
- let account = account::from_secret_uri(&seed)?;
-
- //Executing the transaction
- let tx = sdk.tx.staking.chill();
- let res = tx.execute_and_watch_inclusion(&account, Options::new()).await?;
- assert_eq!(res.is_successful(), Some(true));
-
- println!(
- "Block Hash: {:?}, Block Number: {}, Tx Hash: {:?}, Tx Index: {}",
- res.block_hash, res.block_number, res.tx_hash, res.tx_index
- );
- Ok(())
-}
-
+```rust showLineNumbers filename="avail-rust"
+use avail_rust::{Keypair, Nonce, Options, SecretUri, WaitFor, SDK};
+use core::str::FromStr;
+
#[tokio::main]
-async fn main() {
- if let Err(e) = staking_chill().await {
- eprintln!("Error: {:?}", e);
- }
+async fn main() -> Result<(), String> {
+ let sdk = SDK::new("wss://turing-rpc.avail.so/ws").await.unwrap();
+
+ let alice = "This is a random seed phrase please replace with your own";
+ let secret_uri = SecretUri::from_str(alice).unwrap();
+ let account = Keypair::from_uri(&secret_uri).unwrap();
+ let options = Options::new().nonce(Nonce::BestBlockAndTxPool);
+
+ let result = sdk
+ .tx
+ .staking
+ .chill(WaitFor::BlockInclusion, &account, Some(options))
+ .await?;
+
+ if let Some(event) = result.event {
+ println!("Stash={}", event.stash);
+ }
+
+ println!(
+ "TxHash={:?}, BlockHash={:?}",
+ result.tx_hash, result.block_hash
+ );
+
+ Ok(())
}
```
2. Run the code using:
-```bash filename="terminal" name="cmd4"
+```bash
cargo run
```
@@ -161,78 +131,49 @@ cargo run
1. Inside `main.go`, paste the following code:
-```go showLineNumbers filename="avail-go" name="cmd5"
+```go showLineNumbers filename="avail-go"
package main
import (
- "fmt"
- "log"
- "os"
+ "github.com/availproject/avail-go-sdk/src/config"
+ "github.com/availproject/avail-go-sdk/src/sdk"
+ "github.com/availproject/avail-go-sdk/src/sdk/tx"
- SDK "github.com/availproject/avail-go-sdk/sdk"
- "github.com/joho/godotenv"
+ "fmt"
)
func main() {
- // Load environment variables from .env file
- err := godotenv.Load()
- if err != nil {
- log.Fatal("Error loading .env file")
- }
-
- // Make sure the SEED environment variable is set
- seed := os.Getenv("SEED")
- if seed == "" {
- log.Fatal("SEED environment variable is not set")
- }
-
- // Create an account from the SEED environment variable
- acc, err := SDK.Account.NewKeyPair(seed)
+ config, err := config.LoadConfig()
if err != nil {
- log.Fatalf("Failed to create account: %v", err)
+ fmt.Printf("cannot load config:%v", err)
}
- fmt.Println("Your account Address: " + acc.SS58Address(42))
-
- // Initialize an SDK instance
- sdk, err := SDK.NewSDK("https://turing-rpc.avail.so/rpc")
+ api, err := sdk.NewSDK(config.ApiURL)
if err != nil {
- log.Fatalf("Failed to initialize SDK: %v", err)
+ fmt.Printf("cannot create api:%v", err)
}
+ WaitFor := sdk.BlockInclusion
- // Create the chill transaction
- tx := sdk.Tx.Staking.Chill()
-
- // Execute the transaction
- res, err := tx.ExecuteAndWatchInclusion(acc, SDK.NewTransactionOptions())
+ BlockHash, txHash, err := tx.Chill(api, config.Seed, WaitFor)
if err != nil {
- log.Fatalf("Transaction failed: %v", err)
- }
-
- // Check if the transaction was successful
- if !res.IsSuccessful().UnsafeUnwrap() {
- log.Fatal("Transaction was not successful")
+ fmt.Printf("cannot submit Transaction:%v", err)
}
-
- fmt.Println("Chill transaction successful")
-
- // Printing out all the values of the transaction
- fmt.Println(fmt.Sprintf(`Block Hash: %v, Block Index: %v, Tx Hash: %v, Tx Index: %v`, res.BlockHash.ToHexWith0x(), res.BlockNumber, res.TxHash.ToHexWith0x(), res.TxIndex))
+ fmt.Printf("Transaction submitted successfully with block hash: %v\n and ext hash:%v", BlockHash.Hex(), txHash.Hex())
}
```
2. Run the code using:
-```bash filename="terminal" name="cmd6"
+```bash
go run main.go
```
If you receive errors related to missing dependencies while trying to execute your code, run:
-```bash filename="terminal"
+```bash
go mod tidy
```
and try again.
-
+
\ No newline at end of file
diff --git a/app/api-reference/avail-node-api/staking-nominate/page.mdx b/app/api-reference/avail-node-api/staking-nominate/page.mdx
index b5de1f4b6..cb3933acb 100644
--- a/app/api-reference/avail-node-api/staking-nominate/page.mdx
+++ b/app/api-reference/avail-node-api/staking-nominate/page.mdx
@@ -1,7 +1,3 @@
----
-image: '/img/docs-link-preview.png'
----
-
import { Callout, Steps, Tabs } from 'nextra/components'
# Nominate staked AVAIL tokens to one or more validators
@@ -60,66 +56,37 @@ The rest of the code should work as is.
1. Inside `your-file-name.ts`, add the following code:
-```typescript showLineNumbers filename="avail-js" name="cmd1"
-import * as dotenv from 'dotenv';
-import { Account, SDK, Pallets } from 'avail-js-sdk';
-
-dotenv.config();
-
-export async function stakingNominate() {
- // Initialize SDK with Turing endpoint
- const sdk = await SDK.New('wss://turing-rpc.avail.so/ws');
-
- // Create account from seed in .env file
- const seed = process.env.SEED;
- if (!seed) {
- throw new Error("SEED environment variable is not set");
- }
-
- // Create account from seed
- const account = Account.new(seed);
- console.log("Account Address: ", account.address);
-
- // Validator targets to nominate
- const targets = [
- "5GNJqTPyNqANBkUVMN1LPPrxXnFouWXoe2wNSmmEoLctxiZY", // Alice Stash
- "5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty", // Bob
- ];
- console.log("Nominating validators:");
- targets.forEach((target, index) => {
- console.log(` ${index + 1}. ${target}`);
- });
-
- // Create nominate transaction
- const tx = sdk.tx.staking.nominate(targets);
- console.log("Submitting nomination transaction...");
-
- // Execute and wait for inclusion
- const res = await tx.executeWaitForInclusion(account, {});
-
- // Check if transaction was successful
- const isOk = res.isSuccessful();
- if (isOk === undefined) {
- throw new Error("Cannot check if transaction was successful");
- }
- else if (!isOk) {
- throw new Error("Transaction failed");
- }
-
- console.log("Nomination completed successfully");
- console.log(`Transaction Hash: ${res.txHash}`);
- console.log(`Block Hash: ${res.blockHash}`);
-
- process.exit(0);
-}
+```typescript showLineNumbers filename="avail-js"
+import { SDK, WaitFor, Keyring, BN } from "avail-js-sdk"
+
+const main = async () => {
+ const providerEndpoint = "wss://turing-rpc.avail.so/ws";
+ const sdk = await SDK.New(providerEndpoint)
+
+ const Alice = 'This is a random seed phrase please replace with your own';
+ const account = new Keyring({ type: "sr25519" }).addFromUri(Alice)
+ const targets = [
+ "5GNJqTPyNqANBkUVMN1LPPrxXnFouWXoe2wNSmmEoLctxiZY", // Alice Stash
+ "5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty", // Bob
+ ]
+
+ const result = await sdk.tx.staking.nominate(targets, WaitFor.BlockInclusion, account)
+ if (result.isErr) {
+ console.log(result.reason)
+ process.exit(1)
+ }
-// Execute the function
-stakingNominate();
+ console.log("TxDataTargets=" + result.txData.targets)
+ console.log("TxHash=" + result.txHash + ", BlockHash=" + result.blockHash)
+
+ process.exit()
+}
+main()
```
2. Run the code using:
-```bash filename="terminal" name="cmd2"
+```bash
ts-node your-file-name.ts
```
@@ -128,53 +95,42 @@ ts-node your-file-name.ts
1. Inside `src/main.rs`, paste the following code:
-```rust showLineNumbers filename="avail-rust" name="cmd3"
-use dotenvy::dotenv;
-use std::env;
-use avail_rust::prelude::*;
+```rust showLineNumbers filename="avail-rust"
+use avail_rust::{Keypair, Nonce, Options, SecretUri, WaitFor, SDK};
use core::str::FromStr;
-
-pub async fn staking_nominate() -> Result<(), ClientError> {
-
- // Create a new SDK instance
- let sdk = SDK::new("wss://turing-rpc.avail.so/ws").await?;
-
- // Loading seed phrase and creating an account derived from the seed
- dotenv().ok();
- let seed = env::var("SEED").expect("SEED environment variable is not set");
- let account = account::from_secret_uri(&seed)?;
-
- //Setting the Validator to be nominated, max 16 targets
- let targets = [
- AccountId::from_str("5DqMavSQikX9eMzwHKiC8xS6VWB2yCd5gGQuQq7KheM2Mgc7").expect("Invalid account ID"),
- AccountId::from_str("5FphMk7DhSdq7jXsQCVQthw7XTiCWxdA9ZS6V43rKeJzvya9").expect("Invalid account ID"),
- ];
-
- //Executing the transaction
- let tx = sdk.tx.staking.nominate(&targets);
- let res = tx.execute_and_watch_inclusion(&account, Options::default()).await?;
- assert_eq!(res.is_successful(), Some(true));
-
- println!(
- "Block Hash: {:?}, Block Number: {}, Tx Hash: {:?}, Tx Index: {}",
- res.block_hash, res.block_number, res.tx_hash, res.tx_index
- );
-
- Ok(())
-}
-
+
#[tokio::main]
-async fn main() {
- if let Err(e) = staking_nominate().await {
- eprintln!("Error: {:?}", e);
- }
+async fn main() -> Result<(), String> {
+ let sdk = SDK::new("wss://turing-rpc.avail.so/ws").await.unwrap();
+
+ let alice = "This is a random seed phrase please replace with your own";
+ let secret_uri = SecretUri::from_str(alice).unwrap();
+ let account = Keypair::from_uri(&secret_uri).unwrap();
+ let targets = [
+ String::from("5GNJqTPyNqANBkUVMN1LPPrxXnFouWXoe2wNSmmEoLctxiZY"), // Alice Stash
+ String::from("5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty"), // Bob;
+ ];
+ let options = Options::new().nonce(Nonce::BestBlockAndTxPool);
+
+ let result = sdk
+ .tx
+ .staking
+ .nominate(&targets, WaitFor::BlockInclusion, &account, Some(options))
+ .await?;
+
+ println!("TxDataTargets={:?}", result.tx_data.targets);
+ println!(
+ "TxHash={:?}, BlockHash={:?}",
+ result.tx_hash, result.block_hash
+ );
+
+ Ok(())
}
-
```
2. Run the code using:
-```bash filename="terminal" name="cmd4"
+```bash
cargo run
```
@@ -183,96 +139,50 @@ cargo run
1. Inside `main.go`, paste the following code:
-```go showLineNumbers filename="avail-go" name="cmd5"
+```go showLineNumbers filename="avail-go"
package main
import (
- "fmt"
- "log"
- "os"
+ "github.com/availproject/avail-go-sdk/src/config"
+ "github.com/availproject/avail-go-sdk/src/sdk"
+ "github.com/availproject/avail-go-sdk/src/sdk/tx"
- "github.com/availproject/avail-go-sdk/primitives"
- SDK "github.com/availproject/avail-go-sdk/sdk"
- "github.com/joho/godotenv"
+ "fmt"
)
func main() {
- // Load environment variables from .env file
- err := godotenv.Load()
+ config, err := config.LoadConfig()
if err != nil {
- log.Fatal("Error loading .env file")
+ fmt.Printf("cannot load config:%v", err)
}
-
- // Make sure the SEED environment variable is set
- seed := os.Getenv("SEED")
- if seed == "" {
- log.Fatal("SEED environment variable is not set")
- }
-
- // Create an account from the SEED environment variable
- acc, err := SDK.Account.NewKeyPair(seed)
+ api, err := sdk.NewSDK(config.ApiURL)
if err != nil {
- log.Fatalf("Failed to create account: %v", err)
+ fmt.Printf("cannot create api:%v", err)
}
- fmt.Println("Your account Address: " + acc.SS58Address(42))
+ WaitFor := sdk.BlockInclusion
- // Initialize an SDK instance
- sdk, err := SDK.NewSDK("https://turing-rpc.avail.so/rpc")
+ stash := []string{"5GNJqTPyNqANBkUVMN1LPPrxXnFouWXoe2wNSmmEoLctxiZY", "5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty"}
+ BlockHash, txHash, err := tx.Nominate(api, config.Seed, WaitFor, stash)
if err != nil {
- log.Fatalf("Failed to initialize SDK: %v", err)
+ fmt.Printf("cannot submit Transaction:%v", err)
}
-
- // Convert the addresses to AccountId
- address1, err := primitives.NewAccountIdFromAddress("5DqMavSQikX9eMzwHKiC8xS6VWB2yCd5gGQuQq7KheM2Mgc7")
- if err != nil {
- log.Fatalf("Failed to convert address1: %v", err)
- }
-
- address2, err := primitives.NewAccountIdFromAddress("5FphMk7DhSdq7jXsQCVQthw7XTiCWxdA9ZS6V43rKeJzvya9")
- if err != nil {
- log.Fatalf("Failed to convert address2: %v", err)
- }
-
- // Create an array of AccountId
- targets := []primitives.MultiAddress{
- address1.ToMultiAddress(),
- address2.ToMultiAddress(),
- }
-
- // Create the nominate transaction
- tx := sdk.Tx.Staking.Nominate(targets)
-
- // Execute the transaction
- res, err := tx.ExecuteAndWatchInclusion(acc, SDK.NewTransactionOptions())
- if err != nil {
- log.Fatalf("Transaction failed: %v", err)
- }
-
- // Check if the transaction was successful
- if !res.IsSuccessful().UnsafeUnwrap() {
- log.Fatal("Transaction was not successful")
- }
-
- fmt.Println("Nomination transaction successful")
-
- // Printing out all the values of the transaction
- fmt.Println(fmt.Sprintf(`Block Hash: %v, Block Index: %v, Tx Hash: %v, Tx Index: %v`, res.BlockHash.ToHexWith0x(), res.BlockNumber, res.TxHash.ToHexWith0x(), res.TxIndex))
+ fmt.Printf("Transaction submitted successfully with block hash: %v\n and ext hash:%v", BlockHash.Hex(), txHash.Hex())
}
```
2. Run the code using:
-```bash filename="terminal" name="cmd6"
+```bash
go run main.go
```
If you receive errors related to missing dependencies while trying to execute your code, run:
-```bash filename="terminal"
+```bash
go mod tidy
```
and try again.
-
+
\ No newline at end of file
diff --git a/app/api-reference/avail-node-api/staking-unbond/page.mdx b/app/api-reference/avail-node-api/staking-unbond/page.mdx
index 7b1f6ddc6..d40e19ab2 100644
--- a/app/api-reference/avail-node-api/staking-unbond/page.mdx
+++ b/app/api-reference/avail-node-api/staking-unbond/page.mdx
@@ -1,7 +1,3 @@
----
-image: '/img/docs-link-preview.png'
----
-
import { Callout, Steps, Tabs } from 'nextra/components'
# Unbond AVAIL tokens from Avail DA
@@ -61,60 +57,34 @@ The rest of the code should work as is.
1. Inside `your-file-name.ts`, add the following code:
-```typescript showLineNumbers filename="avail-js" name="cmd1"
-import * as dotenv from 'dotenv';
-import { Account, SDK, BN, Pallets } from 'avail-js-sdk';
-
-dotenv.config();
-
-export async function stakingUnbond() {
- // Initialize SDK with Turing endpoint
- const sdk = await SDK.New('wss://turing-rpc.avail.so/ws');
-
- // Create account from seed in .env file
- const seed = process.env.SEED;
- if (!seed) {
- throw new Error("SEED environment variable is not set");
- }
-
- // Create account from seed
- const account = Account.new(seed);
- console.log("Account Address: ", account.address);
-
- // Unbond amount: 1 AVAIL
- const value = new BN(10).pow(new BN(18)); // 1 AVAIL
- console.log("Unbond Amount: 1 AVAIL");
-
- // Create unbond transaction
- const tx = sdk.tx.staking.unbond(value);
- console.log("Submitting unbond transaction...");
-
- // Execute and wait for inclusion
- const res = await tx.executeWaitForInclusion(account, {});
-
- // Check if transaction was successful
- const isOk = res.isSuccessful();
- if (isOk === undefined) {
- throw new Error("Cannot check if transaction was successful");
- }
- else if (!isOk) {
- throw new Error("Transaction failed");
- }
-
- console.log("Unbond operation completed successfully");
- console.log(`Transaction Hash: ${res.txHash}`);
- console.log(`Block Hash: ${res.blockHash}`);
-
- process.exit(0);
-}
+```typescript showLineNumbers filename="avail-js"
+import { SDK, WaitFor, Keyring, BN } from "avail-js-sdk"
+
+const main = async () => {
+ const providerEndpoint = "wss://turing-rpc.avail.so/ws";
+ const sdk = await SDK.New(providerEndpoint)
+
+ const Alice = 'This is a random seed phrase please replace with your own';
+ const account = new Keyring({ type: "sr25519" }).addFromUri(Alice)
+ const value = new BN(10).pow(new BN(18)) // one Avail
-// Execute the function
-stakingUnbond();
+ const result = await sdk.tx.staking.unbond(value, WaitFor.BlockInclusion, account)
+ if (result.isErr) {
+ console.log(result.reason)
+ process.exit(1)
+ }
+
+ console.log("Stash=" + result.event.stash + ", Amount=" + result.event.amount)
+ console.log("TxHash=" + result.txHash + ", BlockHash=" + result.blockHash)
+
+ process.exit()
+}
+main()
```
2. Run the code using:
-```bash filename="terminal" name="cmd2"
+```bash
ts-node your-file-name.ts
```
@@ -123,46 +93,42 @@ ts-node your-file-name.ts
1. Inside `src/main.rs`, paste the following code:
-```rust showLineNumbers filename="avail-rust" name="cmd3"
-use dotenvy::dotenv;
-use std::env;
-use avail_rust::prelude::*;
-
-pub async fn staking_unbond() -> Result<(), ClientError> {
-
- // Create a new SDK instance
- let sdk = SDK::new("wss://turing-rpc.avail.so/ws").await?;
-
- // Loading seed phrase and creating an account derived from the seed
- dotenv().ok();
- let seed = env::var("SEED").expect("SEED environment variable is not set");
- let account = account::from_secret_uri(&seed)?;
- let value = 1_000_000_000_000_000_000u128; // 1 AVAIL
-
- //Executing the transaction
- let tx = sdk.tx.staking.unbond(value);
- let res = tx.execute_and_watch_inclusion(&account, Options::new()).await?;
- assert_eq!(res.is_successful(), Some(true));
-
- println!(
- "Block Hash: {:?}, Block Number: {}, Tx Hash: {:?}, Tx Index: {}",
- res.block_hash, res.block_number, res.tx_hash, res.tx_index
- );
-
- Ok(())
-}
-
+```rust showLineNumbers filename="avail-rust"
+use avail_rust::{Keypair, Nonce, Options, SecretUri, WaitFor, SDK};
+use core::str::FromStr;
+
#[tokio::main]
-async fn main() {
- if let Err(e) = staking_unbond().await {
- eprintln!("Error: {:?}", e);
- }
+async fn main() -> Result<(), String> {
+ let sdk = SDK::new("wss://turing-rpc.avail.so/ws").await.unwrap();
+
+ let alice = "This is a random seed phrase please replace with your own";
+ let secret_uri = SecretUri::from_str(alice).unwrap();
+ let account = Keypair::from_uri(&secret_uri).unwrap();
+ let value = 1_000_000_000_000_000_000u128; // 1 Avail
+ let options = Options::new().nonce(Nonce::BestBlockAndTxPool);
+
+ let result = sdk
+ .tx
+ .staking
+ .unbond(value, WaitFor::BlockInclusion, &account, Some(options))
+ .await?;
+
+ println!(
+ "Stash={}, Amount={:?}",
+ result.event.stash, result.event.amount
+ );
+ println!(
+ "TxHash={:?}, BlockHash={:?}",
+ result.tx_hash, result.block_hash
+ );
+
+ Ok(())
}
```
2. Run the code using:
-```bash filename="terminal" name="cmd4"
+```bash
cargo run
```
@@ -171,85 +137,57 @@ cargo run
1. Inside `main.go`, paste the following code:
-```go showLineNumbers filename="avail-go" name="cmd5"
+```go showLineNumbers filename="avail-go"
package main
import (
- "fmt"
- "log"
- "os"
+ "math/big"
- "github.com/availproject/avail-go-sdk/metadata"
- SDK "github.com/availproject/avail-go-sdk/sdk"
- "github.com/joho/godotenv"
+ "github.com/availproject/avail-go-sdk/src/config"
+ "github.com/availproject/avail-go-sdk/src/sdk"
+ "github.com/availproject/avail-go-sdk/src/sdk/tx"
+ "github.com/availproject/avail-go-sdk/src/sdk/types"
+
+ "fmt"
)
func main() {
- // Load environment variables from .env file
- err := godotenv.Load()
- if err != nil {
- log.Fatal("Error loading .env file")
- }
-
- // Make sure the SEED environment variable is set
- seed := os.Getenv("SEED")
- if seed == "" {
- log.Fatal("SEED environment variable is not set")
- }
-
- // Create an account from the SEED environment variable
- acc, err := SDK.Account.NewKeyPair(seed)
+ config, err := config.LoadConfig()
if err != nil {
- log.Fatalf("Failed to create account: %v", err)
+ fmt.Printf("cannot load config:%v", err)
}
- fmt.Println("Your account Address: " + acc.SS58Address(42))
-
- // Initialize an SDK instance
- sdk, err := SDK.NewSDK("https://turing-rpc.avail.so/rpc")
+ api, err := sdk.NewSDK(config.ApiURL)
if err != nil {
- log.Fatalf("Failed to initialize SDK: %v", err)
+ fmt.Printf("cannot create api:%v", err)
}
+ WaitFor := sdk.BlockInclusion
- // Create a Balance from a string for the unbond amount
- unbondAmount, err := metadata.NewBalanceFromString("1000000000000000000")
- if err != nil {
- log.Fatalf("Failed to create balance: %v", err)
- }
+ bondAmount := new(big.Int)
+ bondAmount.SetString("100000000000000000000", 10)
- // Create the unbond transaction
- tx := sdk.Tx.Staking.Unbond(unbondAmount)
-
- // Execute the transaction
- res, err := tx.ExecuteAndWatchInclusion(acc, SDK.NewTransactionOptions())
+ // Convert big.Int to types.UCompact
+ bondAmountUCompact := types.NewUCompact(bondAmount)
+ BlockHash, txHash, err := tx.Unbond(api, config.Seed, WaitFor, bondAmountUCompact)
if err != nil {
- log.Fatalf("Transaction failed: %v", err)
- }
-
- // Check if the transaction was successful
- if !res.IsSuccessful().UnsafeUnwrap() {
- log.Fatal("Transaction was not successful")
+ fmt.Printf("cannot submit Transaction:%v", err)
}
-
- fmt.Println("Unbond transaction successful")
-
- // Printing out all the values of the transaction
- fmt.Println(fmt.Sprintf(`Block Hash: %v, Block Index: %v, Tx Hash: %v, Tx Index: %v`, res.BlockHash.ToHexWith0x(), res.BlockNumber, res.TxHash.ToHexWith0x(), res.TxIndex))
+ fmt.Printf("Transaction submitted successfully with block hash: %v\n and ext hash:%v", BlockHash.Hex(), txHash.Hex())
}
```
2. Run the code using:
-```bash filename="terminal" name="cmd6"
+```bash
go run main.go
```
If you receive errors related to missing dependencies while trying to execute your code, run:
-```bash filename="terminal"
+```bash
go mod tidy
```
and try again.
-
+
\ No newline at end of file
diff --git a/app/api-reference/avail-node-api/staking-validate/page.mdx b/app/api-reference/avail-node-api/staking-validate/page.mdx
index 32810882d..917d07cab 100644
--- a/app/api-reference/avail-node-api/staking-validate/page.mdx
+++ b/app/api-reference/avail-node-api/staking-validate/page.mdx
@@ -1,7 +1,3 @@
----
-image: '/img/docs-link-preview.png'
----
-
import { Callout, Steps, Tabs } from 'nextra/components'
# Become a validator on Avail DA
@@ -62,62 +58,37 @@ The rest of the code should work as is.
1. Inside `your-file-name.ts`, add the following code:
-```typescript showLineNumbers filename="avail-js" name="cmd1"
-import * as dotenv from 'dotenv';
-import { Account, SDK, Pallets } from 'avail-js-sdk';
-
-dotenv.config();
-
-export async function stakingValidate() {
- // Initialize SDK with Turing endpoint
- const sdk = await SDK.New('wss://turing-rpc.avail.so/ws');
-
- // Create account from seed in .env file
- const seed = process.env.SEED;
- if (!seed) {
- throw new Error("SEED environment variable is not set");
- }
-
- // Create account from seed
- const account = Account.new(seed);
- console.log("Account Address: ", account.address);
-
- // Validator settings
- const commission = 5; // 5%
- const blocked = false;
- console.log(`Commission: ${commission}%`);
- console.log(`Blocked: ${blocked}`);
-
- // Create validate transaction
- const tx = sdk.tx.staking.validate(commission, blocked);
- console.log("Submitting validate transaction...");
-
- // Execute and wait for inclusion
- const res = await tx.executeWaitForInclusion(account, {});
-
- // Check if transaction was successful
- const isOk = res.isSuccessful();
- if (isOk === undefined) {
- throw new Error("Cannot check if transaction was successful");
- }
- else if (!isOk) {
- throw new Error("Transaction failed");
- }
-
- console.log("Validation setup completed successfully");
- console.log(`Transaction Hash: ${res.txHash}`);
- console.log(`Block Hash: ${res.blockHash}`);
-
- process.exit(0);
-}
+```typescript showLineNumbers filename="avail-js"
+import { SDK, WaitFor, Keyring, BN } from "avail-js-sdk"
+
+const main = async () => {
+ const providerEndpoint = "wss://turing-rpc.avail.so/ws";
+ const sdk = await SDK.New(providerEndpoint)
+
+ const Alice = 'This is a random seed phrase please replace with your own';
+ const account = new Keyring({ type: "sr25519" }).addFromUri(Alice)
+ const commission = 5 // 5%
+ const blocked = false
-// Execute the function
-stakingValidate();
+ const result = await sdk.tx.staking.validate(commission, blocked, WaitFor.BlockInclusion, account)
+ if (result.isErr) {
+ console.log(result.reason)
+ process.exit(1)
+ }
+
+ console.log(
+ "Stash=" + result.event.stash + ", Commission=" + result.event.commission + ", Blocked=" + result.event.blocked,
+ )
+ console.log("TxHash=" + result.txHash + ", BlockHash=" + result.blockHash)
+
+ process.exit()
+}
+main()
```
2. Run the code using:
-```bash filename="terminal" name="cmd2"
+```bash
ts-node your-file-name.ts
```
@@ -126,49 +97,43 @@ ts-node your-file-name.ts
1. Inside `src/main.rs`, paste the following code:
-```rust showLineNumbers filename="avail-rust" name="cmd3"
-use dotenvy::dotenv;
-use std::env;
-use avail_rust::transactions::staking::Commission;
-use avail_rust::prelude::*;
-pub async fn staking_validate() -> Result<(), ClientError> {
-
- // Create a new SDK instance
- let sdk = SDK::new("wss://turing-rpc.avail.so/ws").await?;
-
- // Loading seed phrase and creating an account derived from the seed
- dotenv().ok();
- let seed = env::var("SEED").expect("SEED environment variable is not set");
- let account = account::from_secret_uri(&seed)?;
-
- //Setting your Validator's commission and blocking status
- let commission = Commission::new(5)?; // 5%
- let blocked = false; // Not blocked
-
- //Executing the transaction
- let tx = sdk.tx.staking.validate(commission, blocked);
- let res = tx.execute_and_watch_inclusion(&account, Options::new()).await?;
- assert_eq!(res.is_successful(), Some(true));
-
- println!(
- "Block Hash: {:?}, Block Number: {}, Tx Hash: {:?}, Tx Index: {}",
- res.block_hash, res.block_number, res.tx_hash, res.tx_index
- );
-
- Ok(())
-}
-
+```rust showLineNumbers filename="avail-rust"
+use avail_rust::{Keypair, Nonce, Options, SecretUri, WaitFor, SDK};
+use core::str::FromStr;
+
#[tokio::main]
-async fn main() {
- if let Err(e) = staking_validate().await {
- eprintln!("Error: {:?}", e);
- }
+async fn main() -> Result<(), String> {
+ let sdk = SDK::new("wss://turing-rpc.avail.so/ws").await.unwrap();
+
+ let alice = "This is a random seed phrase please replace with your own";
+ let secret_uri = SecretUri::from_str(alice).unwrap();
+ let account = Keypair::from_uri(&secret_uri).unwrap();
+ let commission = 100;
+ let blocked = false;
+ let options = Options::new().nonce(Nonce::BestBlockAndTxPool);
+
+ let result = sdk
+ .tx
+ .staking
+ .validate(commission, blocked, WaitFor::BlockInclusion, &account, Some(options))
+ .await?;
+
+ println!(
+ "Stash={}, Commission={:?}, Blocked={:?}",
+ result.event.stash, result.event.prefs.commission, result.event.prefs.blocked
+ );
+ println!(
+ "TxHash={:?}, BlockHash={:?}",
+ result.tx_hash, result.block_hash
+ );
+
+ Ok(())
}
```
2. Run the code using:
-```bash filename="terminal" name="cmd4"
+```bash
cargo run
```
@@ -177,81 +142,45 @@ cargo run
1. Inside `main.go`, paste the following code:
-```go showLineNumbers filename="avail-go" name="cmd5"
+```go showLineNumbers filename="avail-go"
package main
import (
"fmt"
- "log"
- "os"
- "github.com/availproject/avail-go-sdk/metadata"
- SDK "github.com/availproject/avail-go-sdk/sdk"
- "github.com/joho/godotenv"
+ "github.com/availproject/avail-go-sdk/src/config"
+ "github.com/availproject/avail-go-sdk/src/sdk"
+ "github.com/availproject/avail-go-sdk/src/sdk/tx"
)
func main() {
- // Load environment variables from .env file
- err := godotenv.Load()
+ config, err := config.LoadConfig()
if err != nil {
- log.Fatal("Error loading .env file")
+ fmt.Printf("cannot load config:%v", err)
}
-
- // Make sure the SEED environment variable is set
- seed := os.Getenv("SEED")
- if seed == "" {
- log.Fatal("SEED environment variable is not set")
- }
-
- // Create an account from the SEED environment variable
- acc, err := SDK.Account.NewKeyPair(seed)
+ api, err := sdk.NewSDK(config.ApiURL)
if err != nil {
- log.Fatalf("Failed to create account: %v", err)
- }
- fmt.Println("Your account Address: " + acc.SS58Address(42))
-
- // Initialize an SDK instance
- sdk, err := SDK.NewSDK("https://turing-rpc.avail.so/rpc")
- if err != nil {
- log.Fatalf("Failed to initialize SDK: %v", err)
- }
-
- // Set validator preferences
- prefs := metadata.ValidatorPrefs{
- Commission: metadata.NewPerbillFromU8(5), // 5% commission
- Blocked: false, // Not blocked
+ fmt.Printf("cannot create api:%v", err)
}
-
- // Create the validate transaction
- tx := sdk.Tx.Staking.Validate(prefs)
-
- // Execute the transaction
- res, err := tx.ExecuteAndWatchInclusion(acc, SDK.NewTransactionOptions())
+ WaitFor := sdk.BlockInclusion
+ commission := 5
+ BlockHash, txHash, err := tx.Validate(api, config.Seed, WaitFor, commission)
if err != nil {
- log.Fatalf("Transaction failed: %v", err)
+ fmt.Printf("cannot submit Transaction:%v", err)
}
-
- // Check if the transaction was successful
- if !res.IsSuccessful().UnsafeUnwrap() {
- log.Fatal("Transaction was not successful")
- }
-
- fmt.Println("Validation transaction successful")
-
- // Printing out all the values of the transaction
- fmt.Println(fmt.Sprintf(`Block Hash: %v, Block Index: %v, Tx Hash: %v, Tx Index: %v`, res.BlockHash.ToHexWith0x(), res.BlockNumber, res.TxHash.ToHexWith0x(), res.TxIndex))
+ fmt.Printf("Transaction submitted successfully with block hash: %v\n and ext hash:%v", BlockHash.Hex(), txHash.Hex())
}
```
2. Run the code using:
-```bash filename="terminal" name="cmd6"
+```bash
go run main.go
```
If you receive errors related to missing dependencies while trying to execute your code, run:
-```bash filename="terminal"
+```bash
go mod tidy
```
and try again.
diff --git a/app/api-reference/avail-node-api/system-account/page.mdx b/app/api-reference/avail-node-api/system-account/page.mdx
index e0e7f01a0..e32f97c07 100644
--- a/app/api-reference/avail-node-api/system-account/page.mdx
+++ b/app/api-reference/avail-node-api/system-account/page.mdx
@@ -1,5 +1,4 @@
---
-image: "/img/docs-link-preview.png"
title: Fetch balances and other information for an account
description: Query the balances and many other informational points for an account on Avail DA
---
@@ -72,50 +71,26 @@ The rest of the code should work as is.
1. Inside `your-file-name.ts`, add the following code:
-```typescript showLineNumbers filename="avail-js" name="cmd1"
-import * as dotenv from 'dotenv';
-import { SDK, Pallets } from 'avail-js-sdk';
-
-dotenv.config();
-
-export async function getAccountBalance() {
- // Initialize SDK with Turing endpoint
- const sdk = await SDK.New('wss://turing-rpc.avail.so/ws');
-
- // Address to check balance for
- const address = "5DDY2yzh8uCysYFAiRSTeQVwtZSKNF49CkQkyPH852xvrYKk";
- console.log(`Checking balance for address: ${address}`);
-
- // Get the current block hash
- const blockHash = await sdk.client.bestBlockHash();
-
- // Get storage at the current block
- const storageAt = await sdk.client.storageAt(blockHash);
-
- // Fetch account information
- const accountInfo = await Pallets.SystemStorage.Account.fetch(storageAt, address);
-
- // Format balances in AVAIL (dividing by 10^18)
- const free = accountInfo.value.accountData.free.toString();
- const reserved = accountInfo.value.accountData.reserved.toString();
- const frozen = accountInfo.value.accountData.frozen.toString();
-
- console.log("The following balances are in the smallest units, divide by 10^18 to get the balance in AVAIL");
- console.log(`Free Balance: ${free}`);
- console.log(`Reserved Balance: ${reserved}`);
- console.log(`Frozen Balance: ${frozen}`);
- console.log("Account information fetched successfully");
-
- process.exit(0);
+```typescript showLineNumbers filename="avail-js"
+import { SDK } from "avail-js-sdk"
+
+const main = async () => {
+ const providerEndpoint = "wss://turing-rpc.avail.so/ws"
+ const sdk = await SDK.New(providerEndpoint)
+
+ const key = "5DDY2yzh8uCysYFAiRSTeQVwtZSKNF49CkQkyPH852xvrYKk"
+ const value = await sdk.api.query.system.account(key)
+ console.log(value.toHuman())
+
+ process.exit()
}
-
-// Execute the function
-getAccountBalance();
+
+main()
```
2. Run the code using:
-```bash filename="terminal" name="cmd2"
+```bash
ts-node your-file-name.ts
```
@@ -124,53 +99,46 @@ ts-node your-file-name.ts
1. Inside `main.rs`, add the following code:
-```rust showLineNumbers filename="avail-rust" name="cmd3"
-use avail_rust::prelude::*;
+```rust showLineNumbers filename="avail-rust" showLineNumbers filename="avail-rust"
+use avail_rust::{avail, AccountId, SDK};
use core::str::FromStr;
-pub async fn system_account() -> Result<(), ClientError> {
-
- // Create a new SDK instance
- let sdk = SDK::new("wss://turing-rpc.avail.so/ws").await?;
-
- let account_id = AccountId::from_str("5CqgQkrDcdg5QrtuxT3H7WszrqgrBMhdwRbmMVXQzc4VSiEg").unwrap();
+#[tokio::main]
+async fn main() -> Result<(), String> {
+ let sdk = SDK::new("wss://turing-rpc.avail.so/ws").await.unwrap();
- let block_hash = sdk.client.best_block_hash().await?;
- let storage = sdk.client.storage().at(block_hash);
- let address = avail::storage().system().account(account_id);
- let result = storage.fetch(&address).await?;
+ let account_id =
+ AccountId::from_str("5DDY2yzh8uCysYFAiRSTeQVwtZSKNF49CkQkyPH852xvrYKk").unwrap(); // Alice_Stash
- if let Some(account) = result {
- println!("Consumers: {}", account.consumers);
- println!("Data: {:?}", account.data);
- println!("Nonce: {}", account.nonce);
- println!("Providers: {}", account.providers);
- println!("Sufficients: {}", account.sufficients);
- }
+ let storage_query = avail::storage().system().account(account_id);
+ let best_block_hash = sdk
+ .rpc
+ .chain
+ .get_block_hash(None)
+ .await
+ .map_err(|e| e.to_string())?;
+ let result = sdk
+ .api
+ .storage()
+ .at(best_block_hash)
+ .fetch(&storage_query)
+ .await
+ .map_err(|e| e.to_string())?;
- Ok(())
-}
+ dbg!(result);
-// Add a main function to call system_account
-#[tokio::main]
-async fn main() {
- if let Err(e) = system_account().await {
- eprintln!("Error: {:?}", e);
- }
- else {
- println!("Account information fetched successfully");
- }
+ Ok(())
}
```
2. Run the code using:
-```bash filename="terminal" name="cmd4"
+```bash
cargo run
```
-
+Sample Response:
```json
result = Some(
@@ -197,71 +165,63 @@ result = Some(
1. Inside `main.go`, add the following code:
-```go showLineNumbers filename="avail-go" name="cmd5"
+```go showLineNumbers filename="avail-go"
package main
import (
"fmt"
- "log"
- prim "github.com/availproject/avail-go-sdk/primitives"
- "github.com/availproject/avail-go-sdk/sdk"
-
- syPallet "github.com/availproject/avail-go-sdk/metadata/pallets/system"
- "github.com/availproject/avail-go-sdk/primitives"
+ "github.com/availproject/avail-go-sdk/src/sdk"
+ "github.com/centrifuge/go-substrate-rpc-client/v4/types"
+ "github.com/vedhavyas/go-subkey/v2"
)
+// The following example shows how to connect to a node and display some basic information.
func main() {
+ api, err := sdk.NewSDK("wss://turing-rpc.avail.so/ws")
- // Initialize the SDK
- sdk, err := sdk.NewSDK("https://turing-rpc.avail.so/rpc")
if err != nil {
- log.Fatalf("Failed to initialize SDK: %v", err)
+ fmt.Printf("cannot create api:%v", err)
}
- // Get the latest block hash
- latestBlockHash, err := sdk.Client.BestBlockHash()
+ meta, err := api.RPC.State.GetMetadataLatest()
if err != nil {
- log.Fatalf("Failed to get latest block hash: %v", err)
+ panic(fmt.Sprintf("cannot get metadata:%v", err))
}
- // Initialize the block storage
- blockStorage, err := sdk.Client.StorageAt(prim.Some(latestBlockHash))
- if err != nil {
- log.Fatalf("Failed to get block storage: %v", err)
- }
+ address := "5DDY2yzh8uCysYFAiRSTeQVwtZSKNF49CkQkyPH852xvrYKk"
+ _, pubKey, err := subkey.SS58Decode(address)
- // Create the account ID
- accountId, err := primitives.NewAccountIdFromAddress("5DDY2yzh8uCysYFAiRSTeQVwtZSKNF49CkQkyPH852xvrYKk")
if err != nil {
- log.Fatalf("Failed to convert address: %v", err)
+ panic(fmt.Sprintf("Failed to decode SS58 address: %v", err))
}
- // Fetch the account data
- storage := syPallet.StorageAccount{}
- val, err := storage.Fetch(&blockStorage, accountId)
+ key, err := types.CreateStorageKey(meta, "System", "Account", pubKey, nil)
if err != nil {
- log.Fatalf("Failed to fetch account: %v", err)
+ panic(fmt.Sprintf("cannot create storage key:%v", err))
}
- // Log the account data
- fmt.Println("Free Balance: ", val.Value.AccountData.Free.ToHuman())
- fmt.Println("Reserved Balance: ", val.Value.AccountData.Reserved.ToHuman())
- fmt.Println("Frozen Balance: ", val.Value.AccountData.Frozen.ToHuman())
- fmt.Println("Account information fetched successfully")
+ var accountInfo types.AccountInfo
+ ok, err := api.RPC.State.GetStorageLatest(key, &accountInfo)
+ if err != nil || !ok {
+ panic(fmt.Sprintf("cannot get latest storage:%v", err))
+ }
+ fmt.Printf("Account address: %v\n", address)
+ fmt.Printf("Account info: %v\n", accountInfo)
+ fmt.Printf("Account balance: %v\n", accountInfo.Data.Free)
}
```
2. Run the code using:
-```bash filename="terminal" name="cmd6"
+```bash
go run main.go
```
If you receive errors related to missing dependencies while trying to execute your code, run:
-```bash filename="terminal"
+```bash
go mod tidy
```
and try again.
diff --git a/app/api-reference/avail-turbo-da-api/_meta.ts b/app/api-reference/avail-turbo-da-api/_meta.ts
deleted file mode 100644
index 732cf95db..000000000
--- a/app/api-reference/avail-turbo-da-api/_meta.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-export default {
-
- "submit-raw-data": "Submit raw data to Turbo DA",
- "submit-data": "Submit JSON data to Turbo DA",
- "get-pre-image": "Fetch pre-image",
- "get-submission-info": "Fetch submission info"
-}
\ No newline at end of file
diff --git a/app/api-reference/avail-turbo-da-api/get-pre-image/page.mdx b/app/api-reference/avail-turbo-da-api/get-pre-image/page.mdx
deleted file mode 100644
index dff07662b..000000000
--- a/app/api-reference/avail-turbo-da-api/get-pre-image/page.mdx
+++ /dev/null
@@ -1,55 +0,0 @@
----
-image: '/img/docs-link-preview.png'
----
-
-import { Tabs } from 'nextra/components'
-import { Callout } from 'nextra/components'
-
-# Retrieve Pre-Image Data
-
-**NEED AN API KEY?**
-Contact our team to get an API key for accessing the Turbo DA API endpoints.
-
-
-> **Endpoint:** `GET /v1/get_pre_image`
-
-Retrieves the original data that was previously submitted to Turbo DA.
-
-## Parameters
-- `x-api-key` - Your API authentication key (required)
-- `submission_id` - The unique identifier received when data was submitted (query parameter)
-
-## Response
-- The raw binary data that was originally submitted
-
-
-
-
-```bash filename="Fetching raw data against your submission ID"
-curl -X GET 'https://staging.turbo-api.availproject.org/v1/get_pre_image?submission_id=YOUR_SUBMISSION_ID' \
--H 'x-api-key: YOUR_API_KEY'
-```
-
-
-
-
-Sample Response:
-```
-{
- "data": "Raw binary data"
-}
-```
-
-> If the submission ID is invalid, you'll receive an appropriate HTTP error code with an error message:
-
-```json
-{
- "error": "Customer Expenditure entry not found"
-}
-```
-
-
-
-This endpoint complements the `submit_raw_data` endpoint by allowing users to retrieve the original data they submitted using the submission ID they received.
-It's particularly useful for verifying that data was correctly stored or for retrieving data that was submitted by others in your organization.
-
diff --git a/app/api-reference/avail-turbo-da-api/get-submission-info/page.mdx b/app/api-reference/avail-turbo-da-api/get-submission-info/page.mdx
deleted file mode 100644
index 03a543d22..000000000
--- a/app/api-reference/avail-turbo-da-api/get-submission-info/page.mdx
+++ /dev/null
@@ -1,59 +0,0 @@
----
-image: '/img/docs-link-preview.png'
----
-
-import { Tabs } from 'nextra/components'
-import { Callout } from 'nextra/components'
-
-# Get Submission Information
-
-**NEED AN API KEY?**
-Contact our team to get an API key for accessing the Turbo DA API endpoints.
-
-
-> **Endpoint:** `GET /v1/get_submission_info`
-
-Retrieves metadata and status information about a previous data submission to Turbo DA.
-
-## Parameters
-- `x-api-key` - Your API authentication key (required)
-- `submission_id` - The unique identifier received when data was submitted (query parameter)
-
-## Response
-- Metadata about the submission including status, transaction details, and timestamps
-
-
-
-
-```bash filename="Fetching submission info against your submission ID"
-curl -X GET 'https://staging.turbo-api.availproject.org/v1/get_submission_info?submission_id=YOUR_SUBMISSION_ID' \
--H 'x-api-key: YOUR_API_KEY'
-```
-
-
-
-
-Sample Response:
-```json
-{
- "data": {
- "amount_data": "20.00 B",
- "block_hash": "0x087c21csd7cdc3d08y007eb940b0883175a20a22965e61819d533efa8d601aec1",
- "block_number": 1465348,
- "created_at": "2023-06-15T10:30:45Z",
- "data_billed": "1024",
- "data_hash": "0xc30f0eadacfc1579a2a6cee3b3154bf5df8f41ac824d555e74363b6fc55df8f8",
- "fees": "124443109311818076",
- "tx_hash": "0xff57e96bee175118f8c3779241469170b692a3d91697182af92774e594963969",
- "tx_index": 1,
- "user_id": "user@example.com"
- },
- "error": null,
- "id": "7b8f9e2a-c531-4d45-8c7a-1b2d3e4f5g6h",
- "state": "Finalized",
-}
-```
-
-> If the submission ID is invalid or not found, you'll receive an appropriate HTTP error code with an error message:
-
-
diff --git a/app/api-reference/avail-turbo-da-api/page.mdx b/app/api-reference/avail-turbo-da-api/page.mdx
deleted file mode 100644
index 271080953..000000000
--- a/app/api-reference/avail-turbo-da-api/page.mdx
+++ /dev/null
@@ -1,33 +0,0 @@
----
-image: "/img/docs-link-preview.png"
-title: Turbo DA API reference
-asIndexPage: true
----
-
-import { Callout, Tabs } from 'nextra/components'
-
-# Turbo DA API reference
-
-
-**NEED AN API KEY? OR ANY OTHER HELP TO GET STARTED?**
-Please go through [this page in our docs](/docs/build-with-avail/turbo-da) to get started with Turbo DA
-before you get started with the API.
-
-
-## Turbo DA endpoints
-
-| | **Mainnet** | **Turing Testnet** |
-| ------------------------ | ----------------------------------------------------------------------| ------------------------------------------------------------------------------------|
-| **Frontend** | [turbo.availproject.org](https://turbo.availproject.org/) | [staging.turbo.availproject.org](https://staging.turbo.availproject.org/) |
-| **API Endpoints** | [turbo-api.availproject.org](https://turbo-api.availproject.org/) | [staging.turbo-api.availproject.org](https://staging.turbo-api.availproject.org/) |
-
-## Setting up the dev environment
-
-1. To use the Turbo DA API as documented in the following pages, you just need to have `curl` installed on your system.
-You can check if it is installed by running:
-
-```bash filename="CURL"
-curl --version
-```
-
-2. If this does not work, go to [curl's website](https://curl.se/) to install it on your system.
diff --git a/app/api-reference/avail-turbo-da-api/submit-data/page.mdx b/app/api-reference/avail-turbo-da-api/submit-data/page.mdx
deleted file mode 100644
index 1fdbf2995..000000000
--- a/app/api-reference/avail-turbo-da-api/submit-data/page.mdx
+++ /dev/null
@@ -1,68 +0,0 @@
----
-image: '/img/docs-link-preview.png'
----
-
-import { Tabs } from 'nextra/components'
-import { Callout } from 'nextra/components'
-
-# Submit JSON Data to Turbo DA
-
-
-**Why does this endpoint exist?**
-
-1. The `submit_data` endpoint exists to provide a more structured interface for applications that prefer working with JSON.
-
-2. For submitting files or arbitrary binary data, use the [`submit_raw_data`](/api-reference/avail-turbo-da-api/submit-raw-data) endpoint instead.
-
-
-
-**NEED AN API KEY?**
-Contact our team to get an API key for accessing the Turbo DA API endpoints.
-
-
-> **Endpoint:** `POST /v1/submit_data`
-
-Submits string data in JSON format to Turbo DA. This endpoint is designed for applications that prefer working with structured JSON data rather than raw binary content.
-
-## Parameters
-- `x-api-key` - Your API authentication key (required)
-- `Content-Type` - Must be `application/json`
-
-## Request Body
-```json
-{
- "data": "Your string data here"
-}
-```
-
-## Response
-- **submission_id** - Unique identifier for tracking your submission
-
-
-
-
-```bash filename="Submitting JSON data"
-curl -X POST 'https://staging.turbo-api.availproject.org/v1/submit_data' \
--H 'x-api-key: YOUR_API_KEY' \
--H 'Content-Type: application/json' \
--d '{"data": "Hello Avail Network!"}'
-```
-
-
-
-
-Sample Response:
-```json
-{
- "submission_id": ""
-}
-```
-
-> If the request fails due to invalid API key or server error, you'll receive an appropriate HTTP error code with an error message:
-
-```json
-{
- "error": "Error message details"
-}
-```
-
diff --git a/app/api-reference/avail-turbo-da-api/submit-raw-data/page.mdx b/app/api-reference/avail-turbo-da-api/submit-raw-data/page.mdx
deleted file mode 100644
index 690a99f54..000000000
--- a/app/api-reference/avail-turbo-da-api/submit-raw-data/page.mdx
+++ /dev/null
@@ -1,66 +0,0 @@
----
-image: '/img/docs-link-preview.png'
----
-
-import { Tabs } from 'nextra/components'
-import { Callout } from 'nextra/components'
-
-# Submit Raw Data to Turbo DA
-
-**NEED AN API KEY?**
-Contact our team to get an API key for accessing the Turbo DA API endpoints.
-
-
-> **Endpoint:** `POST /v1/submit_raw_data`
-
-Submits raw data to Turbo DA.
-
-## Parameters
-- `x-api-key` - Your API authentication key (required)
-- `Content-Type` - Must be `application/octet-stream`
-
-## Response
-- **submission_id** - Unique identifier for tracking your submission
-
-
-
-
-```bash filename="Submitting a file"
-# Create a sample file
-echo "This is test data for Avail network" > data.txt
-
-# Submit the file
-curl -X POST 'https://staging.turbo-api.availproject.org/v1/submit_raw_data' \
--H 'x-api-key: YOUR_API_KEY' \
--H 'Content-Type: application/octet-stream' \
---data-binary '@data.txt'
-```
-
-
-
-```bash filename="Submitting raw data"
-curl -X POST 'https://staging.turbo-api.availproject.org/v1/submit_raw_data' \
--H 'x-api-key: YOUR_API_KEY' \
--H 'Content-Type: application/octet-stream' \
---data-binary 'Hello Avail Network!'
-```
-
-
-
-
-Sample Response:
-```json
-{
- "submission_id": ""
-}
-
-
-> If the request fails due to invalid API key or server error, you'll receive an appropriate HTTP error code with an error message:
-
-```json
-{
- "error": "Error message details"
-}
-```
-
-
diff --git a/app/api-reference/gas-relay-deprecated/page.mdx b/app/api-reference/gas-relay-deprecated/page.mdx
index ef0c00d8a..8d31a6291 100644
--- a/app/api-reference/gas-relay-deprecated/page.mdx
+++ b/app/api-reference/gas-relay-deprecated/page.mdx
@@ -1,7 +1,3 @@
----
-image: '/img/docs-link-preview.png'
----
-
import { Callout } from 'nextra/components'
@@ -10,4 +6,4 @@ import { Callout } from 'nextra/components'
**GAS RELAY IS NOW TURBO DA!**
The gas relay service is being replaced by Turbo DA.
We'll update our docs soon, but you can check out our [Turbo DA Github repo](https://github.com/availproject/turbo-da) for the latest updates.
-
+
\ No newline at end of file
diff --git a/app/api-reference/layout.tsx b/app/api-reference/layout.tsx
deleted file mode 100644
index 92feeec24..000000000
--- a/app/api-reference/layout.tsx
+++ /dev/null
@@ -1,8 +0,0 @@
-import { sharedMetadata } from '@components/lib/metadata';
-import { ReactNode } from 'react';
-
-export const metadata = sharedMetadata;
-
-export default function Layout({ children }: { children: ReactNode }) {
- return children;
-}
\ No newline at end of file
diff --git a/app/api-reference/start-here/page.mdx b/app/api-reference/start-here/page.mdx
index e16e6219c..748aadbcd 100644
--- a/app/api-reference/start-here/page.mdx
+++ b/app/api-reference/start-here/page.mdx
@@ -1,41 +1,13 @@
---
-image: "/img/docs-link-preview.png"
title: Avail API Reference
---
-import { Cards, Image, Callout } from 'nextra/components'
-import { FileIcon, FilesIcon } from '@components/icons'
-import { cloneElement } from 'react'
-
-export default function MdxLayout(props) {
- return cloneElement(props.children, {
- components: {
- img: Image
- }
- })
-}
-
-
-
-1. This section is dedicated towards providing a detailed API reference for all of Avail's APIs and SDKs.
-2. If you are working with older versions of Avail's SDKs, please refer to the menu next to the search bar to access the old API docs.
-
-
-
-
# Avail API reference
This entire section is dedicated towards providing a detailed API reference for all of Avail's dev tooling.
-We currently document the following APIs:
-
-
- } title="Avail node API" href="/api-reference/avail-node-api" />
- } title="Avail light client API" href="/api-reference/avail-lc-api" />
- } title="Avail bridge API" href="/api-reference/avail-bridge-api" />
- } title="Avail Nexus API" href="/api-reference/avail-nexus-sdk" />
- } title="Turbo DA API" href="/api-reference/avail-turbo-da-api" />
-
+We currently document the following APIs, feel free to reach out to us on [our Discord server](https://discord.gg/AvailProject) if there are any error, or if something you need is missing:
-Questions? Errors? Something missing?
-Feel free to reach out to us on [our Discord server](https://discord.gg/AvailProject).
\ No newline at end of file
+1. `Avail node API`: The most comprehensive way of interacting with the Avail network programmatically.
+2. `Avail light client API`: An easier way of interacting with the network and contributing to it's security.
+3. `Avail bridge API`: Use the `VectorX` bridge programmatically to transfer tokens between Avail and Ethereum.
\ No newline at end of file
diff --git a/app/docs/_meta.ts b/app/docs/_meta.ts
index eaec23c58..a91b86811 100644
--- a/app/docs/_meta.ts
+++ b/app/docs/_meta.ts
@@ -10,7 +10,6 @@ export default {
"operate-a-node": "Run a node",
"glossary": "Glossary",
"faqs": "FAQs",
- "bug-bounty": "Bug Bounty",
"archived-content": {
"display": "hidden"
}
diff --git a/app/docs/archived-content/page.mdx b/app/docs/archived-content/page.mdx
index 97170a8e6..e69de29bb 100644
--- a/app/docs/archived-content/page.mdx
+++ b/app/docs/archived-content/page.mdx
@@ -1,4 +0,0 @@
----
-image: '/img/docs-link-preview.png'
----
-
diff --git a/app/docs/bug-bounty/page.mdx b/app/docs/bug-bounty/page.mdx
deleted file mode 100644
index 42abc4a42..000000000
--- a/app/docs/bug-bounty/page.mdx
+++ /dev/null
@@ -1,33 +0,0 @@
----
-image: "/img/docs-link-preview.png"
-id: bug-bounty
-title: Bug Bounty
-sidebar_label: Bug Bounty
-keywords:
- - docs
- - avail
- - Bug Bounty
- - Immunefi
- - Security
----
-
-import { Callout } from 'nextra/components'
-
-# Reporting Vulnerabilities
-
-If you discover security vulnerabilities, **please report it responsibly** to help us keep the Avail ecosystem secure.
-
-## Bug Bounty Program with Immunefi
-
-We offer rewards of upto $500,000 for valid security disclosures through our bug bounty program on Immunefi.
-
-🔗 [View detailed information about the bug bounty on Immunefi](https://immunefi.com/bug-bounty/avail/information/)
-
-### Contact us
-
-If your vulnerability is not in scope of the Immunefi program or you need to contact the team urgently, please email us at:
-📨 **security@availproject.org**
-
-
-We appreciate your help in keeping Avail safe and reliable!
-
diff --git a/app/docs/build-with-avail/_meta.ts b/app/docs/build-with-avail/_meta.ts
index cfb5080c9..6ad10c509 100644
--- a/app/docs/build-with-avail/_meta.ts
+++ b/app/docs/build-with-avail/_meta.ts
@@ -2,6 +2,5 @@ export default {
"interact-with-avail-da": "Interact Directly With Avail DA",
"deploy-rollup-on-avail": "Deploy a Rollup on Avail DA",
- "turbo-da": "Get started with Turbo DA",
"vectorx": "Use the Avail bridge"
}
\ No newline at end of file
diff --git a/app/docs/build-with-avail/deploy-rollup-on-avail/Optimium/arbitrum-nitro/nitro-stack/page.mdx b/app/docs/build-with-avail/deploy-rollup-on-avail/Optimium/arbitrum-nitro/nitro-stack/page.mdx
index e0a8d5539..9cf8a2ac1 100644
--- a/app/docs/build-with-avail/deploy-rollup-on-avail/Optimium/arbitrum-nitro/nitro-stack/page.mdx
+++ b/app/docs/build-with-avail/deploy-rollup-on-avail/Optimium/arbitrum-nitro/nitro-stack/page.mdx
@@ -1,7 +1,3 @@
----
-image: '/img/docs-link-preview.png'
----
-
import { Callout } from 'nextra/components'
# Deploy Arbitrum Orbit with Avail DA
@@ -18,7 +14,7 @@ This guide is based on [Arbitrum Orbit Quickstart](https://docs.arbitrum.io/laun
- You need to have [docker](https://docs.docker.com/engine/) and [docker-compose](https://docs.docker.com/compose/) installed on your machine.
#### Avail
- An Avail account with some AVAIL tokens in it. You can refer to [our docs here](/docs/end-user-guide/accounts) to get started.
-- An application key (`app-id`) for your rollup. Learn [how to get your `app-id` here](/docs/build-with-avail/interact-with-avail-da/app-id).
+- An application key (`app-id`) for your rollup. Learn [how to get your `app-id` here](/docs/end-user-guide/app-id).
#### Arbitrum Sepolia
- At least 1 ETH over Arbsepolia Testnet. You can follow [Step 1](https://docs.arbitrum.io/launch-orbit-chain/orbit-quickstart#step-1-acquire-arbitrum-testnet-eth-and-the-native-token-for-orbit-chains-with-custom-gas-tokens) on Arbitrum Orbit Doc for acquiring testnet $ETH
@@ -41,26 +37,11 @@ This guide is based on [Arbitrum Orbit Quickstart](https://docs.arbitrum.io/laun
```bash
git clone https://github.com/availproject/arbitrum-orbit-sdk.git
git checkout avail-develop-upstream-v0.20.1
- cd arbitrum-orbit-sdk
- ```
-
-Install and build
-
- ```bash
- npm i && npm run build
+ cd arbitrum-orbit-sdk/examples/create-avail-rollup-eth
```
### Step-2: Create `.env` file
-
- Go to `examples/create-avail-rollup-eth` and create a copy of `.env.example` as `.env` file inside.
-
-
- ```bash
- cd examples/create-avail-rollup-eth
- cp env.example .env
- ```
-
- then edit the `.env` file for the following:
+ Create a copy of `.env.sample` as `.env` file and edit the following:
- Set EVM account keys of settlement layer
@@ -103,15 +84,15 @@ Install and build
npm run deploy-avail-orbit-rollup
```
-- Here is a sample response of logs that you may see:
+- You will find this kind of log
-- You will get to see two files added `nodeConfig.json` and `orbitSetupScriptConfig.json`, which will be need in the next step to spin and set up Avail Orbit Rollup.
+- You will get to see two files added `nodeConfig.json` and `orbitSetupScriptConfig.json`, which will be need in next step spin and set up avail orbit rollup
-#### Before proceeding, let's briefly review what just happened:
+Before proceeding, let's briefly review what just happened:
1. You submitted a deployment transaction to an Orbit "factory" smart contract on the Arbitrum Sepolia testnet, the public L2 chain that your local Orbit chain will settle transactions to.
2. This Orbit smart contract then initialized your Orbit chain's base contracts with the values that you specified in the previous step, and deployed these base contracts to the Arbitrum Sepolia testnet.
@@ -272,4 +253,4 @@ The previous release of v1 is not recommended for install any more, but we will
* Arbitrum Sepolia: `0xADCBE5c221566FA6e6Ebf5BA08759c83177DfCDA`
* wasm module root:
* arm64:- `0x30d81f66d40dbb88484524cbce0982ee9adee944d9416c283313560efd5af958`
- * amd64:- `0xc3d6717b86468b20ed2d74fa4484571b51595d56294d154b0fac19d55b599e09`
+ * amd64:- `0xc3d6717b86468b20ed2d74fa4484571b51595d56294d154b0fac19d55b599e09`
\ No newline at end of file
diff --git a/app/docs/build-with-avail/deploy-rollup-on-avail/Optimium/arbitrum-nitro/overview/page.mdx b/app/docs/build-with-avail/deploy-rollup-on-avail/Optimium/arbitrum-nitro/overview/page.mdx
index 27addf860..efca6f33c 100644
--- a/app/docs/build-with-avail/deploy-rollup-on-avail/Optimium/arbitrum-nitro/overview/page.mdx
+++ b/app/docs/build-with-avail/deploy-rollup-on-avail/Optimium/arbitrum-nitro/overview/page.mdx
@@ -1,7 +1,3 @@
----
-image: '/img/docs-link-preview.png'
----
-
# Building on the Arbitrum Nitro stack with Avail DA
## What is Nitro?
@@ -49,4 +45,4 @@ Let’s take a look at the transaction Lifecycle:
- **Component**: `Arbitrator, ArbState`
- Process: Recover payload from Avail DA ([`RecoverPayloadFromAvailBatch`](https://github.com/availproject/avail-nitro-adapter/blob/data-availability-verification-v2.3.1/arbstate/inbox.go#L169C6-L169C34)),
and re-executes the State Transition Function against input messages to determine
- the correct output block.
+ the correct output block.
\ No newline at end of file
diff --git a/app/docs/build-with-avail/deploy-rollup-on-avail/Optimium/arbitrum-nitro/page.mdx b/app/docs/build-with-avail/deploy-rollup-on-avail/Optimium/arbitrum-nitro/page.mdx
index c8868094e..5a085aab9 100644
--- a/app/docs/build-with-avail/deploy-rollup-on-avail/Optimium/arbitrum-nitro/page.mdx
+++ b/app/docs/build-with-avail/deploy-rollup-on-avail/Optimium/arbitrum-nitro/page.mdx
@@ -1,5 +1,4 @@
---
-image: "/img/docs-link-preview.png"
title: Arbitrum Nitro stack
asIndexPage: true
---
@@ -11,5 +10,5 @@ import { FileIcon } from '@components/icons'
} title="Overview" href="/docs/build-with-avail/deploy-rollup-on-avail/Optimium/arbitrum-nitro/overview" />
- } title="[GUIDE] Deploy an Avail-Powered Orbit chain" href="/docs/build-with-avail/deploy-rollup-on-avail/Optimium/arbitrum-nitro/nitro-stack" />
-
+ } title="[GUIDE] Deploy an Avail-Powered Orbit chain" href="/docs/build-with-avail/Optimium/arbitrum-nitro/nitro-stack" />
+
\ No newline at end of file
diff --git a/app/docs/build-with-avail/deploy-rollup-on-avail/Optimium/op-stack/op-stack/page.mdx b/app/docs/build-with-avail/deploy-rollup-on-avail/Optimium/op-stack/op-stack/page.mdx
index b69fb0581..bf780cad0 100644
--- a/app/docs/build-with-avail/deploy-rollup-on-avail/Optimium/op-stack/op-stack/page.mdx
+++ b/app/docs/build-with-avail/deploy-rollup-on-avail/Optimium/op-stack/op-stack/page.mdx
@@ -1,7 +1,6 @@
---
-image: "/img/docs-link-preview.png"
id: op-stack
-title: Deploy OP Stack chain with Avail DA
+title: How to Use the OP Stack with Avail
sidebar_label: Avail-Powered OP Stack Optimium
description: "Discover how to utilize Avail as a data availability layer."
keywords:
@@ -11,488 +10,484 @@ keywords:
- build
- data availability
- da
+image: https://docs.availproject.org/img/avail/AvailDocs.png
---
import { Callout } from "nextra/components";
-# Deploy OP Stack chain with Avail DA
+# How to Use the OP Stack with Avail
## Introduction
-Embark on setting up your own OP stack chain in [alt-da mode](https://docs.optimism.io/stack/beta-features/alt-da-mode) using Avail as Data Availabilty layer . This guide targets Ethereum's Sepolia testnet and Avail Turing testnet. For a detailed understanding, review the [Optimism Documentation](https://stack.optimism.io/docs/build/getting-started/#know-before-you-go).
+Embark on setting up your own Avail-Optimism chain. This guide targets Ethereum's Sepolia testnet and Avail Turing testnet. For a detailed understanding, review the [Optimism Documentation](https://stack.optimism.io/docs/build/getting-started/#know-before-you-go).
## Prerequisites
Ensure you have installed the following software.
-> Installation commands are based on Ubuntu 24.04 LTS:
+> Installation commands are based on Ubuntu 20.04 LTS:
-| **Software** | **Version** | **Version Check Command** |
-| --- | --- | --- |
-| [git](https://git-scm.com/) | `^2` | `git --version` |
-| [go](https://go.dev/) | `^1.21` | `go version` |
-| [node](https://nodejs.org/en/) | `^20` | `node --version` |
-| [pnpm](https://pnpm.io/installation) | `^8` | `pnpm --version` |
-| [foundry](https://github.com/foundry-rs/foundry#installation) | `^0.2.0` | `forge --version` |
-| [make](https://linux.die.net/man/1/make) | `^3` | `make --version` |
-| [jq](https://github.com/jqlang/jq) | `^1.6` | `jq --version` |
-| [direnv](https://direnv.net/) | `^2` | `direnv --version` |
-| [Just](https://github.com/casey/just) | `1.35.0` | `just --version` |
+
+
+| Software | Version |
+| ------------------------------------------------------------------------ | ---------- |
+| [Git](https://git-scm.com/) | OS default |
+| [Go](https://go.dev/) | 1.21 |
+| [Node](https://nodejs.org/en/) | ^20 |
+| [Pnpm](https://pnpm.io/installation) | 8.5.6 |
+| [Make](https://linux.die.net/man/1/make) | OS default |
+| [jq](https://github.com/jqlang/jq) | OS default |
+| [direnv](https://direnv.net/) | Latest |
+| [Foundry](https://github.com/foundry-rs/foundry#installation) | ^0.2.0 |
+
+
+```bash
+# Install Git
+sudo apt install -y git curl make jq
+
+# Install Go
+wget https://go.dev/dl/go1.21.linux-amd64.tar.gz
+tar xvzf go1.21.linux-amd64.tar.gz
+sudo cp go/bin/go /usr/bin/go
+sudo mv go /usr/lib
+echo export GOROOT=/usr/lib/go >> ~/.bashrc
+
+# Install Node.js
+curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
+sudo apt-get install -y nodejs npm
+
+# Install Pnpm
+sudo npm install -g pnpm
+
+# Install Make
+sudo apt install -y make
+
+# Install jq
+sudo apt install -y jq
+
+# Install direnv
+sudo apt install -y direnv
+```
##### Use the following releases while following the guide:
-| **Component** | **Version** |
-| --- | --- |
-| op-node | v1.13.3 |
-| op-geth | v1.101511.0 |
-| op-batcher | v1.13.2 |
-| op-deployer | v0.3.2 |
-| op-proposer | v1.10.0 |
-##### Get Access to a Sepolia Node
+- op-node/v1.9.1
+- op-proposer/v1.9.1
+- op-batcher/v1.9.1
+- op-geth v1.101408.0
-For deploying to Sepolia, access an L1 node using a provider like [Alchemy](https://www.alchemy.com/dapps/Sepolia) or [run your own Sepolia node](https://notes.ethereum.org/@launchpad/Sepolia).
+## Setup Avail DA-server
+#### Run avail-da server ( manually ).
-## Setup Avail DA server
+1. Navigate to
-This introduces a sidecar DA Server for Optimism that interacts with Avail DA for posting and retrieving data.
+```
+git clone https://github.com/availproject/avail-alt-da-server.git
+cd avail-alt-da-server
-#### Run avail-da server(binary).
+```
-1. Build Avail DA Server
- ```bash
- git clone https://github.com/availproject/avail-alt-da-server.git
- cd avail-alt-da-server
- make da-server
- ```
-
-2. Run your DA sidecar:
- ```bash
- ./bin/avail-da-server ./cmd/avail --addr=localhost --port=8000 --avail.rpc= --avail.seed=<> --avail.appid=<>
- ```
+2. Build Avail DA Server:
+ ` make da-server`
+
+3. Run your DA sidecar:
+ `./bin/avail-da-server ./cmd/avail --addr=localhost --port=8000 --avail.rpc= --avail.seed=<> --avail.appid=<>`
#### Run using docker
- Copy `.env.example` to `.env`. Fill the values inside.
- Run the following commands:
- ```bash
+ ```
docker-compose build
docker-compose up
```
-## Configure op-stack
+## Build the Adapter Source
-1. Clone the [optimism](https://github.com/ethereum-optimism/optimism.git) repositroy:
+1. Clone and navigate to the Avail adapter:
```bash
git clone https://github.com/ethereum-optimism/optimism.git
cd optimism
git fetch --tag --all
+ git checkout v1.9.1
git submodule update --init --recursive
```
-2. Add `env` variables at root of the optimism directly
+2. Install modules:
+
+ ```bash
+ pnpm install
+ ```
- file-name: `.envrc`
+3. Compile the necessary packages:
```bash
- ##################################################
- # Getting Started #
- ##################################################
-
- # Admin account
- export GS_ADMIN_ADDRESS=
- export GS_ADMIN_PRIVATE_KEY=
-
- # Batcher account
- export GS_BATCHER_ADDRESS=
- export GS_BATCHER_PRIVATE_KEY=
-
- # Proposer account
- export GS_PROPOSER_ADDRESS=
- export GS_PROPOSER_PRIVATE_KEY=
-
- # Sequencer account
- export GS_SEQUENCER_ADDRESS=
- export GS_SEQUENCER_PRIVATE_KEY=
-
- ##################################################
- # op-node Configuration #
- ##################################################
-
- # The kind of RPC provider, used to inform optimal transactions receipts
- # fetching. Valid options: alchemy, quicknode, infura, parity, nethermind,
- # debug_geth, erigon, basic, any.
- export L1_RPC_KIND=
- export L1_CHAIN_ID=
- export L2_CHAIN_ID=
- export L1_BLOCK_TIME=12
- export L2_BLOCK_TIME=5
- export DA_SERVER_HTTP_URL=http://localhost:8000
- export GAME_FACTORY_ADDRESS=""
- ##################################################
- # Contract Deployment #
- ##################################################
-
- # RPC URL for the L1 network to interact with
- export L1_RPC_URL=
+ make op-node op-batcher op-proposer
+ pnpm build
```
- Fill out the required details
- | **Variable Name** | **Description** |
- | --- | --- |
- | L1_RPC_URL | URL for your L1 node (a Sepolia node in this case).|
- | L1_RPC_KIND | Kind of L1 RPC you're connecting to, used to inform optimal transactions receipts fetching. Valid options: `alchemy`, `quicknode`, `infura`, `parity`, `nethermind`, `debug_geth`, `erigon`, `basic`, `any`.|
- | L1_BLOCK_TIME | Block time of your respective settlement layer for this L2 layer |
- | L2_BLOCK_TIME | Block time of your L2 layer |
- | L1_CHAIN_ID | Chain id of your respective settlement layer for this L2 layer |
- | L2_CHAIN_ID | Chain id of your L2 layer |
-
-3. Generate and Secure Keys
-
- Create and fill these four essential accounts with private keys to above created `.envrc` file:
-
- - `Admin` (contract upgrade authority)
- - `Batcher` (publishes Sequencer data to L1)
- - `Proposer` (publishes L2 results to L1)
- - `Sequencer` (signs blocks on the p2p network)
-
- ```bash
- echo "Admin:"
- cast wallet new
- echo "Proposer:"
- cast wallet new
- echo "Batcher:"
- cast wallet new
- echo "Sequencer:"
- cast wallet new
- ```
-
- You should see an output similar to:
-
- ```bash
- Admin:
- Successfully created new keypair.
- Address: 0xc4A01194958DE0D90A876e8A5fc9D7B530072148
- Private key: 0xb8e39bd94a210e410c4024e1cc91014de45a5eb1e42f3aa99a368b5a5ac19b45
- Proposer:
- Successfully created new keypair.
- Address: 0xFC0374Ae658e46cA4022acA179d3cb6D8e1A4934
- Private key: 0xa9bc1b3f5deb1e00251df68bf86e3493b25bc5430665433546f2f9aacc748d1a
- Batcher:
- Successfully created new keypair.
- Address: 0xD6857B5BE9468Be67d64ABaB48459378d5329b96
- Private key: 0xe9cd8960fc7984a301d567b819e0c62871eb2c7239c2e66b8f319eaa45c3cbd5
- Sequencer:
- Successfully created new keypair.
- Address: 0x33348817E4B1192D576C4f157e9a5EC93dc5392D
- Private key: 0xd98b49e11e4e0be9931017831395e6644a50c36285d08e14d1a479af5ee08675
- ```
-
- You'll need to fund `Admin`, `Proposer`, and `Batcher` with Sepolia ETH (0.5 ETH for `Admin`, 0.2 ETH for `Proposer`, 0.1 ETH for `Batcher`).
-
-
-
- NOTE FOR PRODUCTION
- Use secure hardware for key management in production environments.
- `cast wallet` is not designed for production deployments.
-
-
-
-
-4. Generate a `jwt.txt` file, which is crucial for the secure interaction between `op-node` and `op-geth` client:
+### Build the Optimism Geth Source
+
+1. Clone and navigate to `op-geth`:
```bash
- openssl rand -hex 32 > jwt.txt
+ git clone https://github.com/ethereum-optimism/op-geth.git
+ cd op-geth
+ git fetch --tag --all
+ git checkout v1.101408.0
```
+2. Compile `op-geth`:
+ ```bash
+ make geth
+ ```
+### Get Access to a Sepolia Node
-## Contract Deployment using `op-deployer`
+For deploying to Sepolia, access an L1 node using a provider like [Alchemy](https://www.alchemy.com/dapps/Sepolia) or [run your own Sepolia node](https://notes.ethereum.org/@launchpad/Sepolia).
-Deploy essential L1 contracts for the chain’s functionality:
+## Generate and Secure Keys
-1. Build `op-deplyer`.
+Create four essential accounts with private keys:
- ```bash
- ## op-deployer
- cd op-deployer
- git checkout op-deployer/v0.3.2
- just build
- ```
+- `Admin` (contract upgrade authority)
+- `Batcher` (publishes Sequencer data to L1)
+- `Proposer` (publishes L2 results to L1)
+- `Sequencer` (signs blocks on the p2p network)
-2. Generate `intent.toml` and `state.json` file for deployment configuration:
+You can use `cast wallet` in the `contracts-bedrock` package for key generation:
+
+1. In the Optimism repo, navigate to the [contracts-bedrock package](https://github.com/ethereum-optimism/optimism/tree/129032f15b76b0d2a940443a39433de931a97a44/packages/contracts-bedrock):
```bash
- ## Intent and state file intialization
- ./bin/op-deployer init --l1-chain-id --l2-chain-ids --workdir .deployer --intent-type custom
+ cd ~/optimism/packages/contracts-bedrock
```
- Edit `intent.toml` file
- ```toml
- configType = "custom"
- l1ChainID = 11155111
- fundDevAccounts = false
- useInterop = false
- l1ContractsLocator = "tag://op-contracts/v3.0.0"
- l2ContractsLocator = "tag://op-contracts/v3.0.0"
-
- [superchainRoles]
- proxyAdminOwner = "ENTER_ADMIN_ADDRESS"
- protocolVersionsOwner = "ENTER_ADMIN_ADDRESS"
- guardian = "ENTER_ADMIN_ADDRESS"
-
- [[chains]]
- id = "ENTER_CHAIN_ID"
- baseFeeVaultRecipient = "ENTER_ADMIN_ADDRESS"
- l1FeeVaultRecipient = "ENTER_ADMIN_ADDRESS"
- sequencerFeeVaultRecipient = "ENTER_ADMIN_ADDRESS"
- eip1559DenominatorCanyon = 250
- eip1559Denominator = 50
- eip1559Elasticity = 6
- operatorFeeScalar = 0
- operatorFeeConstant = 0
- [chains.roles]
- l1ProxyAdminOwner = "ENTER_ADMIN_ADDRESS"
- l2ProxyAdminOwner = "ENTER_ADMIN_ADDRESS"
- systemConfigOwner = "ENTER_ADMIN_ADDRESS"
- unsafeBlockSigner = "ENTER_SEQUENCER_ADDRESS"
- batcher = "ENTER_BATCHER_ADDRESS"
- proposer = "ENTER_PROPOSER_ADDRESS"
- challenger = "ENTER_ADMIN_ADDRESS"
- [chains.dangerousAltDAConfig]
- useAltDA = true
- daCommitmentType = "GenericCommitment"
- daChallengeWindow = 160
- daResolveWindow = 160
- daBondSize = 1000000
- daResolverRefundPercentage = 0
- ```
+2. Generate accounts:
-2. Deploy contracts:
```bash
- ## L1 contract deployment
- ./bin/op-deployer apply --workdir .deployer \
- --l1-rpc-url \
- --private-key
+ echo "Admin:"
+ cast wallet new
+ echo "Proposer:"
+ cast wallet new
+ echo "Batcher:"
+ cast wallet new
+ echo "Sequencer:"
+ cast wallet new
```
-3. Generate `genesis.json`, `rollup.json` and `l1-addresses.json`:
+ You should see an output similar to:
+
```bash
- ./bin/op-deployer inspect genesis --workdir .deployer > .deployer/genesis.json
- ./bin/op-deployer inspect rollup --workdir .deployer > .deployer/rollup.json
- ./bin/op-deployer inspect l1 --workdir .deployer > .deployer/l1-addresses.json
+ Admin:
+ Successfully created new keypair.
+ Address: 0xc4A01194958DE0D90A876e8A5fc9D7B530072148
+ Private key: 0xb8e39bd94a210e410c4024e1cc91014de45a5eb1e42f3aa99a368b5a5ac19b45
+ Proposer:
+ Successfully created new keypair.
+ Address: 0xFC0374Ae658e46cA4022acA179d3cb6D8e1A4934
+ Private key: 0xa9bc1b3f5deb1e00251df68bf86e3493b25bc5430665433546f2f9aacc748d1a
+ Batcher:
+ Successfully created new keypair.
+ Address: 0xD6857B5BE9468Be67d64ABaB48459378d5329b96
+ Private key: 0xe9cd8960fc7984a301d567b819e0c62871eb2c7239c2e66b8f319eaa45c3cbd5
+ Sequencer:
+ Successfully created new keypair.
+ Address: 0x33348817E4B1192D576C4f157e9a5EC93dc5392D
+ Private key: 0xd98b49e11e4e0be9931017831395e6644a50c36285d08e14d1a479af5ee08675
```
+ Record and securely store these key details. You'll need to fund `Admin`, `Proposer`, and `Batcher` with Sepolia ETH (0.5 ETH for `Admin`, 0.2 ETH for `Proposer`, 0.1 ETH for `Batcher`).
-## Build and Run the `op-stack` components
+
-### `op-geth`
+NOTE FOR PRODUCTION
+Use secure hardware for key management in production environments.
+`cast wallet` is not designed for production deployments.
-1. Clone [op-geth](https://github.com/ethereum-optimism/op-geth):
- ```bash
- git clone https://github.com/ethereum-optimism/op-geth.git
- cd op-geth
- git checkout v1.101511.0
- make geth
- ```
+
-2. Move the `genesis.json` and `jwt.txt` files into its directory:
- ```bash
- cp genesis.json ~/op-geth
- cp jwt.txt ~/op-geth
- ```
+## Network Configuration and Setup
-3. Create and configure data directory
- ```bash
- mkdir datadir
- ./build/bin/geth init --state.scheme=hash --datadir=datadir genesis.json
- ```
+After building the repositories, configure your chain settings in the [contracts-bedrock package](https://github.com/ethereum-optimism/optimism/tree/129032f15b76b0d2a940443a39433de931a97a44/packages/contracts-bedrock).
+
+1. Ensure you are in the `contracts-bedrock` sub-directory:
-4. Run `op-geth`
```bash
- # Set environment variables
- export L2_CHAIN_ID=
-
- ## Run op-geth
- ./build/bin/geth \
- --datadir ./datadir \
- --http \
- --http.corsdomain="*" \
- --http.vhosts="*" \
- --http.addr=0.0.0.0 \
- --http.port=8545 \
- --http.api=web3,debug,eth,txpool,net,engine \
- --ws \
- --ws.addr=0.0.0.0 \
- --ws.port=8546 \
- --ws.origins="*" \
- --ws.api=debug,eth,txpool,net,engine \
- --syncmode=full \
- --gcmode=archive \
- --nodiscover \
- --maxpeers=0 \
- --networkid=$L2_CHAIN_ID \
- --authrpc.vhosts="*" \
- --authrpc.addr=0.0.0.0 \
- --authrpc.port=8551 \
- --authrpc.jwtsecret=./jwt.txt \
- --rollup.disabletxpoolgossip=true \
- --state.scheme=hash
+ cd ~/optimism/packages/contracts-bedrock
```
- `op-geth` is now active, but block creation will begin once `op-node` is operational.
+2. Activate the environment with `direnv`:
-### `op-node`
+ > If you need to install `direnv`, ensure you also [modify the shell configuration](https://direnv.net/docs/hook.html).
-1. Build `op-node` from [optimism](#configure-op-stack)
```bash
- cd op-node
- git checkout op-node/v1.13.3
- make op-node
+ direnv allow .
```
-2. Move the `rollup.json` and `jwt.txt` files into its directory:
+## Core Contract Deployment
+
+Deploy essential L1 contracts for the chain’s functionality:
+
+1. Update `/optimism/packages/contracts-bedrock/deploy-config` and update file `getting_started.json`.
+
+```
+cd packages/contracts-bedrock
+./scripts/getting-started/config.sh
+```
+
+2. Add the following at the bottom of the config generated:
+
+```
+ "useAltDA": true,
+ "daCommitmentType": "GenericCommitment",
+ "daChallengeWindow": 160,
+ "daResolveWindow": 160,
+ "daBondSize": 1000000,
+ "daResolverRefundPercentage": 0
+```
+
+Example config ( for reference purpose ):
+
+```
+{
+ "l1StartingBlockTag": "0x2c9f156ae1cc024817b920b41c102b23b5a7526e16220c517078341f9890e8bd",
+
+ "l1ChainID": 11155111,
+ "l2ChainID": 11155420,
+ "l2BlockTime": 2,
+ "l1BlockTime": 12,
+
+ "maxSequencerDrift": 600,
+ "sequencerWindowSize": 3600,
+ "channelTimeout": 300,
+
+ "p2pSequencerAddress": "0x15cb6e5fa6a7134F3f6f5a9130F70c1344162b77",
+ "batchInboxAddress": "0xff00000000000000000000000000000000042069",
+ "batchSenderAddress": "0x5bd31d51C4041108c238473f27BF5f72311b1bcF",
+
+ "l2OutputOracleSubmissionInterval": 120,
+ "l2OutputOracleStartingBlockNumber": 0,
+ "l2OutputOracleStartingTimestamp": 1725740628,
+
+ "l2OutputOracleProposer": "0x07B4c44290fD2Fba85d7924Fbf4A6499661bBe53",
+ "l2OutputOracleChallenger": "0x79A953eAc59e40B3c7567a4cfc446c4B4912722f",
+
+ "finalizationPeriodSeconds": 12,
+
+ "proxyAdminOwner": "0x79A953eAc59e40B3c7567a4cfc446c4B4912722f",
+ "baseFeeVaultRecipient": "0x79A953eAc59e40B3c7567a4cfc446c4B4912722f",
+ "l1FeeVaultRecipient": "0x79A953eAc59e40B3c7567a4cfc446c4B4912722f",
+ "sequencerFeeVaultRecipient": "0x79A953eAc59e40B3c7567a4cfc446c4B4912722f",
+ "finalSystemOwner": "0x79A953eAc59e40B3c7567a4cfc446c4B4912722f",
+ "superchainConfigGuardian": "0x79A953eAc59e40B3c7567a4cfc446c4B4912722f",
+
+ "baseFeeVaultMinimumWithdrawalAmount": "0x8ac7230489e80000",
+ "l1FeeVaultMinimumWithdrawalAmount": "0x8ac7230489e80000",
+ "sequencerFeeVaultMinimumWithdrawalAmount": "0x8ac7230489e80000",
+ "baseFeeVaultWithdrawalNetwork": 0,
+ "l1FeeVaultWithdrawalNetwork": 0,
+ "sequencerFeeVaultWithdrawalNetwork": 0,
+
+ "gasPriceOracleOverhead": 0,
+ "gasPriceOracleScalar": 1000000,
+
+ "enableGovernance": true,
+ "governanceTokenSymbol": "OP",
+ "governanceTokenName": "Optimism",
+ "governanceTokenOwner": "0x79A953eAc59e40B3c7567a4cfc446c4B4912722f",
+
+ "l2GenesisBlockGasLimit": "0x1c9c380",
+ "l2GenesisBlockBaseFeePerGas": "0x3b9aca00",
+
+ "eip1559Denominator": 50,
+ "eip1559DenominatorCanyon": 250,
+ "eip1559Elasticity": 6,
+ "l2GenesisFjordTimeOffset": "0x0",
+ "l2GenesisRegolithTimeOffset": "0x0",
+ "l2GenesisEcotoneTimeOffset": "0x0",
+ "l2GenesisDeltaTimeOffset": "0x0",
+ "l2GenesisCanyonTimeOffset": "0x0",
+ "systemConfigStartBlock": 0,
+
+ "requiredProtocolVersion": "0x0000000000000000000000000000000000000000000000000000000000000000",
+ "recommendedProtocolVersion": "0x0000000000000000000000000000000000000000000000000000000000000000",
+
+ "faultGameAbsolutePrestate": "0x03c7ae758795765c6664a5d39bf63841c71ff191e9189522bad8ebff5d4eca98",
+ "faultGameMaxDepth": 44,
+ "faultGameClockExtension": 0,
+ "faultGameMaxClockDuration": 1200,
+ "faultGameGenesisBlock": 0,
+ "faultGameGenesisOutputRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
+ "faultGameSplitDepth": 14,
+ "faultGameWithdrawalDelay": 600,
+
+ "preimageOracleMinProposalSize": 1800000,
+ "preimageOracleChallengePeriod": 300,
+
+ "useAltDA": true,
+ "daCommitmentType": "GenericCommitment",
+ "daChallengeWindow": 160,
+ "daResolveWindow": 160,
+ "daBondSize": 1000000,
+ "daResolverRefundPercentage": 0
+}
+
+```
+
+2. Navigate to `/optimism/packages/contracts-bedrock/deployments`, and create `avail-optimism` directory:
+
+```bash
+cd ~/optimism/packages/contracts-bedrock/deployments
+mkdir avail-optimism
+```
+
+3. Navigate to `/optimism/packages/contracts-bedrock/` and the deploy contracts (this can take up to 15 minutes):
```bash
- cp rollup.json ~/op-node
- cp jwt.txt ~/op-node
+ DEPLOYMENT_OUTFILE=deployments/artifact.json \
+ DEPLOY_CONFIG_PATH=deploy-config/getting-started.json \
+ forge script scripts/deploy/Deploy.s.sol:Deploy --broadcast --private-key $GS_ADMIN_PRIVATE_KEY \
+ --rpc-url $L1_RPC_URL --slow
```
+4. L2 Allocs
-3. Run `op-node`
+```
+CONTRACT_ADDRESSES_PATH=deployments/artifact.json DEPLOY_CONFIG_PATH=deploy-config/getting-started.json STATE_DUMP_PATH=deploy-config/statedump.json forge script scripts/L2Genesis.s.sol:L2Genesis --sig 'runWithStateDump()' --chain
+```
- ```bash
- # Set env variable from `.envrc`
- direnv allow .
+>
- ## Run op-node
- ./bin/op-node \
- --l2=http://localhost:8551 \
- --l2.jwt-secret=./jwt.txt \
- --sequencer.enabled \
- --sequencer.l1-confs=5 \
- --verifier.l1-confs=4 \
- --rollup.config=./rollup.json \
- --rpc.addr=0.0.0.0 \
- --rpc.port=8547 \
- --p2p.disable \
- --rpc.enable-admin \
- --p2p.sequencer.key=$GS_SEQUENCER_PRIVATE_KEY \
- --l1=$L1_RPC_URL \
- --l1.rpckind=$L1_RPC_KIND \
- --altda.enabled=true \
- --altda.da-server=$DA_SERVER_HTTP_URL \
- --altda.da-service=true \
- --l1.beacon.ignore=true
- ```
+
- Block creation will commence once `op-node` starts processing L1 information and interfaces with `op-geth`.
+If you see a nondescript error that includes `EvmError: Revert` and Script failed then you likely need to change the `IMPL_SALT` environment variable. This variable determines the addresses of various smart contracts that are deployed via `CREATE2`.
- To optimize synchronization and avoid network resource waste:
+If the same `IMPL_SALT` is used to deploy the same
+contracts twice, the second deployment will fail.
- - Disable p2p sync (`--p2p.disable`) by default.
- - Use specific command line parameters for synchronization among multiple nodes.
-
-### `op-batcher`
+> You can generate a new `IMPL_SALT` by running `direnv reload` anywhere in the Avail Optimism Monorepo.
-1. Build `op-batcher` from [optimism](#configure-op-stack)
+
+
+## Setting Up L2 Configuration
+
+After configuring the L1 layer, focus shifts to establishing the L2 infrastructure. This involves generating three key files:
+
+- `genesis.json` for the genesis block
+- `rollup.json` for rollup configurations
+- `jwt.txt` for secure communication between `op-node` and `op-geth`
+
+1. Navigate to the `op-node` directory:
```bash
- cd op-batcher
- git checkout op-batcher/v1.13.2
- make op-batcher
+ cd ~/optimism/op-node
```
-2. Run `op-batcher`
+2. Run the following command, ensuring you replace `` with your specific L1 RPC URL. This generates the `genesis.json` and `rollup.json` files:
```bash
- # Set env variable from `.envrc`
- direnv allow .
-
- ## Run op-batcher
- ./bin/op-batcher \
- --l2-eth-rpc=http://localhost:8545 \
- --rollup-rpc=http://localhost:8547 \
- --poll-interval=1s \
- --sub-safety-margin=6 \
- --num-confirmations=1 \
- --safe-abort-nonce-too-low-count=3 \
- --resubmission-timeout=30s \
- --rpc.addr=0.0.0.0 \
- --rpc.port=8548 \
- --rpc.enable-admin \
- --max-channel-duration=25 \
- --l1-eth-rpc=$L1_RPC_URL \
- --private-key=$GS_BATCHER_PRIVATE_KEY \
- --altda.enabled=true \
- --altda.da-service=true \
- --altda.da-server=$DA_SERVER_HTTP_URL \
- --throttle-threshold=0
+ go run cmd/main.go genesis l2 \
+ --deploy-config ../packages/contracts-bedrock/deploy-config/getting-started.json \
+ --l1-deployments ../packages/contracts-bedrock/deployments/artifact.json \
+ --outfile.l2 genesis.json \
+ --outfile.rollup rollup.json \
+ --l1-rpc $L1_RPC_URL \
+ --l2-allocs ../packages/contracts-bedrock/deploy-config/statedump.json
```
- Adjust the `--max-channel-duration=n` setting to balance transaction frequency on L1 and the operational costs of the batcher. Recommended is a minumum of 2 since avail block time is 20s and ethereum's 12sec.
+ You'll find the newly created `genesis.json` and `rollup.json` in the `op-node` package.
+3. Add the following at the end of `rollup.json`:
-### `op-proposer`
+```
+ "alt_da": {
+ "da_challenge_contract_address": "0x0000000000000000000000000000000000000000",
+ "da_commitment_type": "GenericCommitment",
+ "da_challenge_window": 160,
+ "da_resolve_window": 160
+ }
+```
-1. Build `op-proposer` from [optimism](#configure-op-stack)
+4. Generate a `jwt.txt` file, which is crucial for the secure interaction between nodes:
```bash
- cd op-proposer
- git checkout op-proposer/v1.10.0
- make op-proposer
+ openssl rand -hex 32 > jwt.txt
```
-2. Run `op-proposer`
+5. To get `op-geth` ready, move the `genesis.json` and `jwt.txt` files into its directory:
```bash
- # Set env variable from `.envrc`
- direnv allow .
-
- ## Run op-proposer
- ./bin/op-proposer \
- --poll-interval=10s \
- --rpc.port=8560 \
- --rollup-rpc=http://localhost:8547 \
- --game-factory-address=$GAME_FACTORY_ADDRESS \
- --game-type 1 \
- --private-key=$GS_PROPOSER_PRIVATE_KEY \
- --l1-eth-rpc=$L1_RPC_URL \
- --allow-non-finalized \
- --num-confirmations=1 \
- --proposal-interval=10s \
- --wait-node-sync=true \
- --log.level=debug
+ cp genesis.json ~/op-geth
+ cp jwt.txt ~/op-geth
```
+These steps ensure the L2 layer is correctly configured and ready for integration with the L1 components, paving the way for a fully functional EVM Rollup on the Avail-OP Stack.
+## Initialize and Configure Geth
-## Appendix
-
-### Acquire Sepolia ETH for Layer 2
-To obtain ETH on your Rollup:
+Prepare `op-geth` for running the chain:
-1. Go to `contracts-bedrock`:
+1. Navigate to `op-geth`:
```bash
- cd ~/optimism/packages/contracts-bedrock
+ cd ~/op-geth
```
-2. Find the L1 standard bridge contract address:
+2. Create a data directory:
```bash
- cat deployments/avail-optimism/L1StandardBridgeProxy.json | jq -r .address
+ mkdir datadir
```
-3. Send Sepolia ETH to the bridge contract address.
+3. Initialize with the genesis file:
+ ```bash
+ build/bin/geth init --datadir=datadir genesis.json
+ ```
-### Why Archive Mode?
-Archive mode on `op-geth`, requiring more disk space than full mode, is essential for:
+### Running op-geth
+
+To initiate `op-geth`, navigate to its directory and execute the following commands:
+
+```bash
+cd ~/op-geth
+./build/bin/geth \
+ --datadir ./datadir \
+ --http \
+ --http.corsdomain="*" \
+ --http.vhosts="*" \
+ --http.addr=0.0.0.0 \
+ --http.port=9545 \
+ --http.api=web3,debug,eth,txpool,net,engine \
+ --ws \
+ --ws.addr=0.0.0.0 \
+ --ws.port=9546 \
+ --ws.origins="*" \
+ --ws.api=debug,eth,txpool,net,engine \
+ --syncmode=full \
+ --nodiscover \
+ --maxpeers=0 \
+ --networkid=42069 \
+ --authrpc.vhosts="*" \
+ --authrpc.addr=0.0.0.0 \
+ --authrpc.port=9551 \
+ --authrpc.jwtsecret=./jwt.txt \
+ --rollup.disabletxpoolgossip=true \
+ --state.scheme=hash
+```
+
+`op-geth` is now active, but block creation will begin once `op-node` is operational.
+
+#### Why Archive Mode?
+
+Archive mode, requiring more disk space than full mode, is essential for:
1. `op-proposer` to access the full state history.
2. The explorer's functionality.
-### Reinitializing op-geth
+#### Reinitializing op-geth
+
In cases of database corruption indicated by `op-node` errors or failure to find L2 heads, follow these steps:
1. Stop `op-geth`.
@@ -507,6 +502,105 @@ In cases of database corruption indicated by `op-node` errors or failure to find
```
4. Restart `op-geth` and then `op-node`.
+### Running op-node
+
+To launch `op-node`, which acts as a consensus client, run:
+
+```bash
+cd ~/optimism/op-node
+./bin/op-node \
+ --l2=http://localhost:9551 \
+ --l2.jwt-secret=./jwt.txt \
+ --sequencer.enabled \
+ --sequencer.l1-confs=5 \
+ --verifier.l1-confs=4 \
+ --rollup.config=./rollup.json \
+ --rpc.addr=0.0.0.0 \
+ --rpc.port=8547 \
+ --p2p.disable \
+ --rpc.enable-admin \
+ --p2p.sequencer.key=$GS_SEQUENCER_PRIVATE_KEY \
+ --l1=$L1_RPC_URL \
+ --l1.rpckind=$L1_RPC_KIND \
+ --altda.enabled=true \
+ --altda.da-server= \
+ --altda.da-service=true \
+ --l1.beacon.ignore=true
+```
+
+Block creation will commence once `op-node` starts processing L1 information and interfaces with `op-geth`.
+
+#### P2P Synchronization
+
+To optimize synchronization and avoid network resource waste:
+
+- Disable p2p sync (`--p2p.disable`) by default.
+- Use specific command line parameters for synchronization among multiple nodes.
+
+### Running op-batcher
+
+`op-batcher` is crucial in publishing transactions from the Sequencer to L1. Ensure it has at least 1 Sepolia ETH for operational continuity.
+
+```bash
+cd ~/optimism/op-batcher
+./bin/op-batcher \
+ --l2-eth-rpc=http://localhost:9545 \
+ --rollup-rpc=http://localhost:8547 \
+ --poll-interval=1s \
+ --sub-safety-margin=6 \
+ --num-confirmations=1 \
+ --safe-abort-nonce-too-low-count=3 \
+ --resubmission-timeout=30s \
+ --rpc.addr=0.0.0.0 \
+ --rpc.port=8548 \
+ --rpc.enable-admin \
+ --max-channel-duration=1 \
+ --l1-eth-rpc=$L1_RPC_URL \
+ --private-key=$GS_BATCHER_PRIVATE_KEY \
+ --altda.enabled=true \
+ --altda.da-service=true \
+ --altda.da-server=
+```
+
+#### Controlling Batcher Costs
+
+Adjust the `--max-channel-duration=n` setting to balance transaction frequency on L1 and the operational costs of the batcher. Recommended is a minumum of 2 since avail block time is 20s and ethereum's 12sec.
+
+### Running op-proposer
+
+Finally, start `op-proposer` to propose new state roots:
+
+```bash
+cd ~/optimism/op-proposer
+./bin/op-proposer \
+ --poll-interval=12s \
+ --rpc.port=9560 \
+ --rollup-rpc=http://localhost:8547 \
+ --l2oo-address=$L2OO_ADDR \
+ --private-key=$PROPOSER_KEY \
+ --l1-eth-rpc=$L1_RPC
+```
+
+## Acquire Sepolia ETH for Layer 2
+
+To obtain ETH on your Rollup:
+
+1. Go to `contracts-bedrock`:
+
+ ```bash
+ cd ~/optimism/packages/contracts-bedrock
+ ```
+
+2. Find the L1 standard bridge contract address:
+
+ ```bash
+ cat deployments/avail-optimism/L1StandardBridgeProxy.json | jq -r .address
+ ```
+
+3. Send Sepolia ETH to the bridge contract address.
+
+## Conduct Test Transactions
+
+You now have a fully operational Avail-Powered Optimism-based EVM Rollup. Experiment with it as you would with any other test blockchain.
-## See your rollup in action
-You now have a fully operational Avail-Powered Optimism-based EVM Rollup. You can interact with your Rollup the same way you'd interact with any other EVM chain. Send some transactions, deploy some contracts, and see what happens!
\ No newline at end of file
+**Congratulations on setting up your chain!**
diff --git a/app/docs/build-with-avail/deploy-rollup-on-avail/Optimium/op-stack/overview/page.mdx b/app/docs/build-with-avail/deploy-rollup-on-avail/Optimium/op-stack/overview/page.mdx
index 36a15a64a..0c463c123 100644
--- a/app/docs/build-with-avail/deploy-rollup-on-avail/Optimium/op-stack/overview/page.mdx
+++ b/app/docs/build-with-avail/deploy-rollup-on-avail/Optimium/op-stack/overview/page.mdx
@@ -1,5 +1,4 @@
---
-image: "/img/docs-link-preview.png"
id: overview
title: Building on the OP Stack with Avail
sidebar_label: Overview
@@ -11,6 +10,7 @@ keywords:
- build
- data availability
- da
+image: https://docs.availproject.org/img/avail/AvailDocs.png
---
# Building on the OP Stack with Avail
diff --git a/app/docs/build-with-avail/deploy-rollup-on-avail/Optimium/op-stack/page.mdx b/app/docs/build-with-avail/deploy-rollup-on-avail/Optimium/op-stack/page.mdx
index 33312a67f..351f0992a 100644
--- a/app/docs/build-with-avail/deploy-rollup-on-avail/Optimium/op-stack/page.mdx
+++ b/app/docs/build-with-avail/deploy-rollup-on-avail/Optimium/op-stack/page.mdx
@@ -1,5 +1,4 @@
---
-image: "/img/docs-link-preview.png"
title: OP Stack
asIndexPage: true
---
@@ -49,4 +48,4 @@ Get started with building your Avail-powered OP Stack chain today.
} title="Transaction Lifecycle" href="/docs/build-with-avail/Optimium/op-stack/overview" />
} title="Avail-Powered Optimium (OP Stack)" href="/docs/build-with-avail/Optimium/op-stack/op-stack" />
} title="OP Stack Adapter" href="/availproject/avail-op-stack-adapter" />
-
+
\ No newline at end of file
diff --git a/app/docs/build-with-avail/deploy-rollup-on-avail/Optimium/page.mdx b/app/docs/build-with-avail/deploy-rollup-on-avail/Optimium/page.mdx
index e66303779..1d278d1d0 100644
--- a/app/docs/build-with-avail/deploy-rollup-on-avail/Optimium/page.mdx
+++ b/app/docs/build-with-avail/deploy-rollup-on-avail/Optimium/page.mdx
@@ -1,5 +1,4 @@
---
-image: "/img/docs-link-preview.png"
title: Optimium
asIndexPage: true
---
diff --git a/app/docs/build-with-avail/deploy-rollup-on-avail/Validium/_meta.ts b/app/docs/build-with-avail/deploy-rollup-on-avail/Validium/_meta.ts
index ef7b2a5e3..5e6041233 100644
--- a/app/docs/build-with-avail/deploy-rollup-on-avail/Validium/_meta.ts
+++ b/app/docs/build-with-avail/deploy-rollup-on-avail/Validium/_meta.ts
@@ -1,6 +1,5 @@
export default {
"zkevm": "Polygon zkEVM",
- "cdk": "Polygon CDK",
"madara": "Madara Starknet",
"zksync": "ZKsync's ZK Stack"
}
\ No newline at end of file
diff --git a/app/docs/build-with-avail/deploy-rollup-on-avail/Validium/cdk/_meta.ts b/app/docs/build-with-avail/deploy-rollup-on-avail/Validium/cdk/_meta.ts
deleted file mode 100644
index 6e838ebb4..000000000
--- a/app/docs/build-with-avail/deploy-rollup-on-avail/Validium/cdk/_meta.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-export default {
- "cdk": "Avail-Powered Polygon CDK"
-}
\ No newline at end of file
diff --git a/app/docs/build-with-avail/deploy-rollup-on-avail/Validium/cdk/cdk/page.mdx b/app/docs/build-with-avail/deploy-rollup-on-avail/Validium/cdk/cdk/page.mdx
deleted file mode 100644
index 13ad8e883..000000000
--- a/app/docs/build-with-avail/deploy-rollup-on-avail/Validium/cdk/cdk/page.mdx
+++ /dev/null
@@ -1,255 +0,0 @@
----
-# image: "/img/docs-link-preview.png"
-id: cdk
-title: Deploy a Polygon cdk Validium with Avail DA
-sidebar_label: Deploy a Polygon cdk Validium with Avail DA
-description: 'Discover how to utilize Avail as a data availability layer.'
-keywords:
- - documentation
- - avail
- - develop
- - build
- - data availability
- - da
- - cdk
- - polygon
- - validium
----
-import { Tabs } from 'nextra/components'
-import { Callout } from 'nextra/components'
-import { SyncedTabsProvider, SyncedTabs } from '@components/SyncedTabs'
-
-# Deploy a CDK chain with Avail DA
-
-## Introduction
-
-In this guide, we will walk you through the process of deploying a Polygon CDK Validium chain using Avail as the data availability layer. This setup allows you to leverage the scalability and security of Avail for your rollup.
-
-By following this guide, you will learn how to launch a CDK chain on Local or Sepolia testnet, configure it to use Avail for data availability, and interact with your rollup.
-
-- [Learn more about Polygon CDK](https://docs.polygon.technology/cdk/getting-started/local-deployment/)
-
-In this guide, we will cover:
-
-- [Deploying CDK with AvailDA on local](#deploying-cdk-with-availda-on-local)
-- [Deploying CDK with AvailDA on Sepolia](#deploying-cdk-with-availda-on-sepolia)
-
-## Prerequisites:
-
-- CPU: 4 CPUs, amd64
-- Memory: 32 GB
-- Storage: 100 GB
-- OS: Linux
-
-| Software | Version |
-| ------------------------------------------------------ | ------------------ |
-| [**Git**](https://git-scm.com/) | OS Default |
-| [**Docker**](https://www.docker.com/) | Latest |
-| [**Docker Compose**](https://docs.docker.com/compose/) | Latest |
-| [**Kurtosis**](https://docs.kurtosis.com/install/) | Latest |
-| [**GO**](https://go.dev/doc/install) | Latest |
-| [**Make**](https://www.gnu.org/software/make/) | OS Default |
-| [**Polygon-cli**](https://github.com/0xPolygon/polygon-cli) | Latest |
-| [**Foundry**](https://book.getfoundry.sh/getting-started/installation) | Latest |
-
-
-After executing the following commands you will have installed all the prerequisites needed.
-
-
-## Deploying CDK with AvailDA on Local
-
-### 1. Build CDK image
-
-[CDK](https://github.com/availproject/cdk) is a modular framework to build and deploy ZKP enabled rollups and validiums. This framework allows you to build a rollup or validium chain with a few simple commands, which is verifiable using zkEVM prover from Polygon.
-
-```bash
-git clone https://github.com/availproject/cdk.git
-cd cdk
-git checkout avail-develop-v0.5.3-rc1
-make build-docker
-docker tag cdk availproject/cdk:avail-develop-v0.5.3-rc1
-```
-
-### 2. Build [cdk-zkevm-contracts](https://github.com/availproject/cdk-zkevm-contracts) image with mock AvailDABridge and proof verification
-
-```bash
-git clone https://github.com/availproject/kurtosis-cdk.git
-cd kurtosis-cdk/docker
-git checkout avail-develop-v0.3.4
-docker build . \
- --tag availproject/cdk-zkevm-contracts:avail-develop-v9.0.0-rc.6-pp-fork.12 \
- --build-arg ZKEVM_CONTRACTS_BRANCH=mock-bridge-avail-develop-v9.0.0-rc.6-pp \
- --build-arg POLYCLI_VERSION="v0.1.73" \
- --build-arg FOUNDRY_VERSION=stable \
- --file zkevm-contracts.Dockerfile
-```
-
-### 3. Add AvailDA config values in `cdk-node-config.toml`
-
-```bash
-cd kurtosis-cdk/templates/trusted-node
-vim cdk-node-config.toml
-```
-
-Enter your `Seed Phrase` and `appID`. Other information are prefilled for you.
-
-### 4. Run local CDK chain with AvailDA using Kurtosis-cdk
-
-```bash
-cd kurtosis-cdk
-kurtosis run --enclave cdk .
-```
-This command will start a local CDK chain with Avail as the data availability layer. It will take a few minutes to initialize the chain and all the services.
-
-### 5. Chain is up and running
-
-Now you should have a local CDK chain with AvailDA up and running. Try interacting with it as defined in these [docs](https://docs.polygon.technology/cdk/getting-started/local-deployment/#interacting-with-the-chain).
-
-Some useful examples to interact with the chain can be Read/write opertations.
-
-1. First export the RPC URL of your L2 to an environment variable called `ETH_RPC_URL`:
-```bash
-export ETH_RPC_URL="$(kurtosis port print cdk cdk-erigon-sequencer-001 rpc)"
-```
-
-2. Use `cast` to view information about the chain:
-```bash
-cast block-number
-```
-
-3. To View the balance of a pre-funded admin account:
-```bash
-cast balance --ether 0xE34aaF64b29273B7D567FCFc40544c014EEe9970
-```
-
-To check Avail Logs of `cdk-node-001`, use `kurtosis service logs -f `
-
-## Deploying CDK with AvailDA on Sepolia
-
-### 1. Build CDK image
-
-[CDK](https://github.com/availproject/cdk) is a modular framework to build and deploy ZKP enabled rollups and validiums. This framework allows you to build a rollup or validium chain with a few simple commands, which is verifiable using zkEVM prover from Polygon.
-
-```bash
-git clone https://github.com/availproject/cdk.git
-git checkout avail-develop-v0.5.3-rc1
-make build-docker
-docker tag cdk availproject/cdk:avail-develop-v0.5.3-rc1
-```
-
-### 2. Build [cdk-zkevm-contracts](https://github.com/availproject/cdk-zkevm-contracts) image with Sepolia AvailDABridge and proof verification
-
-```bash
-git clone https://github.com/availproject/kurtosis-cdk.git
-git checkout avail-develop-v0.3.4
-cd kurtosis-cdk/docker
-docker build . \
- --tag availproject/cdk-zkevm-contracts:avail-develop-v9.0.0-rc.6-pp-fork.12 \
- --build-arg ZKEVM_CONTRACTS_BRANCH=avail-develop-v9.0.0-rc.6-pp \
- --build-arg POLYCLI_VERSION="v0.1.73" \
- --build-arg FOUNDRY_VERSION=stable \
- --file zkevm-contracts.Dockerfile
-```
-
-### 3. Modify Deployment scalability
-
-In order to deploy on Sepolia, you need to change the [salt](https://github.com/availproject/kurtosis-cdk/blob/avail-develop-v0.2.29/templates/contract-deploy/deploy_parameters.json#L12) value to avoid a deployment failure. This can be done easily by running this script in `kurtosis-cdk`:
-
-```bash
-if sed --version 2>/dev/null | grep -q GNU; then
- sed -i 's/"salt": "0x.*",/"salt": "0x'$(xxd -p < /dev/random | tr -d "\n" | head -c 64)'",/' templates/contract-deploy/deploy_parameters.json
-else
- sed -i '' 's/"salt": "0x.*",/"salt": "0x'$(xxd -p < /dev/random | tr -d "\n" | head -c 64)'",/' templates/contract-deploy/deploy_parameters.json
-fi
-```
-
-### 4. Change Finality Time for erigon
-
-We also need to change the finality time for the Erigon node to avoid any waiting time for the contracts deployment to finalize. This can be achieved by using this small snippet of code:
-
-```bash
-if sed --version 2>/dev/null | grep -q GNU; then
- sed -i 's/zkevm.l1-highest-block-type: finalized/zkevm.l1-highest-block-type: latest/' templates/cdk-erigon/config.yml
-else
- sed -i '' 's/zkevm.l1-highest-block-type: finalized/zkevm.l1-highest-block-type: latest/' templates/cdk-erigon/config.yml
-fi
-```
-### 5. Deploy CDK to Sepolia file
-
-You need to have a file from Kurtosis-cdk to deploy to Sepolia. Copy the file `deploy-cdk-to-sepolia.yml` from `/kurtosis-cdk/.github/tests/external-l1/deploy-cdk-to-sepolia.yml` or this [link](https://github.com/0xPolygon/kurtosis-cdk/blob/v0.2.29/.github/tests/external-l1/deploy-cdk-to-sepolia.yml). Name this file as `params.yml` in your cdk directory.
-
-Now you need to set necessary configs for deploying to Sepolia. You can do this by running the following command L1 Configs:
-
-```bash
-## L1 Config
-l1_chain_id: 11155111
-# TODO: Create another mnemonic seed phrase for running the contract deployment on L1.
-l1_preallocated_mnemonic: CHANGE_ME
-# TODO: Adjust the amount of ETH you want to spend on this deployment.
-l1_funding_amount: 5ether
-# TODO: Configure the L1 RPC URLs to be valid Sepolia endpoints.
-l1_rpc_url: CHANGE_ME
-l1_ws_url: CHANGE_ME
-```
-In order to Derive application keys, you can use the following command:
-
-```bash
-seed="film crazy inform bind stomach weather cruel hold quarter stage country purpose"
-polycli wallet inspect --mnemonic "$seed" --addresses 9 | \
-jq -r '.Addresses[] | [.ETHAddress, .HexPrivateKey] | @tsv' | \
-awk 'BEGIN{split("sequencer,aggregator,claimtxmanager,timelock,admin,loadtest,agglayer,dac,proofsigner",roles,",")} {print "zkevm_l2_" roles[NR] "address: \"" $1 "\""; print "zkevm_l2" roles[NR] "_private_key: \"0x" $2 "\"\n"}'
-```
-
-### 6. Add AvailDA config values in `cdk-node-config.toml`
-
-```bash
-cd kurtosis-cdk/templates/trusted-node
-vim cdk-node-config.toml
-```
-
-Enter your `Seed Phrase` and `appID`. Other information are prefilled for you.
-
-### 7. Run deployment to Sepolia with AvailDA using Kurtosis-cdk
-
-```bash
-cd kurtosis-cdk
-kurtosis run --enclave cdk . --args-file ./params.yml
-```
-
-### 8. Chain is up and running
-
-Now you should have a CDK chain with AvailDA deployed on Sepolia. You can interact with it using the same methods as mentioned in the local deployment section.
-Try interacting with it as defined in these [docs](https://docs.polygon.technology/cdk/getting-started/local-deployment/#interacting-with-the-chain).
-
-Congratulations! You have successfully deployed a Polygon CDK Validium chain with AvailDA on Local & Sepolia. For anymore information on CDK, you can refer to the [Polygon CDK documentation](https://docs.polygon.technology/cdk/getting-started/local-deployment/).
-
-
-## Enable DA attestation verification over Avail Bridge (optional)
-
-The default depolyment of Polygon CDK validium chain using AvailDA, is with DA attestation verfication disabled over [AvailAttestation](https://github.com/availproject/cdk-zkevm-contracts/blob/avail-develop-v9.0.0-rc.6-pp/contracts/v2/consensus/validium/AvailAttestation.sol#L38)
-
-To learn more about DA attestation verification, follow [this](https://docs.availproject.org/docs/build-with-avail/vectorx)
-
-To enable the verification, follow these steps
-
-### 1. Enable the bridge verification on CDK node
-
-There is a config called `bridge_enabled` in `kurtosis-cdk/templates/trusted-node` for sequencer-sender and aggregator component of CDK, Make it `true`
-
-### 2. Enable the bridge verfication on `AvailAttestation` contract
-
-```bash
-cast send "setAvailBridgeVerificationEnabled(bool)" true \
---private-key \
---rpc-url https://sepolia.drpc.org
-```
-
-
-This feature is available for both local and Sepolia deployement, and have these same steps to follow
-
-
-Now you will able to see the DA attestation verification happening over the Polygon CDK chain.
-
-
-
-Congratulations! You have successfully deployed a Polygon CDK Validium chain with AvailDA on Local & Sepolia. For anymore information on CDK, you can refer to the Polygon CDK documentation
\ No newline at end of file
diff --git a/app/docs/build-with-avail/deploy-rollup-on-avail/Validium/cdk/page.mdx b/app/docs/build-with-avail/deploy-rollup-on-avail/Validium/cdk/page.mdx
deleted file mode 100644
index 1155b569d..000000000
--- a/app/docs/build-with-avail/deploy-rollup-on-avail/Validium/cdk/page.mdx
+++ /dev/null
@@ -1,14 +0,0 @@
----
-image: "/img/docs-link-preview.png"
-title: Polygon CDK
-asIndexPage: true
----
-
-import { Cards } from 'nextra/components'
-import { FileIcon } from '@components/icons'
-
-# ZKsync's ZK Stack
-
-
- } title="Deploy a Polygon cdk Validium with Avail DA" href="/docs/build-with-avail/deploy-rollup-on-avail/Validium/cdk/cdk" />
-
diff --git a/app/docs/build-with-avail/deploy-rollup-on-avail/Validium/madara/madara/page.mdx b/app/docs/build-with-avail/deploy-rollup-on-avail/Validium/madara/madara/page.mdx
index f6eab6580..9d55c9ef4 100644
--- a/app/docs/build-with-avail/deploy-rollup-on-avail/Validium/madara/madara/page.mdx
+++ b/app/docs/build-with-avail/deploy-rollup-on-avail/Validium/madara/madara/page.mdx
@@ -1,5 +1,4 @@
---
-image: "/img/docs-link-preview.png"
id: madara
title: How to Use Madara with Avail
sidebar_label: Avail-Powered Madara Validium
@@ -11,6 +10,7 @@ keywords:
- build
- data availability
- da
+image: https://docs.availproject.org/img/avail/AvailDocs.png
---
import { Callout } from 'nextra/components'
@@ -157,4 +157,4 @@ The storage requirements can vary based on the volume of transactions and the le
Remember to adjust the `da-config.json` file based on your setup, whether it's a local node or using the Avail network.
-
+
\ No newline at end of file
diff --git a/app/docs/build-with-avail/deploy-rollup-on-avail/Validium/madara/overview/page.mdx b/app/docs/build-with-avail/deploy-rollup-on-avail/Validium/madara/overview/page.mdx
index fffe8ddcf..94a70f9d6 100644
--- a/app/docs/build-with-avail/deploy-rollup-on-avail/Validium/madara/overview/page.mdx
+++ b/app/docs/build-with-avail/deploy-rollup-on-avail/Validium/madara/overview/page.mdx
@@ -1,5 +1,4 @@
---
-image: "/img/docs-link-preview.png"
id: overview
title: Building on the Madara Stack with Avail
sidebar_label: Overview
@@ -11,6 +10,7 @@ keywords:
- build
- data availability
- da
+image: https://docs.availproject.org/img/avail/AvailDocs.png
---
# Building on the Madara Stack with Avail
diff --git a/app/docs/build-with-avail/deploy-rollup-on-avail/Validium/madara/page.mdx b/app/docs/build-with-avail/deploy-rollup-on-avail/Validium/madara/page.mdx
index a1439824f..3e6262fe2 100644
--- a/app/docs/build-with-avail/deploy-rollup-on-avail/Validium/madara/page.mdx
+++ b/app/docs/build-with-avail/deploy-rollup-on-avail/Validium/madara/page.mdx
@@ -1,5 +1,4 @@
---
-image: "/img/docs-link-preview.png"
title: Madara Starknet
asIndexPage: true
---
@@ -13,4 +12,4 @@ import { FileIcon, FilesIcon } from '@components/icons'
} title="Overview" href="/docs/build-with-avail/deploy-rollup-on-avail/Validium/madara/overview" />
} title="Avail-Powered Madara Validium" href="/docs/build-with-avail/deploy-rollup-on-avail/Validium/madara/madara" />
} title="Madara Starknet" href="/madara-alliance/madara" />
-
+
\ No newline at end of file
diff --git a/app/docs/build-with-avail/deploy-rollup-on-avail/Validium/page.mdx b/app/docs/build-with-avail/deploy-rollup-on-avail/Validium/page.mdx
index 5ec29a2ee..da73a7678 100644
--- a/app/docs/build-with-avail/deploy-rollup-on-avail/Validium/page.mdx
+++ b/app/docs/build-with-avail/deploy-rollup-on-avail/Validium/page.mdx
@@ -1,5 +1,4 @@
---
-image: "/img/docs-link-preview.png"
title: Validium
asIndexPage: true
---
@@ -11,7 +10,6 @@ import { FileIcon, FilesIcon } from '@components/icons'
} title="Polygon zkEVM" href="/docs/build-with-avail/deploy-rollup-on-avail/Validium/zkevm" />
- } title="Polygon CDK" href="/docs/build-with-avail/deploy-rollup-on-avail/Validium/cdk" />
} title="Madara Starknet" href="/docs/build-with-avail/deploy-rollup-on-avail/Validium/madara" />
} title="ZKsync's ZK Stack" href="/docs/build-with-avail/deploy-rollup-on-avail/Validium/zksync" />
-
+
\ No newline at end of file
diff --git a/app/docs/build-with-avail/deploy-rollup-on-avail/Validium/zkevm/overview/page.mdx b/app/docs/build-with-avail/deploy-rollup-on-avail/Validium/zkevm/overview/page.mdx
index 5c105ffe4..7243850f2 100644
--- a/app/docs/build-with-avail/deploy-rollup-on-avail/Validium/zkevm/overview/page.mdx
+++ b/app/docs/build-with-avail/deploy-rollup-on-avail/Validium/zkevm/overview/page.mdx
@@ -1,5 +1,4 @@
---
-image: "/img/docs-link-preview.png"
id: overview
title: Building on the Polygon zkEVM with Avail
sidebar_label: Overview
@@ -11,6 +10,7 @@ keywords:
- build
- data availability
- da
+image: https://docs.availproject.org/img/avail/AvailDocs.png
---
# Building on the Polygon zkEVM with Avail
diff --git a/app/docs/build-with-avail/deploy-rollup-on-avail/Validium/zkevm/page.mdx b/app/docs/build-with-avail/deploy-rollup-on-avail/Validium/zkevm/page.mdx
index 481119d34..615fdf644 100644
--- a/app/docs/build-with-avail/deploy-rollup-on-avail/Validium/zkevm/page.mdx
+++ b/app/docs/build-with-avail/deploy-rollup-on-avail/Validium/zkevm/page.mdx
@@ -1,5 +1,4 @@
---
-image: "/img/docs-link-preview.png"
title: Polygon zkEVM
asIndexPage: true
---
@@ -15,4 +14,4 @@ import { FileIcon, LinkIcon } from '@components/icons'
} title="Validium Node" href="/availproject/validium-node" />
} title="Validium Contracts" href="/availproject/validium-contracts" />
} title="Validium Bridge" href="/availproject/validium-bridge-service" />
-
+
\ No newline at end of file
diff --git a/app/docs/build-with-avail/deploy-rollup-on-avail/Validium/zkevm/zkevm/page.mdx b/app/docs/build-with-avail/deploy-rollup-on-avail/Validium/zkevm/zkevm/page.mdx
index 5b7cd7026..a22309e39 100644
--- a/app/docs/build-with-avail/deploy-rollup-on-avail/Validium/zkevm/zkevm/page.mdx
+++ b/app/docs/build-with-avail/deploy-rollup-on-avail/Validium/zkevm/zkevm/page.mdx
@@ -1,5 +1,4 @@
---
-image: "/img/docs-link-preview.png"
id: zkevm
filename: How to Use Polygon zkEVM with Avail
sidebar_label: Avail-Powered zkEVM Validium
@@ -11,6 +10,7 @@ keywords:
- build
- data availability
- da
+image: https://docs.availproject.org/img/avail/AvailDocs.png
---
import { Callout } from 'nextra/components'
@@ -559,4 +559,4 @@ The zkEVM bridge service is a microservice that simplifies bridging between L1 a
- **Generate Merkle Proofs**: Use the /merkle-proof endpoint to generate the necessary Merkle proofs for bridging transactions.
- **Additional Endpoints**: The microservice provides other endpoints for various functionalities, such as detecting bridge transactions for specific accounts.
- - **Updating Code**: If you need to modify any part of the code, remember that each change necessitates a new build. To update and rerun the service, execute the `make build-docker && make run` commands.
+ - **Updating Code**: If you need to modify any part of the code, remember that each change necessitates a new build. To update and rerun the service, execute the `make build-docker && make run` commands.
\ No newline at end of file
diff --git a/app/docs/build-with-avail/deploy-rollup-on-avail/Validium/zksync/page.mdx b/app/docs/build-with-avail/deploy-rollup-on-avail/Validium/zksync/page.mdx
index 73999ec14..2efe8d369 100644
--- a/app/docs/build-with-avail/deploy-rollup-on-avail/Validium/zksync/page.mdx
+++ b/app/docs/build-with-avail/deploy-rollup-on-avail/Validium/zksync/page.mdx
@@ -1,5 +1,4 @@
---
-image: "/img/docs-link-preview.png"
title: ZKsync's ZK Stack
asIndexPage: true
---
@@ -11,4 +10,4 @@ import { FileIcon } from '@components/icons'
} title="Deploy an Avail-powered ZK Stack Validium" href="/docs/build-with-avail/deploy-rollup-on-avail/Validium/zksync/zksync" />
-
+
\ No newline at end of file
diff --git a/app/docs/build-with-avail/deploy-rollup-on-avail/Validium/zksync/zksync/page.mdx b/app/docs/build-with-avail/deploy-rollup-on-avail/Validium/zksync/zksync/page.mdx
index 9e6871419..63b330aa6 100644
--- a/app/docs/build-with-avail/deploy-rollup-on-avail/Validium/zksync/zksync/page.mdx
+++ b/app/docs/build-with-avail/deploy-rollup-on-avail/Validium/zksync/zksync/page.mdx
@@ -1,5 +1,4 @@
---
-image: "/img/docs-link-preview.png"
id: zksync
title: Deploy a ZK Stack Validium with Avail DA
sidebar_label: Deploy a ZK Stack Validium with Avail DA
@@ -14,6 +13,7 @@ keywords:
- zksync
- zkstack
- validium
+image: https://docs.availproject.org/img/avail/AvailDocs.png
---
import { Tabs } from 'nextra/components'
import { Callout } from 'nextra/components'
@@ -238,7 +238,7 @@ The gas relay API is in ***private beta***. Using the gas relay allows you to po
bridge_api_url: https://turing-bridge-api.avail.so
timeout_ms: 7200000
gas_relay:
- gas_relay_api_url: https://https://staging.turbo-api.availproject.org
+ gas_relay_api_url: https://turing.turbo-api.availproject.org
max_retries: 3
```
@@ -273,4 +273,4 @@ Start the server which will be running the ZK chain. By default, it will be runn
zkstack server --chain $CHAIN_NAME
```
-Your ZK chain is now running and you can start using it. For any troubleshooting or issues, please refer to the original repository which you can find [here](https://docs.zksync.io/zk-stack/running-a-zk-chain/quickstart).
+Your ZK chain is now running and you can start using it. For any troubleshooting or issues, please refer to the original repository which you can find [here](https://docs.zksync.io/zk-stack/running-a-zk-chain/quickstart).
\ No newline at end of file
diff --git a/app/docs/build-with-avail/deploy-rollup-on-avail/page.mdx b/app/docs/build-with-avail/deploy-rollup-on-avail/page.mdx
index edfc82de0..5d8a869b7 100644
--- a/app/docs/build-with-avail/deploy-rollup-on-avail/page.mdx
+++ b/app/docs/build-with-avail/deploy-rollup-on-avail/page.mdx
@@ -1,5 +1,4 @@
---
-image: "/img/docs-link-preview.png"
title: Deploy a Rollup on Avail DA
asIndexPage: true
---
@@ -15,4 +14,4 @@ import { FileIcon, FilesIcon } from '@components/icons'
} title="Validium" href="/docs/build-with-avail/deploy-rollup-on-avail/Validium" />
} title="Sovereign Rollups" href="/docs/build-with-avail/deploy-rollup-on-avail/sovereign-rollups" />
-
+
\ No newline at end of file
diff --git a/app/docs/build-with-avail/deploy-rollup-on-avail/sovereign-rollups/cosmos-avail-module/page.mdx b/app/docs/build-with-avail/deploy-rollup-on-avail/sovereign-rollups/cosmos-avail-module/page.mdx
index 09d71bfdb..4bf5dc238 100644
--- a/app/docs/build-with-avail/deploy-rollup-on-avail/sovereign-rollups/cosmos-avail-module/page.mdx
+++ b/app/docs/build-with-avail/deploy-rollup-on-avail/sovereign-rollups/cosmos-avail-module/page.mdx
@@ -148,4 +148,3 @@ The **Cosmos Provider** is responsible for fetching block data via RPC so that t
- In case of failure at any stage, the whole flow will be repeated.
---
-image: "/img/docs-link-preview.png"
diff --git a/app/docs/build-with-avail/deploy-rollup-on-avail/sovereign-rollups/page.mdx b/app/docs/build-with-avail/deploy-rollup-on-avail/sovereign-rollups/page.mdx
index 1b955580c..ed981760e 100644
--- a/app/docs/build-with-avail/deploy-rollup-on-avail/sovereign-rollups/page.mdx
+++ b/app/docs/build-with-avail/deploy-rollup-on-avail/sovereign-rollups/page.mdx
@@ -1,5 +1,4 @@
---
-image: "/img/docs-link-preview.png"
title: Deploy a Sovereign Rollup on Avail DA
asIndexPage: true
---
diff --git a/app/docs/build-with-avail/interact-with-avail-da/app-id/page.mdx b/app/docs/build-with-avail/interact-with-avail-da/app-id/page.mdx
index aed9cfc63..df523e8e6 100644
--- a/app/docs/build-with-avail/interact-with-avail-da/app-id/page.mdx
+++ b/app/docs/build-with-avail/interact-with-avail-da/app-id/page.mdx
@@ -1,5 +1,4 @@
---
-image: "/img/docs-link-preview.png"
id: app-ids
title: How to register your own `AppID` on Avail DA?
sidebar_label: Create an AppId
@@ -11,6 +10,7 @@ keywords:
- appid
- app
- transaction
+image: https://docs.availproject.org/img/avail/AvailDocs.png
---
import { Callout, Steps, Tabs } from 'nextra/components'
@@ -71,4 +71,4 @@ If you don't have an Avail DA wallet, you can follow our docs on [setting up a n
1. As stated earlier, the `key` and `id` fields of every `AppID` are unique. This means if you try to create an `AppID` with the same `key` as an existing one,
the operation will fail.
-2. If you're a developer and are looking for more programmatic instructions, you can check out our [API reference](/api-reference/avail-node-api/da-create-application-key).
+2. If you're a developer and are looking for more programmatic instructions, you can check out our [API reference](/api-reference/avail-node-api/da-create-application-key).
\ No newline at end of file
diff --git a/app/docs/build-with-avail/interact-with-avail-da/faucet/page.mdx b/app/docs/build-with-avail/interact-with-avail-da/faucet/page.mdx
index d0e38f66c..fe888cf9a 100644
--- a/app/docs/build-with-avail/interact-with-avail-da/faucet/page.mdx
+++ b/app/docs/build-with-avail/interact-with-avail-da/faucet/page.mdx
@@ -1,5 +1,4 @@
---
-image: "/img/docs-link-preview.png"
id: faucet
title: How to Use the Testnet Faucet
sidebar_label: Get Testnet Tokens
@@ -11,6 +10,7 @@ keywords:
- accounts
- faucet
- funding
+image: https://docs.availproject.org/img/avail/AvailDocs.png
---
import { Callout } from 'nextra/components'
import Image from 'next/image'
diff --git a/app/docs/build-with-avail/interact-with-avail-da/page.mdx b/app/docs/build-with-avail/interact-with-avail-da/page.mdx
index 88c69eea6..39164d705 100644
--- a/app/docs/build-with-avail/interact-with-avail-da/page.mdx
+++ b/app/docs/build-with-avail/interact-with-avail-da/page.mdx
@@ -1,5 +1,4 @@
---
-image: "/img/docs-link-preview.png"
title: Interact Directly with Avail DA
asIndexPage: true
---
@@ -17,4 +16,4 @@ import { FileIcon, FilesIcon } from '@components/icons'
} title="Query Balances on Avail DA" href="/docs/build-with-avail/interact-with-avail-da/query-balances" />
} title="Transfer Balances on Avail DA" href="/docs/build-with-avail/interact-with-avail-da/transfer-balances" />
-
+
\ No newline at end of file
diff --git a/app/docs/build-with-avail/interact-with-avail-da/query-balances/page.mdx b/app/docs/build-with-avail/interact-with-avail-da/query-balances/page.mdx
index e175e13f8..1d51b4fc0 100644
--- a/app/docs/build-with-avail/interact-with-avail-da/query-balances/page.mdx
+++ b/app/docs/build-with-avail/interact-with-avail-da/query-balances/page.mdx
@@ -1,7 +1,3 @@
----
-image: '/img/docs-link-preview.png'
----
-
import { Callout, Steps, Tabs } from 'nextra/components'
# Query balances on Avail DA
@@ -20,50 +16,29 @@ To query basic information about an account, including it's balance, you need to
1. Inside `your-file-name.ts`, add the following code:
-```typescript showLineNumbers filename="avail-js" name="cmd1"
-import * as dotenv from 'dotenv';
-import { SDK, Pallets } from 'avail-js-sdk';
-
-dotenv.config();
-
-export async function getAccountBalance() {
- // Initialize SDK with Turing endpoint
- const sdk = await SDK.New('wss://turing-rpc.avail.so/ws');
-
- // Address to check balance for
- const address = "5DDY2yzh8uCysYFAiRSTeQVwtZSKNF49CkQkyPH852xvrYKk";
- console.log(`Checking balance for address: ${address}`);
-
- // Get the current block hash
- const blockHash = await sdk.client.bestBlockHash();
-
- // Get storage at the current block
- const storageAt = await sdk.client.storageAt(blockHash);
-
- // Fetch account information
- const accountInfo = await Pallets.SystemStorage.Account.fetch(storageAt, address);
-
- // Format balances in AVAIL (dividing by 10^18)
- const free = accountInfo.value.accountData.free.toString();
- const reserved = accountInfo.value.accountData.reserved.toString();
- const frozen = accountInfo.value.accountData.frozen.toString();
-
- console.log("The following balances are in the smallest units, divide by 10^18 to get the balance in AVAIL");
- console.log(`Free Balance: ${free}`);
- console.log(`Reserved Balance: ${reserved}`);
- console.log(`Frozen Balance: ${frozen}`);
- console.log("Account information fetched successfully");
-
- process.exit(0);
+```typescript showLineNumbers filename="avail-js"
+import { SDK } from "avail-js-sdk"
+
+const main = async () => {
+ const providerEndpoint = "wss://turing-rpc.avail.so/ws"
+ const sdk = await SDK.New(providerEndpoint)
+
+ const key = "5DDY2yzh8uCysYFAiRSTeQVwtZSKNF49CkQkyPH852xvrYKk"
+ const value: any = await sdk.api.query.system.account(key)
+
+ console.log(value.toHuman())
+ const freeBalanceInAvail = Number(value.data.free.toString()) / Math.pow(10, 18)
+ console.log(`Free balance: ${freeBalanceInAvail} AVAIL`)
+
+ process.exit()
}
-
-// Execute the function
-getAccountBalance();
+
+main()
```
2. Run the code using:
-```bash filename="terminal" name="cmd2"
+```bash
ts-node your-file-name.ts
```
@@ -71,48 +46,41 @@ ts-node your-file-name.ts
1. Inside `main.rs`, add the following code:
-```rust showLineNumbers filename="avail-rust" name="cmd3"
-use avail_rust::prelude::*;
+```rust showLineNumbers filename="avail-rust" showLineNumbers filename="avail-rust"
+use avail_rust::{avail, AccountId, SDK};
use core::str::FromStr;
-pub async fn system_account() -> Result<(), ClientError> {
-
- // Create a new SDK instance
- let sdk = SDK::new("wss://turing-rpc.avail.so/ws").await?;
-
- let account_id = AccountId::from_str("5CqgQkrDcdg5QrtuxT3H7WszrqgrBMhdwRbmMVXQzc4VSiEg").unwrap();
+#[tokio::main]
+async fn main() -> Result<(), String> {
+ let sdk = SDK::new("wss://turing-rpc.avail.so/ws").await.unwrap();
- let block_hash = sdk.client.best_block_hash().await?;
- let storage = sdk.client.storage().at(block_hash);
- let address = avail::storage().system().account(account_id);
- let result = storage.fetch(&address).await?;
+ let account_id =
+ AccountId::from_str("5DDY2yzh8uCysYFAiRSTeQVwtZSKNF49CkQkyPH852xvrYKk").unwrap(); // Alice_Stash
- if let Some(account) = result {
- println!("Consumers: {}", account.consumers);
- println!("Data: {:?}", account.data);
- println!("Nonce: {}", account.nonce);
- println!("Providers: {}", account.providers);
- println!("Sufficients: {}", account.sufficients);
- }
+ let storage_query = avail::storage().system().account(account_id);
+ let best_block_hash = sdk
+ .rpc
+ .chain
+ .get_block_hash(None)
+ .await
+ .map_err(|e| e.to_string())?;
+ let result = sdk
+ .api
+ .storage()
+ .at(best_block_hash)
+ .fetch(&storage_query)
+ .await
+ .map_err(|e| e.to_string())?;
- Ok(())
-}
+ dbg!(result);
-// Add a main function to call system_account
-#[tokio::main]
-async fn main() {
- if let Err(e) = system_account().await {
- eprintln!("Error: {:?}", e);
- }
- else {
- println!("Account information fetched successfully");
- }
+ Ok(())
}
```
2. Run the code using:
-```bash filename="terminal" name="cmd4"
+```bash
cargo run
```
@@ -121,71 +89,65 @@ cargo run
1. Inside `main.go`, add the following code:
-```go showLineNumbers filename="avail-go" name="cmd5"
+```go showLineNumbers filename="avail-go"
package main
import (
"fmt"
- "log"
- prim "github.com/availproject/avail-go-sdk/primitives"
- "github.com/availproject/avail-go-sdk/sdk"
-
- syPallet "github.com/availproject/avail-go-sdk/metadata/pallets/system"
- "github.com/availproject/avail-go-sdk/primitives"
+ "github.com/availproject/avail-go-sdk/src/sdk"
+ "github.com/centrifuge/go-substrate-rpc-client/v4/types"
+ "github.com/vedhavyas/go-subkey/v2"
)
+// The following example shows how to connect to a node and display some basic information.
func main() {
+ api, err := sdk.NewSDK("wss://turing-rpc.avail.so/ws")
- // Initialize the SDK
- sdk, err := sdk.NewSDK("https://turing-rpc.avail.so/rpc")
if err != nil {
- log.Fatalf("Failed to initialize SDK: %v", err)
+ fmt.Printf("cannot create api:%v", err)
}
- // Get the latest block hash
- latestBlockHash, err := sdk.Client.BestBlockHash()
+ meta, err := api.RPC.State.GetMetadataLatest()
if err != nil {
- log.Fatalf("Failed to get latest block hash: %v", err)
+ panic(fmt.Sprintf("cannot get metadata:%v", err))
}
- // Initialize the block storage
- blockStorage, err := sdk.Client.StorageAt(prim.Some(latestBlockHash))
- if err != nil {
- log.Fatalf("Failed to get block storage: %v", err)
- }
+ address := "5DDY2yzh8uCysYFAiRSTeQVwtZSKNF49CkQkyPH852xvrYKk"
+ _, pubKey, err := subkey.SS58Decode(address)
- // Create the account ID
- accountId, err := primitives.NewAccountIdFromAddress("5DDY2yzh8uCysYFAiRSTeQVwtZSKNF49CkQkyPH852xvrYKk")
if err != nil {
- log.Fatalf("Failed to convert address: %v", err)
+ panic(fmt.Sprintf("Failed to decode SS58 address: %v", err))
}
- // Fetch the account data
- storage := syPallet.StorageAccount{}
- val, err := storage.Fetch(&blockStorage, accountId)
+ key, err := types.CreateStorageKey(meta, "System", "Account", pubKey, nil)
if err != nil {
- log.Fatalf("Failed to fetch account: %v", err)
+ panic(fmt.Sprintf("cannot create storage key:%v", err))
}
- // Log the account data
- fmt.Println("Free Balance: ", val.Value.AccountData.Free.ToHuman())
- fmt.Println("Reserved Balance: ", val.Value.AccountData.Reserved.ToHuman())
- fmt.Println("Frozen Balance: ", val.Value.AccountData.Frozen.ToHuman())
- fmt.Println("Account information fetched successfully")
+ var accountInfo types.AccountInfo
+ ok, err := api.RPC.State.GetStorageLatest(key, &accountInfo)
+ if err != nil || !ok {
+ panic(fmt.Sprintf("cannot get latest storage:%v", err))
+ }
+ fmt.Printf("Account info: %v\n", accountInfo)
+
+ freeBalance := new(big.Float).SetInt(accountInfo.Data.Free.Int)
+ freeBalance.Quo(freeBalance, big.NewFloat(1e18))
+ fmt.Printf("Free balance: %v AVAIL\n", freeBalance)
}
```
2. Run the code using:
-```bash filename="terminal" name="cmd6"
+```bash
go run main.go
```
If you receive errors related to missing dependencies while trying to execute your code, run:
-```bash filename="terminal" name="cmd7"
+```bash
go mod tidy
```
and try again.
@@ -223,7 +185,7 @@ pallet from the dropdown on the left, and the `account(AccountId32)` method from
Your response should look something like this:
-
+Sample Response:
```
{
@@ -240,219 +202,4 @@ Your response should look something like this:
}
Free balance: 28.3046577073 AVAIL
```
-
-
-
-## Fetch account information using a simple `curl` request via the Subscan API [#account-info-curl-command]
-
-1. The [Subscan API](https://support.subscan.io/) can be used to make API queries to the Subscan indexer to make various kinds of queries.
-2. Subscan supports a variety of Substrate-based chains, including Avail DA mainnet and the Turing testnet.
-3. You can either use their publicly available endpoints for the Avail networks, or use a [dedicated endpoint](https://pro.subscan.io/).
-4. The examples below use publicly available Subscan API endpoints for both networks.
-
-
-
-
-**You need to have [curl](https://curl.se/) installed to run the following examples.**
-
-
-
-1. Open a terminal and run the following command:
-
-```bash filename="terminal" name="cmd8"
-curl --location --request POST 'https://avail.api.subscan.io/api/v2/scan/search' \
---header 'Content-Type: application/json' \
---data-raw '{
- "key": ""
-}'
-```
-
-2. Replace `` with the address you want to query.
-
-
-
-Sample Response:
-```json filename="JSON response"
-{
- "code": 0,
- "message": "Success",
- "generated_at": 1741796675,
- "data": {
- "account": {
- "address": "5HbUMBK8SBKH22qrm2sRDtWNtfyT331tUHpKkFMUKyirkJ6G",
- "balance": "169389.0977233184983879",
- "lock": "168914.456888072538284769",
- "balance_lock": "168914.456888072538284769",
- "is_evm_contract": false,
- "account_display": {
- "address": "5HbUMBK8SBKH22qrm2sRDtWNtfyT331tUHpKkFMUKyirkJ6G"
- },
- "substrate_account": null,
- "evm_account": "",
- "registrar_info": null,
- "count_extrinsic": 0,
- "nft_amount": "0",
- "extra": null,
- "display": "",
- "web": "",
- "riot": "",
- "email": "",
- "legal": "",
- "twitter": "",
- "github": "",
- "matrix": "",
- "discord": "",
- "judgements": null,
- "reserved": "13000000000000000000",
- "bonded": "168914456888072538284769",
- "unbonding": "0",
- "democracy_lock": "0",
- "conviction_lock": "0",
- "election_lock": "0",
- "staking_info": null,
- "nonce": 0,
- "role": "validator",
- "stash": "5HbUMBK8SBKH22qrm2sRDtWNtfyT331tUHpKkFMUKyirkJ6G",
- "is_council_member": false,
- "is_techcomm_member": false,
- "is_registrar": false,
- "is_fellowship_member": false,
- "is_module_account": false,
- "assets_tag": null,
- "is_erc20": false,
- "is_erc721": false,
- "vesting": null,
- "proxy": {
- "proxy_account": [
- {
- "account_display": {
- "address": "5HmgLcTCi2trnz4AeEiWs4ngAjALu7o4mFnpKdMBnA8jhFnq"
- },
- "proxy_type": "Staking"
- }
- ]
- },
- "multisig": {
- "multi_account_member": [
- {
- "address": "5DfE73hjEYs44JHsuMKzrTMBzkEb6fosaV5xSUEVNjrHwqdB"
- },
- {
- "address": "5DtGLPULvxXoSPvVv2YZdWmCJy8eEYnWj7MwPpdwGgDnFiua"
- },
- {
- "address": "5DyHKiRY2ssTWU4CtbbEPoYFmNKaN2X39KRcgb33fnZqk2Yd"
- }
- ],
- "threshold": 2
- },
- "delegate": null
- }
- }
-}
-```
-
-
-
-
-
-1. Open a terminal and run the following command:
-
-```bash filename="terminal" name="cmd9"
-curl --location --request POST 'https://avail-turing.api.subscan.io/api/v2/scan/search' \
---header 'Content-Type: application/json' \
---data-raw '{
- "key": ""
-}'
-```
-
-2. Replace `` with the address you want to query.
-
-
-
-Sample Response:
-```json filename="JSON response"
-{
- "code": 0,
- "message": "Success",
- "generated_at": 1741798906,
- "data": {
- "account": {
- "address": "5DDY2yzh8uCysYFAiRSTeQVwtZSKNF49CkQkyPH852xvrYKk",
- "balance": "16360.7888064893714931",
- "lock": "1131.93873839810825155",
- "balance_lock": "1131.93873839810825155",
- "is_evm_contract": false,
- "account_display": {
- "address": "5DDY2yzh8uCysYFAiRSTeQVwtZSKNF49CkQkyPH852xvrYKk"
- },
- "substrate_account": null,
- "evm_account": "",
- "registrar_info": null,
- "count_extrinsic": 54,
- "nft_amount": "0",
- "extra": null,
- "display": "",
- "web": "",
- "riot": "",
- "email": "",
- "legal": "",
- "twitter": "",
- "github": "",
- "matrix": "",
- "discord": "",
- "judgements": null,
- "reserved": "15100000000000000000",
- "bonded": "1131938738398108251550",
- "unbonding": "0",
- "democracy_lock": "0",
- "conviction_lock": "0",
- "election_lock": "0",
- "staking_info": null,
- "nonce": 54,
- "role": "nominator",
- "stash": "5DDY2yzh8uCysYFAiRSTeQVwtZSKNF49CkQkyPH852xvrYKk",
- "is_council_member": false,
- "is_techcomm_member": false,
- "is_registrar": false,
- "is_fellowship_member": false,
- "is_module_account": false,
- "assets_tag": null,
- "is_erc20": false,
- "is_erc721": false,
- "is_pool_member": true,
- "vesting": null,
- "proxy": {
- "proxy_account": [
- {
- "account_display": {
- "address": "5GvF6GLPuxbseH5qC9w8doUiCMnT4vGvY3Rznu3Fktdw4N45"
- },
- "proxy_type": "NonTransfer"
- }
- ]
- },
- "multisig": {
- "multi_account": [
- {
- "address": "5DSCqHHH3whUA3xgkyVSekXB36Gc47SwsJEHLuab5RnFvNua"
- }
- ]
- },
- "delegate": null,
- "nomination_pool_balance": [
- {
- "pool_id": 3,
- "bonded": "100000000000000000000",
- "unbonding": "0",
- "claimable": "0"
- }
- ]
- }
- }
-}
-```
-
-
-
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/app/docs/build-with-avail/interact-with-avail-da/read-write-on-avail/page.mdx b/app/docs/build-with-avail/interact-with-avail-da/read-write-on-avail/page.mdx
index 40462524c..5a33cfb20 100644
--- a/app/docs/build-with-avail/interact-with-avail-da/read-write-on-avail/page.mdx
+++ b/app/docs/build-with-avail/interact-with-avail-da/read-write-on-avail/page.mdx
@@ -1,7 +1,3 @@
----
-image: '/img/docs-link-preview.png'
----
-
import { Callout, Steps, Tabs } from 'nextra/components'
# Read & Write data on Avail DA
@@ -25,159 +21,143 @@ To set up a dev environment for `avail-js`, please follow the steps [outlined he
-1. Create a file named `your-file-name.ts`
+1. Create a file named `submit-data.ts`
-2. Paste the following code into the file:
+2. Import the dependencies from `avail-js-sdk` and create a `main` function:
-This pice of code submits:
-- A string named `data` to Avail DA
-- to the `appID` of 89
-- We expect devs to submit data to their own specific `appID`s.
+```typescript showLineNumbers filename="avail-js"
-```typescript showLineNumbers filename="avail-js" name="cmd1"
-import * as dotenv from 'dotenv';
-import { Account, SDK, Pallets } from 'avail-js-sdk';
-
-dotenv.config();
-
-export async function submitData() {
+import { SDK, WaitFor, Keyring, TransactionOptions } from "avail-js-sdk"
+
+const main = async () => {
- // Initialize the SDK with a public Turing testnet endpoint
- // You can always switch it out with your own endpoint
- const sdk = await SDK.New('wss://turing-rpc.avail.so/ws');
-
- // Loading seed phrase and creating an account derived from the seed
- const seed = process.env.SEED;
- if (!seed) {
- throw new Error("SEED environment variable is not set");
- }
-
- // Create account from seed
- const account = Account.new(seed);
- console.log("Account Address: ", account.address);
-
- // Replace with your own AppID
- const appId = 89;
- console.log(`Submitting data to App Id: ${appId}`);
-
- // Create data submission transaction
- const data = "My Data Submission";
- const tx = sdk.tx.dataAvailability.submitData(data);
- console.log("Submitting transaction with data...");
-
- // Execute and wait for inclusion with app_id
- const res = await tx.executeWaitForInclusion(account, { app_id: appId });
-
- // Check if transaction was successful
- const isOk = res.isSuccessful();
- if (isOk === undefined) {
- throw new Error("Cannot check if transaction was successful");
- }
- else if (!isOk) {
- throw new Error("Transaction failed");
- }
-
- // Extract event data
- if (res.events === undefined) throw new Error("No events found");
-
- // Transaction Details
- console.log(
- `Block Hash: ${res.blockHash}, Block Number: ${res.blockNumber}, Tx Hash: ${res.txHash}, Tx Index: ${res.txIndex}`
- );
-
- // Find DataSubmitted event
- const event = res.events.findFirst(Pallets.DataAvailabilityEvents.DataSubmitted);
- if (event === undefined) throw new Error("DataSubmitted event not found");
-
- console.log(`Data submitted successfully:`);
- console.log(`Who: ${event.who}`);
- console.log(`DataHash: ${event.dataHash}`);
-
- console.log("Data submission completed successfully");
- process.exit(0);
}
-submitData()
+main()
```
-3. Run the script using the following command:
+3. Initialize a new instance of the SDK inside the `main` function:
-```bash filename="terminal" name="cmd2"
-ts-node your-file-name.ts
-```
+```typescript showLineNumbers filename="avail-js"
-
+ // Initialize the SDK with a public Turing testnet endpoint
+ // You can always switch it out with your own endpoint
+ const providerEndpoint = "wss://turing-rpc.avail.so/ws";
+ const sdk = await SDK.New(providerEndpoint)
+```
-
-1. Create a file named `main.rs`
+4. Initialize a new wallet using a `12-word seed phrase`, and configure the params for the transaction:
-2. Paste the following code into the file:
+```typescript showLineNumbers filename="avail-js"
-This pice of code submits:
-- A string named `data` to Avail DA
-- to the `appID` of 1
-- We expect devs to submit data to their own specific `appID`s.
+ const Alice = "This is a random seed phrase please replace with your own";
+ const account = new Keyring({ type: "sr25519" }).addFromUri(Alice)
+ const data = "Example data to be submitted to Avail DA"
-```rust showLineNumbers filename="avail-rust" name="cmd3"
-use dotenvy::dotenv;
-use std::env;
-use avail_rust::prelude::*;
+ // You can submit data to any AppID of your choosing
+ const options: TransactionOptions = { app_id: 89 }
+```
-type DataSubmissionCall = avail::data_availability::calls::types::SubmitData;
+5. Submit the transaction by calling the `dataAvailability_submitData` extrinsic via the `avail-js` SDK:
-pub async fn submit_data() -> Result<(), ClientError> {
+```typescript showLineNumbers filename="avail-js"
- // Create a new SDK instance
- let sdk = SDK::new("wss://turing-rpc.avail.so/ws").await?;
+//Submit the transaction
+ const result = await sdk.tx.dataAvailability.submitData(data, WaitFor.BlockInclusion, account, options)
+ if (result.isErr) {
+ console.log(result.reason)
+ process.exit(1)
+ }
- // Loading seed phrase and creating an account derived from the seed
- dotenv().ok();
- let seed = env::var("SEED").expect("SEED environment variable is not set");
- let account = account::from_secret_uri(&seed)?;
- println!("Account Address: {}", account.public_key().to_account_id());
+// Logging transaction details in the terminal
+ console.log("Data=" + result.txData.data)
+ console.log("Who=" + result.event.who + ", DataHash=" + result.event.dataHash)
+ console.log("TxHash=" + result.txHash + ", BlockHash=" + result.blockHash)
+```
- // Please note that the tx will fail if this application key does not exist
- let my_application_key = 1;
+6. Run the script using the following command:
- // Data Submission
- let data = String::from("My Data").into_bytes();
+```bash
+ts-node submit-data.ts
+```
- let options = Options::new().app_id(my_application_key);
- let tx = sdk.tx.data_availability.submit_data(data);
- let res = tx.execute_and_watch_inclusion(&account, options).await?;
- assert_eq!(res.is_successful(), Some(true), "Transactions must be successful");
+7. If everything went well, this is what your terminal should look like:
+
+
+
+
- println!(
- "Block Hash: {:?}, Block Number: {}, Tx Hash: {:?}, Tx Index: {}",
- res.block_hash, res.block_number, res.tx_hash, res.tx_index
- );
+
- // Decoding
- let decoded = res.decode_as::().await?;
- let Some(decoded) = decoded else {
- return Err("Failed to get Data Submission Call data".into());
- };
+
+1. Create a file named `main.rs`
- let data = to_ascii(decoded.data.0).unwrap();
- println!("Call data: {:?}", data);
+2. Import the dependencies from `avail-rust-sdk` and create a `main` function:
- println!("Data Submission finished correctly");
+```rust showLineNumbers filename="avail-rust"
+use avail_rust::{Data, Keypair, Nonce, Options, SecretUri, WaitFor, SDK};
+use core::str::FromStr;
+
+#[tokio::main]
+async fn main() -> Result<(), String> {
- Ok(())
}
+```
-// Add a main function to call submit_data
-#[tokio::main]
-async fn main() {
- if let Err(e) = submit_data().await {
- eprintln!("Error: {:?}", e);
- }
-}
+3. Initialize a new instance of the SDK inside the `main` function:
+
+```rust showLineNumbers filename="avail-rust"
+ let sdk = SDK::new("wss://turing-rpc.avail.so/ws").await.unwrap();
+```
+
+4. Initialize a new wallet using a `12-word seed phrase`, and configure the params for the transaction:
+
+```rust showLineNumbers filename="avail-rust"
+ let alice = "This is a random seed phrase please replace with your own";
+ let secret_uri = SecretUri::from_str(alice).unwrap();
+ let account = Keypair::from_uri(&secret_uri).unwrap();
+ let data = String::from("Sample data being submitted......").as_bytes().to_vec();
+ let data = Data { 0: data };
+
+ let wait_for = WaitFor::BlockInclusion;
+ let options = Options::new().nonce(Nonce::BestBlockAndTxPool);
+
+ let app_id = 89; // You can change this value to your desired app_id
```
-3. Run the script using the following command:
+5. Submit the transaction by calling the `dataAvailability_submitData` extrinsic via the `avail-rust` SDK:
-```bash filename="terminal" name="cmd4"
+```rust showLineNumbers filename="avail-rust"
+ // Create the options with the app_id included
+ let options = Options {
+ app_id: Some(app_id),
+ mortality: None,
+ nonce: Some(Nonce::BestBlockAndTxPool),
+ tip: None,
+ };
+
+ let result = sdk
+ .tx
+ .data_availability
+ .submit_data(data, wait_for, &account, Some(options))
+ .await?;
+
+ println!(
+ "Who={}, DataHash={:?}",
+ result.event.who, result.event.data_hash
+ );
+ println!("TxData={:?}", result.tx_data.data);
+ println!(
+ "TxHash={:?}, BlockHash={:?}",
+ result.tx_hash, result.block_hash
+ );
+
+ Ok(())
+```
+
+6. Run the script using the following command:
+
+```bash
cargo run
```
@@ -187,76 +167,60 @@ cargo run
1. Create a file named `main.go`
-2. Paste the following code into the file:
+2. Import the dependencies from `avail-go-sdk` and create a `main` function:
-This pice of code submits:
-- A string to Avail DA
-- to the `appID` of 89
-- We expect devs to submit data to their own specific `appID`s.
-
-```go showLineNumbers filename="avail-go" name="cmd5"
+```go showLineNumbers filename="avail-go"
package main
import (
- "fmt"
- "log"
- "os"
+ "github.com/availproject/avail-go-sdk/src/config"
+ "github.com/availproject/avail-go-sdk/src/sdk"
+ "github.com/availproject/avail-go-sdk/src/sdk/tx"
- SDK "github.com/availproject/avail-go-sdk/sdk"
- "github.com/joho/godotenv"
+ "fmt"
)
func main() {
- // Load environment variables from .env file
- err := godotenv.Load()
- if err != nil {
- log.Fatal("Error loading .env file")
- }
- // Make sure the SEED environment variable is set
- seed := os.Getenv("SEED")
- if seed == "" {
- log.Fatal("SEED environment variable is not set")
- }
+}
+```
- // Create an account from the SEED environment variable
- acc, err := SDK.Account.NewKeyPair(seed)
- if err != nil {
- log.Fatalf("Failed to create account: %v", err)
- }
- fmt.Println("Your account Address: " + acc.SS58Address(42))
+3. Initialize a new instance of the SDK inside the `main` function:
- // Initialize an SDK instance
- sdk, err := SDK.NewSDK("https://turing-rpc.avail.so/rpc")
+```go showLineNumbers filename="avail-go"
+ config, err := config.LoadConfig()
if err != nil {
- log.Fatalf("Failed to initialize SDK: %v", err)
+ fmt.Printf("cannot load config:%v", err)
}
-
- // Submit data to Avail
- appId := uint32(89)
- tx := sdk.Tx.DataAvailability.SubmitData([]byte("Submitting some data using avail-go-sdk"))
- res, err := tx.ExecuteAndWatchInclusion(acc, SDK.NewTransactionOptions().WithAppId(appId))
+ api, err := sdk.NewSDK(config.ApiURL)
if err != nil {
- log.Fatalf("Transaction failed: %v", err)
+ fmt.Printf("cannot create api:%v", err)
}
- // Check if the transaction was successful
- if !res.IsSuccessful().UnsafeUnwrap() {
- log.Fatal("Transaction was not successful")
- }
+ // You can your own app id here
+ appID := 0
+
+ fmt.Println("Submitting data ...")
+ WaitFor := sdk.BlockInclusion
+```
+
+4. Pass the seed phrase and data string as params for the transaction:
- // Printing out all the values of the transaction
- fmt.Println(fmt.Sprintf(`Block Hash: %v, Block Index: %v, Tx Hash: %v, Tx Index: %v`, res.BlockHash.ToHexWith0x(), res.BlockNumber, res.TxHash.ToHexWith0x(), res.TxIndex))
- fmt.Println("Data submission completed successfully")
+```go showLineNumbers filename="avail-go"
+ // submit data
+ BlockHash, txHash, err := tx.SubmitData(api, config.Seed, appID, "my happy data", WaitFor)
+ if err != nil {
+ fmt.Printf("cannot submit data:%v", err)
+ }
+ fmt.Printf("Data submitted successfully with block hash: %v\n and ext hash:%v", BlockHash.Hex(), txHash.Hex())
}
```
-3. Run the script using the following command:
+5. Run the script using the following command:
-```bash filename="terminal" name="cmd6"
+```bash
go run main.go
```
-
@@ -291,1046 +255,183 @@ To check out how to create an AppID on Avail, [refer to this page](/docs/build-w
-## Fetch data submission transactions from Avail DA [#fetch-data-submissions]
-
-### Fetch data submissions using transaction hash and block hash [#da-transactions-by-hash]
+## Reading data from Avail DA
> You can read back your submitted data from Avail DA using the `blockHash` and `txHash` of the transaction.
-
-
-
-1. Create a file named `your-file-name.ts`
-
-2. Paste the following code into the file:
-
-```typescript showLineNumbers filename="avail-js" name="cmd7"
-import { SDK, Block } from 'avail-js-sdk';
-
-export async function readDataByHash() {
-
- // Initialize SDK with Turing endpoint
- const sdk = await SDK.New('wss://turing-rpc.avail.so/ws');
-
- // Transaction hash and block hash to look up
- const txHash = "0x70d8cc521c341d717f5b11d1898fc7a21f9d894c3617929aaabaea71c4814911";
- const blockHash = "0xd5f95593d91a581d7ce7b8717789298345be4be47e75ba93e7159cfe23083a7b";
-
- console.log(`Looking up transaction: ${txHash}`);
- console.log(`In block: ${blockHash}`);
-
- // Create a Block object for the specified block hash
- const block = await Block.New(sdk.client, blockHash);
-
- // Get data submissions for the specified transaction hash
- const blobs = block.dataSubmissions({ txHash: txHash });
-
- console.log(`Found ${blobs.length} data submission(s)`);
-
- // Display information for each data blob
- if (blobs.length === 0) {
- console.log("No data submissions found for this transaction");
- } else {
- console.log("\nData Submission Details:");
- for (const blob of blobs) {
- console.log(`Tx Hash: ${blob.txHash}`);
- console.log(`Tx Index: ${blob.txIndex}`);
- console.log(`Data (ASCII): ${blob.toAscii()}`);
- console.log(`App Id: ${blob.appId}`);
- console.log(`Signer: ${blob.txSigner}`);
- console.log("---");
- }
- }
-
- console.log("Data retrieval completed successfully");
- process.exit(0);
-
-}
-readDataByHash()
-```
-
-3. Run the script using the following command:
-
-```bash filename="terminal" name="cmd8"
-ts-node your-file-name.ts
-```
-
-
-
-
-1. Create a file named `main.rs`
-
-2. Paste the following code into the file:
-
-```rust showLineNumbers filename="avail-rust" name="cmd9"
-use avail_rust::prelude::*;
-
-pub async fn read_data_by_hash() -> Result<(), ClientError> {
-
- // Create a new SDK instance
- let sdk = SDK::new("wss://turing-rpc.avail.so/ws").await?;
-
- let block_hash = new_h256_from_hex("0xd5f95593d91a581d7ce7b8717789298345be4be47e75ba93e7159cfe23083a7b")?;
-
- let block = Block::new(&sdk.client, block_hash).await?;
-
- // All Block Blobs by Hash
- let tx_hash = new_h256_from_hex("0x70d8cc521c341d717f5b11d1898fc7a21f9d894c3617929aaabaea71c4814911")?;
-
- let blobs = block.data_submissions(Filter::new().tx_hash(tx_hash));
- assert_eq!(blobs.len(), 1, "");
-
- let blob = &blobs[0];
-
- // Printout All Block Blobs by Hash
- let blob_data = blob.to_ascii().unwrap();
- assert_eq!(blob.tx_hash, tx_hash, "Tx Hash must be the same");
-
- println!(
- "Tx Hash: {:?}, Tx Index: {}, Data: {:?}, App Id: {}, Tx Singer: {:?}",
- blob.tx_hash,
- blob.tx_index,
- blob_data,
- blob.app_id,
- blob.ss58address(),
- );
- println!("Data retrieval completed successfully");
-
- Ok(())
-}
-
-// Add a main function to call submit_data
-#[tokio::main]
-async fn main() {
- if let Err(e) = read_data_by_hash().await {
- eprintln!("Error: {:?}", e);
- }
-}
-```
-
-3. Run the script using the following command:
-
-```bash filename="terminal" name="cmd10"
-cargo run
-```
-
-
-
-
-
-1. Create a file named `main.go`
-
-2. Paste the following code into the file:
-
-```go showLineNumbers filename="avail-go" name="cmd11"
-package main
-
-import (
- "fmt"
- "log"
-
- "github.com/availproject/avail-go-sdk/primitives"
-
- SDK "github.com/availproject/avail-go-sdk/sdk"
-)
-
-func main() {
+1. Create a file named `read-data.ts`
- // Initialize an SDK instance
- sdk, err := SDK.NewSDK("https://turing-rpc.avail.so/rpc")
- if err != nil {
- log.Fatalf("Failed to initialize SDK: %v", err)
- }
+2. Import the dependencies from `avail-js-sdk` and create a `main` function:
- blockHash, err := primitives.NewBlockHashFromHexString("0xd5f95593d91a581d7ce7b8717789298345be4be47e75ba93e7159cfe23083a7b")
- if err != nil {
- log.Fatalf("Failed to create block hash: %v", err)
- }
+```typescript showLineNumbers filename="avail-js"
- block, err := SDK.NewBlock(sdk.Client, blockHash)
- if err != nil {
- log.Fatalf("Failed to create block: %v", err)
- }
+import { initialize } from "avail-js-sdk"
- // Block Blobs filtered by Transaction Hash
- txHash, err := primitives.NewH256FromHexString("0x70d8cc521c341d717f5b11d1898fc7a21f9d894c3617929aaabaea71c4814911")
- if err != nil {
- log.Fatalf("Failed to create transaction hash: %v", err)
- }
+const main = async () => {
+ try {
- blobs := block.DataSubmissions(SDK.Filter{}.WTxHash(txHash))
- if err != nil {
- log.Fatalf("Failed to create data submissions: %v", err)
- }
-
- blob := &blobs[0]
-
- // Printout Block Blobs filtered by Transaction Hash
- accountId, err := primitives.NewAccountIdFromMultiAddress(blob.TxSigner)
- if err != nil {
- log.Fatalf("Failed to create account ID: %v", err)
- }
- fmt.Println(fmt.Sprintf(`Tx Hash: %v, Tx Index: %v, Data: %v, App Id: %v, Signer: %v,`, blob.TxHash, blob.TxIndex, string(blob.Data), blob.AppId, accountId.ToHuman()))
-
- fmt.Println("Data retrieval completed successfully")
-
-}
+} catch (err) {
+ console.error(err)
+ process.exit(1)
+ }}
+main()
```
-3. Run the script using the following command:
-
-```bash filename="terminal" name="cmd12"
-go run main.go
-```
-
-
-
-
-
+3. Initialize a new instance of the SDK inside the `main` function, and declare the params:
-### Fetch data submissions using AppID [#da-transactions-by-app-id]
+```typescript showLineNumbers filename="avail-js"
-> You can read back your submitted data from Avail DA using the `AppID`.
+ //initialize sdk
+ const api = await initialize("wss://turing-rpc.avail.so/ws")
-
-
-
-
-1. Create a file named `your-file-name.ts`
-
-2. Paste the following code into the file:
-
-```typescript showLineNumbers filename="avail-js" name="cmd13"
-import * as dotenv from 'dotenv';
-import { SDK, Block } from 'avail-js-sdk';
-
-dotenv.config();
-
-export async function readDataByAppId() {
-
- // Initialize SDK with Turing endpoint
- const sdk = await SDK.New('wss://turing-rpc.avail.so/ws');
-
- // App ID and block hash to look up
- const appId = 89;
- const blockHash = "0xd5f95593d91a581d7ce7b8717789298345be4be47e75ba93e7159cfe23083a7b";
-
- console.log(`Looking up data for App ID: ${appId}`);
- console.log(`In block: ${blockHash}`);
-
- // Create a Block object for the specified block hash
- const block = await Block.New(sdk.client, blockHash);
-
- // Get data submissions for the specified app ID
- const blobs = block.dataSubmissions({ appId: appId });
-
- console.log(`Found ${blobs.length} data submission(s)`);
-
- // Display information for each data blob
- if (blobs.length === 0) {
- console.log("No data submissions found for this app ID");
- } else {
- console.log("\nData Submission Details:");
- for (const blob of blobs) {
- console.log(`Tx Hash: ${blob.txHash}`);
- console.log(`Tx Index: ${blob.txIndex}`);
- console.log(`Data (ASCII): ${blob.toAscii()}`);
- console.log(`App Id: ${blob.appId}`);
- console.log(`Signer: ${blob.txSigner}`);
- console.log("---");
- }
- }
-
- console.log("Data retrieval completed successfully");
- process.exit(0);
-
-
-}
-readDataByAppId()
+ // Provide the transaction hash and block hash
+ const [txHash, blockHash] = ["0x17463754ef4185f4faba2473535890e4397aa403830f3b5a77295340b9e7cf56", "0x758036aa0db77bb34f6bf23b9fe290900f203ef4547e46c36fa486adbe6488e8"]
+ console.log(`Tx Hash: ${txHash}, Block Hash: ${blockHash}`)
```
-3. Run the script using the following command:
+4. Extract the data:
-```bash filename="terminal" name="cmd14"
-ts-node your-file-name.ts
-```
-
-
-
-
-1. Create a file named `main.rs`
-
-2. Paste the following code into the file:
-
-```rust showLineNumbers filename="avail-rust" name="cmd15"
-use avail_rust::prelude::*;
-
-pub async fn read_data_by_appid() -> Result<(), ClientError> {
+```typescript showLineNumbers filename="avail-js"
- // Create a new SDK instance
- let sdk = SDK::new("wss://turing-rpc.avail.so/ws").await?;
- let block_hash = new_h256_from_hex("0xd5f95593d91a581d7ce7b8717789298345be4be47e75ba93e7159cfe23083a7b")?;
-
- let block = Block::new(&sdk.client, block_hash).await?;
-
- // All Block Blobs by App Id
- let app_id = 89;
-
- let blobs = block.data_submissions(Filter::new().app_id(app_id));
-
- // Printout All Block Blobs by App Id
- for blob in blobs {
- let blob_data = blob.to_ascii().unwrap();
-
- println!(
- "Tx Hash: {:?}, Tx Index: {}, Data: {:?}, App Id: {}, Tx Singer: {:?}",
- blob.tx_hash,
- blob.tx_index,
- blob_data,
- blob.app_id,
- blob.ss58address(),
- );
+ // Extracting data
+ const block = await api.rpc.chain.getBlock(blockHash)
+ const tx = block.block.extrinsics.find((tx) => tx.hash.toHex() == txHash)
+ if (tx == undefined) {
+ console.log("Failed to find the Submit Data transaction")
+ process.exit(1)
}
- println!("Data retrieval completed successfully");
-
- Ok(())
-
-}
-
-#[tokio::main]
-async fn main() {
- if let Err(e) = read_data_by_appid().await {
- eprintln!("Error: {:?}", e);
- }
-}
-```
-
-3. Run the script using the following command:
-
-```bash filename="terminal" name="cmd16"
-cargo run
```
-
-
-
-
-1. Create a file named `main.go`
-
-2. Paste the following code into the file:
+5. Parse the data to extract a `string`:
-```go showLineNumbers filename="avail-go" name="cmd17"
-package main
+```typescript showLineNumbers filename="avail-js"
-import (
- "fmt"
- "log"
-
- "github.com/availproject/avail-go-sdk/primitives"
-
- SDK "github.com/availproject/avail-go-sdk/sdk"
-)
-
-func main() {
-
- // Initialize an SDK instance
- sdk, err := SDK.NewSDK("https://turing-rpc.avail.so/rpc")
- if err != nil {
- log.Fatalf("Failed to initialize SDK: %v", err)
- }
-
- blockHash, err := primitives.NewBlockHashFromHexString("0x94746ba186876d7407ee618d10cb6619befc59eeb173cacb00c14d1ff492fc58")
- if err != nil {
- log.Fatalf("Failed to create block hash: %v", err)
- }
-
- block, err := SDK.NewBlock(sdk.Client, blockHash)
- if err != nil {
- log.Fatalf("Failed to create block: %v", err)
- }
-
- // Block Blobs filtered by App Id
- appId := uint32(2)
- blobs := block.DataSubmissions(SDK.Filter{}.WAppId(appId))
- if err != nil {
- log.Fatalf("Failed to create data submissions: %v", err)
- }
-
- // Printout Block Blobs filtered by App Id
- for _, blob := range blobs {
- if blob.AppId != appId {
- log.Fatalf("Transaction App Ids are not the same.")
- }
-
- accountId, err := primitives.NewAccountIdFromMultiAddress(blob.TxSigner)
- if err != nil {
- log.Fatalf("Failed to create account ID: %v", err)
- }
-
- fmt.Println(fmt.Sprintf(`Tx Hash: %v, Tx Index: %v, Data: %v, App Id: %v, Signer: %v,`, blob.TxHash, blob.TxIndex, string(blob.Data), blob.AppId, accountId.ToHuman()))
- }
-
- fmt.Println("Data retrieval completed successfully")
-
-}
-```
-
-3. Run the script using the following command:
-
-```bash filename="terminal" name="cmd18"
-go run main.go
-```
-
-
-
-
-
-
-### Fetch all data submissions for a given block [#da-transactions-by-block]
-
-Here is a complete example of how to fetch all the data submissions for a given block:
-
-
-
-
-
-```typescript showLineNumbers filename="avail-js" name="cmd19"
-import * as dotenv from 'dotenv';
-import { SDK, Block } from 'avail-js-sdk';
-
-dotenv.config();
-
-export async function readDataByBlock() {
- // Initialize SDK with Turing endpoint
- const sdk = await SDK.New('wss://turing-rpc.avail.so/ws');
-
- // Block hash to look up
- const blockHash = "0x94746ba186876d7407ee618d10cb6619befc59eeb173cacb00c14d1ff492fc58";
-
- console.log(`Looking up all data submissions in block: ${blockHash}`);
-
- // Create a Block object for the specified block hash
- const block = await Block.New(sdk.client, blockHash);
-
- // Get all data submissions in the block
- const blobs = block.dataSubmissions();
-
- console.log(`Found ${blobs.length} data submission(s)`);
-
- // Display information for each data blob
- if (blobs.length === 0) {
- console.log("No data submissions found in this block");
- } else {
- console.log("\nData Submission Details:");
- for (const blob of blobs) {
- console.log(`Tx Hash: ${blob.txHash}`);
- console.log(`Tx Index: ${blob.txIndex}`);
- console.log(`Data (ASCII): ${blob.toAscii()}`);
- console.log(`App Id: ${blob.appId}`);
- console.log(`Signer: ${blob.txSigner}`);
- console.log("---");
- }
+ console.log(JSON.stringify(tx))
+ const dataHex = tx.method.args.map((a) => a.toString()).join(", ")
+ // Data retrieved from the extrinsic data
+ let str = ""
+ for (let n = 0; n < dataHex.length; n += 2) {
+ str += String.fromCharCode(parseInt(dataHex.substring(n, n + 2), 16))
}
-
- console.log("Data retrieval completed successfully");
- process.exit(0);
-}
-
-// Execute the function
-readDataByBlock();
+ console.log(`This is the string that was submitted: ${str}`)
```
6. Run the script using the following command:
-```bash filename="terminal" name="cmd20"
-ts-node your-file-name.ts
+```bash
+ts-node read-data.ts
```
-
-
-
-
-```rust showLineNumbers filename="avail-rust" name="cmd21"
-use avail_rust::prelude::*;
-
-pub async fn read_data_by_block() -> Result<(), ClientError> {
-
- // Create a new SDK instance
- let sdk = SDK::new("wss://turing-rpc.avail.so/ws").await?;
- let block_hash = new_h256_from_hex("0x94746ba186876d7407ee618d10cb6619befc59eeb173cacb00c14d1ff492fc58")?;
-
- let block = Block::new(&sdk.client, block_hash).await?;
-
- // All Block Blobs
- let blobs = block.data_submissions(Filter::default());
-
- // Printout All Block Blobs
- for blob in blobs {
- let blob_data = blob.to_ascii().unwrap();
-
- println!(
- "Tx Hash: {:?}, Tx Index: {}, Data: {:?}, App Id: {}, Tx Singer: {:?}",
- blob.tx_hash,
- blob.tx_index,
- blob_data,
- blob.app_id,
- blob.ss58address(),
- );
- }
- println!("Data retrieval completed successfully");
-
- Ok(())
-}
-
-#[tokio::main]
-async fn main() {
- if let Err(e) = read_data_by_block().await {
- eprintln!("Error: {:?}", e);
- }
-}
-```
-
-6. Run the script using the following command:
-
-```bash filename="terminal" name="cmd22"
-cargo run
-```
-
-
-
-
-
-```go showLineNumbers filename="avail-go" name="cmd23"
-package main
-
-import (
- "fmt"
- "log"
-
- "github.com/availproject/avail-go-sdk/primitives"
-
- SDK "github.com/availproject/avail-go-sdk/sdk"
-)
-
-func main() {
-
- // Initialize an SDK instance
- sdk, err := SDK.NewSDK("https://turing-rpc.avail.so/rpc")
- if err != nil {
- log.Fatalf("Failed to initialize SDK: %v", err)
- }
-
- blockHash, err := primitives.NewBlockHashFromHexString("0x94746ba186876d7407ee618d10cb6619befc59eeb173cacb00c14d1ff492fc58")
- if err != nil {
- log.Fatalf("Failed to create block hash: %v", err)
- }
-
- block, err := SDK.NewBlock(sdk.Client, blockHash)
- if err != nil {
- log.Fatalf("Failed to create block: %v", err)
- }
-
- // All Block Blobs
- blobs := block.DataSubmissions(SDK.Filter{})
- fmt.Println(len(blobs))
-
- // Printout All Block Blobs
- for _, blob := range blobs {
- accountId, err := primitives.NewAccountIdFromMultiAddress(blob.TxSigner)
- if err != nil {
- log.Fatalf("Failed to create account ID: %v", err)
- }
-
- fmt.Println(fmt.Sprintf(`Tx Hash: %v, Tx Index: %v, Data: %v, App Id: %v, Signer: %v,`, blob.TxHash, blob.TxIndex, string(blob.Data), blob.AppId, accountId.ToHuman()))
- }
-
- fmt.Println("Data retrieval completed successfully")
-
-}
-```
-
-6. Run the script using the following command:
-
-```bash filename="terminal" name="cmd24"
-go run main.go
-```
-
-
-
-
-
-## Fetch all types of transactions on Avail DA [#fetch-all-transactions]
-
-### Fetch all transactions by a particular signer in a block [#fetch-transactions-by-signer]
-
-Here is a complete example of how to fetch all the transactions by a particular signer in a particular block:
-
-
+7. If everything went well, this is what your terminal should look like:
+
+
+
+
-
-1. Create a file named `your-file-name.ts`
-
-2. Paste the following code into your file:
-
-```typescript showLineNumbers filename="avail-js" name="cmd25"
-import { SDK, Block } from 'avail-js-sdk';
-
-export async function fetchTransactionsBySigner() {
-
- // Initialize SDK with Turing endpoint
- const sdk = await SDK.New('wss://turing-rpc.avail.so/ws');
-
- // Block hash and signer address to look up
- const blockHash = "0x75a6c54bb5ea904e47fa151956992d7cf543bc7c936d78488e311db8e10397c1";
- const signer = "5CqgQkrDcdg5QrtuxT3H7WszrqgrBMhdwRbmMVXQzc4VSiEg";
-
- console.log(`Looking up transactions by signer: ${signer}`);
- console.log(`In block: ${blockHash}`);
-
- // Create a Block object for the specified block hash
- const block = await Block.New(sdk.client, blockHash);
-
- // Get transactions for the specified signer
- const blockTxs = block.transactions({ txSigner: signer });
-
- console.log(`Found ${blockTxs.length} transaction(s)`);
-
- // Display information for each transaction
- if (blockTxs.length === 0) {
- console.log("No transactions found for this signer");
- } else {
- console.log("\nTransaction Details:");
- for (const tx of blockTxs) {
- console.log(`Pallet Name: ${tx.palletName()}`);
- console.log(`Pallet Index: ${tx.palletIndex()}`);
- console.log(`Call Name: ${tx.callName()}`);
- console.log(`Call Index: ${tx.callIndex()}`);
- console.log(`Tx Hash: ${tx.txHash()}`);
- console.log(`Tx Index: ${tx.txIndex()}`);
- console.log(`Signer: ${tx.ss58Address()}`);
- console.log("---");
+## Complete example
+
+The following code snippet combines the steps above into a single script to submit and fetch data from Avail:
+
+```typescript showLineNumbers filename="avail-js"
+
+import { initialize, getKeyringFromSeed } from "avail-js-sdk"
+import { ISubmittableResult } from "@polkadot/types/types/extrinsic"
+import { H256 } from "@polkadot/types/interfaces/runtime"
+const main = async () => {
+ try {
+ //initialize sdk
+ const api = await initialize("wss://turing-rpc.avail.so/ws")
+ // get your Avail account
+ const account = getKeyringFromSeed("This is a random seed phrase please replace with your own")
+ console.log(account.address)
+
+ // Data to be submitted
+ const data = "Hello World"
+
+ // submit the data using dataAvailability.submitData extrinsic
+ const txResult = await new Promise((res) => {
+ api.tx.dataAvailability.submitData(data).signAndSend(account, (result: ISubmittableResult) => {
+ console.log(`Tx status: ${result.status}`)
+ console.log(`Block finalization and data retrieval can take upto 30 seconds...:⏰⏰⏰`)
+ if (result.isFinalized || result.isError) {
+ res(result)
}
-
- }
-
- console.log("Transaction retrieval completed successfully");
- process.exit(0);
-}
-
-// Execute the function
-fetchTransactionsBySigner();
-```
-
-3. Run the script using the following command:
-
-```bash filename="terminal" name="cmd26"
-ts-node your-file-name.ts
-```
+ })
+ })
-
-
-
-1. Create a file named `main.rs`
-
-2. Paste the following code into your file:
-
-```rust showLineNumbers filename="avail-rust" name="cmd27"
-use avail_rust::prelude::*;
-
-pub async fn fetch_transactions_by_signer() -> Result<(), ClientError> {
-
- // Create a new SDK instance
- let sdk = SDK::new("wss://turing-rpc.avail.so/ws").await?;
-
- // Enter the block hash you want to fetch transactions from
- let block_hash = new_h256_from_hex("0x75a6c54bb5ea904e47fa151956992d7cf543bc7c936d78488e311db8e10397c1")?;
- // Fetch the Block
- let block = Block::new(&sdk.client, block_hash).await?;
-
- // Fetch All Transaction filtered by Signer
- let account_id = account_id_from_str("5CqgQkrDcdg5QrtuxT3H7WszrqgrBMhdwRbmMVXQzc4VSiEg")?;
- let block_transactions = block.transactions(Filter::new().tx_signer(account_id.clone()));
-
- // Printout Block Transactions made by Signer
- for tx in block_transactions.iter() {
-
- println!(
- "Pallet Name: {:?}, Pallet Index: {}, Call Name: {:?}, Call Index: {:?}, Tx Hash: {:?}, Tx Index: {}",
- tx.pallet_name(),
- tx.pallet_index(),
- tx.call_name(),
- tx.call_index(),
- tx.tx_hash(),
- tx.tx_index()
- );
-
- println!(
- "Tx Signer: {:?}, App Id: {:?}, Tip: {:?}, Mortality: {:?}, Nonce: {:?}",
- tx.ss58address(),
- tx.app_id(),
- tx.tip(),
- tx.mortality(),
- tx.nonce(),
- );
+ // Rejected Transaction handling
+ if (txResult.isError) {
+ console.log(`Transaction was not executed`)
+ process.exit(1)
}
-
- println!("Transaction retrieval completed successfully");
-
- Ok(())
-}
-
-#[tokio::main]
-async fn main() -> Result<(), ClientError> {
- fetch_transactions_by_signer().await?;
- Ok(())
-}
-```
-
-3. Run the script using the following command:
-
-```bash filename="terminal" name="cmd28"
-cargo run
-```
-
-
-
-
-1. Create a file named `main.go`
-
-2. Paste the following code into your file:
-```go showLineNumbers filename="avail-go" name="cmd29"
-package main
-
-import (
- "fmt"
- "log"
-
- "github.com/availproject/avail-go-sdk/primitives"
-
- SDK "github.com/availproject/avail-go-sdk/sdk"
-)
-
-func main() {
-
- // Initialize an SDK instance
- sdk, err := SDK.NewSDK("https://turing-rpc.avail.so/rpc")
- if err != nil {
- log.Fatalf("Failed to initialize SDK: %v", err)
- }
-
- blockHash, err := primitives.NewBlockHashFromHexString("0x75a6c54bb5ea904e47fa151956992d7cf543bc7c936d78488e311db8e10397c1")
- if err != nil {
- log.Fatalf("Failed to create block hash: %v", err)
- }
+ // Passing the transaction hash and block hash to fetch the submitted data
+ const [txHash, blockHash] = [txResult.txHash as H256, txResult.status.asFinalized as H256]
+ console.log(`Tx Hash: ${txHash}, Block Hash: ${blockHash}`)
- block, err := SDK.NewBlock(sdk.Client, blockHash)
- if err != nil {
- log.Fatalf("Failed to create block: %v", err)
- }
-
- // Create an account ID
- accountId, err := primitives.NewAccountIdFromAddress("5CqgQkrDcdg5QrtuxT3H7WszrqgrBMhdwRbmMVXQzc4VSiEg")
- if err != nil {
- log.Fatalf("Failed to create account ID: %v", err)
- }
-
- // All Transaction filtered by Signer
- blockTxs := block.Transactions(SDK.Filter{}.WTxSigner(accountId))
- fmt.Println("Transaction Count: ", len(blockTxs))
-
- // Printout Block Transactions filtered by Signer
- for _, tx := range blockTxs {
- fmt.Println(fmt.Sprintf(`Pallet Name: %v, Pallet Index: %v, Call Name: %v, Call Index: %v, Tx Hash: %v, Tx Index: %v`, tx.PalletName(), tx.PalletIndex(), tx.CallName(), tx.CallIndex(), tx.TxHash(), tx.TxIndex()))
- fmt.Println(fmt.Sprintf(`Tx Signer: %v, App Id: %v, Tip: %v, Mortality: %v, Nonce: %v`, tx.SS58Address(), tx.AppId(), tx.Tip(), tx.Mortality(), tx.Nonce()))
- }
-
- fmt.Println("Transaction retrieval completed successfully")
-
-}
-```
-
-3. Run the script using the following command:
-
-```bash filename="terminal" name="cmd30"
-go run main.go
-```
-
-
-
-
-
-### Fetch all transactions from a particular block [#fetch-transactions-by-block]
-
-Here is a complete example of how to fetch all the transactions from a particular block:
-
-
-
-
-1. Create a file named `your-file-name.ts`
-
-2. Paste the following code into your file:
-
-```typescript showLineNumbers filename="avail-js" name="cmd31"
-import { SDK, Block } from 'avail-js-sdk';
-
-export async function fetchAllTransactions() {
-
- // Initialize SDK with Turing endpoint
- const sdk = await SDK.New('wss://turing-rpc.avail.so/ws');
-
- // Block hash to look up
- const blockHash = "0x9016d7953c88115534a602f2d2548c70c4f5b378d86f4bedda82be2655467c5d";
-
- console.log(`Looking up all transactions in block: ${blockHash}`);
-
- // Create a Block object for the specified block hash
- const block = await Block.New(sdk.client, blockHash);
-
- // Get all transactions in the block
- const blockTxs = block.transactions();
-
- console.log(`Found ${blockTxs.length} transaction(s)`);
-
- // Display information for each transaction
- if (blockTxs.length === 0) {
- console.log("No transactions found in this block");
- } else {
- console.log("\nTransaction Details:");
- for (const tx of blockTxs) {
- console.log(`Pallet Name: ${tx.palletName()}`);
- console.log(`Pallet Index: ${tx.palletIndex()}`);
- console.log(`Call Name: ${tx.callName()}`);
- console.log(`Call Index: ${tx.callIndex()}`);
- console.log(`Tx Hash: ${tx.txHash()}`);
- console.log(`Tx Index: ${tx.txIndex()}`);
- console.log(`Signer: ${tx.ss58Address()}`);
- console.log("---");
- }
+ // Extracting data
+ const block = await api.rpc.chain.getBlock(blockHash)
+ const tx = block.block.extrinsics.find((tx) => tx.hash.toHex() == txHash.toHex())
+ if (tx == undefined) {
+ console.log("Failed to find the Submit Data transaction")
+ process.exit(1)
}
-
- console.log("Transaction retrieval completed successfully");
- process.exit(0);
-}
-// Execute the function
-fetchAllTransactions();
-```
-
-3. Run the script using the following command:
-
-```bash filename="terminal" name="cmd32"
-ts-node your-file-name.ts
-```
+ console.log(JSON.stringify(tx))
+ const dataHex = tx.method.args.map((a) => a.toString()).join(", ")
-
-
-
-1. Create a file named `main.rs`
-
-2. Paste the following code into your file:
-
-```rust showLineNumbers filename="avail-rust" name="cmd33"
-use avail_rust::prelude::*;
-
-pub async fn fetch_all_transactions() -> Result<(), ClientError> {
-
- // Create a new SDK instance
- let sdk = SDK::new("wss://turing-rpc.avail.so/ws").await?;
-
- // Enter the block hash you want to fetch transactions from
- let block_hash = new_h256_from_hex("0x9016d7953c88115534a602f2d2548c70c4f5b378d86f4bedda82be2655467c5d")?;
- let block = Block::new(&sdk.client, block_hash).await?;
-
- // Fetch All Transactions
- let block_transactions = block.transactions(Filter::default());
-
- // Printout Block Transactions
- for tx in block_transactions.iter() {
- println!(
- "Pallet Name: {:?}, Pallet Index: {}, Call Name: {:?}, Call Index: {:?}, Tx Hash: {:?}, Tx Index: {}",
- tx.pallet_name(),
- tx.pallet_index(),
- tx.call_name(),
- tx.call_index(),
- tx.tx_hash(),
- tx.tx_index()
- );
-
- println!(
- "Tx Signer: {:?}, App Id: {:?}, Tip: {:?}, Mortality: {:?}, Nonce: {:?}",
- tx.ss58address(),
- tx.app_id(),
- tx.tip(),
- tx.mortality(),
- tx.nonce(),
- );
+ // Data retrieved from the extrinsic data
+ let str = ""
+ for (let n = 0; n < dataHex.length; n += 2) {
+ str += String.fromCharCode(parseInt(dataHex.substring(n, n + 2), 16))
}
- println!("Transaction retrieval completed successfully");
-
- Ok(())
-}
-
-#[tokio::main]
-async fn main() -> Result<(), ClientError> {
- fetch_all_transactions().await?;
- Ok(())
-}
-```
-
-3. Run the script using the following command:
-
-```bash filename="terminal" name="cmd34"
-cargo run
-```
-
-
-
-
-1. Create a file named `main.go`
-
-2. Paste the following code into your file:
-
-```go showLineNumbers filename="avail-go" name="cmd35"
-package main
-
-import (
- "fmt"
- "log"
-
- "github.com/availproject/avail-go-sdk/primitives"
-
- SDK "github.com/availproject/avail-go-sdk/sdk"
-)
-
-func main() {
-
- sdk, err := SDK.NewSDK("https://turing-rpc.avail.so/rpc")
- if err != nil {
- log.Fatalf("Failed to initialize SDK: %v", err)
- }
-
- blockHash, err := primitives.NewBlockHashFromHexString("0x9016d7953c88115534a602f2d2548c70c4f5b378d86f4bedda82be2655467c5d")
- if err != nil {
- log.Fatalf("Failed to create block hash: %v", err)
- }
-
- block, err := SDK.NewBlock(sdk.Client, blockHash)
- if err != nil {
- log.Fatalf("Failed to create block: %v", err)
- }
-
- // Fetch All Transactions
- blockTxs := block.Transactions(SDK.Filter{})
- fmt.Println("Transaction Count: ", len(blockTxs))
-
- // Printout Block Transactions
- for _, tx := range blockTxs {
- fmt.Println(fmt.Sprintf(`Pallet Name: %v, Pallet Index: %v, Call Name: %v, Call Index: %v, Tx Hash: %v, Tx Index: %v`, tx.PalletName(), tx.PalletIndex(), tx.CallName(), tx.CallIndex(), tx.TxHash(), tx.TxIndex()))
- fmt.Println(fmt.Sprintf(`Tx Signer: %v, App Id: %v, Tip: %v, Mortality: %v, Nonce: %v`, tx.SS58Address(), tx.AppId(), tx.Tip(), tx.Mortality(), tx.Nonce()))
- }
-
- fmt.Println("Transaction retrieval completed successfully")
-
-}
+ console.log(`submitted data: ${str}`)
+ process.exit()
+} catch (err) {
+ console.error(err)
+ process.exit(1)
+ }}
+main()
```
-3. Run the script using the following command:
-
-```bash filename="terminal" name="cmd36"
-go run main.go
-```
-
-
-
-
-
-## Estimate fees for your data submission [#estimate-fees]
+## Estimate fees for your data submission
The `avail-js` SDK provides a method to estimate the cost of submitting a particular piece of data to Avail DA.
Here is how you can use it:
-
+```typescript showLineNumbers filename="avail-js"
-
-
-
-
-
-
-```typescript showLineNumbers filename="avail-js" name="cmd37"
-import { initialize, disconnect } from "avail-js-sdk";
+import { initialize, disconnect } from "avail-js-sdk"
const calculateCost = async () => {
- // Initialize the avail sdk providerEndpoint
- const providerEndpoint = await initialize("wss://turing-rpc.avail.so/ws");
-
- // Dummy sender - insert any address
- const sender = "5CDGXH8Q9DzD3TnATTG6qm6f4yR1kbECBGUmh2XbEBQ8Jfa5";
-
- //10^18 decimals to denominate to AVAIL
- const DECIMAL = 1000000000000000000;
-
- // Input the data
- let data = "This is a random piece of string data!!!";
-
- //Get the estimated cost in AVAIL
- const cost = await providerEndpoint.tx.dataAvailability.submitData(data).paymentInfo(sender);
- const costInAvail = (parseInt(cost.partialFee.toString()) / DECIMAL).toFixed(6);
-
- console.log(`Estimated Fees: ${costInAvail} AVAIL`);
-
- await disconnect();
-};
-
-calculateCost();
-```
-
-
-
-
-
-```typescript showLineNumbers filename="avail-js" name="cmd38"
-import * as fs from "fs";
-import { initialize, disconnect } from "avail-js-sdk";
-
-const calculateCost = async () => {
- // Initialize the avail sdk providerEndpoint
- const providerEndpoint = await initialize("wss://turing-rpc.avail.so/ws");
-
- // Dummy sender - insert any address
- const sender = "5CDGXH8Q9DzD3TnATTG6qm6f4yR1kbECBGUmh2XbEBQ8Jfa5";
-
- //10^18 decimals to denominate to AVAIL
- const DECIMAL = 1000000000000000000;
-
- // Pass the path to your txt file
- const filePath = "/Users/abosolute/path/to-file/.txt";
- const data = fs.readFileSync(filePath, "utf8");
-
- //Get the estimated cost in AVAIL
- const cost = await providerEndpoint.tx.dataAvailability.submitData(data).paymentInfo(sender);
- const costInAvail = (parseInt(cost.partialFee.toString()) / DECIMAL).toFixed(6);
-
- console.log(`Estimated Fees: ${costInAvail} AVAIL`);
-
- await disconnect();
-};
-
-calculateCost();
+ // Initialize the avail sdk providerEndpoint
+ const providerEndpoint = await initialize("wss://turing-rpc.avail.so/ws")
+
+ // Dummy sender - insert any address
+ const sender = "5CDGXH8Q9DzD3TnATTG6qm6f4yR1kbECBGUmh2XbEBQ8Jfa5"
+
+ //10^18 decimals to denominate to AVAIL
+ const DECIMAL = 1000000000000000000
+
+ // Input the data
+ let data = "This is a random piece of string data!!!"
+
+ //Get the estimated cost in AVAIL
+ const cost = await providerEndpoint.tx.dataAvailability.submitData(data).paymentInfo(sender)
+ const costInAvail = (parseInt(cost.partialFee.toString())/DECIMAL).toFixed(6)
+
+ console.log(`Estimated Fees: ${costInAvail} AVAIL`)
+
+ await disconnect()
+ }
+
+ calculateCost()
```
-
-
-
-
-
-
-
-
-2. Run the script using the following command:
-
-```bash filename="terminal" name="cmd39"
-ts-node your-file-name.ts
-```
\ No newline at end of file
+
+**LOOKING FOR MORE EXAMPLES?**
+This page was written as an introduction to working with data submission/reading on Avail DA.
+In particular, we used the `dataAvailability_submitData` extrinsic to submit data to the network.
+Refer to our [API reference](/api-reference/avail-node-api) for more detailed examples.
+
\ No newline at end of file
diff --git a/app/docs/build-with-avail/interact-with-avail-da/transfer-balances/page.mdx b/app/docs/build-with-avail/interact-with-avail-da/transfer-balances/page.mdx
index b70fa9ee7..f21315196 100644
--- a/app/docs/build-with-avail/interact-with-avail-da/transfer-balances/page.mdx
+++ b/app/docs/build-with-avail/interact-with-avail-da/transfer-balances/page.mdx
@@ -1,17 +1,7 @@
----
-image: '/img/docs-link-preview.png'
----
-
import { Callout, Steps, Tabs } from 'nextra/components'
# Transfer balances programmatically on Avail DA
-
-**SETTING UP THE DEV ENVIRONMENT**
-In this guide we will use Avail's dedicated SDKs to interact with the [Turing testnet](/docs/networks).
-To set up a dev environment for the SDK of your choice, please follow the steps [outlined here](/api-reference/avail-node-api#setting-up-the-dev-environment).
-
-
## Transferring funds programmatically
You can transfer `AVAIL` from one account to another programmatically by calling any one of these three extrinsics
@@ -27,7 +17,7 @@ the existential deposit.
**EXISTENTIAL DEPOSIT**
Only accounts with a balance equal to or greater than the `existential deposit` are stored on the state trie.
The current value of the existential deposit is `0.000001 AVAIL`.
-Any account whose balance dips below this amount is *'reaped'*.
+Any account whose balane dips below this amount is *'reaped'*.
### Transferring funds using `balances_transferKeepAlive`
@@ -37,65 +27,35 @@ Any account whose balance dips below this amount is *'reaped'*.
1. Inside `your-file-name.ts`, add the following code:
-```typescript showLineNumbers filename="avail-js" name="cmd1"
-import * as dotenv from 'dotenv';
-import { Account, SDK, BN } from 'avail-js-sdk';
-
-dotenv.config();
-
-export async function transferKeepAlive() {
- // Initialize SDK with Turing endpoint
- const sdk = await SDK.New('wss://turing-rpc.avail.so/ws');
-
- // Create account from seed in .env file
- const seed = process.env.SEED;
- if (!seed) {
- throw new Error("SEED environment variable is not set");
- }
-
- // Create account from seed
- const account = Account.new(seed);
- console.log("Sender Address: ", account.address);
-
- // Destination address to send AVAIL to
- const destinationAddress = "5DDY2yzh8uCysYFAiRSTeQVwtZSKNF49CkQkyPH852xvrYKk";
- console.log("Recipient Address: ", destinationAddress);
-
- // Amount to transfer: 12 AVAIL
- const amount = new BN('12000000000000000000'); // 12 with 18 zeroes
- console.log("Transfer Amount: 12 AVAIL");
-
- // Create transfer transaction
- const tx = sdk.tx.balances.transferKeepAlive(destinationAddress, amount);
- console.log("Submitting transfer transaction...");
-
- // Execute and wait for inclusion
- const res = await tx.executeWaitForInclusion(account, {});
-
- // Check if transaction was successful
- const isOk = res.isSuccessful();
- if (isOk === undefined) {
- throw new Error("Cannot check if transaction was successful");
- }
- else if (!isOk) {
- throw new Error("Transaction failed");
- }
-
- console.log(`Transaction Hash: ${res.txHash}`);
- console.log(`Block Hash: ${res.blockHash}`);
- console.log(`Block Number: ${res.blockNumber}`);
- console.log("Transfer completed successfully");
-
- process.exit(0);
-}
+```typescript showLineNumbers filename="avail-js"
+import { SDK, WaitFor, Keyring, BN } from "avail-js-sdk"
+
+const main = async () => {
+ const providerEndpoint = "wss://turing-rpc.avail.so/ws";
+ const sdk = await SDK.New(providerEndpoint)
+
+ const Alice = 'This is a random seed phrase please replace with your own';
+ const account = new Keyring({ type: "sr25519" }).addFromUri(Alice)
+ const dest = "5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw" // Eve
+ const amount = new BN(12).mul(new BN(10).pow(new BN("18"))) // twelve Avail
-// Execute the function
-transferKeepAlive();
+ const result = await sdk.tx.balances.transferKeepAlive(dest, amount, WaitFor.BlockInclusion, account)
+ if (result.isErr) {
+ console.log(result.reason)
+ process.exit(1)
+ }
+
+ console.log("From=" + result.event.from + ", To=" + result.event.to + ", Amount=" + result.event.amount)
+ console.log("TxHash=" + result.txHash + ", BlockHash=" + result.blockHash)
+
+ process.exit()
+}
+main()
```
2. Run the code using:
-```bash filename="terminal" name="cmd2"
+```bash
ts-node your-file-name.ts
```
@@ -104,50 +64,43 @@ ts-node your-file-name.ts
1. Inside `main.rs`, add the following code:
-```rust showLineNumbers filename="avail-rust" name="cmd3"
-use dotenvy::dotenv;
-use std::env;
-use avail_rust::prelude::*;
+```rust showLineNumbers filename="avail-rust" showLineNumbers filename="avail-rust"
+use avail_rust::{Keypair, Nonce, Options, SecretUri, WaitFor, SDK};
use core::str::FromStr;
-pub async fn transfer_keep_alive() -> Result<(), ClientError> {
-
- // Create a new SDK instance
- let sdk = SDK::new("wss://turing-rpc.avail.so/ws").await?;
-
- // Loading seed phrase and creating an account derived from the seed
- dotenv().ok();
- let seed = env::var("SEED").expect("SEED environment variable is not set");
- let account = account::from_secret_uri(&seed)?;
- println!("Account Address: {}", account.public_key().to_account_id());
+#[tokio::main]
+async fn main() -> Result<(), String> {
+ let sdk = SDK::new("wss://turing-rpc.avail.so/ws").await.unwrap();
- // Executing the transaction
- let dest = AccountId::from_str("5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw").unwrap();
- let amount = 1_000_000_000_000_000_000u128; // 1 AVAIL being transferred to the destination account
- let tx = sdk.tx.balances.transfer_keep_alive(dest, amount);
- let res = tx.execute_and_watch_inclusion(&account, Options::default()).await?;
+ let alice = "This is a random seed phrase please replace with your own";
+ let secret_uri = SecretUri::from_str(alice).unwrap();
+ let account = Keypair::from_uri(&secret_uri).unwrap();
+ let dest: &str = "5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw"; // Eve
+ let amount = 1_000_000_000_000_000_000u128; // 1 Avail
+ let options = Options::new().nonce(Nonce::BestBlockAndTxPool);
+
+ let result = sdk
+ .tx
+ .balances
+ .transfer_keep_alive(dest, amount, WaitFor::BlockInclusion, &account, Some(options))
+ .await?;
- println!(
- "Block Hash: {:?}, Block Number: {}, Tx Hash: {:?}, Tx Index: {}",
- res.block_hash, res.block_number, res.tx_hash, res.tx_index
- );
- println!("Transfer completed successfully");
+ println!(
+ "From={}, To={}, Amount={}",
+ result.event.from, result.event.to, result.event.amount
+ );
+ println!(
+ "TxHash={:?}, BlockHash={:?}",
+ result.tx_hash, result.block_hash
+ );
- Ok(())
-}
-
-// Add a main function to call transfer_keep_alive
-#[tokio::main]
-async fn main() {
- if let Err(e) = transfer_keep_alive().await {
- eprintln!("Error: {:?}", e);
- }
+ Ok(())
}
```
2. Run the code using:
-```bash filename="terminal" name="cmd4"
+```bash
cargo run
```
@@ -156,92 +109,52 @@ cargo run
1. Inside `main.go`, add the following code:
-```go showLineNumbers filename="avail-go" name="cmd5"
+```go showLineNumbers filename="avail-go"
package main
import (
- "fmt"
- "log"
- "os"
+ "math"
+
+ "github.com/availproject/avail-go-sdk/src/config"
+ "github.com/availproject/avail-go-sdk/src/sdk"
+ "github.com/availproject/avail-go-sdk/src/sdk/tx"
+ "github.com/availproject/avail-go-sdk/src/sdk/types"
- "github.com/availproject/avail-go-sdk/metadata"
- "github.com/availproject/avail-go-sdk/primitives"
- SDK "github.com/availproject/avail-go-sdk/sdk"
- "github.com/joho/godotenv"
+ "fmt"
)
func main() {
- // Load environment variables from .env file
- err := godotenv.Load()
- if err != nil {
- log.Fatal("Error loading .env file")
- }
-
- // Make sure the SEED environment variable is set
- seed := os.Getenv("SEED")
- if seed == "" {
- log.Fatal("SEED environment variable is not set")
- }
-
- // Create an account from the SEED environment variable
- acc, err := SDK.Account.NewKeyPair(seed)
- if err != nil {
- log.Fatalf("Failed to create account: %v", err)
- }
- fmt.Println("Your account Address: " + acc.SS58Address(42))
-
- // Initialize an SDK instance
- sdk, err := SDK.NewSDK("https://turing-rpc.avail.so/rpc")
+ config, err := config.LoadConfig()
if err != nil {
- log.Fatalf("Failed to initialize SDK: %v", err)
+ fmt.Printf("cannot load config:%v", err)
}
-
- // Destination address
- destAddress, err := primitives.NewAccountIdFromAddress("5DDY2yzh8uCysYFAiRSTeQVwtZSKNF49CkQkyPH852xvrYKk")
+ api, err := sdk.NewSDK(config.ApiURL)
if err != nil {
- log.Fatalf("Failed to convert address: %v", err)
+ fmt.Printf("cannot create api:%v", err)
}
- dest := destAddress.ToMultiAddress()
+ WaitFor := sdk.BlockInclusion
- // Create a Balance from a string
- // The value is 10 AVAIL
- amount, err := metadata.NewBalanceFromString("10000000000000000000")
+ amount := uint64(math.Pow(10, 18)) * 10 // send amount 10 AVAIL
+ dest := "5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty"
+ bondAmountUCompact := types.NewUCompactFromUInt(amount)
+ BlockHash, txHash, err := tx.TransferKeepAlive(api, config.Seed, WaitFor, dest, bondAmountUCompact)
if err != nil {
- log.Fatalf("Failed to create balance: %v", err)
- }
-
- // Transferring funds while ensuring the sender's account
- // retains a minimum balance
- tx := sdk.Tx.Balances.TransferKeepAlive(dest, amount)
-
- // Execute the transaction
- res, err := tx.ExecuteAndWatchInclusion(acc, SDK.NewTransactionOptions())
- if err != nil {
- log.Fatalf("Transaction failed: %v", err)
- }
-
- // Check if the transaction was successful
- if !res.IsSuccessful().UnsafeUnwrap() {
- log.Fatal("Transaction was not successful")
+ fmt.Printf("cannot submit Transaction:%v", err)
}
-
- fmt.Println("Transaction successful")
-
- // Printing out all the values of the transaction
- fmt.Println(fmt.Sprintf(`Block Hash: %v, Block Index: %v, Tx Hash: %v, Tx Index: %v`, res.BlockHash.ToHexWith0x(), res.BlockNumber, res.TxHash.ToHexWith0x(), res.TxIndex))
- fmt.Println("Transfer completed successfully")
+ fmt.Printf("Transaction submitted successfully with block hash: %v\n and ext hash:%v", BlockHash.Hex(), txHash.Hex())
+ sdk.EventParser(api, BlockHash, "BalanceTransfer")
}
```
2. Run the code using:
-```bash filename="terminal" name="cmd6"
+```bash
go run main.go --config config.json
```
If you receive errors related to missing dependencies while trying to execute your code, run:
-```bash filename="terminal" name="cmd7"
+```bash
go mod tidy
```
and try again.
@@ -282,7 +195,7 @@ All such operations are executed with the `AppID set to 0`.
Your response should look something like this:
-
+Sample Response:
```
From=5CqgQkrDcdg5QrtuxT3H7WszrqgrBMhdwRbmMVXQzc4VSiEg, To=5DDY2yzh8uCysYFAiRSTeQVwtZSKNF49CkQkyPH852xvrYKk, Amount=10000000000000000000
@@ -299,64 +212,36 @@ TxHash=0x45a3ec18b96c2bff0d92d70ba5f0fa904b79a49610e845b72d16ccf7c094533d, Block
1. Inside `your-file-name.ts`, add the following code:
-```typescript showLineNumbers filename="avail-js" name="cmd8"
-import * as dotenv from 'dotenv';
-import { Account, SDK, BN } from 'avail-js-sdk';
-
-dotenv.config();
-
-export async function transferAllowDeath() {
- // Initialize SDK with Turing endpoint
- const sdk = await SDK.New('wss://turing-rpc.avail.so/ws');
-
- // Create account from seed in .env file
- const seed = process.env.SEED;
- if (!seed) {
- throw new Error("SEED environment variable is not set");
- }
-
- // Create account from seed
- const account = Account.new(seed);
- console.log("Sender Address: ", account.address);
-
- // Destination address to send AVAIL to
- const destinationAddress = "5DDY2yzh8uCysYFAiRSTeQVwtZSKNF49CkQkyPH852xvrYKk";
- console.log("Recipient Address: ", destinationAddress);
-
- // Amount to transfer: 12.345 AVAIL
- const amount = new BN('12345000000000000000');
-
- // Create transfer transaction
- const tx = sdk.tx.balances.transferAllowDeath(destinationAddress, amount);
- console.log("Submitting transfer transaction...");
-
- // Execute and wait for inclusion
- const res = await tx.executeWaitForInclusion(account, {});
-
- // Check if transaction was successful
- const isOk = res.isSuccessful();
- if (isOk === undefined) {
- throw new Error("Cannot check if transaction was successful");
- }
- else if (!isOk) {
- throw new Error("Transaction failed");
- }
-
- console.log(`Transaction Hash: ${res.txHash}`);
- console.log(`Block Hash: ${res.blockHash}`);
- console.log(`Block Number: ${res.blockNumber}`);
- console.log("Transfer completed successfully");
-
- process.exit(0);
-}
+```typescript showLineNumbers filename="avail-js"
+import { SDK, WaitFor, Keyring, BN } from "avail-js-sdk"
+
+const main = async () => {
+ const providerEndpoint = "wss://turing-rpc.avail.so/ws";
+ const sdk = await SDK.New(providerEndpoint)
+
+ const Alice = 'This is a random seed phrase please replace with your own';
+ const account = new Keyring({ type: "sr25519" }).addFromUri(Alice)
+ const dest = "5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw" // Eve
+ const amount = new BN(12).mul(new BN(10).pow(new BN("18"))) // twelve Avail
+
+ const result = await sdk.tx.balances.transferAllowDeath(dest, amount, WaitFor.BlockInclusion, account)
+ if (result.isErr) {
+ console.log(result.reason)
+ process.exit(1)
+ }
+
+ console.log("From=" + result.event.from + ", To=" + result.event.to + ", Amount=" + result.event.amount)
+ console.log("MaybeKilled=" + result.event2?.account)
+ console.log("TxHash=" + result.txHash + ", BlockHash=" + result.blockHash)
-// Execute the function
-transferAllowDeath();
+ process.exit()
+}
+main()
```
2. Run the code using:
-```bash filename="terminal" name="cmd9"
+```bash
ts-node your-file-name.ts
```
@@ -365,50 +250,46 @@ ts-node your-file-name.ts
1. Inside `main.rs`, add the following code:
-```rust showLineNumbers filename="avail-rust" name="cmd10"
-use dotenvy::dotenv;
-use std::env;
-use avail_rust::prelude::*;
+```rust showLineNumbers filename="avail-rust"
+use avail_rust::{Keypair, Nonce, Options, SecretUri, WaitFor, SDK};
use core::str::FromStr;
-pub async fn transfer_allow_death() -> Result<(), ClientError> {
-
- // Create a new SDK instance
- let sdk = SDK::new("wss://turing-rpc.avail.so/ws").await?;
-
- // Loading seed phrase and creating an account derived from the seed
- dotenv().ok();
- let seed = env::var("SEED").expect("SEED environment variable is not set");
- let account = account::from_secret_uri(&seed)?;
- println!("Account Address: {}", account.public_key().to_account_id());
+#[tokio::main]
+async fn main() -> Result<(), String> {
+ let sdk = SDK::new("wss://turing-rpc.avail.so/ws").await.unwrap();
- // Executing the transaction
- let dest = AccountId::from_str("5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw").unwrap();
- let amount = 12_345_000_000_000_000_000u128; // 12.345 AVAIL being transferred to the destination account
- let tx = sdk.tx.balances.transfer_allow_death(dest, amount);
- let res = tx.execute_and_watch_inclusion(&account, Options::default()).await?;
+ let alice = "This is a random seed phrase please replace with your own";
+ let secret_uri = SecretUri::from_str(alice).unwrap();
+ let account = Keypair::from_uri(&secret_uri).unwrap();
+ let dest = "5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw"; // Eve
+ let amount = 1_000_000_000_000_000_00u128; // 1 Avail
+ let options = Options::new().nonce(Nonce::BestBlockAndTxPool);
- println!(
- "Block Hash: {:?}, Block Number: {}, Tx Hash: {:?}, Tx Index: {}",
- res.block_hash, res.block_number, res.tx_hash, res.tx_index
- );
- println!("Transfer completed successfully");
+ let result = sdk
+ .tx
+ .balances
+ .transfer_allow_death(dest, amount, WaitFor::BlockInclusion, &account, Some(options))
+ .await?;
- Ok(())
-}
+ println!(
+ "From={}, To={}, Amount={}",
+ result.event.from, result.event.to, result.event.amount
+ );
+ if let Some(event) = result.event2 {
+ println!("Killed={}", event.account);
+ }
+ println!(
+ "TxHash={:?}, BlockHash={:?}",
+ result.tx_hash, result.block_hash
+ );
-// Add a main function to call transfer_allow_death
-#[tokio::main]
-async fn main() {
- if let Err(e) = transfer_allow_death().await {
- eprintln!("Error: {:?}", e);
- }
+ Ok(())
}
```
2. Run the code using:
-```bash filename="terminal" name="cmd11"
+```bash
cargo run
```
@@ -417,92 +298,52 @@ cargo run
1. Inside `main.go`, add the following code:
-```go showLineNumbers filename="avail-go" name="cmd12"
+```go showLineNumbers filename="avail-go"
package main
import (
- "fmt"
- "log"
- "os"
+ "math"
+
+ "github.com/availproject/avail-go-sdk/src/config"
+ "github.com/availproject/avail-go-sdk/src/sdk"
+ "github.com/availproject/avail-go-sdk/src/sdk/tx"
+ "github.com/availproject/avail-go-sdk/src/sdk/types"
- "github.com/availproject/avail-go-sdk/metadata"
- "github.com/availproject/avail-go-sdk/primitives"
- SDK "github.com/availproject/avail-go-sdk/sdk"
- "github.com/joho/godotenv"
+ "fmt"
)
func main() {
- // Load environment variables from .env file
- err := godotenv.Load()
- if err != nil {
- log.Fatal("Error loading .env file")
- }
-
- // Make sure the SEED environment variable is set
- seed := os.Getenv("SEED")
- if seed == "" {
- log.Fatal("SEED environment variable is not set")
- }
-
- // Create an account from the SEED environment variable
- acc, err := SDK.Account.NewKeyPair(seed)
- if err != nil {
- log.Fatalf("Failed to create account: %v", err)
- }
- fmt.Println("Your account Address: " + acc.SS58Address(42))
-
- // Initialize an SDK instance
- sdk, err := SDK.NewSDK("https://turing-rpc.avail.so/rpc")
- if err != nil {
- log.Fatalf("Failed to initialize SDK: %v", err)
- }
-
- // Destination address
- destAddress, err := primitives.NewAccountIdFromAddress("5DDY2yzh8uCysYFAiRSTeQVwtZSKNF49CkQkyPH852xvrYKk")
+ config, err := config.LoadConfig()
if err != nil {
- log.Fatalf("Failed to convert address: %v", err)
+ fmt.Printf("cannot load config:%v", err)
}
- dest := destAddress.ToMultiAddress()
-
- // Create a Balance from a string
- // The value is 10 AVAIL
- amount, err := metadata.NewBalanceFromString("10000000000000000000")
+ api, err := sdk.NewSDK(config.ApiURL)
if err != nil {
- log.Fatalf("Failed to create balance: %v", err)
+ fmt.Printf("cannot create api:%v", err)
}
+ WaitFor := sdk.BlockInclusion
- // Transferring funds without the
- // necessary checks of keeping the sender's account alive
- tx := sdk.Tx.Balances.TransferAllowDeath(dest, amount)
-
- // Execute the transaction
- res, err := tx.ExecuteAndWatchInclusion(acc, SDK.NewTransactionOptions())
+ amount := uint64(math.Pow(10, 18)) * 10 // send amount 10 AVAIL
+ dest := "5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty"
+ bondAmountUCompact := types.NewUCompactFromUInt(amount)
+ BlockHash, txHash, err := tx.TransferAllowDeath(api, config.Seed, WaitFor, dest, bondAmountUCompact)
if err != nil {
- log.Fatalf("Transaction failed: %v", err)
+ fmt.Printf("cannot submit Transaction:%v", err)
}
-
- // Check if the transaction was successful
- if !res.IsSuccessful().UnsafeUnwrap() {
- log.Fatal("Transaction was not successful")
- }
-
- fmt.Println("Transaction successful")
-
- // Printing out all the values of the transaction
- fmt.Println(fmt.Sprintf(`Block Hash: %v, Block Index: %v, Tx Hash: %v, Tx Index: %v`, res.BlockHash.ToHexWith0x(), res.BlockNumber, res.TxHash.ToHexWith0x(), res.TxIndex))
- fmt.Println("Transfer completed successfully")
+ fmt.Printf("Transaction submitted successfully with block hash: %v\n and ext hash:%v", BlockHash.Hex(), txHash.Hex())
+ sdk.EventParser(api, BlockHash, "BalanceTransfer")
}
```
2. Run the code using:
-```bash filename="terminal" name="cmd13"
+```bash
go run main.go
```
If you receive errors related to missing dependencies while trying to execute your code, run:
-```bash filename="terminal" name="cmd14"
+```bash
go mod tidy
```
and try again.
@@ -524,7 +365,7 @@ The only difference being that you need to select `balances_transferAllowDeath`
Your response should look something like this:
-
+Sample Response:
```
From=5CqgQkrDcdg5QrtuxT3H7WszrqgrBMhdwRbmMVXQzc4VSiEg, To=5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw, Amount=12000000000000000000
@@ -541,64 +382,36 @@ TxHash=0x4be89fffca3b7849066c3a7b6b29af318caa49ca12a1ba17610b0a30d97fd30e, Block
1. Inside `your-file-name.ts`, add the following code:
-```typescript showLineNumbers filename="avail-js" name="cmd15"
-import * as dotenv from 'dotenv';
-import { Account, SDK } from 'avail-js-sdk';
-
-dotenv.config();
-
-export async function transferAll() {
- // Initialize SDK with Turing endpoint
- const sdk = await SDK.New('wss://turing-rpc.avail.so/ws');
-
- // Create account from seed in .env file
- const seed = process.env.SEED;
- if (!seed) {
- throw new Error("SEED environment variable is not set");
- }
-
- // Create account from seed
- const account = Account.new(seed);
- console.log("Sender Address: ", account.address);
-
- // Destination address to send all available AVAIL to
- const destinationAddress = "5DDY2yzh8uCysYFAiRSTeQVwtZSKNF49CkQkyPH852xvrYKk";
- console.log("Recipient Address: ", destinationAddress);
-
- // Setting this value to false will reap your account
- const keepAlive = true;
-
- // Create transfer all transaction
- const tx = sdk.tx.balances.transferAll(destinationAddress, keepAlive);
- console.log("Submitting transfer all transaction...");
-
- // Execute and wait for inclusion
- const res = await tx.executeWaitForInclusion(account, {});
-
- // Check if transaction was successful
- const isOk = res.isSuccessful();
- if (isOk === undefined) {
- throw new Error("Cannot check if transaction was successful");
- }
- else if (!isOk) {
- throw new Error("Transaction failed");
- }
-
- console.log("Transfer all completed successfully");
- console.log(`Transaction Hash: ${res.txHash}`);
- console.log(`Block Hash: ${res.blockHash}`);
- console.log(`Block Number: ${res.blockNumber}`);
-
- process.exit(0);
+```typescript showLineNumbers filename="avail-js"
+import { SDK, WaitFor, Keyring, BN } from "avail-js-sdk"
+
+const main = async () => {
+ const providerEndpoint = "wss://turing-rpc.avail.so/ws";
+ const sdk = await SDK.New(providerEndpoint)
+
+ const Alice = 'This is a random seed phrase please replace with your own';
+ const account = new Keyring({ type: "sr25519" }).addFromUri(Alice)
+ const dest = "5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw" // Eve
+ const keepAlive = false
+
+ const result = await sdk.tx.balances.transferAll(dest, keepAlive, WaitFor.BlockInclusion, account)
+ if (result.isErr) {
+ console.log(result.reason)
+ process.exit(1)
+ }
+
+ console.log("From=" + result.event.from + ", To=" + result.event.to + ", Amount=" + result.event.amount)
+ console.log("MaybeKilled=" + result.event2?.account)
+ console.log("TxHash=" + result.txHash + ", BlockHash=" + result.blockHash)
+
+ process.exit()
}
-
-// Execute the function
-transferAll();
+main()
```
2. Run the code using:
-```bash filename="terminal" name="cmd16"
+```bash
ts-node your-file-name.ts
```
@@ -607,54 +420,46 @@ ts-node your-file-name.ts
1. Inside `main.rs`, add the following code:
-```rust showLineNumbers filename="avail-rust" name="cmd17"
-use dotenvy::dotenv;
-use std::env;
-use avail_rust::prelude::*;
+```rust showLineNumbers filename="avail-rust"
+use avail_rust::{Keypair, Nonce, Options, SecretUri, WaitFor, SDK};
use core::str::FromStr;
-
-pub async fn transfer_all() -> Result<(), ClientError> {
-
- // Create a new SDK instance
- let sdk = SDK::new("wss://turing-rpc.avail.so/ws").await?;
-
- // Loading seed phrase and creating an account derived from the seed
- dotenv().ok();
- let seed = env::var("SEED").expect("SEED environment variable is not set");
- let account = account::from_secret_uri(&seed)?;
- println!("Account Address: {}", account.public_key().to_account_id());
-
- // Executing the transaction
- let dest = AccountId::from_str("5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw").unwrap();
-
- // Please take note of the `keep_alive` bool parameter
- // If set to true, the transfer transaction will leave the origin account with a small balance
- // that is above the existential deposit and prevents the account from being reaped
-
- // Set the `keep_alive` parameter to `false` only if you are ok with the origin account being reaped
- let tx = sdk.tx.balances.transfer_all(dest, true);
- let res = tx.execute_and_watch_inclusion(&account, Options::default()).await?;
-
- println!(
- "Block Hash: {:?}, Block Number: {}, Tx Hash: {:?}, Tx Index: {}",
- res.block_hash, res.block_number, res.tx_hash, res.tx_index
- );
-
- Ok(())
-}
-
-// Add a main function to call transfer_all
+
#[tokio::main]
-async fn main() {
- if let Err(e) = transfer_all().await {
- eprintln!("Error: {:?}", e);
- }
+async fn main() -> Result<(), String> {
+ let sdk = SDK::new("wss://turing-rpc.avail.so/ws").await.unwrap();
+
+ let alice = "This is a random seed phrase please replace with your own";
+ let secret_uri = SecretUri::from_str(alice).unwrap();
+ let account = Keypair::from_uri(&secret_uri).unwrap();
+ let dest = "5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw"; // Eve
+ let keep_alive = false;
+ let options = Options::new().nonce(Nonce::BestBlockAndTxPool);
+
+ let result = sdk
+ .tx
+ .balances
+ .transfer_all(dest, keep_alive, WaitFor::BlockInclusion, &account, Some(options))
+ .await?;
+
+ println!(
+ "From={}, To={}, Amount={}",
+ result.event.from, result.event.to, result.event.amount
+ );
+ if let Some(event) = result.event2 {
+ println!("Killed={}", event.account);
+ }
+ println!(
+ "TxHash={:?}, BlockHash={:?}",
+ result.tx_hash, result.block_hash
+ );
+
+ Ok(())
}
```
2. Run the code using:
-```bash filename="terminal" name="cmd18"
+```bash
cargo run
```
@@ -663,85 +468,46 @@ cargo run
1. Inside `main.go`, add the following code:
-```go showLineNumbers filename="avail-go" name="cmd19"
+```go showLineNumbers filename="avail-go"
package main
import (
- "fmt"
- "log"
- "os"
+ "github.com/availproject/avail-go-sdk/src/config"
+ "github.com/availproject/avail-go-sdk/src/sdk"
+ "github.com/availproject/avail-go-sdk/src/sdk/tx"
- "github.com/availproject/avail-go-sdk/primitives"
- SDK "github.com/availproject/avail-go-sdk/sdk"
- "github.com/joho/godotenv"
+ "fmt"
)
func main() {
- // Load environment variables from .env file
- err := godotenv.Load()
+ config, err := config.LoadConfig()
if err != nil {
- log.Fatal("Error loading .env file")
- }
-
- // Make sure the SEED environment variable is set
- seed := os.Getenv("SEED")
- if seed == "" {
- log.Fatal("SEED environment variable is not set")
+ fmt.Printf("cannot load config:%v", err)
}
-
- // Create an account from the SEED environment variable
- acc, err := SDK.Account.NewKeyPair(seed)
- if err != nil {
- log.Fatalf("Failed to create account: %v", err)
- }
- fmt.Println("Your account Address: " + acc.SS58Address(42))
-
- // Initialize an SDK instance
- sdk, err := SDK.NewSDK("https://turing-rpc.avail.so/rpc")
+ api, err := sdk.NewSDK(config.ApiURL)
if err != nil {
- log.Fatalf("Failed to initialize SDK: %v", err)
+ fmt.Printf("cannot create api:%v", err)
}
+ WaitFor := sdk.BlockInclusion
- // Convert the hex string to a MultiAddress
- destAddress, err := primitives.NewAccountIdFromAddress("5DDY2yzh8uCysYFAiRSTeQVwtZSKNF49CkQkyPH852xvrYKk")
+ dest := "5GNJqTPyNqANBkUVMN1LPPrxXnFouWXoe2wNSmmEoLctxiZY"
+ BlockHash, txHash, err := tx.TransferAll(api, config.Seed, WaitFor, dest)
if err != nil {
- log.Fatalf("Failed to convert address: %v", err)
+ fmt.Printf("cannot submit Transaction:%v", err)
}
- dest := destAddress.ToMultiAddress()
-
- // Set to false if you don't want to keep the account alive
- keepAlive := true
-
- // Transferring all funds
- tx := sdk.Tx.Balances.TransferAll(dest, keepAlive)
-
- // Execute the transaction
- res, err := tx.ExecuteAndWatchInclusion(acc, SDK.NewTransactionOptions())
- if err != nil {
- log.Fatalf("Transaction failed: %v", err)
- }
-
- // Check if the transaction was successful
- if !res.IsSuccessful().UnsafeUnwrap() {
- log.Fatal("Transaction was not successful")
- }
-
- fmt.Println("Transaction successful")
-
- // Printing out all the values of the transaction
- fmt.Println(fmt.Sprintf(`Block Hash: %v, Block Index: %v, Tx Hash: %v, Tx Index: %v`, res.BlockHash.ToHexWith0x(), res.BlockNumber, res.TxHash.ToHexWith0x(), res.TxIndex))
+ fmt.Printf("Transaction submitted successfully with block hash: %v\n and ext hash:%v", BlockHash.Hex(), txHash.Hex())
}
```
2. Run the code using:
-```bash filename="terminal" name="cmd20"
+```bash
go run main.go
```
If you receive errors related to missing dependencies while trying to execute your code, run:
-```bash filename="terminal" name="cmd21"
+```bash
go mod tidy
```
and try again.
@@ -765,7 +531,7 @@ The only difference being that:
Your response should look something like this:
-
+Sample Response:
```
From=5CqgQkrDcdg5QrtuxT3H7WszrqgrBMhdwRbmMVXQzc4VSiEg, To=5DDY2yzh8uCysYFAiRSTeQVwtZSKNF49CkQkyPH852xvrYKk, Amount=14967497534555492726990
@@ -775,4 +541,4 @@ TxHash=0x3dbf0865aae15137e1fe3f922d70b7ff514a8c27e712d12ea1a8a1d4a7af9437, Block
> If you check the balance of the sender account now, it will either be `0` or equal to the `existential deposit` amount, if
> the account is unable to be reaped due to dependencies on the network.
-> In this case, while the account will continue to exist on the state trie, it's balance will be too low to perform any operations.
+> In this case, while the account will continue to exist on the state trie, it's balance will be too low to perform any operations.
\ No newline at end of file
diff --git a/app/docs/build-with-avail/page.mdx b/app/docs/build-with-avail/page.mdx
index 8a4ab8f5a..5886c8118 100644
--- a/app/docs/build-with-avail/page.mdx
+++ b/app/docs/build-with-avail/page.mdx
@@ -1,5 +1,4 @@
---
-image: "/img/docs-link-preview.png"
title: Build on Avail
asIndexPage: true
---
@@ -12,6 +11,5 @@ import { FileIcon, FilesIcon } from '@components/icons'
} title="Interact Directly with Avail DA" href="/docs/build-with-avail/interact-with-avail-da" />
} title="Deploy a Rollup on Avail DA" href="/docs/build-with-avail/deploy-rollup-on-avail" />
- } title="Get started with Turbo DA" href="/docs/build-with-avail/turbo-da" />
- } title="Use the Avail Bridge" href="/docs/build-with-avail/vectorx" />
-
+ } title="Use the Avail Bridge" href="/docs/build-with-avail/vectorx" />
+
\ No newline at end of file
diff --git a/app/docs/build-with-avail/turbo-da/page.mdx b/app/docs/build-with-avail/turbo-da/page.mdx
deleted file mode 100644
index cd979b8b0..000000000
--- a/app/docs/build-with-avail/turbo-da/page.mdx
+++ /dev/null
@@ -1,81 +0,0 @@
----
-image: "/img/docs-link-preview.png"
-title: Get started with Turbo DA
----
-
-import { Callout, Steps, Tabs } from 'nextra/components'
-
-# Get started with Turbo DA
-
-
-**TURBO DA IS CURRENTLY IN PRIVATE BETA**
-Access to Turbo DA is currently limited only to whitelisted users.
-If your team is interested in using Turbo DA, please reach out to us at [business@availproject.org](mailto:business@availproject.org)
-
-
-## Introduction
-Avail DA today has a block time of 20 seconds, and a finalization time of 2-3 blocks,
-which is to say about 60 seconds in most cases. While this is more than enough for most use cases, some applications require a faster finality process to power their
-use cases.
-
-Turbo DA is a solution to this problem. With Turbo DA, you can simply post your data to the Turbo DA API, and the service will give you a lightning-fast pre-confirmation in less than 250 milliseconds.
-Following this, we will make sure your data is eventually posted to Avail DA, with you not needing to do anything else.
-
-## How to get started
-
-1. Every account on Turbo DA needs to buy '*credits*', measured in `KBs/MBs` of data which is the amount of data they can submit to Turbo DA.
-2. Turbo DA is a highly versatile service, and allows you to buy credits in exchange for a wide variety of ERC-20 tokens.
-3. Follow the steps below to get started:
-
-
-
-### Step 1: Reach out to us (This step is only needed while the service is in private beta) [#reach-out]
-
-If your team is interested in using Turbo DA, please reach out to us at [business@availproject.org](mailto:business@availproject.org)
-
-### Step 2: Sign in to the Turbo DA dashboard [#sign-in-dashboard]
-
-Go to the the following dashboard and sign in with your whitelisted account:
-
-| | **Mainnet** | **Turing Testnet** |
-| ------------------------ | ----------------------------------------------------------------------| ------------------------------------------------------------------------------------|
-| **Frontend** | [turbo.availproject.org](https://turbo.availproject.org/) | [staging.turbo.availproject.org](https://staging.turbo.availproject.org/) |
-
-### Step 3: Configure your AppID [#configure-appid]
-
-1. We expect developers building on top of Avail DA to have a specific AppID for their application.
-2. Configure this `AppID` in the dashboard, and this is where your data will eventually be posted.
-
-
-**NOT FAMILIAR WITH APPIDS?**
-`AppIDs` are a core concept every developer building on top of Avail DA should be familiar with.
-You can go through [this page in our docs for the same](/docs/learn-about-avail/app-ids).
-
-
-
-
-
-
-### Step 4: Get your API key [#get-api-key]
-
-Click on the `Generate new key` button to generate a new API key.
-
-
-**IMPORTANT**
-1. Every API key will only be shown once on the dashboard, so make sure to copy and save it securely.
-2. You can always delete an existing API key, or generate a new one.
-
-
-
-
-
-
-### Step 5: Use the API key to submit data [#submit-data-to-turbo-da]
-
-Once you have your API key, feel free to head on over to our
-[API reference](/api-reference/avail-turbo-da-api) to start leveraging the power of Turbo DA.
-
-
-
-
-
diff --git a/app/docs/build-with-avail/vectorx/page.mdx b/app/docs/build-with-avail/vectorx/page.mdx
index d9fc9d6e5..7096ba0a1 100644
--- a/app/docs/build-with-avail/vectorx/page.mdx
+++ b/app/docs/build-with-avail/vectorx/page.mdx
@@ -1,7 +1,3 @@
----
-image: '/img/docs-link-preview.png'
----
-
import { Callout, Steps } from 'nextra/components'
# VectorX
diff --git a/app/docs/clash-of-nodes/page.mdx b/app/docs/clash-of-nodes/page.mdx
index 97170a8e6..e69de29bb 100644
--- a/app/docs/clash-of-nodes/page.mdx
+++ b/app/docs/clash-of-nodes/page.mdx
@@ -1,4 +0,0 @@
----
-image: '/img/docs-link-preview.png'
----
-
diff --git a/app/docs/faqs/page.mdx b/app/docs/faqs/page.mdx
index 392d456fd..c7a364578 100644
--- a/app/docs/faqs/page.mdx
+++ b/app/docs/faqs/page.mdx
@@ -1,5 +1,4 @@
---
-image: "/img/docs-link-preview.png"
id: faqs
title: General Frequently Asked Questions
sidebar_label: FAQs
@@ -10,6 +9,7 @@ keywords:
- node
- faqs
- question
+image: https://docs.availproject.org/img/avail/AvailDocs.png
---
import { Callout } from 'nextra/components'
@@ -72,9 +72,6 @@ Then comes Fusion Security to enable fair and additive crypto economic security.
- Business → [business@availproject.org](mailto:business@availproject.org)
- Technical questions → [Discord](https://discord.gg/AvailProject) or [Forum](https://forum.availproject.org/)
-## I found a bug/vulnerability. Where do I report it?
-We have a bug bounty program where you can report the vulnerability. Please check out the [Bug Bounty](/docs/bug-bounty) page for detailed information on how to responsibly report it.
-
## What is a popular use case of a light client?
There are many use-cases which today rely on an intermediary to maintain a full node, such that end users of a blockchain do not communicate directly with the blockchain but instead through the intermediary. Light clients have until now not been a suitable replacement for this architecture because they lacked data availability guarantees. Avail solves this issue, thus enabling more applications to directly participate on the blockchain network without intermediaries. Although Avail does support full nodes, we expect most applications will not need to run one, or will need to run fewer.
diff --git a/app/docs/glossary/page.mdx b/app/docs/glossary/page.mdx
index e911bfcdb..d450724b8 100644
--- a/app/docs/glossary/page.mdx
+++ b/app/docs/glossary/page.mdx
@@ -1,5 +1,4 @@
---
-image: "/img/docs-link-preview.png"
id: glossary
title: Glossary
sidebar_label: Glossary
@@ -10,6 +9,7 @@ keywords:
- Glossary
- Monolithic
- data availability
+image: https://availproject.github.io/img/avail/AvailDocs.png
---
import { Callout } from 'nextra/components'
diff --git a/app/docs/learn-about-avail/app-ids/page.mdx b/app/docs/learn-about-avail/app-ids/page.mdx
index b9d049e4c..dcc47f5f1 100644
--- a/app/docs/learn-about-avail/app-ids/page.mdx
+++ b/app/docs/learn-about-avail/app-ids/page.mdx
@@ -1,7 +1,3 @@
----
-image: '/img/docs-link-preview.png'
----
-
import { Callout, Steps, Tabs } from 'nextra/components'
# AppIds on Avail DA?
@@ -258,4 +254,4 @@ We are not concerned with the validity of the data being submitted, only with it
- This does not constitute an attack vector since that any app or execution layer building on top of Avail DA can always set up
certain rules to filter out unwanted data submissions.
- They could for example make it so that only data submitted with a particular signature, i.e. from a particular address, is accepted.
-All other data submitted to the particular `appID` is treated as spam, and ignored.
+All other data submitted to the particular `appID` is treated as spam, and ignored.
\ No newline at end of file
diff --git a/app/docs/learn-about-avail/avail-apps-explorer/page.mdx b/app/docs/learn-about-avail/avail-apps-explorer/page.mdx
index 4756a5f68..cd46b5c31 100644
--- a/app/docs/learn-about-avail/avail-apps-explorer/page.mdx
+++ b/app/docs/learn-about-avail/avail-apps-explorer/page.mdx
@@ -1,7 +1,3 @@
----
-image: '/img/docs-link-preview.png'
----
-
import { Callout, Steps, Tabs } from 'nextra/components'
import { Cards, Image } from 'nextra/components'
import { FileIcon, FilesIcon } from '@components/icons'
@@ -157,7 +153,7 @@ You can do a few things here:
2. Import an account via an encrypted JSON file.
3. Connect extension accounts from wallets like `Polkadot.js`, `Subwallet`, `Talisman`, etc...
4. Create a multisig account. We have covered instructions to do so [in our docs here](/user-guides/avail-multisig).
-5. Create a proxy account. We have covered instructions to do so [in our docs here](/user-guides/proxies-on-avail).
+5. Create a proxy account. We have covered instructions to do so [in our docs here](/user-guides/avail-proxy).
6. The `AvailApps` explorer also allows you to use hardware wallets to safely connect cold accounts. We have covered
instructions to do so [in our docs here](/user-guides/ledger-avail).
@@ -312,4 +308,4 @@ The `Subscan` explorer leverages it's dedicated indexer to enable users to brows
## Wrapping up
We will update this page with more examples and information as we go along.
-Feel free to join [our Discord](https://discord.gg/AvailProject) and suggest any additions that you would like to see here.
+Feel free to join [our Discord](https://discord.gg/AvailProject) and suggest any additions that you would like to see here.
\ No newline at end of file
diff --git a/app/docs/learn-about-avail/page.mdx b/app/docs/learn-about-avail/page.mdx
index 99728e6a4..475055c5b 100644
--- a/app/docs/learn-about-avail/page.mdx
+++ b/app/docs/learn-about-avail/page.mdx
@@ -1,5 +1,4 @@
---
-image: "/img/docs-link-preview.png"
title: Learn more about Avail
asIndexPage: true
---
@@ -13,4 +12,4 @@ import { FileIcon, FilesIcon } from '@components/icons'
} title="AppIDs on Avail" href="/docs/learn-about-avail/app-ids" />
} title="Get started with Avail's explorer" href="/docs/learn-about-avail/avail-apps-explorer" />
} title="Transaction fees on Avail" href="/docs/learn-about-avail/tx-pricing" />
-
+
\ No newline at end of file
diff --git a/app/docs/learn-about-avail/tx-pricing/page.mdx b/app/docs/learn-about-avail/tx-pricing/page.mdx
index a2d4b5b57..738fc403b 100644
--- a/app/docs/learn-about-avail/tx-pricing/page.mdx
+++ b/app/docs/learn-about-avail/tx-pricing/page.mdx
@@ -1,7 +1,3 @@
----
-image: '/img/docs-link-preview.png'
----
-
import { Callout, Steps, Tabs } from 'nextra/components'
# Transaction fees on Avail
diff --git a/app/docs/networks/page.mdx b/app/docs/networks/page.mdx
index 38b17e87c..ea0e3608a 100644
--- a/app/docs/networks/page.mdx
+++ b/app/docs/networks/page.mdx
@@ -1,5 +1,4 @@
---
-image: "/img/docs-link-preview.png"
id: networks
title: Network Information
sidebar_label: Network Info
@@ -12,6 +11,7 @@ keywords:
- testnet
- rpc
- chainspec
+image: https://docs.availproject.org/img/avail/AvailDocs.png
---
import { Callout, Tabs } from 'nextra/components'
@@ -19,22 +19,30 @@ import { Callout, Tabs } from 'nextra/components'
# Network Information
-As of now, **Turing** is the only supported testnet on Avail. **Kate** & **Goldberg** have been decommissioned.
+As of now, Turing is the only supported testnet on Avail. Kate has been fully decomissioned, while Goldberg is deprecated and will be decomissioned soon, even though we will keep
+some critical infra for Goldberg alive for the time being so you can keep using it.
We will keep this page updated with the latest information on new networks.
+
+THE TOKEN SYMBOL
+Please note that the token symbol for Avail DA has been changed from `AVL` to `AVAIL`.
+The Goldberg testnet however will carry on with the legacy symbol `AVL`.
+All future testnets including turing, and the mainnet will use the new symbol `AVAIL`.
+
+
**The Turing Testnet is the latest test network of the Avail Project.**
-| | **Mainnet** | **Turing Testnet** |
-| ------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| ---------------------------------------------------------------------------------------------------------------------------------|
-| **Status** | **Active** | **Active** |
-| **Subscan Explorer** | [avail.subscan.io](https://avail.subscan.io/) | [avail-turing.subscan.io](https://avail-turing.subscan.io/) |
-| **AvailApps Explorer** | [mainnet.explorer.availproject.org](http://mainnet.explorer.availproject.org/) | [turing.explorer.availproject.org](http://turing.explorer.availproject.org/) |
-| **RPC Endpoints** | [https://avail-mainnet.public.blastapi.io/](https://avail-mainnet.public.blastapi.io/)
| [wss://turing-rpc.avail.so/ws](wss://turing-rpc.avail.so/ws) | [wss://goldberg.avail.tools/ws](wss://goldberg.avail.tools/ws) |
+| **Chain Spec** | [chainspec.raw.json](https://raw.githubusercontent.com/availproject/avail/main/misc/genesis/mainnet.chain.spec.raw.json) | [chainspec.raw.json](https://github.com/availproject/avail/blob/main/misc/genesis/testnet.turing.chain.spec.raw.json) | [chainspec.raw.json](https://github.com/availproject/avail/blob/main/misc/genesis/testnet.goldberg.chain.raw.json) |
+| **Node Version** | [Latest release](https://github.com/availproject/avail/releases) | [Latest release](https://github.com/availproject/avail/releases) | [v1.10.0.0](https://github.com/availproject/avail/releases/tag/v1.10.0.0) |
+| **Light Client Version** | [Latest release](https://github.com/availproject/avail-light/releases) | [Latest release](https://github.com/availproject/avail-light/releases) | [v1.7.6](https://github.com/availproject/avail-light/releases/tag/v1.7.6) |
## Avail DA - Ethereum Bridge
@@ -76,21 +84,6 @@ deployments of the VectorX bridge.
-#### Other deployments
-
-##### Timelock
-
-| **Network** | **Timelock Contract Address** |
-|--------------------------|-------------------------------------------------------------------------------------------------------------------------------|
-| **Ethereum Mainnet** | [0x45828180bbE489350D621d002968A0585406d487](https://etherscan.io/address/0x45828180bbE489350D621d002968A0585406d487) |
-
-##### Governance
-
-| **Network** | **Governance Contract Address** |
-|--------------------------|-------------------------------------------------------------------------------------------------------------------------------|
-| **Ethereum Mainnet** | [0x7f2f87b0efc66fea0b7c30c61654e53c37993666](https://etherscan.io/address/0x7f2f87b0efc66fea0b7c30c61654e53c37993666) |
-
-
{/* | **Bridge Indexer** | [zeref-bridge-indexer.fra.avail.so](https://zeref-bridge-indexer.fra.avail.so) | [turing-bridge-indexer.fra.avail.so](https://turing-bridge-indexer.fra.avail.so/) | */}
@@ -113,18 +106,16 @@ people to connect to Avail DA. We will keep this table updated as we onboard mor
| **GlobalStake** | [https://rpc-avail.globalstake.io](https://rpc-avail.globalstake.io) | [wss://rpc-avail.globalstake.io](wss://rpc-avail.globalstake.io) |
| **BountyBlok** | [https://avail.rpc.bountyblok.io/](https://avail.rpc.bountyblok.io/) | [wss://avail.rpc.bountyblok.io/](wss://avail.rpc.bountyblok.io/) |
| **RadiumBlock** | [https://avail.public.curie.radiumblock.co/http](https://avail.public.curie.radiumblock.co/http) | [wss://avail.public.curie.radiumblock.co/ws](wss://avail.public.curie.radiumblock.co/ws) |
+| **LugaNodes** | [https://avail-rpc.lgns.net/](https://avail-rpc.lgns.net/) | [wss://avail-rpc.lgns.net/](wss://avail-rpc.lgns.net/) |
| **StakePool** | [https://rpc.avail.stakepool.dev.br/rpc](https://rpc.avail.stakepool.dev.br/rpc) | [wss://rpc.avail.stakepool.dev.br/ws](wss://rpc.avail.stakepool.dev.br/ws) |
| **OnFinality** | [https://avail.api.onfinality.io/public](https://avail.api.onfinality.io/public) | [wss://avail.api.onfinality.io/public-ws](wss://avail.api.onfinality.io/public-ws) |
### Turing Testnet
-| **Partner** | **RPC Endpoint (Turing)** | **WSS Endpoint (Turing)** |
-| ------------------------ | --------------------------------------------------------------------------------------------------------------| ------------------------------------------------------------------------------------------------------------|
-| **Ankr** | [https://rpc.ankr.com/avail_turing_testnet](https://rpc.ankr.com/avail_turing_testnet) | [wss://turing-testnet.avail-rpc.com](wss://turing-testnet.avail-rpc.com) |
-| **Bware** | [https://avail-turing.public.blastapi.io](https://avail-turing.public.blastapi.io) | [wss://avail-turing.public.blastapi.io](wss://avail-turing.public.blastapi.io) |
-| **AllNodes** | [https://avail-turing-rpc.publicnode.com](https://avail-turing-rpc.publicnode.com) | [wss://avail-turing-rpc.publicnode.com](wss://avail-turing-rpc.publicnode.com) |
-| **RadiumBlock** | [https://turing.public.curie.radiumblock.co/http](https://turing.public.curie.radiumblock.co/http) | [wss://turing.public.curie.radiumblock.co/ws](wss://turing.public.curie.radiumblock.co/ws) |
-| **BountyBlok** | [https://avail-turing.bountyblok.io/](https://avail-turing.bountyblok.io/) | [wss://avail-turing.bountyblok.io](wss://avail-turing.bountyblok.io) |
-| **OnFinality** | [https://avail-turing.api.onfinality.io/public](https://avail-turing.api.onfinality.io/public) | [wss://avail-turing.api.onfinality.io/public-ws](wss://avail-turing.api.onfinality.io/public-ws) |
-
-
+| **Partner** | **RPC Endpoint (Turing)** | **WSS Endpoint (Turing)** |
+| ------------------------ | --------------------------------------------------------------------------------------------------| ------------------------------------------------------------------------------------------|
+| **Ankr** | [https://rpc.ankr.com/avail_turing_testnet](https://rpc.ankr.com/avail_turing_testnet) | [wss://turing-testnet.avail-rpc.com](wss://turing-testnet.avail-rpc.com) |
+| **Bware** | [https://avail-turing.public.blastapi.io](https://avail-turing.public.blastapi.io) | [wss://avail-turing.public.blastapi.io](wss://avail-turing.public.blastapi.io) |
+| **AllNodes** | [https://avail-turing-rpc.publicnode.com](https://avail-turing-rpc.publicnode.com) | [wss://avail-turing-rpc.publicnode.com](wss://avail-turing-rpc.publicnode.com) |
+| **RadiumBlock** | [https://turing.public.curie.radiumblock.co/http](https://turing.public.curie.radiumblock.co/http) | [wss://turing.public.curie.radiumblock.co/ws](wss://turing.public.curie.radiumblock.co/ws) |
+| **BountyBlok** | [https://avail-turing.bountyblok.io/](https://avail-turing.bountyblok.io/) | [wss://avail-turing.bountyblok.io](wss://avail-turing.bountyblok.io) |
diff --git a/app/docs/operate-a-node/become-a-validator/0010-basics/page.mdx b/app/docs/operate-a-node/become-a-validator/0010-basics/page.mdx
index 737ebe336..0e8ef3bc0 100644
--- a/app/docs/operate-a-node/become-a-validator/0010-basics/page.mdx
+++ b/app/docs/operate-a-node/become-a-validator/0010-basics/page.mdx
@@ -1,5 +1,4 @@
---
-image: "/img/docs-link-preview.png"
id: avail-node-basics
title: Avail Node - Basics
sidebar_label: Basics
@@ -9,6 +8,7 @@ keywords:
- avail
- node
- da
+image: https://docs.availproject.org/img/avail/AvailDocs.png
---
import { Callout } from 'nextra/components'
import { Tabs } from 'nextra/components'
@@ -279,7 +279,7 @@ With all this preliminary knowledge ready to be used, we can now finally take th
Before running our node, ensure that our storage folder is removed or empty, and that we don't have any previous nodes already running. With that said, let's finally do what we've been waiting for since the beginning:
```bash
-./avail-node --chain turing --name KingMagnifico --validator -d ./node-data
+./avail-node --chain mainnet --name KingMagnifico --validator -d ./node-data
```
Output:
diff --git a/app/docs/operate-a-node/become-a-validator/0020-simple-deployment/page.mdx b/app/docs/operate-a-node/become-a-validator/0020-simple-deployment/page.mdx
index faafe18c4..3dc79bcc3 100644
--- a/app/docs/operate-a-node/become-a-validator/0020-simple-deployment/page.mdx
+++ b/app/docs/operate-a-node/become-a-validator/0020-simple-deployment/page.mdx
@@ -1,5 +1,4 @@
---
-image: "/img/docs-link-preview.png"
id: simple-node-deployment
title: Avail Node - Simple Deployment
sidebar_label: Simple Deployment
@@ -9,6 +8,7 @@ keywords:
- avail
- node
- da
+image: https://docs.availproject.org/img/avail/AvailDocs.png
---
import { Callout } from 'nextra/components'
@@ -333,4 +333,4 @@ As expected, the node is syncing new blocks. If these logs are new to you, head
## What's Next
-This is where our story ends. We have a working node connected to the Turing chain and deployed on a cloud provider. If the system restarts or the Avail Node program suddenly ends, it will be automatically restarted, so there will be almost no downtime.
+This is where our story ends. We have a working node connected to the Turing chain and deployed on a cloud provider. If the system restarts or the Avail Node program suddenly ends, it will be automatically restarted, so there will be almost no downtime.
\ No newline at end of file
diff --git a/app/docs/operate-a-node/become-a-validator/0030-session-keys/page.mdx b/app/docs/operate-a-node/become-a-validator/0030-session-keys/page.mdx
index 32c87edf6..390c424b1 100644
--- a/app/docs/operate-a-node/become-a-validator/0030-session-keys/page.mdx
+++ b/app/docs/operate-a-node/become-a-validator/0030-session-keys/page.mdx
@@ -1,5 +1,4 @@
---
-image: "/img/docs-link-preview.png"
id: session-keys
title: Avail Node - Session Keys
sidebar_label: Session Keys
@@ -9,6 +8,7 @@ keywords:
- avail
- node
- da
+image: https://docs.availproject.org/img/avail/AvailDocs.png
---
import { Callout } from 'nextra/components'
diff --git a/app/docs/operate-a-node/become-a-validator/backup-your-validator/page.mdx b/app/docs/operate-a-node/become-a-validator/backup-your-validator/page.mdx
index 99a436048..ffacc5485 100644
--- a/app/docs/operate-a-node/become-a-validator/backup-your-validator/page.mdx
+++ b/app/docs/operate-a-node/become-a-validator/backup-your-validator/page.mdx
@@ -1,5 +1,4 @@
---
-image: "/img/docs-link-preview.png"
id: backup
title: How to Backup Your Avail Validator
sidebar_label: Backup Your Validator
@@ -9,6 +8,7 @@ keywords:
- avail
- node
- validator
+image: https://docs.availproject.org/img/avail/AvailDocs.png
---
import { Callout } from 'nextra/components'
@@ -73,4 +73,4 @@ EQUIVIVOCAITON RISK
Never run two nodes with identical keys at the same time to avoid double-signing.
-This method is not recommended for routine transitions between nodes. For safer alternatives, consult the [Upgrading Guide](/docs/operate-a-node/become-a-validator/upgrade-your-validator).
+This method is not recommended for routine transitions between nodes. For safer alternatives, consult the [Upgrading Guide](/docs/operate-a-node/become-a-validator/upgrade-your-validator).
\ No newline at end of file
diff --git a/app/docs/operate-a-node/become-a-validator/chill-your-validator/page.mdx b/app/docs/operate-a-node/become-a-validator/chill-your-validator/page.mdx
index 33df7dd23..9168dad78 100644
--- a/app/docs/operate-a-node/become-a-validator/chill-your-validator/page.mdx
+++ b/app/docs/operate-a-node/become-a-validator/chill-your-validator/page.mdx
@@ -1,5 +1,4 @@
---
-image: "/img/docs-link-preview.png"
id: chill
title: Chill Your Validator
sidebar_label: Chill Your Validator
@@ -9,6 +8,7 @@ keywords:
- avail
- node
- validator
+image: https://docs.availproject.org/img/avail/AvailDocs.png
---
# Chill Your Validator
@@ -52,4 +52,4 @@ validator stake and nominator stake happens at a later stage. A governance propo
Governance intervention the physical coin deduction will happen a few days later.
Example of a slash shown in Avail Apps:
-
+
\ No newline at end of file
diff --git a/app/docs/operate-a-node/become-a-validator/monitor-your-validator/page.mdx b/app/docs/operate-a-node/become-a-validator/monitor-your-validator/page.mdx
index fee5f0f6e..bb8d49fee 100644
--- a/app/docs/operate-a-node/become-a-validator/monitor-your-validator/page.mdx
+++ b/app/docs/operate-a-node/become-a-validator/monitor-your-validator/page.mdx
@@ -1,5 +1,4 @@
---
-image: "/img/docs-link-preview.png"
id: monitor
title: How to Monitor Your Avail Validator Node
sidebar_label: Monitor Your Validator
@@ -10,6 +9,7 @@ keywords:
- node
- validator
- monitoring
+image: https://docs.availproject.org/img/avail/AvailDocs.png
---
# How to Monitor Your Avail Validator Node
@@ -185,4 +185,4 @@ Import the [Avail Node Metrics file](/static/validator_metrics.json)
You will have a new dashboard that opens and that you can use to monitor your node
-
+
\ No newline at end of file
diff --git a/app/docs/operate-a-node/become-a-validator/page.mdx b/app/docs/operate-a-node/become-a-validator/page.mdx
index b2bd94c2f..32b8cf6b5 100644
--- a/app/docs/operate-a-node/become-a-validator/page.mdx
+++ b/app/docs/operate-a-node/become-a-validator/page.mdx
@@ -1,5 +1,4 @@
---
-image: "/img/docs-link-preview.png"
title: Become a Validator
asIndexPage: true
---
@@ -19,4 +18,4 @@ import { FileIcon } from '@components/icons'
} title="Monitor Your Validator" href="/docs/operate-a-node/become-a-validator/monitor-your-validator" />
} title="Chill Your Validator" href="/docs/operate-a-node/become-a-validator/chill-your-validator" />
-
+
\ No newline at end of file
diff --git a/app/docs/operate-a-node/become-a-validator/stake-your-validator/page.mdx b/app/docs/operate-a-node/become-a-validator/stake-your-validator/page.mdx
index 5a7db2078..f97043faf 100644
--- a/app/docs/operate-a-node/become-a-validator/stake-your-validator/page.mdx
+++ b/app/docs/operate-a-node/become-a-validator/stake-your-validator/page.mdx
@@ -1,5 +1,4 @@
---
-image: "/img/docs-link-preview.png"
id: staking
title: How to Stake Your Validator
sidebar_label: Stake Your Validator
@@ -9,6 +8,7 @@ keywords:
- avail
- node
- validator
+image: https://docs.availproject.org/img/avail/AvailDocs.png
---
import { Callout } from 'nextra/components'
@@ -160,4 +160,4 @@ As you move forward, here are some essential actions to consider:
2. **Start Monitoring**: If you haven't already, set up monitoring tools to keep track of your validator's performance. Check out the [Monitoring Guide](/docs/operate-a-node/become-a-validator/monitor-your-validator) for recommendations.
-3. **Join the Community**: Connect with other validators and the Avail team on the official [Discord Channel](https://discord.com/invite/AvailProject). It's a great place to share experiences, ask questions, and get updates.
+3. **Join the Community**: Connect with other validators and the Avail team on the official [Discord Channel](https://discord.com/invite/AvailProject). It's a great place to share experiences, ask questions, and get updates.
\ No newline at end of file
diff --git a/app/docs/operate-a-node/become-a-validator/upgrade-your-validator/page.mdx b/app/docs/operate-a-node/become-a-validator/upgrade-your-validator/page.mdx
index 292360b8c..b4ec7cbdf 100644
--- a/app/docs/operate-a-node/become-a-validator/upgrade-your-validator/page.mdx
+++ b/app/docs/operate-a-node/become-a-validator/upgrade-your-validator/page.mdx
@@ -1,5 +1,4 @@
---
-image: "/img/docs-link-preview.png"
id: upgrade
title: How to Upgrade Your Avail Validator
sidebar_label: Upgrade Your Validator
@@ -9,6 +8,7 @@ keywords:
- avail
- node
- validator
+image: https://docs.availproject.org/img/avail/AvailDocs.png
---
import { Callout } from 'nextra/components'
diff --git a/app/docs/operate-a-node/deployment-options/page.mdx b/app/docs/operate-a-node/deployment-options/page.mdx
index c3545fd97..7b5eca42f 100644
--- a/app/docs/operate-a-node/deployment-options/page.mdx
+++ b/app/docs/operate-a-node/deployment-options/page.mdx
@@ -1,5 +1,4 @@
---
-image: "/img/docs-link-preview.png"
id: deployment-options
title: Hosted Deployment Options
sidebar_label: Hosted Deployments
@@ -10,6 +9,7 @@ keywords:
- node
- deployment
- provider
+image: https://docs.availproject.org/img/avail/AvailDocs.png
---
# Hosted Deployment Options
@@ -18,4 +18,4 @@ Different service providers offer hosted deployment options for Avail. These pla
| Service | Description | Deployment Type | Documentation |
| ---------- |-----------------------------------------------------------------------------------------------------------------------| --------------- |-------------------------------------------------------------------------------------------------------------------------------------------------|
-| Spheron | Cloud-based, decentralized, infrastructure services for blockchain applications, offering simplicity and scalability. | Hosted | [Deploy and Operate an Avail Testnet Validator](https://blog.spheron.network/deploy-an-avail-node-in-minutes-using-spheron-compute) |
+| Spheron | Cloud-based, decentralized, infrastructure services for blockchain applications, offering simplicity and scalability. | Hosted | [Deploy and Operate an Avail Testnet Validator](https://blog.spheron.network/deploy-an-avail-node-in-minutes-using-spheron-compute) |
\ No newline at end of file
diff --git a/app/docs/operate-a-node/node-types/page.mdx b/app/docs/operate-a-node/node-types/page.mdx
index 44aafba05..f787c15c3 100644
--- a/app/docs/operate-a-node/node-types/page.mdx
+++ b/app/docs/operate-a-node/node-types/page.mdx
@@ -1,5 +1,4 @@
---
-image: "/img/docs-link-preview.png"
id: node-types
title: What are the Types of Nodes in the Avail Network?
sidebar_label: Types of Nodes
@@ -10,6 +9,7 @@ keywords:
- node
- data availability
- da
+image: https://docs.availproject.org/img/avail/AvailDocs.png
---
# What are the Types of Nodes in the Avail Network?
diff --git a/app/docs/operate-a-node/page.mdx b/app/docs/operate-a-node/page.mdx
index 802f9da2e..3497c27e9 100644
--- a/app/docs/operate-a-node/page.mdx
+++ b/app/docs/operate-a-node/page.mdx
@@ -1,5 +1,4 @@
---
-image: "/img/docs-link-preview.png"
title: Operate a Node
asIndexPage: true
---
@@ -16,4 +15,4 @@ import { FileIcon, FilesIcon } from '@components/icons'
} title="Run an Avail Node" href="/docs/operate-a-node/run-a-full-node" />
} title="Become a Validator" href="/docs/operate-a-node/become-a-validator" />
-
+
\ No newline at end of file
diff --git a/app/docs/operate-a-node/run-a-full-node/full-node/page.mdx b/app/docs/operate-a-node/run-a-full-node/full-node/page.mdx
index dfc5b6651..2ede67ccf 100644
--- a/app/docs/operate-a-node/run-a-full-node/full-node/page.mdx
+++ b/app/docs/operate-a-node/run-a-full-node/full-node/page.mdx
@@ -1,7 +1,3 @@
----
-image: '/img/docs-link-preview.png'
----
-
import { Tabs } from 'nextra/components'
import { Callout } from 'nextra/components'
import { Steps } from 'nextra/components'
@@ -17,70 +13,6 @@ There are two main ways of running an Avail node:
2. By building from source
3. By running a pre-built image using Docker
-
-**LOOKING TO BE AN RPC PROVIDER?**
-
-We welcome all community members who are looking to run an RPC node on Avail.
-While the exact config of your node will depend on your unique requirements, the following flags are
-required to make sure your node can be used to access all RPC methods:
-
-```bash showLineNumbers filename="avail-node flags"
---state-pruning archive
---blocks-pruning archive
---rpc-methods Safe
---rpc-cors all
---unsafe-rpc-external
---enable-kate-rpc
-```
-
-
-Description of the flags:
-
-- **--state-pruning archive**:
-
- Specify the state pruning mode.
- This mode specifies when the block's state (ie, storage) should be pruned (ie, removed) from the database. This setting can only
- be set on the first creation of the database. Every subsequent run will load the pruning mode from the database and will error
- if the stored mode doesn't match this CLI value. It is fine to drop this CLI flag for subsequent runs. Possible values: -
- archive: Keep the state of all blocks. - `archive-canonical`: Keep only the state of finalized blocks. - number Keep the state of
- the last number of finalized blocks. [default: 256]
-
-- **--blocks-pruning archive**:
-
- Specify the blocks pruning mode.
- This mode specifies when the block's body (including justifications) should be pruned (ie, removed) from the database. Possible
- values: - `archive`: Keep all blocks. - `archive-canonical`: Keep only finalized blocks. - number Keep the last `number` of
- finalized blocks.
-
-- **--rpc-methods Safe**:
-
- RPC methods to expose.
- [default: auto] \
- Possible values:
- - auto: Expose every RPC method only when RPC is listening on `localhost`, otherwise serve only safe RPC methods
- - safe: Allow only a safe subset of RPC methods
- - unsafe: Expose every RPC method (even potentially unsafe ones)
-
-- **--rpc-cors all**:
-
- Specify browser *origins* allowed to access the HTTP & WS RPC servers.
- A comma-separated list of origins (protocol://domain or special `null` value). Value of `all` will disable origin validation.
-
-- **--unsafe-rpc-external**:
-
- Listen to all RPC interfaces.
-
-- **--enable-kate-rpc**:
-
- Enable the Kate pallet.
-
-
-- Looking for a list of all available config flags? Check out the [last section of this page](/docs/operate-a-node/run-a-full-node/full-node#additional-configs).
-
-
-
-
-
@@ -413,4 +345,4 @@ Alternatively, you can check out [this notion page](https://avail-project.notion
Please note that the notion page may not always be updated.
The best way to reliably get the latest config options will be `./avail-node --help`.
-
+
\ No newline at end of file
diff --git a/app/docs/operate-a-node/run-a-full-node/overview/page.mdx b/app/docs/operate-a-node/run-a-full-node/overview/page.mdx
index dfa6dc4b4..156207fb9 100644
--- a/app/docs/operate-a-node/run-a-full-node/overview/page.mdx
+++ b/app/docs/operate-a-node/run-a-full-node/overview/page.mdx
@@ -1,5 +1,4 @@
---
-image: "/img/docs-link-preview.png"
id: system-requirements
title: System Requirements
sidebar_label: System Requirements
@@ -11,6 +10,7 @@ keywords:
- docker
- validator
- data availability
+image: https://docs.availproject.org/img/avail/AvailDocs.png
---
import { Callout } from 'nextra/components'
@@ -43,4 +43,4 @@ a list of binary releases.
[clone the repo](https://github.com/availproject/avail) and build it locally.
3. **Using Docker:** If you have docker engine installed on your machine, you can use it to run
-a [pre-built docker image for the Avail node](https://hub.docker.com/r/availj/avail/tags).
+a [pre-built docker image for the Avail node](https://hub.docker.com/r/availj/avail/tags).
\ No newline at end of file
diff --git a/app/docs/operate-a-node/run-a-full-node/page.mdx b/app/docs/operate-a-node/run-a-full-node/page.mdx
index 922bb908c..a6a0d354c 100644
--- a/app/docs/operate-a-node/run-a-full-node/page.mdx
+++ b/app/docs/operate-a-node/run-a-full-node/page.mdx
@@ -1,5 +1,4 @@
---
-image: "/img/docs-link-preview.png"
title: Run an Avail node
asIndexPage: true
---
@@ -12,4 +11,4 @@ import { FileIcon } from '@components/icons'
} title="Overview" href="/docs/operate-a-node/run-a-full-node/requirements" />
} title="Run an Avail node" href="/docs/operate-a-node/run-a-full-node/full-node" />
-
+
\ No newline at end of file
diff --git a/app/docs/operate-a-node/run-a-light-client/0010-light-client/page.mdx b/app/docs/operate-a-node/run-a-light-client/0010-light-client/page.mdx
index e306485c7..37ba20f95 100644
--- a/app/docs/operate-a-node/run-a-light-client/0010-light-client/page.mdx
+++ b/app/docs/operate-a-node/run-a-light-client/0010-light-client/page.mdx
@@ -1,5 +1,4 @@
---
-image: "/img/docs-link-preview.png"
id: light-client
title: How to Run an Avail light client
sidebar_label: Run a Light Client
@@ -10,6 +9,7 @@ keywords:
- node
- light client
- da
+image: https://docs.availproject.org/img/avail/AvailDocs.png
---
import { Tabs } from 'nextra/components'
@@ -89,7 +89,7 @@ curl -sL1 avail.sh | bash
2. If everything goes well, the client output will look like this:
-
+ Sample output
```shell
2024-03-20T10:50:25.528628Z INFO avail_light::light_client: Processing finalized block block_number=562690 block_delay=20
@@ -189,7 +189,7 @@ You can configure the run command with a variety of [config flags](https://githu
4. If everything goes well, the client output will look like this:
-
+ Sample output
```shell
@@ -254,7 +254,7 @@ Detailed documentation for them can be found [in our Github repo](https://github
5. If everything goes well, the client output will look like this:
-
+ Sample output
```shell
@@ -305,7 +305,7 @@ instructions on how to run the Avail light client natively on Windows without ha
4. If everything goes well, the client output will look like this:
-
+ Sample output
```shell
2024-03-20T10:22:23.821042Z INFO avail_light::api::v2: Message published to clients topic=HeaderVerified published=0 failed=0
@@ -379,7 +379,7 @@ curl -sL1 avail.sh | bash
7. If everything goes well, the client output will look like this:
-
+ Sample output
```shell
2024-03-20T10:22:23.821042Z INFO avail_light::api::v2: Message published to clients topic=HeaderVerified published=0 failed=0
@@ -589,4 +589,4 @@ Detailed documentation for them can be found [in our Github repo](https://github
-
+
\ No newline at end of file
diff --git a/app/docs/operate-a-node/run-a-light-client/Overview/page.mdx b/app/docs/operate-a-node/run-a-light-client/Overview/page.mdx
index 316e71456..18f83a97b 100644
--- a/app/docs/operate-a-node/run-a-light-client/Overview/page.mdx
+++ b/app/docs/operate-a-node/run-a-light-client/Overview/page.mdx
@@ -1,5 +1,4 @@
---
-image: "/img/docs-link-preview.png"
id: light-client
title: Introduction to Avail light clients
sidebar_label: Overview
@@ -10,6 +9,7 @@ keywords:
- availability
- scale
- rollup
+image: https://docs.availproject.org/img/avail/AvailDocs.png
---
import { Callout } from 'nextra/components'
@@ -85,4 +85,4 @@ You can check out all the different methods supported by the Avail light client
The light client exposes an HTTP API that enables users to query the status, confidence, and application data
for each processed block. When a block is finalized in Avail, the light client performs random sampling and
verification, calculates confidence in the given block data, and if the confidence is high, retrieves the
-application data from the block. This data is then verified and stored locally for easy access.
+application data from the block. This data is then verified and stored locally for easy access.
\ No newline at end of file
diff --git a/app/docs/operate-a-node/run-a-light-client/light-client-challenge/page.mdx b/app/docs/operate-a-node/run-a-light-client/light-client-challenge/page.mdx
index a532ac627..8d6bb89bc 100644
--- a/app/docs/operate-a-node/run-a-light-client/light-client-challenge/page.mdx
+++ b/app/docs/operate-a-node/run-a-light-client/light-client-challenge/page.mdx
@@ -1,7 +1,3 @@
----
-image: '/img/docs-link-preview.png'
----
-
import { Callout } from 'nextra/components'
# The Light Client Lift-off challenge
diff --git a/app/docs/operate-a-node/run-a-light-client/page.mdx b/app/docs/operate-a-node/run-a-light-client/page.mdx
index 88782c1ff..e1f56ab5d 100644
--- a/app/docs/operate-a-node/run-a-light-client/page.mdx
+++ b/app/docs/operate-a-node/run-a-light-client/page.mdx
@@ -1,5 +1,4 @@
---
-image: "/img/docs-link-preview.png"
title: Run an Avail light client
asIndexPage: true
---
@@ -12,4 +11,4 @@ import { FileIcon } from '@components/icons'
} title="Overview" href="/docs/operate-a-node/run-a-light-client/Overview" />
} title="Run a Light Client" href="/docs/operate-a-node/run-a-light-client/0010-light-client" />
-
+
\ No newline at end of file
diff --git a/app/docs/welcome-to-avail-docs/page.mdx b/app/docs/welcome-to-avail-docs/page.mdx
index c1413d0fe..10c768a65 100644
--- a/app/docs/welcome-to-avail-docs/page.mdx
+++ b/app/docs/welcome-to-avail-docs/page.mdx
@@ -1,5 +1,4 @@
---
-image: "/img/docs-link-preview.png"
title: Start Here
---
@@ -52,7 +51,6 @@ learn more about our upcoming offerings as well as our vision for the unified fu
} title="Deploy your own rollup on Avail DA" href="/docs/build-with-avail/deploy-rollup-on-avail" />
} title="Start posting data to Avail DA" href="/docs/build-with-avail/interact-with-avail-da/read-write-on-avail" />
} title="Run your own Avail light client" href="/docs/operate-a-node/run-a-light-client" />
- } title="Run your own Avail node" href="/docs/operate-a-node/run-a-full-node" />
} title="Become a validator on Avail DA" href="/docs/operate-a-node/become-a-validator" />
@@ -62,10 +60,4 @@ learn more about our upcoming offerings as well as our vision for the unified fu
} title="Avail node API reference" href="/api-reference/avail-node-api" />
} title="Avail light client API reference" href="/api-reference/avail-lc-api" />
} title="Avail VectorX API reference" href="/api-reference/avail-bridge-api" />
-
-
-### Bug Bounty
-
-
- } title="Bug Bounty" href="/docs/bug-bounty" />
-
+
\ No newline at end of file
diff --git a/app/globals.css b/app/globals.css
index 131bb56db..0d50957ba 100644
--- a/app/globals.css
+++ b/app/globals.css
@@ -79,10 +79,12 @@
color: inherit;
}
}
+
.card_background{
- background: #141414;
- border-radius: 12px;
-}
+ border-image-source: linear-gradient(139.26deg, rgba(255, 255, 255, 0.8) -0.73%, rgba(234, 241, 251, 0.8) 100.78%);
+ box-shadow: 0px 4px 88px -16px #59789E52;
+ border-radius: 24px;
+ }
.cardImage {
height: 200px;
diff --git a/app/layout.tsx b/app/layout.tsx
index c916b3a39..b1e66f769 100644
--- a/app/layout.tsx
+++ b/app/layout.tsx
@@ -1,17 +1,17 @@
-import { Layout, Navbar, Link } from 'nextra-theme-docs'
+import { Layout, Navbar } from 'nextra-theme-docs'
import { Footer } from "@components/Footer/Footer";
-import { Head, Search, Banner } from 'nextra/components'
+import { Head, Search } from 'nextra/components'
import { Metadata } from "next";
import { ReactNode } from "react";
import { getPageMap } from 'nextra/page-map'
+import DarkHorizontal from '../public/Dark_Horizontal.svg'
import 'nextra-theme-docs/style.css'
+import Image from 'next/image'
import './globals.css'
-import { CustomNavbar } from '@components/Navbar';
-import { sharedMetadata } from '@components/lib/metadata';
-
-
-// Metadata for the website
-export const metadata = sharedMetadata
+export const metadata: Metadata = {
+ title: "Avail docs",
+ description: "Avail developer docs built using Nextra V4",
+}
const footer =
@@ -21,16 +21,6 @@ const defaultSearchOptions = {
filters: {},
sort: {}
};
-
-const banner = (
-
- Avail Nexus is now live!{" "}
-
- Check out our docs
-
- to get started.
-
-)
export default async function RootLayout({
children,
@@ -39,19 +29,29 @@ export default async function RootLayout({
}) {
return (
-
-
-
-
-
-
+
+
+
+
+
}
projectLink="https://github.com/availproject/docs"
chatLink="https://twitter.com/AvailProject"
@@ -72,7 +72,7 @@ export default async function RootLayout({
}}
pageMap={await getPageMap()}
- docsRepositoryBase="https://github.com/availproject/docs/tree/main"
+ docsRepositoryBase="https://github.com/availproject/docs/tree/main/docs"
editLink="Edit this page on GitHub"
sidebar={{ defaultMenuCollapseLevel: 1, autoCollapse: true, toggleButton: true }}
footer={footer}
diff --git a/app/opengraph-image.png b/app/opengraph-image.png
deleted file mode 100644
index 0f42d0498..000000000
Binary files a/app/opengraph-image.png and /dev/null differ
diff --git a/app/twitter-image.png b/app/twitter-image.png
deleted file mode 100644
index 0f42d0498..000000000
Binary files a/app/twitter-image.png and /dev/null differ
diff --git a/app/user-guides/_meta.ts b/app/user-guides/_meta.ts
index 3cef5296f..06854f181 100644
--- a/app/user-guides/_meta.ts
+++ b/app/user-guides/_meta.ts
@@ -1,11 +1,11 @@
export default {
"accounts": "Get started with an Avail wallet",
"avail-multisig": "Set up a multisig on Avail",
- "proxies-on-avail": "Proxy accounts on Avail",
+ "avail-proxy": "Set up a proxy on Avail",
"identity": "Set an on-chain identity",
"avail-snap": "Use Avail with MetaMask",
"ledger-avail": "Use a ledger wallet on Avail",
- "bridge-avail": "Bridge AVAIL to different chains",
+ "vectorx": "Bridge AVAIL to Ethereum",
"staking-governance": "Staking & Governance on Avail",
"avail-funds-recovery": {
"display": "hidden"
diff --git a/app/user-guides/accounts/page.mdx b/app/user-guides/accounts/page.mdx
index afb7f935a..e7a85b6d9 100644
--- a/app/user-guides/accounts/page.mdx
+++ b/app/user-guides/accounts/page.mdx
@@ -1,5 +1,4 @@
---
-image: "/img/docs-link-preview.png"
id: accounts
sidebarTitle: Get started with an Avail wallet
description: Comprehensive guide on creating and managing Avail accounts.
@@ -244,4 +243,4 @@ You can update your metedata, if needed, using the [AvailApps explorer](https://
Congratulations on successfully creating and managing your Avail account! Remember to always safeguard your account details, JSON file, and seed phrase to ensure the security of your assets.
-Ready to explore further? Navigate to the next guide to learn [how to use the Avail Explorer](/docs/learn-about-avail/avail-apps-explorer) and get hands-on experience with the network.
+Ready to explore further? Navigate to the next guide to learn [how to use the Avail Explorer](/docs/learn-about-avail/avail-apps-explorer) and get hands-on experience with the network.
\ No newline at end of file
diff --git a/app/user-guides/avail-funds-recovery/page.mdx b/app/user-guides/avail-funds-recovery/page.mdx
index 523b168af..6dcde43ff 100644
--- a/app/user-guides/avail-funds-recovery/page.mdx
+++ b/app/user-guides/avail-funds-recovery/page.mdx
@@ -1,7 +1,3 @@
----
-image: '/img/docs-link-preview.png'
----
-
import Image from 'next/image'
import { Tabs, Steps } from 'nextra/components'
import { Callout } from 'nextra/components'
diff --git a/app/user-guides/avail-multisig/page.mdx b/app/user-guides/avail-multisig/page.mdx
index a36e38bac..a84c58e60 100644
--- a/app/user-guides/avail-multisig/page.mdx
+++ b/app/user-guides/avail-multisig/page.mdx
@@ -1,7 +1,3 @@
----
-image: '/img/docs-link-preview.png'
----
-
import { Callout, Steps, Tabs } from 'nextra/components'
# Set up a multisig wallet on Avail DA
@@ -214,4 +210,4 @@ Needless to say, you will, as a signatory, be able to execute the transaction on
## 2nd way to use a multisig wallet on Avail DA (for advanced users)
Let us go through the same process as before, i.e., executing a transaction from our multisig wallet
-to transfer funds, but using the `extrinsics` tab instead. */}
+to transfer funds, but using the `extrinsics` tab instead. */}
\ No newline at end of file
diff --git a/app/user-guides/proxies-on-avail/avail-proxy/page.mdx b/app/user-guides/avail-proxy/page.mdx
similarity index 98%
rename from app/user-guides/proxies-on-avail/avail-proxy/page.mdx
rename to app/user-guides/avail-proxy/page.mdx
index 52b14339d..716488a5b 100644
--- a/app/user-guides/proxies-on-avail/avail-proxy/page.mdx
+++ b/app/user-guides/avail-proxy/page.mdx
@@ -1,7 +1,3 @@
----
-image: '/img/docs-link-preview.png'
----
-
import { Callout, Steps, Tabs } from 'nextra/components'
# Proxy Accounts on Avail DA
@@ -157,4 +153,4 @@ are actually staked from the main account, all without ever signing the transact
While proxy accounts add convenience, they also introduce new security considerations. Always verify proxy settings and permissions carefully.
-
+
\ No newline at end of file
diff --git a/app/user-guides/avail-snap/page.mdx b/app/user-guides/avail-snap/page.mdx
index 375312f1c..a437877a7 100644
--- a/app/user-guides/avail-snap/page.mdx
+++ b/app/user-guides/avail-snap/page.mdx
@@ -1,7 +1,3 @@
----
-image: '/img/docs-link-preview.png'
----
-
import { Tabs } from 'nextra/components'
import { Callout } from 'nextra/components'
import { Steps } from 'nextra/components'
@@ -111,4 +107,4 @@ Yes, the Avail Snap has been audited by [SayFer](https://sayfer.io/).
### How do I reach out to the Avail team if I have any questions related to the Avail Snap?
-We are always happy to help out our users. You can reach out to us on [Discord](https://discord.gg/AvailProject).
+We are always happy to help out our users. You can reach out to us on [Discord](https://discord.gg/AvailProject).
\ No newline at end of file
diff --git a/app/user-guides/bridge-avail/_meta.ts b/app/user-guides/bridge-avail/_meta.ts
deleted file mode 100644
index 99f086dee..000000000
--- a/app/user-guides/bridge-avail/_meta.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-export default {
- "avail-ethereum": "Bridge b/w Avail & Ethereum",
- "avail-base": "Bridge b/w Avail & Base",
- "ethereum-base": "Bridge b/w Ethereum & Base",
-}
\ No newline at end of file
diff --git a/app/user-guides/bridge-avail/avail-base/page.mdx b/app/user-guides/bridge-avail/avail-base/page.mdx
deleted file mode 100644
index 96476438e..000000000
--- a/app/user-guides/bridge-avail/avail-base/page.mdx
+++ /dev/null
@@ -1,92 +0,0 @@
----
-image: '/img/docs-link-preview.png'
----
-
-import { Callout, Steps, Tabs } from 'nextra/components'
-
-# Bridge between Avail & Base
-
-## Video guide
-
-If Youtube is more your style, you can watch the video guide below,
-or else you can just refer to the written guide below this section.
-
-
-
-
-
-## Using the Bridge
-
-
-**CHOOSE NETWORKS CAREFULLY**
-The bridge UI defaults to a `Avail → Ethereum` network combination. \
-Choose your networks carefully.
-
-
-
-
-### Go to the official `avail-bridge` UI & select the networks you want to bridge between
-
-1. Go to [bridge.availproject.org](https://bridge.availproject.org/).
-2. Select the source chain as `Avail`
-3. Select the destination chain as `Base`
-4. Or vice-versa, if you want to bridge from Base to Avail.
-
-
-
-
-
-
-### Connect your wallets
-
-1. Connect your Avail wallet.
-2. Connect your Base EVM wallet.
-
-
-
-
-
-
-### Enter transaction details
-
-1. Enter the amount you want to bridge.
-2. Click on the `Review` button to review your transaction details.
-
-
-
-
-
-
-### Initiate the bridging process
-
-1. Click on the `Initiate` button to start the bridging process.
-2. Approve the two signatures that pop up.
-
-
-
-
-
-
-### And that's it!
-
-The bridging process between Avail & Base takes around 5 minutes and the funds are sent automatically to the user
-on the destination chain.
-
-
-
-
-
-
-
-
-
-This exact process can be reversed to bridge AVAIL from Base to Avail.
-
-
diff --git a/app/user-guides/bridge-avail/ethereum-base/page.mdx b/app/user-guides/bridge-avail/ethereum-base/page.mdx
deleted file mode 100644
index d126fd262..000000000
--- a/app/user-guides/bridge-avail/ethereum-base/page.mdx
+++ /dev/null
@@ -1,67 +0,0 @@
----
-image: '/img/docs-link-preview.png'
----
-
-import { Callout, Steps, Tabs } from 'nextra/components'
-
-# Bridge between Ethereum & Base
-
-## Using the Bridge
-
-
-**CHOOSE NETWORKS CAREFULLY**
-The bridge UI defaults to a `Avail → Ethereum` network combination. \
-Choose your networks carefully.
-
-
-
-
-### Go to the official `avail-bridge` UI & select the networks you want to bridge between
-
-1. Go to [bridge.availproject.org](https://bridge.availproject.org/).
-2. Select the source chain as `Ethereum`
-3. Select the destination chain as `Base`
-4. Or vice-versa, if you want to bridge from Base to Ethereum.
-
-
-
-
-
-
-### Connect your wallets
-
-1. Connect your Ethereum EVM wallet.
-2. Connect your Base EVM wallet.
-
-
-
-
-
-
-### Enter transaction details
-
-1. Enter the amount you want to bridge.
-2. Click on the `Review` button to review your transaction details.
-
-
-
-
-
-
-### Initiate the bridging process
-
-1. Click on the `Initiate` button to start the bridging process.
-2. Approve the two signatures that pop up.
-
-
-
-
-
-
-
-
-
-This exact process can be reversed to bridge AVAIL from Base to Ethereum.
-
-
-
diff --git a/app/user-guides/bridge-avail/page.mdx b/app/user-guides/bridge-avail/page.mdx
deleted file mode 100644
index 5df2fc026..000000000
--- a/app/user-guides/bridge-avail/page.mdx
+++ /dev/null
@@ -1,17 +0,0 @@
----
-title: "Bridge AVAIL to different chains"
-asIndexPage: true
-id: bridge-avail
-description: "Bridge AVAIL to different chains"
----
-
-import { Cards } from 'nextra/components'
-import { FileIcon, FilesIcon } from '@components/icons'
-
-# Bridge AVAIL to different chains
-
-
- } title="Bridge b/w Avail & Ethereum" href="/user-guides/bridge-avail/avail-ethereum" />
- } title="Bridge b/w Avail & Base" href="/user-guides/bridge-avail/avail-base" />
- } title="Bridge b/w Ethereum & Base" href="/user-guides/bridge-avail/ethereum-base" />
-
diff --git a/app/user-guides/identity/page.mdx b/app/user-guides/identity/page.mdx
index 567d811e4..3ff1eda55 100644
--- a/app/user-guides/identity/page.mdx
+++ b/app/user-guides/identity/page.mdx
@@ -1,5 +1,4 @@
---
-image: "/img/docs-link-preview.png"
id: identity
title: How to Set an On-Chain Identity
sidebar_label: Set Your Identity
@@ -9,6 +8,7 @@ keywords:
- avail
- explorer
- identity
+image: https://docs.availproject.org/img/avail/AvailDocs.png
---
import { Callout, Steps, Tabs } from 'nextra/components'
@@ -23,7 +23,7 @@ The AvailApps explorer provides a convenient UI to set an identity for your acco
next section.
-
+Identities vs Sub-Identities
1. Each account on Avail can create a main identity and up to 100 sub-identities.
@@ -81,4 +81,4 @@ Click on `Set Identity`. Make sure the `appID` is `0`, and click on `Sign and Su
> The account will now have a registered on-chain identity which you can clear to recover the bonded AVAIL tokens.
-
+
\ No newline at end of file
diff --git a/app/user-guides/ledger-avail/page.mdx b/app/user-guides/ledger-avail/page.mdx
index 775b1b484..bb67805d4 100644
--- a/app/user-guides/ledger-avail/page.mdx
+++ b/app/user-guides/ledger-avail/page.mdx
@@ -1,7 +1,3 @@
----
-image: '/img/docs-link-preview.png'
----
-
import { Callout, Tabs, Steps} from 'nextra/components'
import YouTube from '@components/Youtube'
diff --git a/app/user-guides/proxies-on-avail/_meta.ts b/app/user-guides/proxies-on-avail/_meta.ts
deleted file mode 100644
index a665557f4..000000000
--- a/app/user-guides/proxies-on-avail/_meta.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-export default {
- "avail-proxy": "Proxy accounts",
- "avail-pure-proxy": "Pure proxy accounts",
-}
\ No newline at end of file
diff --git a/app/user-guides/proxies-on-avail/avail-pure-proxy/page.mdx b/app/user-guides/proxies-on-avail/avail-pure-proxy/page.mdx
deleted file mode 100644
index d7017aedb..000000000
--- a/app/user-guides/proxies-on-avail/avail-pure-proxy/page.mdx
+++ /dev/null
@@ -1,242 +0,0 @@
----
-title: "Pure proxy accounts on Avail"
-id: avail-pure-proxy
-description: "How to create pure proxy accounts on Avail"
----
-
-import { Callout, Steps, Tabs } from 'nextra/components'
-
-# Pure proxy accounts on Avail
-
-
-We recommend going through the previous page on [proxy accounts](/user-guides/proxies-on-avail/avail-proxy) before proceeding with this guide.
-
-
-The previous guide went over assigning ***existing*** accounts as proxies for your own account.
-The following guide will teach you how to set up proxied accounts that are not owned by anybody, but can still be used
-to sign transactions on using accounts that we own, which act as proxies for these keyless proxied accounts.
-
-The guide will have two parts:
-
-- Creating a pure proxy for a single account.
-- Creating a multisig committee with the pure proxy.
-
-## Create a pure proxy for a single account
-
-
-The proxy types remain the same for a pure proxy, you can go over them again [in our docs here](/user-guides/proxies-on-avail/avail-proxy#proxy-types)
-
-
-
-
-### Go to the Explorer
-
-Head on over to the [accounts section of the Avail explorer](https://explorer.availproject.org/#/accounts) and connect your main account.
-In my case, I start out with the highlighted account.
-
-
-
-
-
-
-### Set up the pure proxy call
-
-1. Go to the [Extrinsics section](https://explorer.avail.so/#/extrinsics) of the explorer.
-2. Select the `proxy` pallet.
-3. Select the `createPure` extrinsic.
-4. Fill in the values of the parameters according to your needs. Use a positive integer for the `index` field that you haven't used before.
-
-
-
-
-
-
-### Submit the transaction
-
-1. Click on the *'Submit Transaction'* button.
-2. Review the transaction details and submit it by clicking on the *'Sign and Submit'* button.
-
-
-
-
-
-
-### Retrieve the pure proxy address
-
-The address of the pure proxy generated by the `createPure` extrinsic is returned in the event logs of the block
-that your transaction was included in.
-We need to retrieve this address from the logs to be able to use the pure proxy. \
-There are two ways to do this:
-
-
-
-
-1. You will need the block number or block hash of the block that your transaction was included in.
-2. Go to the [network explorer page](https://explorer.avail.so/#/network) and search for your block.
-3. Scroll down to look for the event logs related to the `proxy.createPure` extrinsic.
-4. Copy the address of the pure proxy from the event logs.
-
-
-
-
-
-
-
-
-
-1. Go to the [subscan explorer](https://avail-turing.subscan.io/) and search for the address of your original account.
-2. Scroll down and click on the transaction hash of your `createPure` transaction.
-
-
-
-
-
-
-3. Scroll down to look for the event logs relevant to your transaction.
-4. Expand the event log and copy the address under the `pure` field.
-
-
-
-
-
-
-
-
-
-
-### Add the pure proxy to your address book
-
-1. Go to the [accounts page](https://explorer.availproject.org/#/accounts) of the explorer.
-2. Click on the *'Proxied'* button.
-3. Fill the pop-up with the address and give it a name of your choice.
-4. Click on the *'Add'* button to save the address.
-
-
-
-
-
-
-### Verify that the pure proxy was set up correctly
-
-1. Go to the [accounts page](https://explorer.availproject.org/#/accounts) of the explorer.
-2. Click on the *'Proxied'* button.
-
-
-
-
-
-
-3. Check that the pure proxy address is listed under the *'Proxied'* section, and that your original account
-is set up as an `any` proxy for the pure proxy.
-
-
-
-
-
-
-
-
-
-**WHAT DID WE JUST DO?**
-
-1. We started with an account that we own, in my case '*Original Account*'.
-2. We have turned that original account into an `any proxy` for this new account, in my case '*Pure Proxy 1*'.
-3. 'Pure Proxy 1' thus acts as a proxied account and we can use it to sign transactions on-chain,
-even though we don't have access to it's private key.
-
-
-## Set up a multisig committee with the pure proxy
-
-In this section, we will expand over what we learned till now to set up a multisig committee
-that will be able to securely sign transactions on-chain through a multisig proxy that will be able to sign transactions
-on behalf of the keyless proxied account we just derived.
-Here is how it will work:
-
-1. Any proposal or transaction that needs to be executed by the committee will be signed on-chain by the proxied account.
-2. The proxied account in-turn will be controlled by a multisig account that will act as it's proxy.
-3. This multisig will have a threshold of 2 out of 3 members.
-
-The structure will look like this:
-
-
-
-
-
-
-
-
-### Create a multisig with the signer addresses
-
-1. If you need instructions to set up a multisig wallet, please go through [this page in our docs](/user-guides/avail-multisig).
-2. Here is what my multisig looks like, you might need to change the number of signers or the threshold according to your needs.
-
-
-
-
-
-
-
-**TIP**
-If your multisig needs to have signatory addresses that are not owned by you, add them to your address book
-before setting up the multisig.
-
-
-### Set up the multisig as a proxy for the pure proxy
-
-> 👉 Make sure the pure proxy has some funds to pay for the transaction fees before proceeding.
-
-1. Go to the [accounts page](https://explorer.availproject.org/#/accounts) of the explorer.
-2. Click on the *'Manage proxies'* button next to the pure proxy address.
-
-
-
-
-
-
-3. Click on the *'Add proxy'* button and select your multisig address from the dropdown menu as the proxy.
-
-
-
-
-
-
-4. Submit the transaction by clicking on the *'Submit Transaction'* button.
-5. Once the transaction is successful, you should see that the pure proxy account now has two proxies.
-
-
-
-
-
-
-### Remove the original account as a proxy for the pure proxy
-
-
-**IMPORTANT**
-1. Take care to maintain at least one proxy for the pure proxy account at any given time.
-2. If you remove the last proxy for the pure proxy, you will permanently lose control over the pure proxy, with no way to recover it.
-3. The correct way to rotate proxies for your pure proxy is to first add a new proxy, and then remove the old proxy.
-
-
-1. Go back to the 'manage proxies' UI for the pure proxy, and click on the 'X' button next to the original account.
-2. Submit the transaction by clicking on the *'Submit Transaction'* button.
-
-
-
-
-
-
-3. Once the transaction is successful, you should see that the pure proxy account now has only one proxy, the multisig.
-
-
-
-
-
-
-
-
-## Final notes
-
-Hurray! You have successfully set up a multisig committee with the pure proxy.
-
-1. In this setup, you will never need to rotate the pure proxy account, since nobody has it's private key, and thus it can't be compromised.
-2. You can easily rotate the controlling multisig by adding another multisig as a proxy for the pure proxy, and then removing the old multisig as a proxy.
diff --git a/app/user-guides/proxies-on-avail/page.mdx b/app/user-guides/proxies-on-avail/page.mdx
deleted file mode 100644
index a7deaa9d4..000000000
--- a/app/user-guides/proxies-on-avail/page.mdx
+++ /dev/null
@@ -1,106 +0,0 @@
----
-title: "Proxy accounts on Avail"
-asIndexPage: true
-id: proxies-on-avail
-description: "Proxy accounts on Avail"
----
-
-import { Cards, Callout } from 'nextra/components'
-import { FileIcon, FilesIcon } from '@components/icons'
-
-# Proxy accounts on Avail
-
-## Introduction
-
-A *'proxy'* of an account on Avail DA is simply another account on the network that has the power to sign transactions on behalf of the
-original account, also known as the *'proxied'* account.
-
-We can also configure the proxy to only have permission to sign a subset of all possible transactions on behalf of the proxied account.
-We will learn more about this later.
-
-
-**MAKE SURE YOU'RE COMFORTABLE WITH THE LINGO**
-- *'Proxy'* - A proxy is an account that has the power to sign transactions on behalf of the proxied account.
-- *'Proxied'* - Refers to the original account that the proxies are signing for.
-- *'Any proxy'* - An account that has the power to sign any type of transaction on behalf of the proxied account.
-You can have many different types of proxies on Avail network. Refer to [this section in our docs](/user-guides/proxies-on-avail/avail-proxy#proxy-types) for more information.
-
-
-## 'Proxy' vs 'Pure proxy'
-
-You can create two types of proxies on Avail DA:
-
-
-
-
-
-
-### Proxy accounts
-
-When creating a proxy for an account you own, you choose the exact address of the proxy, which may or may not
-be an address that you control.
-You can do this using the `proxy.addProxy` extrinsic. The Avail Apps explorer provides a convenient UI abstraction for this,
-instructions for which can be found here:
-
-
- } title="Proxy accounts" href="/user-guides/proxies-on-avail/avail-proxy" />
-
-
-> 👉 The key principle to note here that is that you can create a proxy account that is not under your control.
-
-
-For Example
-
-You might have an account with a significant amount of funds that you want to stake on the network without taking on the
-responsibility of managing the staking operation itself.
-
-You may, in this scenario, choose to add a friend's account as a proxy to your original account, but with the stipulation that
-this proxy can only sign staking-related operations on your behalf.
-
-You therefore have a situation where a second person has the power to stake funds on your behalf, but without the ability to outright
-transfer your tokens away.
-
-
-
-1. The example above was a hypothetical scenario. Please take care while delegating responsibilities to proxies that you do not control.
-2. You can always revoke a specific proxy's permissions using the `proxy.removeProxy` extrinsic.
-
-
-### Pure proxy accounts
-
-When creating a pure proxy for an account you own, you do not get to choose the address of the proxy.
-Therein lies the key difference between a proxy and a pure proxy.
-While you get a deterministic address in the first case, the proxy address is randomly assigned in the second.
-You can create a pure proxy using the `proxy.createPure` extrinsic.
-The instructions for this can be found here:
-
-
- } title="Pure proxy accounts" href="/user-guides/proxies-on-avail/avail-pure-proxy" />
-
-
-
-Why would you want a pure proxy?
-
-You will see this more clearly in the [dedicated guide for setting up pure proxies](/user-guides/proxies-on-avail/avail-pure-proxy), but the
-short answer is that using a pure proxy setup allows you to conveniently rotate the any proxy behind the pure proxy without having to
-move funds out of the pure proxy.
-
-This is especially useful when the pure proxy is being used to hold funds on behalf of a committee that
-needs to vote on proposals using a multisig, which acts as the any proxy for the pure proxy.
-
-For example:
-
-1. Consider that a pure proxy account is being used to stake `AVAIL` on the network on behalf of a committee of 3 people.
-The committee votes on proposals using a multisig, which acts as the any proxy for the pure proxy.
-
-2. If one of the committee members needs to be replaced, a fresh multisig will need to be setup to accommodate the new member.
-
-3. With a pure proxy setup, the old multisig can simply be rotated out in favour of the new multisig without having to unstake or move funds
- out of the pure proxy.
-
-4. Any other way of implementing this would require an unstaking of funds followed by a migration into a new account.
-
-
-
-Since nobody actually owns the private key of a pure proxy, it cannot be compromised via a private key leak.
-
diff --git a/app/user-guides/staking-governance/governance-on-avail/avail-improvement-proposal/page.mdx b/app/user-guides/staking-governance/governance-on-avail/avail-improvement-proposal/page.mdx
index 2262bb232..dff74dd1f 100644
--- a/app/user-guides/staking-governance/governance-on-avail/avail-improvement-proposal/page.mdx
+++ b/app/user-guides/staking-governance/governance-on-avail/avail-improvement-proposal/page.mdx
@@ -1,7 +1,3 @@
----
-image: '/img/docs-link-preview.png'
----
-
# Avail Improvement Proposal (AIP)
The Avail Improvement Proposal (AIP) is a standard format for community members to propose changes to the Avail network.
diff --git a/app/user-guides/staking-governance/governance-on-avail/avail-transparency-report/page.mdx b/app/user-guides/staking-governance/governance-on-avail/avail-transparency-report/page.mdx
index a45df883f..f9bc68adb 100644
--- a/app/user-guides/staking-governance/governance-on-avail/avail-transparency-report/page.mdx
+++ b/app/user-guides/staking-governance/governance-on-avail/avail-transparency-report/page.mdx
@@ -1,7 +1,3 @@
----
-image: '/img/docs-link-preview.png'
----
-
# Avail Transparency Report
Avail Transparency Reports (ATR) are simple summaries of upcoming or executed changes made to the Avail Network.
@@ -15,4 +11,4 @@ ATRs include:
ATRs will be posted on the [Avail Community Forum](https://forum.availproject.org/c/governance/avail-transparency-report/34) under the ATR sub-category in the Governance section.
-> *Given the sensitivity of emergency changes, ATRs will be posted for community transparency on the forum after the changes have been made.*
+> *Given the sensitivity of emergency changes, ATRs will be posted for community transparency on the forum after the changes have been made.*
\ No newline at end of file
diff --git a/app/user-guides/staking-governance/governance-on-avail/overview/page.mdx b/app/user-guides/staking-governance/governance-on-avail/overview/page.mdx
index d51c61864..e86185d29 100644
--- a/app/user-guides/staking-governance/governance-on-avail/overview/page.mdx
+++ b/app/user-guides/staking-governance/governance-on-avail/overview/page.mdx
@@ -1,7 +1,3 @@
----
-image: '/img/docs-link-preview.png'
----
-
import { Callout } from 'nextra/components'
# Governance Phase 1 Overview
@@ -50,4 +46,4 @@ The technical committee can fast track certain critical upgrades in case of an e
## Community Feedback on Governance Process
-If you have feedback or recommendations on how the Avail governance process should be improved please share them on the [Avail community forum](https://forum.availproject.org/).
+If you have feedback or recommendations on how the Avail governance process should be improved please share them on the [Avail community forum](https://forum.availproject.org/).
\ No newline at end of file
diff --git a/app/user-guides/staking-governance/governance-on-avail/page.mdx b/app/user-guides/staking-governance/governance-on-avail/page.mdx
index e61861ee9..1393b1839 100644
--- a/app/user-guides/staking-governance/governance-on-avail/page.mdx
+++ b/app/user-guides/staking-governance/governance-on-avail/page.mdx
@@ -1,5 +1,4 @@
---
-image: "/img/docs-link-preview.png"
asIndexPage: true
sidebarTitle: Avail Governance V1
---
@@ -14,4 +13,4 @@ import { FileIcon, FilesIcon } from '@components/icons'
} title="Avail Improvement Proposal (AIP)" href="/user-guides/staking-governance/governance-on-avail/avail-improvement-proposal" />
} title="Avail Transparency Report (ATR)" href="/user-guides/staking-governance/governance-on-avail/avail-transparency-report" />
} title="Technical Committee" href="/user-guides/staking-governance/governance-on-avail/technical-committee" />
-
+
\ No newline at end of file
diff --git a/app/user-guides/staking-governance/governance-on-avail/technical-committee/page.mdx b/app/user-guides/staking-governance/governance-on-avail/technical-committee/page.mdx
index 28076cbcb..c7df2a4e9 100644
--- a/app/user-guides/staking-governance/governance-on-avail/technical-committee/page.mdx
+++ b/app/user-guides/staking-governance/governance-on-avail/technical-committee/page.mdx
@@ -1,7 +1,3 @@
----
-image: '/img/docs-link-preview.png'
----
-
# Technical Committee
The Technical Committee consists of 7 members which can perform both Emergency and Regular actions. For on-chain actions to be deployed, they must be signed for on-chain by 5/7 Technical Committee members. The Technical Committee will have more members from the community and will introduce voting parameters in the upcoming Governance phases.
diff --git a/app/user-guides/staking-governance/overview/page.mdx b/app/user-guides/staking-governance/overview/page.mdx
index a328456c6..7bc91c836 100644
--- a/app/user-guides/staking-governance/overview/page.mdx
+++ b/app/user-guides/staking-governance/overview/page.mdx
@@ -1,7 +1,3 @@
----
-image: '/img/docs-link-preview.png'
----
-
import { Callout } from 'nextra/components'
# AVAIL
@@ -49,17 +45,9 @@ The exact percentages of the AVAIL token allocation are:
PLEASE NOTE
-1. `*` This amount will be distributed through the Avail foundation.
-
-2. `**` **Public Allocation (Future Initiatives) category** is now active and may be used to support community-oriented programs
-such as airdrops, listings, campaigns, and public growth initiatives. While this allocation is currently unlocked,
-tokens only enter circulating supply once distributed to participants. All disbursements from this category are transparently
-tracked and remain subject to governance oversight by the Avail Foundation.
-You can monitor the wallet address here: [Public Allocation - Future Initiatives Wallet](https://avail.subscan.io/account/5FtmS7yZvxps28shKggLJejmDtsxyRgzhcS68sNFALuxw1UP).
+`*` This amount will be distributed through the Avail foundation.
-3. **`AVAIL` Circulating Supply:**
-The total circulating supply of `AVAIL` can vary, but an updated figure is always available
-at this endpoint: [https://www.availproject.org/api/circulating-supply](https://www.availproject.org/api/circulating-supply)
+`**` Public Allocation (Future Initiatives) category is currently unlocked but not circulating. It will be used in future public initiatives and will be subject to governance approval facilitated by the Avail Foundation. It will become part of the circulating supply once allocated to the community in future public initiatives. This category wallet can be tracked for transparency at [Public Allocation - Future Initiatives Wallet](https://avail.subscan.io/account/5FtmS7yZvxps28shKggLJejmDtsxyRgzhcS68sNFALuxw1UP).
@@ -112,4 +100,4 @@ Notice:
Effective January 20, 2025, locked tokens will be redistributed from a single account to multiple secure accounts to enhance operational security.
This strategic measure aims to strengthen the security of foundation-held assets by reducing concentration risk.
The foundation remains committed to improving operational security while maintaining transparency.
-There are no changes to the fundamental tokenomics, and distribution parameters will remain exactly as outlined in the existing documentation.
+There are no changes to the fundamental tokenomics, and distribution parameters will remain exactly as outlined in the existing documentation.
\ No newline at end of file
diff --git a/app/user-guides/staking-governance/page.mdx b/app/user-guides/staking-governance/page.mdx
index 455a555e4..de5e423d3 100644
--- a/app/user-guides/staking-governance/page.mdx
+++ b/app/user-guides/staking-governance/page.mdx
@@ -1,5 +1,4 @@
---
-image: "/img/docs-link-preview.png"
asIndexPage: true
sidebarTitle: Staking and Governance on Avail
---
@@ -13,4 +12,4 @@ import { FileIcon, FilesIcon } from '@components/icons'
} title="The AVAIL Token" href="/user-guides/staking-governance/overview" />
} title="Stake on Avail" href="/user-guides/staking-governance/stake-on-avail" />
} title="Avail Governance V1" href="/user-guides/staking-governance/governance-on-avail" />
-
+
\ No newline at end of file
diff --git a/app/user-guides/staking-governance/stake-on-avail/direct-nomination/page.mdx b/app/user-guides/staking-governance/stake-on-avail/direct-nomination/page.mdx
index 70ad1a052..465b5fbc2 100644
--- a/app/user-guides/staking-governance/stake-on-avail/direct-nomination/page.mdx
+++ b/app/user-guides/staking-governance/stake-on-avail/direct-nomination/page.mdx
@@ -1,5 +1,4 @@
---
-image: "/img/docs-link-preview.png"
id: nominating
title: How to Nominate
sidebar_label: Nominating (Staking)
@@ -11,6 +10,7 @@ keywords:
- nominate
- staking
- delegating
+image: https://docs.availproject.org/img/avail/AvailDocs.png
---
import Image from 'next/image'
import { Steps } from 'nextra/components'
@@ -139,4 +139,4 @@ What happens with your stake depends on the choice you made in `Step 5`:
- **To Your Account**: This will send your rewards to the account you used to stake.
- **To Another Account**: This will send your rewards to the account you specified.
-
+
\ No newline at end of file
diff --git a/app/user-guides/staking-governance/stake-on-avail/nomination-pools/page.mdx b/app/user-guides/staking-governance/stake-on-avail/nomination-pools/page.mdx
index 723fdc1b5..dd0f43530 100644
--- a/app/user-guides/staking-governance/stake-on-avail/nomination-pools/page.mdx
+++ b/app/user-guides/staking-governance/stake-on-avail/nomination-pools/page.mdx
@@ -1,5 +1,4 @@
---
-image: "/img/docs-link-preview.png"
id: nomination-pools
title: How to Create Nomination Pools on Avail
sidebar_label: Nomination Pools
@@ -12,6 +11,7 @@ keywords:
- nominate
- pools
- stake
+image: https://docs.availproject.org/img/avail/AvailDocs.png
---
import Image from 'next/image'
import { Steps } from 'nextra/components'
@@ -25,7 +25,7 @@ import { Tabs } from 'nextra/components'
Nomination pools are a critical feature in Avail's consensus system, akin to those in [Polkadot and Substrate](https://wiki.polkadot.network/docs/learn-nomination-pools), They allow users to combine their stakes, effectively acting as a single nominator. This approach addresses the limitations of individual small stakes and ensures more efficient participation in the staking process.
-
+Pool Mechanics
### Features
@@ -62,7 +62,7 @@ Nomination pools are a critical feature in Avail's consensus system, akin to tho
-
+Pool Administration
### States of a Pool
@@ -221,7 +221,7 @@ Read below for more information on the same.
-
+Setting Pool Commissions
As the pool administrator on Avail, you have the capability to establish commission rates that affect the staking rewards distribution. These are the steps and parameters to configure your pool's commissions:
@@ -254,7 +254,7 @@ When setting these parameters, balance the need to incentivize pool operation wi
-
+Exiting a Nomination Pool
Members of a nomination pool on Avail have the flexibility to leave the pool at any time through a process called unbonding. Here's how it works:
@@ -280,4 +280,4 @@ Members of a nomination pool on Avail have the flexibility to leave the pool at
- Pool admins should provide members with clear instructions on the unbonding and withdrawal process, including any platform-specific timelines or conditions.
- It is advisable to keep members informed about the status of their unbonding requests and any actions they need to take to complete the withdrawal.
-
+
\ No newline at end of file
diff --git a/app/user-guides/staking-governance/stake-on-avail/overview/page.mdx b/app/user-guides/staking-governance/stake-on-avail/overview/page.mdx
index 85b042afb..dd08c773b 100644
--- a/app/user-guides/staking-governance/stake-on-avail/overview/page.mdx
+++ b/app/user-guides/staking-governance/stake-on-avail/overview/page.mdx
@@ -1,7 +1,3 @@
----
-image: '/img/docs-link-preview.png'
----
-
import { Callout } from 'nextra/components'
# Stake on Avail
diff --git a/app/user-guides/staking-governance/stake-on-avail/page.mdx b/app/user-guides/staking-governance/stake-on-avail/page.mdx
index 9d4bb7f5d..18d31a3a4 100644
--- a/app/user-guides/staking-governance/stake-on-avail/page.mdx
+++ b/app/user-guides/staking-governance/stake-on-avail/page.mdx
@@ -1,5 +1,4 @@
---
-image: "/img/docs-link-preview.png"
asIndexPage: true
sidebarTitle: Stake on Avail
---
@@ -13,4 +12,4 @@ import { FileIcon, FilesIcon } from '@components/icons'
} title="Overview" href="/user-guides/staking-governance/stake-on-avail/overview" />
} title="Direct Nomination" href="/user-guides/staking-governance/stake-on-avail/direct-nomination"/>
} title="Nomination Pools" href="/user-guides/staking-governance/stake-on-avail/nomination-pools" />
-
+
\ No newline at end of file
diff --git a/app/user-guides/bridge-avail/avail-ethereum/page.mdx b/app/user-guides/vectorx/page.mdx
similarity index 91%
rename from app/user-guides/bridge-avail/avail-ethereum/page.mdx
rename to app/user-guides/vectorx/page.mdx
index 72584cf18..7df23850c 100644
--- a/app/user-guides/bridge-avail/avail-ethereum/page.mdx
+++ b/app/user-guides/vectorx/page.mdx
@@ -1,7 +1,3 @@
----
-image: '/img/docs-link-preview.png'
----
-
import { Callout, Steps, Tabs } from 'nextra/components'
@@ -21,7 +17,7 @@ between Avail DA and Ethereum, which enables use cases like token bridging.
This is a non-technical tutorial focussed on actually using the bridge via a convinient web interface built by Avail.
-
+Frequently Asked Questions (FAQs)
1. Will my bridged tokens automatically appear in my wallet on the other side?
@@ -70,7 +66,7 @@ Please keep this in mind and have some ETH ready on the EVM wallet address that
-### Go to the official `avail-bridge` UI & fill out your transaction details
+### Go to the official `avail-bridge` UI
Go to [bridge.availproject.org](https://bridge.availproject.org/), and then connect an Avail wallet,
and an EVM wallet to the website.
@@ -81,26 +77,17 @@ The funds on Ethereum will be claimable only by the EVM address you connect here
-
+
-### Review your transaction details
-
-Click on the `Initiate` button to start the bridging process.
-
-
-
-
-
-### Now, wait!
+### Initiate the bridging, and wait!
Bridging AVAIL from Avail DA to Ethereum typically takes 1-2 hours.
You can check the `Transactions` tab in the UI to see the status of your transaction.
Wait for the transaction status to change to `Claim Ready`.
-
-
+
### Claim your funds
@@ -115,7 +102,7 @@ Please note that you are executing a transaction on Ethereum in this step, so yo