使用 SDK (Using the SDK)

Namada 软件开发套件(SDK)可以在 namada 仓库的 namada/shared路径下找到。SDK 是用 Rust 编写的,可用于与 Namada 区块链交互,通过构建交易、签名它们,并将它们提交到网络。


快速开始 (Quick Start)

查看 SDK 使用的好起点是查看 namada 接口仓库。该仓库包含一个简单的 Web 应用程序,该程序使用 SDK 与 Namada 区块链交互。然而,重要的是要注意,应用程序集成了使用 wasm-bindgen 的 javascript,这增加了一些复杂性,但这不是必需的。


安装 (Installation)

可以通过创建一个新的 Rust 项目并在 Cargo.toml 文件中添加以下内容来安装 Namada SDK:

[package]
name = "namada-sdk-starter"
version = "0.1.0"
edition = "2021"
 
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 
[dependencies]
async-std = "1.11.0"
async-trait = "0.1.51"
borsh = "0.9.0"
file-lock = "2.0.2"
futures = "0.3.28"
getrandom = { version = "0.2" }
masp_primitives = { git = "https://github.com/anoma/masp.git", rev = "50acc5028fbcd52a05970fe7991c7850ab04358e" }
masp_proofs = { git = "https://github.com/anoma/masp.git", rev = "50acc5028fbcd52a05970fe7991c7850ab04358e", features = ["download-params"]}
# Make sure the rev is to the latest version of namada in the below repo
namada_sdk = { git = "https://github.com/anoma/namada.git", rev = "v0.24.0", default-features = false, features = ["abciplus", "namada-sdk", "std"] }
rand = {version = "0.8", default-features = false}
rand_core = {version = "0.6", default-features = false}
tendermint-config = {git="https://github.com/heliaxdev/tendermint-rs.git", rev="b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7"}
tendermint-rpc = {git="https://github.com/heliaxdev/tendermint-rs.git", rev="b7d1e5afc6f2ccb3fd1545c2174bab1cc48d7fa7", features = ["http-client"]}
thiserror = "1.0.38"
tokio = {version = "1.8.2", default-features = false}
toml = "0.5.8"
zeroize = "1.5.5"
 
[patch.crates-io]
borsh = {git = "https://github.com/heliaxdev/borsh-rs.git", rev = "cd5223e5103c4f139e0c54cf8259b7ec5ec4073a"}
borsh-derive = {git = "https://github.com/heliaxdev/borsh-rs.git", rev = "cd5223e5103c4f139e0c54cf8259b7ec5ec4073a"}
borsh-derive-internal = {git = "https://github.com/heliaxdev/borsh-rs.git", rev = "cd5223e5103c4f139e0c54cf8259b7ec5ec4073a"}
borsh-schema-derive-internal = {git = "https://github.com/heliaxdev/borsh-rs.git", rev = "cd5223e5103c4f139e0c54cf8259b7ec5ec4073a"}

安装了 sdk 后,您可以使用它与 Namada 区块链交互。


目录 (Table of contents)

Last updated