Skip to content

BEP-702: Compliant Asset Standard on BNB Smart Chain - #702

Open
joey0612 wants to merge 10 commits into
masterfrom
new_token
Open

BEP-702: Compliant Asset Standard on BNB Smart Chain#702
joey0612 wants to merge 10 commits into
masterfrom
new_token

Conversation

@joey0612

@joey0612 joey0612 commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Description

Adds BEP-702: CAS20, the Compliant Asset Standard — a fungible-token standard built into the BSC protocol, where a token is a stateful precompile at a derived address rather than deployed bytecode.

Reference implementation: bnb-chain/bsc#3813

At a high level, the standard:

  • keeps the BEP-20 selector and event surface, so existing wallets and indexers need no change
  • makes compliance part of the standard rather than per-issuer code: transfer policies from shared allow/blocklists, per-feature pause, and role-separated mint, burn and seizure
  • defines two variants — Asset, adding the ERC-8056 scaled multiplier, and Stablecoin, adding a currency code
  • separates shipping from activation: a per-feature switch that each network throws on its own schedule

Rationale

A BEP-20 transfer spends most of its gas on interpreting bytecode rather than on the state it touches, and every issuer reimplements the same compliance logic with its own bugs. Putting the token in the protocol removes that overhead and lets one audited implementation serve every token of a variant, with compliance state shared across tokens instead of duplicated.

What is specified, and why

Everything a second implementation must agree on, because each of these decides a state root:

§3.3 the address derivation and its exact preimage
§3.14 the gas schedule and the EIP-2929 warm-set rules
§3.16 the account sentinel that keeps a code-less token from being reaped with its balances
§3.17 the ERC-7201 storage layout, down to the slot and the packed lane
throughout the order in which a call's checks apply, and therefore which error a caller receives

Two behaviours are called out explicitly because they surprise integrators rather than implementers. The Asset variant's scheduled multiplier takes effect on read, with no transaction and no event, so an indexer rebuilding balances from the log stream alone will silently diverge (§3.12). And deactivating a feature reaches creation and registry writes only — never a token that already exists, and never a read, because a network-level switch must not be able to make transfers fail (§3.15).

Activation authority

Governance appoints the account that may throw the switch; that account opens or closes a feature immediately. The split lets a network hold an emergency stop without waiting out a voting period, while the authority behind it stays with governance and a lost key is replaced by a parameter-change proposal rather than a fork (§3.15).

Changes

  • BEPs/BEP-702.md — the specification
  • README.md — index row

@joey0612 joey0612 changed the title doc: add New Tokens on BNB Smart Chain bep BEP-702: New Tokens on BNB Smart Chain Aug 11, 2026
@hashdit-bot

hashdit-bot Bot commented Sep 3, 2026

Copy link
Copy Markdown

Pull Request Review

This PR adds BEP-702, a draft protocol specification for CAS20 fungible tokens implemented as stateful precompiled contracts on BNB Smart Chain. It defines deterministic token addressing, factory and registry components, role-based controls, compliance policies, pause and supply controls, permit support, token variants, gas accounting, activation, and consensus storage layout, and adds the proposal to the README index.

Sensitive Content

No sensitive content detected.

Security Issues

No serious security issues detected.


Generated by Hashdit Bot. This tool can absolutely NOT replace manual audits.

CAS20 is a fungible-token standard built into the protocol: a token is a
stateful precompile at a derived address rather than deployed bytecode, so its
behaviour is a guarantee of the chain instead of of per-token contract code. It
keeps the BEP-20 selector and event surface, so existing wallets and indexers
need no change, and it makes the compliance controls an issuer would otherwise
reimplement part of the standard — transfer policies resolved from shared allow-
and blocklists, per-feature pause, and role-separated mint, burn and seizure.

Everything a second implementation must agree on is specified rather than left
to the client, because each of these decides a state root: the address
derivation and its preimage, the ERC-7201 storage layout down to the slot and
the packed lane, the gas schedule and the EIP-2929 warm-set rules, the order in
which a call's checks apply and therefore which error a caller receives, and the
account sentinel that keeps a code-less token from being reaped with its
balances.

