b402 payments on BSC
Project description
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:
- Checks token allowance
- Approves up to $10,000 if needed (costs gas once)
- Sends payment (gasless)
Subsequent Payments:
- Uses existing allowance
- Sends immediately (gasless)
- 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 approvalb402.check_approval(token)- Check approval statusb402.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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file b402-1.2.1.tar.gz.
File metadata
- Download URL: b402-1.2.1.tar.gz
- Upload date:
- Size: 9.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
95060e0e4aa639bb7fed85bd858dfd13e904c575878e73f91d8a6b6761126864
|
|
| MD5 |
1af226e17dbdb33d4e3e10446a36f0a5
|
|
| BLAKE2b-256 |
051f132435103594ad7b31ba44277c15f4b86e23b8aca39a472f279f60eebd3f
|
File details
Details for the file b402-1.2.1-py3-none-any.whl.
File metadata
- Download URL: b402-1.2.1-py3-none-any.whl
- Upload date:
- Size: 9.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
92f47f046065d9545a73c0e55f2847b660ec6200285874959cc7038ed5226313
|
|
| MD5 |
70e0f1220d8388bcfd92195c5288eef8
|
|
| BLAKE2b-256 |
324938a5755d174166c1f3c6dca573244dc58089476310f68d887b0f0e59b22a
|