11 breaking releases

0.12.0 Sep 18, 2024
0.11.0 Jun 17, 2024
0.10.0 Mar 27, 2024
0.8.0 Dec 9, 2023
0.1.0 Jan 6, 2022

#7 in #web3

Download history 3350/week @ 2024-07-25 3614/week @ 2024-08-01 5559/week @ 2024-08-08 5132/week @ 2024-08-15 3891/week @ 2024-08-22 4136/week @ 2024-08-29 4818/week @ 2024-09-05 5020/week @ 2024-09-12 4491/week @ 2024-09-19 3281/week @ 2024-09-26 5338/week @ 2024-10-03 2902/week @ 2024-10-10 2954/week @ 2024-10-17 3508/week @ 2024-10-24 2627/week @ 2024-10-31 1862/week @ 2024-11-07

11,353 downloads per month
Used in 24 crates (22 directly)

MIT/Apache

1MB
21K SLoC

Logo

starknet-rs

Complete Starknet library in Rust

starknet-version-v0.13.0 jsonrpc-spec-v0.7.1 linting-badge crates-badge

Note that starknet-rs is still experimental. Breaking changes will be made before the first stable release. The library is also NOT audited or reviewed for security at the moment. Use at your own risk.

The underlying cryptography library starknet-crypto does NOT provide constant-time guarantees.

Adding starknet-rs to your project

To use the crate from crates.io, add the following to your Cargo.toml file:

[dependencies]
starknet = "0.11.0"

Note that the crates.io version might be outdated. You may want to use the library directly from GitHub for all the latest features and fixes:

[dependencies]
starknet = { git = "https://github.com/xJonathanLEI/starknet-rs" }

Features

  • Sequencer gateway / feeder gateway client
  • Full node JSON-RPC API client
  • Smart contract deployment
  • Signer for using IAccount account contracts
  • Strongly-typed smart contract binding code generation from ABI
  • Ledger hardware wallet support

Crates

This workspace contains the following crates:

  • starknet: Re-export of other sub-crates (recommended)
  • starknet-core: Core data structures for interacting with Starknet
  • starknet-providers: Abstraction and implementation of clients for interacting with Starknet nodes and sequencers
  • starknet-contract: Types for deploying and interacting with Starknet smart contracts
  • starknet-crypto: Low-level cryptography utilities for Starknet
  • starknet-signers: Starknet signer implementations
  • starknet-accounts: Types for handling Starknet account abstraction
  • starknet-curve: Starknet curve operations
  • starknet-macros: Useful macros for using the starknet crates

WebAssembly

starknet-rs can be used as a WebAssembly module. Check out this example.

Using starknet-rs from C++

starknet-rs can be used as a dynamic or static library from C++. Check out this example.

Performance

Benchmark results for native and WebAssembly targets are available for these crates:

For instructions on running the benchmark yourself, check here.

Example

Examples can be found in the examples folder:

  1. Get the latest block from alpha-sepolia testnet

  2. Deploy contract to alpha-sepolia testnet via UDC

  3. Mint yourself 1,000 TST tokens on alpha-sepolia

    Make sure your account has some L2 Sepolia ETH to pay for the transaction fee.

  4. Declare Cairo 1 contract on alpha-sepolia testnet

    Make sure your account has some L2 Sepolia ETH to pay for the transaction fee.

  5. Declare legacy Cairo 0 contract on alpha-sepolia testnet

    Make sure your account has some L2 Sepolia ETH to pay for the transaction fee.

  6. Query the latest block number with JSON-RPC

  7. Batched JSON-RPC requests

  8. Call a contract view function

  9. Deploy an Argent X account to a pre-funded address

  10. Inspect public key with Ledger

  11. Deploy an OpenZeppelin account with Ledger

  12. Transfer ERC20 tokens with Ledger

  13. Parsing a JSON-RPC request on the server side

  14. Inspecting a erased provider-specific error type

License

Licensed under either of

at your option.

Dependencies

~12–25MB
~380K SLoC