Two variants share that surface. Asset adds the ERC-8056 scaled multiplier,
including a scheduled change that takes effect on read with no transaction and
no event — stated explicitly, because an indexer rebuilding from logs alone
would silently diverge. Stablecoin adds a currency code.

Activation is separate from shipping. A per-feature switch lives in a singleton
registry: governance appoints the account that may throw it, and that account
opens or closes a feature immediately, so a network chooses its own schedule
without a fork and without waiting out a voting period for an emergency stop.
The switch reaches creation and registry writes only; it can never touch a token
that already exists, and reads are never gated, because a network-level switch
must not be able to make transfers fail.
@hashdit-bot

hashdit-bot Bot commented Sep 3, 2026

Copy link
Copy Markdown

Pull Request Review

This PR adds BEP-702, a protocol-level CAS20 fungible-token standard implemented through stateful precompiled contracts, with native roles, compliance policies, pausing, supply caps, permits, and asset/stablecoin variants. It also documents consensus-critical addressing, storage, gas, activation, and account-sentinel behavior, and adds BEP-702 to the README index.

Sensitive Content

No sensitive content detected.

Security Issues

🟠 [HIGH] Conflicting CAS20 address namespace definitions could cause consensus divergence

File: BEPs/BEP-702.md

Section 3.1's address table assigns the factory to 0xCA5F... and Section 3.3 assigns tokens the 0xCA50 prefix, but the accompanying text says the second byte is 0xBF for the factory and 0xB0 for tokens. Because address recognition and native dispatch are consensus-critical, implementations following different definitions could route different accounts to CAS20 handlers and derive different state transitions.

Recommendation: Define one canonical byte-level layout for both factory and token addresses, remove the contradictory 0xB0/0xBF wording, and add consensus tests covering exact recognition and dispatch for the singleton, every current variant, and adjacent non-CAS20 addresses.

🟠 [HIGH] Composite policy identifiers conflict with authorization rules

File: BEPs/BEP-702.md

Section 3.8 defines UNION and INTERSECT as PolicyType values 2 and 3, but also states that only most-significant type bytes 0x00 and 0x01 are valid and that any other value authorizes no one. Consequently, an implementation following that rule would treat every composite policy as invalid and deny transfers, while another implementation honoring the composite-policy section could authorize them. The interface shown also omits signatures for createCompositePolicy and updateComposite, further leaving consensus-visible selectors undefined.

Recommendation: Explicitly define type bytes 0x02 and 0x03 and their isAuthorized evaluation semantics, reserve only values above the supported enum, and add the complete composite-policy ABI and events. Include cross-client vectors for composite creation, updates, nonexistent children, and UNION/INTERSECT authorization results.


Generated by Hashdit Bot. This tool can absolutely NOT replace manual audits.

@zlacfzy zlacfzy changed the title BEP-702: New Tokens on BNB Smart Chain BEP-702: Compliant Asset Standard on BNB Smart Chain Sep 3, 2026
@bnb-chain bnb-chain deleted a comment from hashdit-bot Bot Sep 3, 2026
@bnb-chain bnb-chain deleted a comment from hashdit-bot Bot Sep 3, 2026
@bnb-chain bnb-chain deleted a comment from hashdit-bot Bot Sep 3, 2026
@bnb-chain bnb-chain deleted a comment from hashdit-bot Bot Sep 3, 2026
@bnb-chain bnb-chain deleted a comment from hashdit-bot Bot Sep 3, 2026
@bnb-chain bnb-chain deleted a comment from hashdit-bot Bot Sep 3, 2026
@bnb-chain bnb-chain deleted a comment from hashdit-bot Bot Sep 3, 2026
@bnb-chain bnb-chain deleted a comment from hashdit-bot Bot Sep 3, 2026
Each of these would let two implementations disagree while both followed the
document.

