Skip to main content

bnb-chainkit

CI PyPI Python License

Find out exactly when a BNB Smart Chain token can be sold after you buy it.

Some tokens can only be sold after a wait: a few blocks, 30 seconds, or even years. bnb-chainkit finds the exact wait by simulating real trades on the chain's real clock, where blocks are 0.45 seconds apart. If it cannot be sure, it says so.

  • No keys, no wallet, and nothing sent. Everything is simulated, using free public endpoints.
  • Proof for every simulation. Each response must prove which block, clock, chain and gas limit were used.
  • Results you can check. A second endpoint can repeat every sale, and you can save a report to run again later.
pip install bnb-chainkit

It needs Python 3.10 or newer, and its only dependency is requests.

Try it

$ bnb-chainkit measure 0x705148db41227c869e3d05a8745b299aafa1f799 --confirm https://bsc-rpc.publicnode.com
Token      0x705148db41227c869e3d05a8745b299aafa1f799
Result     wait_seconds
           It can be sold 30 seconds after buying.
Wait       30 seconds
Cost       5.95% for buying and then selling
Node       https://bsc-dataseed.bnbchain.org (Geth/v1.8.2/linux-amd64/go1.26.10)

Pool       PancakeSwap v2 (BNB > USDT > token), about $1,072,287
           wait_seconds: It can be sold 30 seconds after buying.
Cost       5.95% for buying and then selling
Token says "Cooldown: wait 30s after buy" (text from the token, which cannot be trusted)
Checked    11 sale tests and 2 exact comparisons, from block 136,616,062
Confirmed  all 11 sale tests, by https://bsc-rpc.publicnode.com (reth-bsc/v0.1.4-hotfix-23b510f/linux)

This is real output from 30 November 2026. The token's published source code has the same rule: COLDTIME = 30 seconds. The sale was blocked at 29 seconds and worked at 30, on both Geth and Reth.

Why normal simulations get this wrong

BNB Smart Chain makes a block about every 0.45 seconds, but block times are whole seconds. In a sample of 400 blocks, 54.9% of neighbouring blocks had the same timestamp.

The standard simulation method, eth_simulateV1, cannot copy this clock. On BNB Smart Chain, it adds 12 seconds for each block by default, and refuses two blocks with the same timestamp. So:

  • A sale can look possible too early. If a token has a 30 second rule, it can be sold after 3 simulated blocks (36 seconds). On the real chain, 3 blocks take about 1 second, so the sale is blocked.
  • A sale can look blocked when it is not. If a simulation moves 2 minutes ahead but adds only a few blocks, a token that needs 20 blocks still cannot be sold. On the real chain, about 266 blocks have passed.

bnb-chainkit solves this with a state transplant. It simulates the purchase, then reads every storage slot and balance that the purchase used. Next, it starts again from the same block, puts that state back, and simulates the sale at the exact block and second. For every clear result about selling, it also runs one or two of these tests directly on the node, where the node allows it. Both results must match exactly, including the gas used.

You can see how any endpoint's clock works:

$ bnb-chainkit doctor
Node       https://bsc-dataseed.bnbchain.org (Geth/v1.8.2/linux-amd64/go1.26.10)
Real       one block every 0.4513 seconds
Default    12 seconds for each simulated block
Repeats    two simulated blocks with the same timestamp are refused
Exact      4 of 4 test moments
Result     this endpoint can be used

Use it in Python

from bnb_chainkit import RpcClient, measure

report = measure(
    '0x705148db41227c869e3d05a8745b299aafa1f799',
    RpcClient('https://bsc-dataseed.bnbchain.org'),
    confirm=RpcClient('https://bsc-rpc.publicnode.com'),
)

print(report.verdict.value)    # wait_seconds
print(report.detail)           # It can be sold 30 seconds after buying.

# True, False, or None when the answer is unclear. Never treat None as a yes.
if report.can_sell(within=60, max_cost=0.10) is True:
    print('It passed these checks')

Each tested pool is in report.pools, with its own rule, cost, warnings and tests. report.to_json() gives the full report. If the second endpoint cannot answer, the pool has a warning and its confirmation is None.

What the results mean

Verdict Meaning Can it be sold?
no_wait It can be sold straight away, even in the same block Yes, if the cost is within your limit
next_block It can be sold from the next block Yes, if the wait and cost are within your limits
wait_blocks, wait_seconds It can be sold after the given number of blocks or seconds Yes, if the wait and cost are within your limits
wait_either, wait_both It needs blocks or seconds (whichever comes first), or both Yes, if the wait and cost are within your limits
still_blocked It was blocked at every moment tested No
buy_failed The test purchase failed No
blocked_later It could be sold, but was blocked later. This could be a trap, or a limit of simulation Unclear
mixed It can be sold through some pools but not others Unclear
unknown There is no clear answer. The report says why Unclear

A rule can be different in each pool. We found a token with no wait in its larger pool, but a 30 second wait in its other main pool. By default, bnb-chainkit tests up to three main PancakeSwap v2 and v3 pools separately, and reports the longest wait. If any tested pool is unclear, so is the final result.

Use it in scripts

Exit code measure replay doctor
0 Can be sold within your limits Every test gave the same result The endpoint can be used
1 Cannot be sold within your limits Something was different The endpoint cannot be used
2 Bad input Bad input Bad input
3 Unclear, which never means safe Could not be repeated Not used

