티스토리 뷰
Rust/코딩 하기
[Rust] stylus를 사용해 Rust로 Arbitrum stylus testnet에 스마트 컨트랙트 배포하기
piatoss 2023. 12. 28. 18:23Arbitrum stylus testnet faucet
네트워크 이름 | Stylus testnet |
RPC URL | https://stylus-testnet.arbitrum.io/rpc |
체인 ID | 23011913 |
통화 기호 | ETH |
블록 탐색기 URL | https://stylus-testnet-explorer.arbitrum.io/ |
stylus 설치
설치
$ RUSTFLAGS="-C link-args=-rdynamic" cargo install --force cargo-stylus
빌드 타겟 설정
$ rustup target add wasm32-unknown-unknown
설치 확인
$ cargo stylus --help
Cargo command for developing Arbitrum Stylus projects
Usage: cargo stylus <COMMAND>
Commands:
new Create a new Rust project
export-abi Export a Solidity ABI
check Check that a contract can be activated onchain
deploy Deploy a stylus contract
replay Replay a transaction in gdb
trace Trace a transaction
help Print this message or the help of the given subcommand(s)
Options:
-h, --help Print help
-V, --version Print version
stylus 프로젝트 생성
cargo stylus new <프로젝트명>
$ cargo stylus new counter
Cloning into 'counter'...
remote: Enumerating objects: 243, done.
remote: Counting objects: 100% (85/85), done.
remote: Compressing objects: 100% (49/49), done.
remote: Total 243 (delta 43), reused 53 (delta 30), pack-reused 158
Receiving objects: 100% (243/243), 652.46 KiB | 1.65 MiB/s, done.
Resolving deltas: 100% (121/121), done.
Initialized Stylus project at: /home/piatoss/counter
- stylus-hello-world의 사본을 생성
- --minimal 플래그를 사용하여 더 간단한 구조의 프로젝트 생성 가능
디렉터리 구조
$ cd counter/
$ tree
.
├── Cargo.lock
├── Cargo.toml
├── README.md
├── examples
│ └── counter.rs
├── header.png
├── licenses
│ ├── Apache-2.0
│ ├── COPYRIGHT.md
│ ├── DCO.txt
│ └── MIT
└── src
├── lib.rs
└── main.rs
3 directories, 11 files
프로젝트 유효성 검사
$ cargo stylus check
...
Uncompressed WASM size: 29.4 KB
Compressed WASM size to be deployed onchain: 10.7 KB
Connecting to Stylus RPC endpoint: https://stylus-testnet.arbitrum.io/rpc
Program succeeded Stylus onchain activation checks with Stylus version: 1
stylus 프로젝트 배포
가스비용 확인
$ cargo stylus deploy --private-key <프라이빗 키> --estimate-gas-only
...
====DEPLOYMENT====
Deploying program to address 0x4addc1557a14457AE4e9176de7B86e10e0e8d7Ac
Base fee: 0.100000000 gwei
Estimated gas for deployment: 16715512 gas units
배포
$ cargo stylus deploy --private-key <프라이빗 키>
...
====DEPLOYMENT====
Deploying program to address 0x4addc1557a14457AE4e9176de7B86e10e0e8d7Ac
Base fee: 0.100000000 gwei
Estimated gas for deployment: 20727838 gas units
Submitting deployment tx...
Confirmed deployment tx 0xba952bb6c920f8c9d3fb15250022cb895e47c0b6e39c8f0e39c0273b585e216c
Gas units used 18858620, effective gas price 0.100000000 gwei
Transaction fee: 0.001885862000000000 ETH
====ACTIVATION====
Activating program at address 0x4addc1557a14457AE4e9176de7B86e10e0e8d7Ac
Base fee: 0.100000000 gwei
Estimated gas for activation: 14345129 gas units
Submitting activation tx...
Confirmed activation tx 0xe106799bf33aa0c4483e1b5f235c0d37d0389673aff3c34387fb8d0ac04d4ab8
Gas units used 14278678, effective gas price 0.100000000 gwei
Transaction fee: 0.001427867800000000 ETH
stylus testnet 블록 탐색기 확인
'Rust > 코딩 하기' 카테고리의 다른 글
[Rust] gRPC 서버 Docker 이미지 빌드 및 docker compose 네트워크 에러 해결 (0) | 2023.12.27 |
---|---|
[Rust] tonic-build를 사용해 ProtoBuf 파일 컴파일하기 (0) | 2023.12.26 |