Web3 开发神器:Arbitrum Stylus 智能合约全攻略

Web3开发神器:ArbitrumStylus智能合约全攻略Web3浪潮席卷全球,Arbitrum作为以太坊二层解决方案的明星项目,以低成本和高性能赢得开发者青睐。其最新工具ArbitrumStylus更是颠覆传统,让你用Rust语言轻松开发高效智能合约!通过WebAssem

Web3 开发神器:Arbitrum Stylus 智能合约全攻略

Web3 浪潮席卷全球,Arbitrum 作为以太坊二层解决方案的明星项目,以低成本和高性能赢得开发者青睐。其最新工具 Arbitrum Stylus 更是颠覆传统,让你用 Rust 语言轻松开发高效智能合约!通过 WebAssembly (WASM) 技术,Stylus 不仅大幅降低 Gas 费用,还让合约开发变得更灵活、更强大。想快速上手 Web3 开发?本文为你献上一份 Arbitrum Stylus 智能合约全攻略,从环境搭建到合约部署,手把手带你解锁 Web3 开发的无限可能!准备好了吗?让我们一起开启这场开发之旅!

本文是 Web3 开发者的入门宝典,详细讲解如何利用 Arbitrum Stylus 和 Rust 开发智能合约。内容涵盖开发环境搭建(Rust 和 Stylus CLI 安装、WASM 配置)、测试网钱包创建、项目初始化、ABI 导出、Gas 费用预估、合约部署与验证,以及合约调用和缓存优化。通过实战项目 stylus-hello-world,你将学会部署一个简单的计数器合约,并在 Arbitrum Sepolia 测试网上运行。无论你是 Web3 新手还是进阶开发者,这篇全攻略都能帮你快速掌握 Stylus 的核心技能,开启低成本、高性能的智能合约开发之旅!

实操

安装 Rust

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

安装 Stylus CLI tool

cargo install --force cargo-stylus

添加 WASM (WebAssembly) 作为 Rust 编译器的构建目标

rustup target add wasm32-unknown-unknown

验证是否安装成功

cargo stylus --version
stylus 0.5.12

cargo stylus -V
stylus 0.5.12

cargo stylus --help 
Cargo subcommand for developing Stylus projects

Usage: cargo stylus <COMMAND>

Commands:
  new           Create a new Stylus project
  init          Initializes a Stylus project in the current directory
  export-abi    Export a Solidity ABI
  constructor   Print the signature of the constructor
  activate      Activate an already deployed contract [aliases: a]
  cache         Cache a contract using the Stylus CacheManager for Arbitrum chains
  check         Check a contract [aliases: c]
  get-initcode  Generate and print initcode for the contract [aliases: e]
  deploy        Deploy a contract [aliases: d]
  verify        Verify the deployment of a Stylus contract [aliases: v]
  cgen          Generate c code bindings for a Stylus contract
  replay        Replay a transaction in gdb [aliases: r]
  trace         Trace a transaction [aliases: t]
  simulate      Simulate a transaction [aliases: s]
  help          Print this message or the help of the given subcommand(s)

Options:
  -h, --help     Print help
  -V, --version  Print version

创建开发者钱包或账户

在测试链上玩合约时,一定要用全新的空钱包(里面别放真钱)!

也就是说,测试网操作必须用零余额的新钱包,别用存过真钱的钱包!

领水

https://www.hackquest.io/zh-cn/faucets/421614

初始化项目

cargo stylus new stylus-hello-world
Cloning into '.'...
remote: Enumerating objects: 23, done.
remote: Counting objects: 100% (23/23), done.
remote: Compressing objects: 100% (18/18), done.
remote: Total 23 (delta 0), reused 12 (delta 0), pack-reused 0 (from 0)
Receiving objects: 100% (23/23), 370.10 KiB | 820.00 KiB/s, done.
initialized project in: /Users/qiaopengjun/Code/Arbitrum/stylus-hello-world

查看项目目录结构

cd stylus-hello-world/

ls
Cargo.lock          README.md           header.png          rust-toolchain.toml
Cargo.toml          examples            licenses            src