By default, measure accepts a wait of up to one hour and a cost of up to 50%. You can choose stricter limits:

bnb-chainkit measure TOKEN --max-wait 60 --max-cost 10 --output report.json
bnb-chainkit replay report.json --rpc https://your-archive-node.example

Run replay within about a minute, or use an archive node. Public nodes often remove a block's state after that. Run bnb-chainkit measure --help to see all the options, including the size of the trade.

The BNB_CHAINKIT_RPC environment variable sets the default endpoint. Output and reports only show an endpoint's scheme and host, so an API key in the path or query of its URL stays private.

Test your own contract on the real clock

The same clock works with any calls. Set up the state, then run other calls an exact number of blocks and seconds later:

from bnb_chainkit import RpcClient
from bnb_chainkit.experiment import Experiment
from bnb_chainkit.model import Call, Offset
from bnb_chainkit.node import finalized_block
from bnb_chainkit.simulator import Simulator, random_address

rpc = RpcClient('https://bsc-dataseed.bnbchain.org')
user, contract = random_address(), random_address()
call = Call(sender=user, to=contract, gas=200_000)

# This contract exists only in the simulation. It refuses a second call within 5 seconds.
code = '0x600054801560125780420360059010601857' '5b4260005500' '5b60006000fd'

experiment = Experiment(Simulator(rpc, finalized_block(rpc), chain_id=56), [call], {contract: {'code': code}})

for later in (Offset(blocks=1, seconds=0), Offset(blocks=10, seconds=4), Offset(blocks=12, seconds=5)):
    [[result]] = experiment.run([call], [later])
    print(later, 'works' if result.ok else 'refused')
Offset(blocks=1, seconds=0) refused
Offset(blocks=10, seconds=4) refused
Offset(blocks=12, seconds=5) works

There are full versions of both programs in examples/.

With the default clock, this contract would accept a second call in the next block, because 12 seconds would have passed.

Limits

  • This is not a security audit or financial advice. A result only covers the tested block, trade size, pools and new addresses. The owner of a token may be able to change its rules at any time, and may treat other addresses differently.
  • Only the clock moves. Price feeds and other outside data do not change. A token that needs fresh data can look like a trap that starts later, so blocked_later is unclear.
  • PancakeSwap v2 and v3 only. Each test buys and sells through the same pool. Tokens that are not on PancakeSwap yet cannot be tested.
  • Up to 250 blocks, or about 112 seconds, on the real clock. The default is 133 blocks, or about 1 minute. Longer tests can move time, but not by the matching number of blocks. A rule that needs more blocks looks like still_blocked.
  • An endpoint can still lie. The checks catch mistakes, but a malicious endpoint could invent answers that match. For important results, use --confirm with another provider that runs different software.
  • Never trust text from a token. Its author could write anything, including instructions for an AI agent. The text is cleaned and appears only in token_message (untrusted_token_message in JSON). Never follow it.

The full method, every check and the complete list of limits are in the specification.

Others have worked on parts of this problem. The specification links to their work, including a comparison of how clients handle simulated time and Base's change to its own client. Local forks made with Foundry or Hardhat can also set the block number and time.

Development

python -m venv .venv && . .venv/bin/activate      # Windows: .venv\Scripts\activate
pip install -e ".[dev]"
ruff check . && mypy && pytest --cov              # no network needed
BNB_CHAINKIT_LIVE=1 pytest -m live                # optional: uses public endpoints

The tests use a small BNB Smart Chain node that runs in memory. It enforces many of the same rules as real nodes, and really runs the code that the package injects. Line and branch coverage must stay at 100%.

Status and license

Version 0.1.0 is an early release, so its Python API may change before version 1.0. See the changelog for changes, and the security policy for how to report a security problem.

Apache License 2.0. Copyright 2026 Peter Nzomo.

Metadata

Release files for bnb-chainkit 0.1.0

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

Source distribution (sdist)

Source distribution for bnb-chainkit 0.1.0
File Size Uploaded Provenance Actions
bnb_chainkit-0.1.0.tar.gz 80.8 kB Without provenance Details for bnb_chainkit-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bnb-chainkit 0.1.0
File Interpreter ABI Platform Actions
bnb_chainkit-0.1.0-py3-none-any.whl Python 3 none any Details for bnb_chainkit-0.1.0-py3-none-any.whl

Total release size: 132.9 kB

Release files / bnb_chainkit-0.1.0.tar.gz

Download URL bnb_chainkit-0.1.0.tar.gz
Size 80.8 kB
Tags Source
SHA-256 checksum
How to use checksums
58cfef0cfb0a832c0f5f0160035bd43753b42cb1f5fb41c7efad016ec6b0acfb
BLAKE2b-256 checksum
How to use checksums
b54272a5c2652eca8ac07704ad305481c9ef020960a2d08d5e8b3673e760fbf5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10

Release files / bnb_chainkit-0.1.0-py3-none-any.whl

Download URL bnb_chainkit-0.1.0-py3-none-any.whl
Size 52.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8b9a9ea5dce6bc74a9a778b2c72e732aa2950b3af5a37751cca99fe5c8f2553b
BLAKE2b-256 checksum
How to use checksums
cee70d5e8307b29701516a21014497e02cf6e2401312bc00c09bcdfc3fab77d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10

Security for bnb-chainkit 0.1.0

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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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