Skip to main content

Python SDK for Flexvaults - manage deposits, withdrawals, locks, and transfers

Project description

flexvaults

Python SDK for Flexvaults - manage deposits, withdrawals, locks, and transfers on the Oasis Sapphire network.

Installation

pip install flexvaults

Quick Start

import asyncio
from flexvaults import FlexvaultsClient, DepositQuoteRequest

async def main():
    async with FlexvaultsClient(base_url="https://api.example.com") as client:
        # Get a deposit quote
        quote = await client.get_deposit_quote(
            DepositQuoteRequest(
                user_address="0xYourAddress",
                token_id="0xTokenId",
                amount=1000000,
            )
        )
        print(f"Deposit to: {quote.deposit_address}")

        # Check balance
        balance = await client.get_balance("0xYourAddress", "0xTokenId")
        print(f"Balance: {balance.balance}")

asyncio.run(main())

EIP-712 Signing

from eth_account import Account
from flexvaults import (
    sign_lock_message,
    SignLockParams,
    LockMessage,
    get_accounting_contract,
    create_lock_expiry,
)

account = Account.from_key("0xYourPrivateKey")

signature = sign_lock_message(
    SignLockParams(
        account=account,
        network="testnet",
        verifying_contract=get_accounting_contract("testnet"),
        message=LockMessage(
            user_address=account.address,
            service_address="0xServiceAddress",
            token_id="0xTokenId",
            amount=1000000,
            expiry=create_lock_expiry(60),
        ),
    )
)

API Reference

Client

  • FlexvaultsClient(base_url, timeout=30.0, headers=None) - Main API client
    • get_deposit_quote(request) - Get deposit quote
    • include_deposit(request) - Include deposit proof
    • get_balance(user_address, token_id) - Get token balance
    • get_batch_balances(request) - Get multiple token balances
    • get_token_info(token_id) - Get token information
    • lock_funds(request) - Lock funds for a service
    • unlock_funds(request) - Unlock specific lock
    • unlock_all_expired(request) - Unlock all expired locks
    • get_locked_funds(user_address, service_address=None) - Get locked funds
    • get_total_locked_balance(user_address, token_id) - Get total locked balance
    • get_expired_locks(user_address) - Get expired locks
    • transfer_funds(request) - Transfer tokens
    • transfer_locked_funds(request) - Transfer locked tokens
    • request_withdrawal(request) - Request withdrawal
    • get_pending_withdrawals(user_address) - Get pending withdrawals
    • get_withdrawal_info(index) - Get withdrawal info

Signing

  • sign_lock_message(params) - Sign lock message
  • sign_transfer_message(params) - Sign transfer message
  • sign_transfer_locked_message(params) - Sign transfer locked message
  • sign_withdraw_message(params) - Sign withdrawal message
  • create_lock_expiry(minutes_from_now=60) - Create expiry timestamp

Utilities

  • format_token_amount(amount, decimals=18) - Format wei to human-readable
  • parse_token_amount(amount, decimals=18) - Parse human-readable to wei
  • shorten_address(address, chars=4) - Shorten Ethereum address
  • is_expired(expiry) - Check if timestamp is expired
  • format_time_remaining(expiry_timestamp) - Format time remaining
  • format_relative_time(timestamp) - Format relative time (e.g., "5m ago")

License

Apache-2.0

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

flexvaults-0.1.5.tar.gz (14.4 kB view details)

Uploaded Source

Built Distribution

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

flexvaults-0.1.5-py3-none-any.whl (17.0 kB view details)

Uploaded Python 3

File details

Details for the file flexvaults-0.1.5.tar.gz.

File metadata

  • Download URL: flexvaults-0.1.5.tar.gz
  • Upload date:
  • Size: 14.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for flexvaults-0.1.5.tar.gz
Algorithm Hash digest
SHA256 59bf0fba68df966df019b2b7dcea9e05b53c6bc3e3d9c4f67ab95947d7512762
MD5 faeaf8a9c56d7337d3554876e960035d
BLAKE2b-256 b65947130700c5c1a8c81bd2a993b412d5911fa94c51d93dd2e043b39aef9557

See more details on using hashes here.

File details

Details for the file flexvaults-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: flexvaults-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 17.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for flexvaults-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 5be3fe2df246fac07a53f9d4464b8a1b98ac42339217b63567b0e2354ffe71e5
MD5 bf8ccd447a96d60ff6c382bc7c122dca
BLAKE2b-256 a9ca391f964584fbae8c4046626e7547459ee9f15b279c9a638725a17ed44f9c

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