tree
.
├── Cargo.lock
├── Cargo.toml
├── README.md
├── examples
│   └── counter.rs
├── header.png
├── licenses
│   ├── Apache-2.0
│   ├── COPYRIGHT.md
│   ├── DCO.txt
│   └── MIT
├── rust-toolchain.toml
└── src
    ├── lib.rs
    └── main.rs

4 directories, 12 files
  • examples/counter.rs 使用 ethers-rs 调用智能合约的代码示意,ethers-rs 是支持跟 Ethereum 或 EVM 兼容的区块链进行交互的 Rust 库 。
  • src 使用 Rust 语言编写的智能合约源码。
  • Cargo.toml 项目的依赖配置。

导出智能合约的 ABI

Exporting the Solidity ABI interface

stylus-hello-world on  main is 📦 0.1.11 via 🦀 1.83.0 
➜ cargo stylus export-abi
/**
 * This file was automatically generated by Stylus and represents a Rust program.
 * For more information, please see [The Stylus SDK](https://github.com/OffchainLabs/stylus-sdk-rs).
 */

// SPDX-License-Identifier: MIT-OR-APACHE-2.0
pragma solidity ^0.8.23;

interface ICounter  {
    function number() external view returns (uint256);

    function setNumber(uint256 new_number) external;

    function mulNumber(uint256 new_number) external;

    function addNumber(uint256 new_number) external;

    function increment() external;

    function addFromMsgValue() external payable;
}

stylus-hello-world on  main [?] is 📦 0.1.11 via 🦀 1.83.0 took 15.9s 
➜ cargo stylus export-abi --output ./abi.json

stylus-hello-world on  main [?] is 📦 0.1.11 via 🦀 1.83.0 
➜ cat ./abi.json                             
/**
 * This file was automatically generated by Stylus and represents a Rust program.
 * For more information, please see [The Stylus SDK](https://github.com/OffchainLabs/stylus-sdk-rs).
 */

// SPDX-License-Identifier: MIT-OR-APACHE-2.0
pragma solidity ^0.8.23;

interface ICounter  {
    function number() external view returns (uint256);

    function setNumber(uint256 new_number) external;

    function mulNumber(uint256 new_number) external;

    function addNumber(uint256 new_number) external;

    function increment() external;

    function addFromMsgValue() external payable;
}

在 Stylus 项目中,cargo stylus export-abi 命令用于导出智能合约的 ABI(应用二进制接口)文件。

Check 合约

stylus-hello-world on  main [?] is 📦 0.1.11 via 🦀 1.83.0 took 12.6s 
➜  cargo stylus check -e https://sepolia-rollup.arbitrum.io/rpc
Building project with Cargo.toml version: 0.1.11
warning: unstable feature specified for `-Ctarget-feature`: `reference-types`
  |
  = note: this feature is not stably supported; its behavior can change in the future

warning: `stylus-hello-world` (lib) generated 1 warning
    Finished `release` profile [optimized] target(s) in 0.40s
stripped custom section from user wasm to remove any sensitive data
contract size: 6.4 KB (6368 bytes)
wasm size: 19.5 KB (19515 bytes)
File used for deployment hash: ./Cargo.lock
File used for deployment hash: ./Cargo.toml
File used for deployment hash: ./examples/counter.rs
File used for deployment hash: ./rust-toolchain.toml
File used for deployment hash: ./src/lib.rs
File used for deployment hash: ./src/main.rs
project metadata hash computed on deployment: "685e3cd6d6f8eeb9d74f9765b9871e81b67df06608b4f14343baeebc0c7cdc8e"
stripped custom section from user wasm to remove any sensitive data
contract size: 6.4 KB (6368 bytes)
wasm data fee: 0.000073 ETH (originally 0.000061 ETH with 20% bump)

预估 gas

stylus-hello-world on  main [?] is 📦 0.1.11 via 🦀 1.83.0 
➜ cargo stylus deploy \                                           
  --endpoint='https://sepolia-rollup.arbitrum.io/rpc' \
  --private-key="d5649d51457c" \
  --estimate-gas
Running in a Docker container for reproducibility, this may take a while
NOTE: You can opt out by doing --no-verify
Running reproducible Stylus command with toolchain 1.83.0
Cargo stylus deploy|check|verify run in a Docker container by default to ensure deployments
are reproducible, but Docker is not found in your system. Please install Docker if you wish to create 
a reproducible deployment, or opt out by using the --no-verify flag for local builds
Error: failed reproducible run

