Skip to content

software-mansion/starknet-rust

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Logo

starknet-rust

Complete Starknet library in Rust

starknet-version-v0.14.1 jsonrpc-spec-v0.10.0 linting-badge crates-badge

Note that starknet-rust 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-rust-crypto does NOT provide constant-time guarantees.

Adding starknet-rust to your project

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

[dependencies]
starknet-rust = "0.18.0"

Features

  • Sequencer gateway / feeder gateway client
  • Full node JSON-RPC API client
    • HTTP transport
    • WebSocket transport (subscriptions only)
  • 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-rust: Re-export of other sub-crates (recommended)
  • starknet-rust-core: Core data structures for interacting with Starknet
  • starknet-rust-providers: Abstraction and implementation of clients for interacting with Starknet nodes and sequencers
  • starknet-rust-contract: Types for deploying and interacting with Starknet smart contracts
  • starknet-rust-crypto: Low-level cryptography utilities for Starknet
  • starknet-rust-signers: Starknet signer implementations
  • starknet-rust-accounts: Types for handling Starknet account abstraction
  • starknet-rust-curve: Starknet curve operations
  • starknet-rust-macros: Useful macros for using the starknet-rust crates
  • starknet-rust-core-derive: Derive macros for traits in starknet-rust-core
  • starknet-rust-tokio-tungstenite: WebSocket subscription client with tokio-tungstenite

WebAssembly

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

Using starknet-rust from C++

starknet-rust 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. Query the latest block number with JSON-RPC

  6. Encoding and decoding Cairo types

  7. Parse a SNIP-12 message and compute its hash

  8. Batched JSON-RPC requests

  9. Call a contract view function

  10. WebSocket subscription

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

  12. Inspect public key with Ledger

  13. Deploy an OpenZeppelin account with Ledger

  14. Transfer ERC20 tokens with Ledger

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

  16. Inspecting a erased provider-specific error type

License

Licensed under either of

at your option.

Acknowledgements

This project is a fork of the original starknet-rs by Jonathan LEI.

We would like to express our sincere thanks and appreciation to xJonathanLEI and all contributors to the original starknet-rs repository for their outstanding work.

About

Complete Starknet library in Rust

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Packages

No packages published