PRC-20: Fungible Token Standard

Status: Draft
Panda analogue: EIP-20 (ERC-20)


Copyright

Copyright and related rights waived via CC0.


Simple Summary

A standard interface for fungible tokens on Panda: metadata, balances, transfers, and allowances so wallets, DEX-style contracts, and other apps can interact with any compliant token the same way.


Abstract

The following standard defines a minimal API for fungible tokens implemented as Panda smart contracts. It mirrors the intent of ERC-20: name, symbol, decimals, supply, balance_of, transfer, approve / allowance, and transfer_from, plus the corresponding Transfer and Approval events. Panda uses Python contracts, string account identifiers (and chain-defined addresses), and integers for amounts; failures are signaled by raising (there is no bool success return).


Motivation

A single, well-known interface lets applications reuse token logic: portfolio views, swaps, vesting, and governance that operate on “any PRC-20” without bespoke ABIs per project.


Specification

Conventions

ERC-20 (Solidity)PRC-20 (Panda)
addressstr (account id / address string)
uint256 amountnon-negative int (base units)
returns (bool success)success implied if call completes; errors MUST raise
view / pure@query
state-changing@call

Callers MUST NOT assume that operations always succeed; they MUST handle contract errors (failed transfer, overflow checks, etc.) at the RPC / client layer.

Token contract

A PRC-20-compliant contract SHOULD expose the following behaviors (names may be snake_case in Python).

Metadata (optional but recommended)

  • name() -> str
    Human-readable name (e.g. "My Token").

  • symbol() -> str
    Short symbol (e.g. "MTK").

  • decimals() -> int
    Number of decimal places; amount 1 means 10^-decimals human units. Typical value 18.

Supply and balances

  • total_supply() -> int
    Total minted supply in base units (see Notes on burn).

  • balance_of(owner: str) -> int
    Balance of owner in base units.

Transfers and allowances

  • transfer(ctx, to: str, value: int)
    Transfers value from ctx.sender to to.
    MUST emit Transfer on success.
    Transfers of value == 0 SHOULD be allowed and MUST still emit Transfer if the ERC-20 style is followed.
    SHOULD reject insufficient balance by raising.

  • approve(ctx, spender: str, value: int)
    Sets allowance of spender for ctx.sender to value (replacing prior allowance for that pair).
    MUST emit Approval on success.
    Clients SHOULD follow the ERC-20 mitigation: set allowance to 0 before changing to a new non-zero value when interacting with untrusted spenders.

  • allowance(owner: str, spender: str) -> int
    Remaining allowance.

  • transfer_from(ctx, owner: str, to: str, value: int)
    Transfers value from owner to to using allowance for ctx.sender.
    MUST emit Transfer on success.

Events

Events are emitted with Panda’s event.<Name>(...) pattern. Indexing is a chain/explorer concern; fields below are logical.

Transfer

MUST trigger when tokens move, including zero-value transfers if supported.

  • _from: str — sender (mint: use a convention such as zero-address 0x0000... or documented mint origin).
  • _to: str — recipient.
  • _value: int — amount in base units.

Approval

MUST trigger on successful approve.

  • _owner: str
  • _spender: str
  • _value: int

Notes

  • Mint / burn: ERC-20 suggests emitting Transfer from 0x0 on mint. PRC-20 implementations SHOULD document mint/burn behavior and emit Transfer (or dedicated events) consistently.
  • Reference stdlib: panda.token.FungibleToken implements the core ledger (balances, allowances, metadata).
  • Reference contract: contracts/tokens/prc20_token.py.

Implementation

Implementations may use FungibleToken from panda.token and persist its serialized dict in contract state, or implement equivalent logic with the same external behavior.

Example (deploy args vary by contract):

panda deploy contracts/tokens/prc20_token.py \
  --rpc http://localhost:8545 \
  --args '{"name":"My Coin","symbol":"MYC","decimals":18,"max_supply":0,"initial_supply":1000000}'

History

  • Inspired by EIP-20 (Fabian Vogelsteller, Vitalik Buterin, et al.).

Citation

Please cite this document as:

Panda Protocol. PRC-20: Fungible Token Standard. Panda documentation: docs/PRC20.md.

Historical ERC-20 reference:

Fabian Vogelsteller, Vitalik Buterin, et al. EIP-20: Token Standard. https://eips.ethereum.org/EIPS/eip-20