Caused by:
    Docker not running

Location:
    /Users/qiaopengjun/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/cargo-stylus-0.5.12/src/docker.rs:38:13

stylus-hello-world on  main [?] is 📦 0.1.11 via 🦀 1.83.0 
➜ cargo stylus deploy \
  --endpoint='https://sepolia-rollup.arbitrum.io/rpc' \
  --private-key="d5641457c" \
  --estimate-gas --no-verify
Building project with Cargo.toml version: 0.1.11
warning: unstable feature specified for `-Ctarget-feature`: `reference-types`
  |
  = note: this feature is not stably supported; its behavior can change in the future

warning: `stylus-hello-world` (lib) generated 1 warning
    Finished `release` profile [optimized] target(s) in 0.36s
stripped custom section from user wasm to remove any sensitive data
contract size: 6.4 KB (6368 bytes)
wasm size: 19.5 KB (19515 bytes)
File used for deployment hash: ./Cargo.lock
File used for deployment hash: ./Cargo.toml
File used for deployment hash: ./examples/counter.rs
File used for deployment hash: ./rust-toolchain.toml
File used for deployment hash: ./src/lib.rs
File used for deployment hash: ./src/main.rs
project metadata hash computed on deployment: "685e3cd6d6f8eeb9d74f9765b9871e81b67df06608b4f14343baeebc0c7cdc8e"
stripped custom section from user wasm to remove any sensitive data
contract size: 6.4 KB (6368 bytes)
wasm data fee: 0.000073 ETH (originally 0.000061 ETH with 20% bump)
estimates
deployment tx gas: 3386968
gas price: "0.100000000" gwei
deployment tx total cost: "0.000338696800000000" ETH

部署合约

stylus-hello-world on  main [?] is 📦 0.1.11 via 🦀 1.83.0 
➜ cargo stylus deploy \
  --endpoint='https://sepolia-rollup.arbitrum.io/rpc' \
  --private-key="d567c" \ 
  --no-verify 
Building project with Cargo.toml version: 0.1.11
warning: unstable feature specified for `-Ctarget-feature`: `reference-types`
  |
  = note: this feature is not stably supported; its behavior can change in the future

warning: `stylus-hello-world` (lib) generated 1 warning
    Finished `release` profile [optimized] target(s) in 0.37s
stripped custom section from user wasm to remove any sensitive data
contract size: 6.4 KB (6368 bytes)
wasm size: 19.5 KB (19515 bytes)
File used for deployment hash: ./Cargo.lock
File used for deployment hash: ./Cargo.toml
File used for deployment hash: ./examples/counter.rs
File used for deployment hash: ./rust-toolchain.toml
File used for deployment hash: ./src/lib.rs
File used for deployment hash: ./src/main.rs
project metadata hash computed on deployment: "685e3cd6d6f8eeb9d74f9765b9871e81b67df06608b4f14343baeebc0c7cdc8e"
stripped custom section from user wasm to remove any sensitive data
contract size: 6.4 KB (6368 bytes)
wasm data fee: 0.000073 ETH (originally 0.000061 ETH with 20% bump)
deployed code at address: 0x4c7701e5cdc0439d179e9ca702a8bd7904cc82fe
deployment tx hash: 0xcf05fa833211d6c6f05491177e2342bd7f59494f812187c5ac06025f0df7d3bc
contract activated and ready onchain with tx hash: 0x853b7b7189d1edbcb8e18ae9be57822148dfe0bb685a2d352b246c984b2130e6

NOTE: We recommend running cargo stylus cache bid 4c7701e5cdc0439d179e9ca702a8bd7904cc82fe 0 to cache your activated contract in ArbOS.
Cached contracts benefit from cheaper calls. To read more about the Stylus contract cache, see
https://docs.arbitrum.io/stylus/how-tos/caching-contracts

本地验证合约

stylus-hello-world on  main [?] is 📦 0.1.11 via 🦀 1.83.0 
➜ cargo stylus verify  --endpoint='https://sepolia-rollup.arbitrum.io/rpc' --deployment-tx=0xcf05fa833211d6c6f05491177e2342bd7f59494f812187c5ac06025f0df7d3bc --no-verify 
     Removed 5894 files, 1.3GiB total
