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
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)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| b402-1.2.1.tar.gz | 9.0 kB | Without provenance | Details for b402-1.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| b402-1.2.1-py3-none-any.whl | Python 3 | none | any | Details for b402-1.2.1-py3-none-any.whl |
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
|
Security for b402 1.2.1
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.