Skip to main content

No project description provided

Project description

Python client for Tread contracts

Getting started

This project is using the following tools:

You can install these as follows:

> brew install pipx
> pipx ensurepath
> pipx install poetry
> poetry completions bash >> ~/.bash_completion

With poetry, you can install dependencies as follows. Note that if you do not have a virtual env active, poetry will automatically create and manage one for you, specific to this project.

> poetry install

Run tests

You can run simple tests as follows. These will run on the Sepolia Base testnet by default.

# when we require multiple validators for consensus, below tests won't work
# Note: Make sure the poetry virtualenv is active, e.g. `source .venv/bin/activate`.
#
# Run with Gelato meta-transactions (enabled by default).
> python -m test_client.main auto
# Run with meta-transactions disabled.
> python -m test_client.main auto false

Publish to PyPI

Make sure the version field in pyproject.toml is updated as needed.

poetry publish --build --dry-run
poetry publish --build

Example transactions

Trader ID

Reading a record or writing an attestations requires a trader ID. We are using 0xABCD as a mock trader ID for these examples.

Contract read example

> python -m test_client.main read-info

Attestations contract 0xB4f9A1f1347b7D8eb97dC70672576BB96E0510e0:
  data group members: 0x64D8672534A169B0340fA10F6340CE45aE36d0e7
  epoch length: 600 seconds
  epoch zero start: 0 (1969-12-31 19:00:00 local)
  Current epoch number: 2880124
  Current epoch 2880124 starts at 1728074400 (2024-10-04 16:40:00 local) and ends at 1728075000 (2024-10-04 16:50:00 local)

Data attestation write example

> python -m test_client.main write-data 0xABCD 0 0 0x1234 mock-cid

Submitted transaction 0x2280079a88ae3af1923feeb40e0938862d7f141c1c87d31d5da0ca189c1010c7. Waiting for confirmation...
Transaction confirmed in block 16153093

Data attestation read example

> python -m test_client.main read-data 0xABCD 0 0

Consensus for epoch 0:
  Merkle root: 0x0000000000000000000000000000000000000000000000000000000000001234

Risk end-to-end example

>  python -m test_client.main create-group 0x64D8672534A169B0340fA10F6340CE45aE36d0e7 1

Submitting and waiting for transaction...
Created risk group 1

> python -m test_client.main read-group 1

Risk group 1:
  members: ['0x64D8672534A169B0340fA10F6340CE45aE36d0e7']
  threshold: 1

> python -m test_client.main create-parameter mock-name mock-desc

Submitting and waiting for transaction...
Created risk parameter 0

> python -m test_client.main read-parameter 0

Risk parameter 0:
  name: mock-name
  description: mock-desc

> python -m test_client.main write-risk 0xABCD 0 0 1 123

Submitted transaction 0xb9d1ae7fd71d43a456a62fcffba7aae0542671e66eef410136be547d803c7205. Waiting for confirmation...
Transaction confirmed in block 16153127

> python -m test_client.main read-risk 0xABCD 0 0 1

Consensus for epoch 0:
  Risk value: 1234

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

tread_contracts-0.1.9.tar.gz (13.7 kB view details)

Uploaded Source

Built Distribution

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

tread_contracts-0.1.9-py3-none-any.whl (15.4 kB view details)

Uploaded Python 3

File details

Details for the file tread_contracts-0.1.9.tar.gz.

File metadata

  • Download URL: tread_contracts-0.1.9.tar.gz
  • Upload date:
  • Size: 13.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.13.1 Darwin/24.5.0

File hashes

Hashes for tread_contracts-0.1.9.tar.gz
Algorithm Hash digest
SHA256 09590a31759b571ad4ec96bb5b1b89c02d06d48c3741c9cd4305219a03451716
MD5 cd084a2cb7c8f3170738482559ac14e2
BLAKE2b-256 3ba36a77a16bbe06a458af234ca07d9a6272b9b336354a8661ea6da18e865f90

See more details on using hashes here.

File details

Details for the file tread_contracts-0.1.9-py3-none-any.whl.

File metadata

  • Download URL: tread_contracts-0.1.9-py3-none-any.whl
  • Upload date:
  • Size: 15.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.13.1 Darwin/24.5.0

File hashes

Hashes for tread_contracts-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 fd3cda4b1f0dd0f728f8a5d5771a572e4b201792ff682f9cbf01b36cb8c02038
MD5 c8fc0c6095c347bbdcab22b390afc2c9
BLAKE2b-256 efab4d57e6d1abb21a45fb661be78f8818b14f5a4920e61cfa698b7746d0f390

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