Building project with Cargo.toml version: 0.1.11
   Compiling proc-macro2 v1.0.94
   Compiling unicode-ident v1.0.18
   Compiling crunchy v0.2.3
   Compiling version_check v0.9.5
   Compiling tiny-keccak v2.0.2
   Compiling paste v1.0.15
   Compiling hashbrown v0.15.2
   Compiling equivalent v1.0.2
   Compiling cfg-if v1.0.0
   Compiling serde v1.0.219
   Compiling unicode-xid v0.2.6
   Compiling typenum v1.18.0
   Compiling const-hex v1.14.0
   Compiling ruint-macro v1.2.1
   Compiling heck v0.5.0
   Compiling dunce v1.0.5
   Compiling libc v0.2.171
   Compiling generic-array v0.14.7
   Compiling memchr v2.7.4
   Compiling syn v1.0.109
   Compiling indexmap v2.8.0
   Compiling itoa v1.0.15
   Compiling proc-macro-error-attr v1.0.4
   Compiling serde_json v1.0.140
   Compiling foldhash v0.1.5
   Compiling target-triple v0.1.4
   Compiling winnow v0.7.4
   Compiling cpufeatures v0.2.17
   Compiling ruint v1.13.1
   Compiling quote v1.0.40
   Compiling syn v2.0.100
   Compiling proc-macro-error-attr2 v2.0.0
   Compiling aho-corasick v1.1.3
   Compiling crypto-common v0.1.6
   Compiling block-buffer v0.10.4
   Compiling proc-macro-error v1.0.4
   Compiling ryu v1.0.20
   Compiling bytes v1.10.1
   Compiling regex-syntax v0.8.5
   Compiling digest v0.10.7
   Compiling keccak v0.1.5
   Compiling unicode-segmentation v1.12.0
   Compiling termcolor v1.4.1
   Compiling glob v0.3.2
   Compiling sha3 v0.10.8
   Compiling dyn-clone v1.0.19
   Compiling lazy_static v1.5.0
   Compiling convert_case v0.6.0
   Compiling mini-alloc v0.8.4
   Compiling keccak-const v0.2.0
   Compiling hex v0.4.3
   Compiling dotenv v0.15.0
   Compiling macro-string v0.1.4
   Compiling syn-solidity v0.8.23
   Compiling proc-macro-error2 v2.0.1
   Compiling derivative v2.2.0
   Compiling toml_datetime v0.6.8
   Compiling serde_spanned v0.6.8
   Compiling toml_edit v0.22.24
   Compiling regex-automata v0.4.9
   Compiling derive_more-impl v1.0.0
   Compiling serde_derive v1.0.219
   Compiling toml v0.8.20
   Compiling regex v1.11.1
   Compiling derive_more v1.0.0
   Compiling trybuild v1.0.104
   Compiling alloy-sol-macro-input v0.8.23
   Compiling alloy-primitives v0.8.20
   Compiling alloy-sol-macro-expander v0.8.23
   Compiling alloy-sol-macro v0.8.23
   Compiling alloy-sol-types v0.8.20
   Compiling stylus-proc v0.8.4
   Compiling stylus-core v0.8.4
   Compiling stylus-sdk v0.8.4
   Compiling stylus-hello-world v0.1.11 (/Users/qiaopengjun/Code/Arbitrum/stylus-hello-world)
warning: unstable feature specified for `-Ctarget-feature`: `reference-types`
  |
  = note: this feature is not stably supported; its behavior can change in the future

warning: `stylus-hello-world` (lib) generated 1 warning
    Finished `release` profile [optimized] target(s) in 13.68s
stripped custom section from user wasm to remove any sensitive data
contract size: 6.4 KB (6368 bytes)
wasm size: 19.5 KB (19515 bytes)
File used for deployment hash: ./Cargo.lock
File used for deployment hash: ./Cargo.toml
File used for deployment hash: ./examples/counter.rs
File used for deployment hash: ./rust-toolchain.toml
File used for deployment hash: ./src/lib.rs
File used for deployment hash: ./src/main.rs
project metadata hash computed on deployment: "685e3cd6d6f8eeb9d74f9765b9871e81b67df06608b4f14343baeebc0c7cdc8e"
stripped custom section from user wasm to remove any sensitive data
contract size: 6.4 KB (6368 bytes)
Building project with Cargo.toml version: 0.1.11
warning: unstable feature specified for `-Ctarget-feature`: `reference-types`
  |
  = note: this feature is not stably supported; its behavior can change in the future

