14 个稳定版本
4.166.0 | 2024 年 7 月 5 日 |
---|---|
4.104.0 | 2024 年 4 月 12 日 |
4.96.0 | 2024 年 3 月 4 日 |
4.51.0 | 2023 年 12 月 6 日 |
0.2.16 | 2022 年 9 月 2 日 |
#505 in 魔法豆
610KB
3.5K SLoC
Cargo partisia-contract
为 Partisia 区块链编译智能合约,以便在链上部署。
安装
要安装,请运行以下命令
cargo install cargo-partisia-contract
用法
为 Partisia 区块链编译智能合约,以便在链上部署。
Usage: cargo partisia-contract <COMMAND>
Commands:
build Compile contracts to WASM and generate ABI files.
init Initialize the contract. Retrieves dependencies for build.
new Create a new smart contract project.
print-version Print the client and binder version of the contract.
path-of-wasm Print the expected WASM file path based on the context of Cargo.toml
path-of-abi Print the expected ABI file path based on the context of Cargo.toml
set-sdk Update the sdk used for compiling the contracts.
abi Inspect or generate code from an ABI-file.
cli Interact with the Partisia blockchain through the partisia-cli.
help Print this message or the help of the given subcommand(s)
Options:
-h, --help
Print help (see a summary with '-h')
-V, --version
Print version
build
编译用于在 Partisia 区块链上部署的智能合约。
Usage: cargo partisia-contract build [OPTIONS] [ADDITIONAL_ARGS]...
Arguments:
[ADDITIONAL_ARGS]... Additional arguments that will be passed along to cargo build,
see cargo build --help for details.
Options:
-r, --release Build artifacts in release mode, with optimizations
-n, --no-abi Skip generating .abi file
-q, --quiet No messages printed to stdout
-w, --no-wasm-strip Do not remove custom sections from the WASM-file (will produce a much larger file).
-z, --no-zk Only compile the public part of the contract. Skips compilation of ZK computation.
--zkcompiler <ZK_COMPILER_PATH> Specify path to a zk-compiler JAR to use for compiling the ZK code
--disable-git-fetch-with-cli Uses cargo's built-in git library to fetch dependencies instead of the git executable
--workspace Build all packages in the workspace
--manifest-path <MANIFEST_PATH> Specify path to the Cargo.toml of the contract or workspace
--sdk <SDK> Override the sdk used for compiling the contracts. Git url and tag/branch/rev can be supplied at the same time or separately.
Example usage:
--sdk "git: https://[email protected]/partisiablockchain/language/contract-sdk.git, tag: 9.1.2"
--sdk "branch: example_branch"
--sdk "rev: 55061d796e5547e3cdf637407d928f95e2e32c59"
--coverage Compile an instrumented binary for the smart contract. This enables generation of coverage files.
-h, --help Print help
new
创建一个新的智能合约项目。
Usage: cargo partisia-contract new [OPTIONS] <path> [ADDITIONAL_ARGS]...
Arguments:
<path> The contract folder that will be created
[ADDITIONAL_ARGS]... Additional arguments that will be passed along to cargo new,
see cargo new --help for details.
Options:
-n, --name <NAME> Set the name of the contract project created
-z Create a zero knowledge contract
-h, --help Print help
init
初始化合同。检索构建依赖项。
Usage: cargo partisia-contract init [OPTIONS]
Options:
--workspace Init all zk contracts in the workspace
--manifest-path <MANIFEST_PATH> Specify path to the Cargo.toml of the contract or workspace
-h, --help Print help
path-of-abi
根据 Cargo.toml 的上下文打印预期的 ABI 文件路径。
Usage: cargo partisia-contract path-of-abi [OPTIONS]
Options:
-r, --release File is in release folder instead of debug
--manifest-path <MANIFEST_PATH> Specify path to the Cargo.toml of the contract or workspace
-h, --help Print help
path-of-wasm
根据 Cargo.toml 的上下文打印预期的 WASM 文件路径。
Usage: cargo partisia-contract path-of-wasm [OPTIONS]
Options:
-r, --release File is in release folder instead of debug
--manifest-path <MANIFEST_PATH> Specify path to the Cargo.toml of the contract or workspace
-h, --help Print help
print-version
打印合同的客户端和绑定器版本。
Usage: cargo partisia-contract print-version [OPTIONS] <WASM contract>
Arguments:
<WASM contract> The wasm file to load
Options:
-b, --bashlike Print the version as bash variables
-h, --help Print help
set-sdk
更新用于编译合同的 SDK。
Usage: cargo partisia-contract set-sdk [OPTIONS] <sdk>
Arguments:
<sdk> The new sdk value. Git url and tag/branch/rev can be supplied at the same time or separately.
Example usage:
set-sdk "git: https://[email protected]/partisiablockchain/language/contract-sdk.git, tag: 9.1.2"
set-sdk "branch: example_branch"
set-sdk "rev: 55061d796e5547e3cdf637407d928f95e2e32c59"
Options:
--workspace Set the sdk for all packages in the workspace
--manifest-path <MANIFEST_PATH> Specify path to the Cargo.toml of the contract or workspace
-h, --help Print help
abi
检查或从 ABI 文件生成代码。ABI 客户端命令的规范可以在 此处 找到。
Inspect or generate code from an ABI-file.
Usage: cargo partisia-contract abi [OPTIONS] [ADDITIONAL_ARGS]...
Arguments:
[ADDITIONAL_ARGS]... Additional arguments that will be passed along to abi-cli.jar
Options:
-q, --quiet No messages printed to stdout
-u, --use <URL> Url specifying the location to retrieve the abi-cli JAR from. If not given, a user configuration file in
~/.abigen/config.toml or default values will be used.
Uses netrc for authentication.
Example usage:
--use https://gitlab.com/api/v4/groups/12499775/-/packages/maven/com/partisiablockchain/language/abi-cli/4.75.0/abi-cli-4.75.0-jar-with-dependencies.jar
-h, --help Print help
cli
通过 partisia-cli 与 Partisia 区块链交互。Partisia-CLI 命令的规范可以在 此处 找到。
Interact with the Partisia blockchain through the partisia-cli.
Usage: cargo partisia-contract cli [OPTIONS] [ADDITIONAL_ARGS]...
Arguments:
[ADDITIONAL_ARGS]... Additional arguments that will be passed along to partisia-cli.jar
Options:
-q, --quiet No messages printed to stdout
-u, --use <URL> Url specifying the location to retrieve the partisia-cli JAR from. If not given, a user configuration file in
~/.pbc/config.toml or default values will be used.
Uses netrc for authentication.
Example usage:
--use https://gitlab.com/api/v4/groups/12499775/-/packages/maven/com/partisiablockchain/language/partisia-cli/4.1.0/partisia-cli-4.1.0-jar-with-dependencies.jar
-h, --help Print help
如何使用
进入包含您的 Cargo.toml 和合同的 rust 项目。
可以在 此处 找到用 rust 编写的合同的示例。
当您位于该目录时,运行以下命令以编译合同并生成 ABI。
cargo partisia-contract build
这将构建并写入合同和 ABI 文件到 target/wasm32-unknown-unknown/debug
。
如果您使用--release
标志运行,文件将位于target/wasm32-unknown-unknown/release
目录中。
依赖项
~25–39MB
~624K SLoC