golem_base_sdk/
lib.rs

1// # GolemBase SDK
2//!
3//! This is part of the [Golem Base](https://github.com/Golem-Base) project, which is designed as a Layer2 Network deployed on Ethereum, acting as a gateway to various Layer 3 Database Chains (DB-Chains).
4//! For an overview of Golem Base, **check out our [Litepaper](https://golem-base.io/wp-content/uploads/2025/03/GolemBase-Litepaper.pdf)**.
5//!
6//! This SDK allows you to use [GolemBase](https://github.com/Golem-Base) from Rust, it is available on [crates.io](https://crates.io/crates/golem-base-sdk), alng with its [generated documentation](https://docs.rs/golem-base-sdk). We provide an [example application](https://github.com/Golem-Base/rust-sdk/tree/main/demo) to showcase how you can use this SDK.
7//!
8//! For **getting up and running quickly**, we recommend the following two steps:
9//! 1. Start golembase-op-geth through its [`docker-compose`](https://github.com/Golem-Base/golembase-op-geth/blob/main/RUN_LOCALLY.md) ;
10//! 2. [Install the demo CLI](https://github.com/Golem-Base/golembase-demo-cli?tab=readme-ov-file#installation) and [create a user](https://github.com/Golem-Base/golembase-demo-cli?tab=readme-ov-file#quickstart), or build the [actual CLI](https://github.com/Golem-Base/golembase-op-geth/blob/main/cmd/golembase/README.md) as it's included in the `golembase-op-geth` repository.
11//!
12//! When you create a user, it will generate a private key file called `private.key` and store it in the standard folder as per the [XDG specification](https://specifications.freedesktop.org/basedir-spec/latest/):
13//! - `~/.config/golembase/` on **Linux**
14//! - `~/Library/Application Support/golembase/` on **macOS**
15//! - `%LOCALAPPDATA%\golembase\` on **Windows**
16//!
17//! You will also need to fund the account, you can do it with: `golembase-demo-cli account fund 10`
18//!
19//! # Transaction Abstractions
20//!
21//! This SDK provides multiple layers for sending transactions:
22//! - Use [`GolemBaseClient`] for high-level operations such as creating, updating, or deleting entities.
23//! - Use [`Account`](crate::account::Account) for account-centric and lower-level transaction control.
24//! - Advanced users can construct and submit raw Ethereum transactions directly using the types and helpers re-exported from `Alloy`.
25
26/// Re-export commonly used types from `alloy`.
27pub use alloy::primitives::{Address, keccak256};
28pub use alloy::signers::Signature;
29pub use alloy::signers::local::PrivateKeySigner;
30pub use alloy::transports::http::reqwest::Url;
31
32pub use client::{GolemBaseClient, GolemBaseRoClient};
33pub use entity::{Annotation, Hash, NumericAnnotation, StringAnnotation};
34
35/// Module for Ethereum transaction-related functionality.
36/// Provides helpers for constructing, signing, and sending Ethereum transactions.
37pub mod eth;
38
39/// Module for JSON-RPC-related functionality.
40/// Contains utilities for interacting with JSON-RPC endpoints, including request/response types.
41pub mod rpc;
42
43/// Module for GolemBase client functionality.
44/// Exposes the main client interface for interacting with the GolemBase network.
45pub mod client;
46
47/// Module for GolemBase entities and data types.
48/// Defines core types such as annotations, hashes, and entity representations.
49pub mod entity;
50
51/// Module for event handling.
52/// Contains types and utilities for working with GolemBase events.
53pub mod events;
54
55/// Module with utility functions.
56/// Includes helpers for encoding, decoding, and other common tasks.
57pub mod utils;