warning: `stylus-hello-world` (lib) generated 1 warning
    Finished `release` profile [optimized] target(s) in 0.26s
stripped custom section from user wasm to remove any sensitive data
contract size: 6.4 KB (6368 bytes)
wasm size: 19.5 KB (19515 bytes)
File used for deployment hash: ./Cargo.lock
File used for deployment hash: ./Cargo.toml
File used for deployment hash: ./examples/counter.rs
File used for deployment hash: ./rust-toolchain.toml
File used for deployment hash: ./src/lib.rs
File used for deployment hash: ./src/main.rs
project metadata hash computed on deployment: "685e3cd6d6f8eeb9d74f9765b9871e81b67df06608b4f14343baeebc0c7cdc8e"
stripped custom section from user wasm to remove any sensitive data
Verified - contract matches local project's file hashes

查看缓存合约状态

stylus-hello-world on  main [?] is 📦 0.1.11 via 🦀 1.83.0 
➜ cargo stylus cache status --address=0x4C7701E5CdC0439D179E9cA702a8bD7904Cc82fe --endpoint='https://sepolia-rollup.arbitrum.io/rpc'
Cache manager address: 0x0c9043d042ab52cfa8d0207459260040cca54253
Cache manager status: "active"
Cache size: 536.9 MB
Queue size: 103.5 MB
Minimum bid for "8kb" contract: 0
Minimum bid for "16kb" contract: 0
Minimum bid for "24kb" contract: 0
Cache is not yet at capacity, so bids of size 0 are accepted
Contract at address 0x4c7701e5cdc0439d179e9ca702a8bd7904cc82fe "is not yet cached" please use cargo stylus cache bid to cache it

缓存合约

stylus-hello-world on  main [?] is 📦 0.1.11 via 🦀 1.83.0 
➜ cargo stylus cache bid 4c7701e5cdc0439d179e9ca702a8bd7904cc82fe 0 --endpoint='https://sepolia-rollup.arbitrum.io/rpc'  --private-key="d564be417bc4d46f203b8db25df1e8d0a37be05cdec0257d7bd94d9a9d51457c"  
Checking if contract can be cached...
Sending cache bid tx...
Successfully cached contract at address: 0x4C7701E5CdC0439D179E9cA702a8bD7904Cc82fe
Sent Stylus cache bid tx with hash: 0x964f51ff3426982abc326e5308784255fb5d35e6908cc0d4c4f37e4150cccd56

查看合约

https://sepolia.arbiscan.io/address/0x4c7701e5cdc0439d179e9ca702a8bd7904cc82fe

image-20250426174441702.png

调用合约

stylus-hello-world on  main [?] is 📦 0.1.11 via 🦀 1.83.0 
➜ rustc -vV | grep host  # 获取运行 Rust 编译器的主机架构
host: aarch64-apple-darwin

stylus-hello-world on  main [!?] is 📦 0.1.11 via 🦀 1.83.0 
➜ cargo run --example counter --target=aarch64-apple-darwin
   Compiling proc-macro2 v1.0.94
......
   Compiling stylus-sdk v0.8.4
   Compiling stylus-hello-world v0.1.11 (/Users/qiaopengjun/Code/Arbitrum/stylus-hello-world)
   Compiling ethers-middleware v2.0.14
   Compiling ethers v2.0.14
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 45.74s
     Running `target/aarch64-apple-darwin/debug/examples/counter`
