Skip to main content

GolemBase Python SDK

Project description

Golem Base

This is part of the 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).

For an overview of Golem Base, check out our Litepaper.

GolemBase SDK for Python

This SDK allows you to use GolemBase from Python. It is available on PyPI.

We also publish generated documentation.

The repo also contains an example application to showcase how you can use this SDK.

Tip: For getting up and running quickly, we recommend the following two steps:

(Note: As an alternative to installing the demo CLI, you can build the actual CLI as it's included in the golembase-op-geth repo.)

When you create a user, it will generate a private key file called private.key and store it in:

  • ~/.config/golembase/ on Linux
  • ~/Library/Application Support/golembase/ on macOS
  • %LOCALAPPDATA%\golembase\ on Windows

(This is a standard folder as per the XDG specification.)

You will also need to fund the account. You can do so by typing:

golembase-demo-cli account fund 10

Getting Started Example

Here's how you can get going with the SDK. First, create a new folder to hold your project:

mkdir golem-sdk-practice
cd golem-sdk-practice

Then create and activate a virtual environment:

python3 -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

Next, install the GolemBase SDK from PyPI:

pip install golem-base-sdk

You can find some base starter code here; copy the __init__.py into your project folder.

This is a basic Python application that:

  • Imports several items from the SDK (golem_base_sdk), including:

    • GolemBaseClient: A class that creates a client to interact with GolemBase
    • GolemBaseCreate: A class representing a create transaction in GolemBase
    • GolemBaseExtend: A class for extending entity lifetime
    • Annotation: A class for key-value annotations
  • Reads the private key, which it locates using the xdg module.

  • Sets up logging with the standard Python logging module.

  • The main() function follows, which is where the bulk of the example code runs.

The main function demonstrates how to create, extend, and query entities:

  • Creates a client object that connects to the GolemBase network (e.g., Kaolin testnet) using rpc and ws URLs, and your private key.

  • Subscribes to log events from the network (create, update, delete, extend).

  • Creates an entity with data "hello", TTL of 60, and an annotation of ("foo", "bar").

  • Prints various metadata and state:

    • The latest block
    • Entity count before and after creation
    • Entity metadata
    • Storage value
    • Entity expiration info
    • Query results by annotation
  • Extends the created entity’s lifetime using client.extend_entities.

  • Lists entities owned by your account, and all known entity keys.

Building and Running from sources

You can also, from this cloned repo, build the SDK and run the example using Nix:

nix build .#golem-base-sdk-example
./result/bin/main

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

golem_base_sdk-0.0.2.tar.gz (22.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

golem_base_sdk-0.0.2-py3-none-any.whl (23.3 kB view details)

Uploaded Python 3

File details

Details for the file golem_base_sdk-0.0.2.tar.gz.

File metadata

  • Download URL: golem_base_sdk-0.0.2.tar.gz
  • Upload date:
  • Size: 22.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for golem_base_sdk-0.0.2.tar.gz
Algorithm Hash digest
SHA256 de5dd9b78d663094c2d5dc18cc768b3c6621a7ec14dda8464c761f5de02c277e
MD5 01118bc62f12095b06ce9384ea865e7c
BLAKE2b-256 1bc0d480ac4029c120c986bb2bf6a793c3157d86b48e0bc5b3f53dcb3093fd63

See more details on using hashes here.

File details

Details for the file golem_base_sdk-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: golem_base_sdk-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 23.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for golem_base_sdk-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b9a42bc0c19a70a555d48b07c1bec9da7f890479a182b735a40d476d31926068
MD5 23d7ba6eb03be8e72dd8e2b53f3a615f
BLAKE2b-256 9fce6745902f4c450397a2e26c1942150e3717f137a84c5ff721a76d8ab46e3f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page