Skip to main content

Python SDK for PaySponge

Project description

paysponge

Python SDK for Sponge.

The paysponge package gives Python apps access to Sponge agent wallets, platform provisioning, transfers, balances, and paid request workflows.

Concepts

Sponge has two client types:

  • SpongeWallet is the runtime client for one agent. Use it with an agent API key when that agent needs to inspect balances, get wallet addresses, transfer funds, or make paid requests.
  • SpongePlatform is the control-plane client for your backend. Use it with a master/platform API key when you need to create agents or manage many agents for your product.

An agent is the Sponge identity that owns wallets and permissions. In a multi-user app, you typically create one Sponge agent per user, bot, workflow, or worker. Each agent gets its own agent API key. Your backend can use SpongePlatform to provision those agents, then store the returned agent key with your own user or worker record. At runtime, use SpongeWallet with that agent key so actions are scoped to the correct agent.

Install

pip install paysponge

Quick Start

Use an agent API key with SpongeWallet. The wallet client acts on behalf of one Sponge agent.

from paysponge import SpongeWallet

wallet = SpongeWallet.connect(api_key="sponge_test_xxx")

agent = wallet.get_agent()
addresses = wallet.get_addresses()
balances = wallet.get_balances()

print(agent.id)
print(addresses)
print(balances)

An agent is the Sponge identity that owns the wallets and permissions used by the SDK. wallet.get_agent() fetches the current agent for the API key and stores its agent.id on the client, so later calls can use that agent by default.

You can also read the API key from the environment:

export SPONGE_API_KEY=sponge_test_xxx
from paysponge import SpongeWallet

wallet = SpongeWallet.connect()
print(wallet.get_addresses())

Platform Usage

Use a master/platform API key with SpongePlatform when your backend needs to create or manage agents. Platform keys are higher-trust credentials and should stay on your server. They are for provisioning and administration, not for day-to-day agent actions.

from paysponge import SpongePlatform

platform = SpongePlatform.connect(api_key="sponge_master_xxx")
agent = platform.create_agent(name="Hackathon Agent")

print(agent.id)

Typical platform flow:

  1. Your backend authenticates with SpongePlatform using a master key.
  2. It creates a Sponge agent for a user, bot, or worker.
  3. It stores the returned agent API key with your own application record.
  4. Runtime code uses SpongeWallet with that agent API key.

Examples

Source examples are available in the repository:

  • mobwallet/python/paysponge/examples/basic.py
  • mobwallet/python/paysponge/examples/transfer.py
  • mobwallet/python/paysponge/examples/basic_sdk.py

From a clone of the repository:

cd mobwallet/python/paysponge
SPONGE_API_KEY=sponge_test_xxx uv run python examples/basic.py
SPONGE_API_KEY=sponge_test_xxx RECIPIENT_ADDRESS=0x... uv run python examples/transfer.py

Common Methods

wallet.get_agent()
wallet.get_addresses()
wallet.get_balances()
wallet.get_wallets()
wallet.transfer(chain="base", to="0x...", amount="1.00", currency="USDC")
wallet.paid_fetch(url="https://example.com")

Links

Tests

From a clone of the repository:

cd mobwallet/python/paysponge
uv run python -m unittest discover -s tests

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

paysponge-0.1.2.tar.gz (111.6 kB view details)

Uploaded Source

Built Distribution

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

paysponge-0.1.2-py3-none-any.whl (283.3 kB view details)

Uploaded Python 3

File details

Details for the file paysponge-0.1.2.tar.gz.

File metadata

  • Download URL: paysponge-0.1.2.tar.gz
  • Upload date:
  • Size: 111.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for paysponge-0.1.2.tar.gz
Algorithm Hash digest
SHA256 33e895e42615990268d20e87e6df712f6372a654caaeceb40c5a1fe61711050c
MD5 04583110b96a5219ac9d700d12f385b4
BLAKE2b-256 98bb8e8c5765940c48ff4eb85cb175322ed0e8cca97dd91a249d9c623cf48528

See more details on using hashes here.

Provenance

The following attestation bundles were made for paysponge-0.1.2.tar.gz:

Publisher: sdk-publish.yml on paysponge/sponge

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file paysponge-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: paysponge-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 283.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for paysponge-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5c30c0b39829fecab480f04df4972096657b8377a67a3f395448d5becf545e94
MD5 9783b02ffe15db47e12c6e65d54d6c52
BLAKE2b-256 5530032ff5a4cafd8006724b7585aa464fd8bd0f6ea11c9d78d90a0b70500ad1

See more details on using hashes here.

Provenance

The following attestation bundles were made for paysponge-0.1.2-py3-none-any.whl:

Publisher: sdk-publish.yml on paysponge/sponge

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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