Counter number value = Ok(0)
Receipt = TransactionReceipt { transaction_hash: 0xc96a4d749e527f04c136b1be3bda88fbe6a45c9a5a5c5fdafda6e46ddac318a8, transaction_index: 9, block_hash: Some(0x992f2201d991d8fbbc1f04d7ff2ff552fcb95e2a41513dfcee7cf6a3d0bca491), block_number: Some(146643884), from: 0xbeabf59851426483dc70bb88860987f975c3e9a0, to: Some(0x4c7701e5cdc0439d179e9ca702a8bd7904cc82fe), cumulative_gas_used: 7328132, gas_used: Some(46684), contract_address: None, logs: [], status: Some(1), root: None, logs_bloom: 0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000, transaction_type: Some(2), effective_gas_price: Some(100000000), other: OtherFields { inner: {"gasUsedForL1": String("0x927"), "l1BlockNumber": String("0x7d19c6"), "timeboosted": Bool(false)} } }
Successfully incremented counter via a tx
New counter number value = Ok(1)

stylus-hello-world on  main [!?] is 📦 0.1.11 via 🦀 1.83.0 took 57.2s 
➜ cargo run --example counter --target=aarch64-apple-darwin
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.64s
     Running `target/aarch64-apple-darwin/debug/examples/counter`
Counter number value = Ok(1)
Receipt = TransactionReceipt { transaction_hash: 0xa8929b1db15f38df6c5c6004761ca2ea6e6d40574fb7116206e5dbe5f224a864, transaction_index: 6, block_hash: Some(0x65d687e1c1078e25dfdd5530f2f1b4726dadc0eb7cfc94d8c4c7ff1f1cb0950f), block_number: Some(146644208), from: 0xbeabf59851426483dc70bb88860987f975c3e9a0, to: Some(0x4c7701e5cdc0439d179e9ca702a8bd7904cc82fe), cumulative_gas_used: 347068, gas_used: Some(29584), contract_address: None, logs: [], status: Some(1), root: None, logs_bloom: 0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000, transaction_type: Some(2), effective_gas_price: Some(100000000), other: OtherFields { inner: {"gasUsedForL1": String("0x927"), "l1BlockNumber": String("0x7d19cd"), "timeboosted": Bool(false)} } }
Successfully incremented counter via a tx
New counter number value = Ok(2)

stylus-hello-world on  main [!?] is 📦 0.1.11 via 🦀 1.83.0 took 11.6s 
➜ cargo run --example counter --target=aarch64-apple-darwin
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.46s
     Running `target/aarch64-apple-darwin/debug/examples/counter`
Counter number value = Ok(2)
Receipt = TransactionReceipt { transaction_hash: 0x62a2f8d4d90dacfbe95775c4b5a67e6ff2590b0879b4fbea25eeaca76c5b9e3c, transaction_index: 1, block_hash: Some(0xf9cb1517c19bc8740069dfa53d35d0a88ab90d530ecdc60d5148b374f6bd8455), block_number: Some(146644270), from: 0xbeabf59851426483dc70bb88860987f975c3e9a0, to: Some(0x4c7701e5cdc0439d179e9ca702a8bd7904cc82fe), cumulative_gas_used: 29584, gas_used: Some(29584), contract_address: None, logs: [], status: Some(1), root: None, logs_bloom: 0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000, transaction_type: Some(2), effective_gas_price: Some(100000000), other: OtherFields { inner: {"gasUsedForL1": String("0x927"), "l1BlockNumber": String("0x7d19ce"), "timeboosted": Bool(false)} } }
Successfully incremented counter via a tx
New counter number value = Ok(3)

总结

通过这份 Web3 开发神器:Arbitrum Stylus 智能合约全攻略,你已经掌握了从零开始用 Rust 开发和部署 Arbitrum Stylus 智能合约的完整流程!从环境配置到合约部署,再到验证和调用,每一步都清晰可操作,助你快速上手 Web3 开发。Arbitrum Stylus 结合 Rust 和 WASM 的强大优势,为开发者提供了高效、低成本的开发体验。接下来,不妨尝试更复杂的合约逻辑,或结合前端打造属于你的 DApp!关注 Arbitrum 官方文档和社区,获取最新动态,继续探索 Web3 的无限可能!快去部署你的第一个合约,留言分享你的成果吧!

参考

点赞 0
收藏 0
分享
本文参与登链社区写作激励计划 ,好文好收益,欢迎正在阅读的你也加入。

0 条评论

请先 登录 后评论
寻月隐君
寻月隐君
0xE91e...6bE5
不要放弃,如果你喜欢这件事,就不要放弃。如果你不喜欢,那这也不好,因为一个人不应该做自己不喜欢的事。