The address section named the reserved namespace as 0xCA5… and then said the
distinguishing second byte was 0xB0 for tokens and 0xBF for the factory — the
values from before the rename, left behind because the replacement only caught
the fully-written 0x20B0 form. An implementation reading the sentence rather
than the table would recognise a different address range.

The policy-id encoding said the most significant byte is 0x00 for BLOCKLIST or
0x01 for ALLOWLIST and that "any other value is not a valid type", while the
enum three sections earlier has four members and composites carry 0x02 and 0x03.
Read literally, every composite policy is invalid and authorizes nobody — so one
implementation refuses a transfer the other permits. All four values are now
named, and an id above the enum is refused as naming no policy rather than
treated as a policy that authorizes nobody, which is the safer of the two
readings and the one the reference implementation takes.

createCompositePolicy, updateComposite and compositePolicyChildIds were
described in prose but absent from IPolicyRegistry, leaving three
consensus-visible selectors without a signature to derive them from. They are
declared now, and their selectors were checked against the implementation rather
than transcribed.
@hashdit-bot

hashdit-bot Bot commented Sep 3, 2026

Copy link
Copy Markdown

Pull Request Review

This PR adds BEP-702, a specification for CAS20 protocol-native compliant fungible tokens implemented as stateful precompiles on BNB Smart Chain. It defines token variants, deterministic addressing, role-based controls, shared transfer policies, pausing, permits, gas accounting, activation governance, account sentinels, and consensus storage layouts, and adds the proposal to the README index.

Sensitive Content

No sensitive content detected.

Security Issues

No serious security issues detected.


Generated by Hashdit Bot. This tool can absolutely NOT replace manual audits.

Eighteen edits, all of them places where the document and the reference client
disagreed. Ten describe behavior the client already had and the document had not
written down; the rest correct claims the client does not implement.

Undeclared surface. The gas table called itself exhaustive while permit charges
the ECRECOVER precompile's own cost, which it owes: a signature check at less
than the price of the same work in bytecode would be the one charge the parity
rule forbids skipping. A composite creation and every replacement emit
CompositePolicyUpdated, which no interface declared, so an implementation
following the document literally would produce a different receipt root. Eight
callable selectors were undeclared: the six policy-scope identifiers, which are
keccak256 of the names the scope table already used, and the two composite child
bounds. ICAS20Factory omitted InternalCallMalformed, which 3.4 requires it to
raise. And Panic(uint256) is Solidity's own, declared by no interface, so the
declare-where-raised rule needs its one exemption stated rather than silently
broken.

Corrections. 3.8 said a malformed policy id must be refused wherever an id is
accepted "rather than treated as a policy that authorizes nobody" — which is what
the next paragraph, and the client, do on the read path. The clause now covers
the paths that mutate, bind or nest, which are the ones that refuse. The
composite constructor was documented as checking the type before the admin, and
as being asymmetric with the simple constructors; it is neither. Child validation
is two passes over the whole set, and a sentinel is no more eligible as a child
than a composite. isAuthorized's empty-set rule was stated as a principle without
saying where the four types land, which left the one case that surprises — an
INTERSECT over no children is vacuously true — to be inferred. variantOf does not
read byte [10] alone; it establishes the address is in the reserved space first,
and rejects a variant the fork does not recognize, because its return type has no
member for one. The Go interface in 3.2 was the shape from an earlier draft. The
scope rule as first written claimed updatePolicy refuses an unknown scope, which
it does only after the caller clears the role check. 3.3 said NonPayable precedes
anything else, though the call-form guards precede it. A paragraph in 3.15
described an activation surface that is not the one specified here. And the
sentinel policies exist from the registry's first block, before any creation has
seeded them — a rule the client enforces and the document never stated.

Removed the claim that an operator can audit the reserved space with a client
subcommand. No such command is part of this proposal.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@hashdit-bot

hashdit-bot Bot commented Sep 4, 2026

Copy link
Copy Markdown

Pull Request Review

