Skip to main content

b402

Gasless crypto payments on BSC.

Install

pip install b402

Usage

export PRIVATE_KEY="0x..."
from b402 import pay

result = pay(amount="0.01", token="USD1", recipient="0x...")

if result.success:
    print(f"TX: {result.tx_hash}")
else:
    print(f"Error: {result.error}")

First payment auto-approves $10,000 worth (one-time, costs gas). Future payments use existing allowance.

Defaults to BSC mainnet.

Manual Control

from b402 import B402

b402 = B402()

# Check approval
approved, allowance = b402.check_approval("USD1")

# Setup
if not approved:
    b402.setup("USD1")

# Pay
result = b402.pay(amount="0.01", token="USD1", recipient="0x...")

How It Works

First Payment:

  1. Checks token allowance
  2. Approves up to $10,000 if needed (costs gas once)
  3. Sends payment (gasless)

Subsequent Payments:

  1. Uses existing allowance
  2. Sends immediately (gasless)
  3. Re-approves automatically when low

Security

Capped approvals prevent unlimited token exposure.

Most SDKs:

approve(relayer, 2^256-1)  # Infinite

B402:

approve(relayer, 10_000 * 10^18)  # $10k cap

API

pay()

from b402 import pay

result = pay(
    amount="0.01",
    token="USD1",
    recipient="0x...",
    network="mainnet",  # Optional
    auto_approve=True,  # Optional
    debug=False         # Optional
)

B402()

from b402 import B402

b402 = B402()  # mainnet

Methods:

  • b402.setup(token) - One-time approval
  • b402.check_approval(token) - Check approval status
  • b402.pay(amount, token, recipient) - Send payment

Supported Tokens

Mainnet: USD1, USDT, USDC Testnet: USDT

Network Details

BSC Mainnet (Chain ID: 56)

  • Relayer: 0xE1C2830d5DDd6B49E9c46EbE03a98Cb44CD8eA5a
  • USD1: 0x8d0d000ee44948fc98c9b98a4fa4921476f08b0d
  • USDT: 0x55d398326f99059fF775485246999027B3197955
  • USDC: 0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d

BSC Testnet (Chain ID: 97)

  • Relayer: 0x62150F2c3A29fDA8bCf22c0F22Eb17270FCBb78A
  • USDT: 0x337610d27c682E347C9cD60BD4b3b107C9d34dDd

License

MIT

Metadata

Release files for b402 1.2.1

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

Source distribution (sdist)

Source distribution for b402 1.2.1
File Size Uploaded
b402-1.2.1.tar.gz 9.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for b402 1.2.1
File Interpreter ABI Platform
b402-1.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 18.3 kB

Release files / b402-1.2.1.tar.gz

Download URL b402-1.2.1.tar.gz
Size 9.0 kB
Tags Source
SHA-256 checksum
How to use checksums
95060e0e4aa639bb7fed85bd858dfd13e904c575878e73f91d8a6b6761126864
BLAKE2b-256 checksum
How to use checksums
051f132435103594ad7b31ba44277c15f4b86e23b8aca39a472f279f60eebd3f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release files / b402-1.2.1-py3-none-any.whl

Download URL b402-1.2.1-py3-none-any.whl
Size 9.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
92f47f046065d9545a73c0e55f2847b660ec6200285874959cc7038ed5226313
BLAKE2b-256 checksum
How to use checksums
324938a5755d174166c1f3c6dca573244dc58089476310f68d887b0f0e59b22a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release history Release notifications | RSS feed

This release

1.2.1 This release

2 release files

1.2.0

2 release files

1.0.0

2 release files

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