Skip to main content

Convex Python SDK

Checked with pyright PyPI version

The official Python client library for interacting with the Convex decentralised lattice network.

📚 Documentation

Official documentation is available at docs.convex.world/docs/tutorial/client-sdks/python

Installation

pip install convex-sdk

Quick Example

from convex_sdk import Convex, KeyPair

# Connect to the network
convex = Convex('https://peer.convex.live')

# Create a new account
key_pair = KeyPair()
account = convex.create_account(key_pair)

# Request test funds
convex.request_funds(100_000_000, account)

# Query balance
balance = convex.get_balance(account)
print(f'Balance: {balance / 1_000_000_000} Convex Coins')

Resources


Development Setup

To set up the project for development, follow these steps:

Prerequisites:

  • Python 3.10 or higher
  • pip (Python package installer)

Setup Steps:

  1. Create a virtual environment:

    python -m venv .venv
    

    This creates a virtual environment in a .venv directory.

  2. Activate the virtual environment:

    • On Windows (PowerShell or Command Prompt):

      .venv\Scripts\activate
      
    • On Windows (Git Bash):

      source .venv/Scripts/activate
      
    • On Linux/Mac:

      source .venv/bin/activate
      

    When activated, you should see (venv) at the beginning of your command prompt.

  3. Upgrade pip (recommended):

    python -m pip install --upgrade pip
    
  4. Install the package in development mode with all dependencies:

    Option 1 - Using setup.py extras (recommended):

    pip install -e ".[dev,test,docs]"
    

    Option 2 - Using requirements files:

    pip install -r requirements-dev.txt
    pip install -e .
    
  5. Verify the installation:

    pytest tests
    

Deactivating the virtual environment: When you're done working, you can deactivate the virtual environment by running:

deactivate

Note: Always activate your virtual environment before working on the project. The virtual environment ensures that dependencies are isolated from your system Python installation.

Quick Start

First you need to download the convex-sdk package from the python package index PyPi.

pip install convex-sdk

You can now access the convex network, and get a balance from an existing account on the network by doing the following:

>>> from convex_sdk import Convex, KeyPair
>>> convex = Convex('https://peer.convex.live')
>>> convex.get_balance(9)
99396961137042

You can create a new empty account, with no balance:

>>> key_pair = KeyPair()
>>> account = convex.create_account(key_pair)
>>> account.address
809

You can request some funds to the new account and then get the account information:

>>> convex.request_funds(1000000, account)
1000000
>>> convex.get_account_info(account)
AccountDetailsResponse(sequence=0, address=809, memorySize=42, balance=1000000, allowance=0, type='user')

You can export the accounts private key encoded as PKCS8 encrypt the key with a password:

>>> account.key_pair.export_to_text('secret')
'-----BEGIN ENCRYPTED PRIVATE KEY-----\nMIGbMFcGCSqGSIb3DQEFDTBKMCkGCSqGSIb3DQEFDDAcBAiMY42UY4PXHAICCAAw\nDAYIKoZIhvcNAgkFADAdBglghkgBZQMEASoEEJpwDMicGbGj2iSJesktIVYEQBsp\nKMTAHzvUyw8jZRr8WSrmxH7938sjma8XWI6lgd9jwTZzcGamog7p3zatw0Wp+jFK\nKruWAZmIqhBZ/2ezDv8=\n-----END ENCRYPTED PRIVATE KEY-----\n'

>>> account.address
809

To re-use your account again you need to import the encrypted private key and set the correct account address

>>> from convex_sdk import Account, KeyPair
>>> key_pair = KeyPair.import_from_file('my_key.dat', 'secret')
>>> account = Account(key_pair, 809)

To create a new address with the same account keys in your new or imported account object, you can do:

>>> new_account = convex.create_account(key_pair)
>>> account.address
809
>>> new_account.address
934

To use account names, where an account name is resolved to a fixed address. You can create or load an account based on it's name by doing the following:

>>> account = convex.setup_account('my-account-name', key_pair)
>>> account.address
934

>>> convex.resolve_account_name('my-account-name')
934

>>> same_account = convex.setup_account('my-account-name', key_pair)
>>> same_account.address
934

To submit a transaction, use Convex.transact(). This will cost a small amount of juice, and reduce your balance

>>> convex.request_funds(1000000, account)
1000000
>>> convex.transact('(map inc [1 2 3 4])', account)
{'value': [2, 3, 4, 5]}
>>> convex.get_balance(account)
996360

To send a query a transaction, this is free and can be performed by any valid account address. So for example to query a balance of an account:

>>> convex.query(f'(balance {account.address})', account)
{'value': 996360}

# this is the same as above
>>> convex.query(f'(balance {account.address})', account.address)
{'value': 996360}

# get the balance using one of the standard account addresses (#1)
>>> convex.query(f'(balance {account.address})', 1)
{'value': 996360}

Metadata

Release files for convex-sdk 0.3.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for convex-sdk 0.3.4
File Size Uploaded Provenance Actions
convex_sdk-0.3.4.tar.gz 34.2 kB With provenance Details for convex_sdk-0.3.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for convex-sdk 0.3.4
File Interpreter ABI Platform Actions
convex_sdk-0.3.4-py2.py3-none-any.whl Python 3, Python 2 none any Details for convex_sdk-0.3.4-py2.py3-none-any.whl

Total release size: 74.5 kB

Release files / convex_sdk-0.3.4.tar.gz

Download URL convex_sdk-0.3.4.tar.gz
Size 34.2 kB
Tags Source
SHA-256 checksum
How to use checksums
fc12380583ca0a768c84c32e949bd2fedf7536e42ece527308b94eb1e7bbe3cb
BLAKE2b-256 checksum
How to use checksums
ec9895639e77de508cc7d28a76dbfdcf8658dc5d0e7bd7a1f69db94df4e83275
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.

Transparency log

Release files / convex_sdk-0.3.4-py2.py3-none-any.whl

Download URL convex_sdk-0.3.4-py2.py3-none-any.whl
Size 40.3 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
e8ab7b62f4aa8d328bb8e9a8ea560669d8a48c98a056ee952d7ffa5a346c55bc
BLAKE2b-256 checksum
How to use checksums
425fe0c8ec99e34f8e927e2b1da53ff45fa6dea549ecc99f52e71754ddf90e67
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.

Transparency log

Security for convex-sdk 0.3.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for convex_sdk-0.3.4.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page