This PR adds BEP-702, a specification for CAS20 compliant assets implemented as stateful BSC precompiles, including shared compliance controls, token variants, deterministic storage/address rules, gas behavior, and network-level feature activation. It also adds BEP-702 to the README proposal index as a draft standard.

Sensitive Content

No sensitive content detected.

Security Issues

No serious security issues detected.


Generated by Hashdit Bot. This tool can absolutely NOT replace manual audits.

The marker is two bytes, but the eight zero bytes that follow it belong to the
layout, so the first five hex digits of every token address are the marker plus a
zero the padding supplies. Spending the second byte on 0x52 makes those digits
spell the standard's name, which 0x50 did without its number.

The factory keeps 0xCA5F and the registries keep 0x7020. The reserved-space check
was made against the whole 0xCA5 namespace rather than the token prefix alone, so
it already covers this choice; the paragraph recording it now says so, in place of
a sentence that narrated when the prefix was last chosen.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@hashdit-bot

hashdit-bot Bot commented Sep 4, 2026

Copy link
Copy Markdown

Pull Request Review

This PR adds BEP-702, specifying CAS20 as a protocol-level compliant fungible-asset standard implemented through stateful precompiles on BNB Smart Chain. It also adds the draft proposal to the README index; no executable implementation changes are included in the supplied diff.

Sensitive Content

No sensitive content detected.

Security Issues

No serious security issues detected.


Generated by Hashdit Bot. This tool can absolutely NOT replace manual audits.

zlacfzy and others added 4 commits September 6, 2026 23:43
…annot wait

A token's sentinel is written by the factory at creation and metered;
a registry's is written by the fork transition as an irregular state
change. The registry's cannot wait for its first write: GovHub tests
extcodesize before forwarding a parameter change, so a registry
without code could never be appointed an admin.

Also index all three RoleAdminChanged arguments, as the client emits
them, and state that role mutation is gated on the target role's own
admin role rather than on DEFAULT_ADMIN_ROLE.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…n genesis

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
… dispatch

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
A review against the two-client premise found the standard silent where
bsc-geth and reth-bsc could each make a defensible choice and fork.

- The check order of every token entry point is now a table, with the
  shared prefix (call form, existence, decoding, static frame) and the
  exit precedence spelled out; from == to takes no policy fast path,
  and a self transferFrom spends the allowance.
- Account fields: the nonce and balance are never written; the initial
  state table lists exactly the slots createCAS20 writes, including the
  Asset multiplier at 1e18, and forbids writing a default.
- The registry sentinels are planted at the start of the fork block, in
  the same pass as HistoryStorageAddress.
- EIP-7702 delegation to a CAS20 address executes the sentinel byte and
  halts; EIP-7928 records a CAS20 account as an ordinary account.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@hashdit-bot

hashdit-bot Bot commented Sep 8, 2026

Copy link
Copy Markdown

Pull Request Review

This PR adds BEP-702, a specification for protocol-native compliant fungible assets on BNB Smart Chain, including shared compliance controls, role-separated operations, token variants, and network-level feature activation. It also adds BEP-702 to the README index as a draft standard; however, the actual BEP file is represented as binary or empty and was unavailable for line-level review.

Sensitive Content

No sensitive content detected.

Security Issues

No serious security issues detected.


Generated by Hashdit Bot. This tool can absolutely NOT replace manual audits.

…and backed at every mutation

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@hashdit-bot

hashdit-bot Bot commented Sep 8, 2026

Copy link
Copy Markdown

Pull Request Review

This PR adds BEP-702, a specification for CAS20 compliant assets implemented as stateful BSC precompiles, including shared compliance controls, Asset and Stablecoin variants, protocol storage and gas rules, and network-level feature activation. It also adds BEP-702 to the README’s standards index with Draft status; the specification file itself was not available for content-level review in the supplied diff.

Sensitive Content

No sensitive content detected.

Security Issues

No serious security issues detected.


Generated by Hashdit Bot. This tool can absolutely NOT replace manual audits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants