Skip to main content
NEP-20 is the fungible token standard for NEXUS, equivalent to ERC-20 on Ethereum. Every token deployed on NEXUS follows this interface, enabling wallets, DEXes, and other contracts to interact with any token in a uniform way.

Interface

Required Functions

Events


Storage Layout


Production Source

The full production implementation (apps/contracts/nep20/src/lib.rs):
U256 arithmetic is implemented manually (word-by-word carry/borrow) to avoid WASM compiler intrinsics that are not available in no_std environments. This is a hard requirement for NEXUS contracts.
ReentrancyGuard::new() is a built-in NEXUS primitive. It prevents reentrancy attacks on any function that modifies balances or makes external calls.

Deploying a Token


Interacting with a Token


Security Notes

  • init_token can only be called once — it checks the INITIALIZED flag ("AI" error = Already Initialized) and reverts if already set
  • mint and burn are owner-only — after renounceOwnership(), no one can ever mint or burn again
  • transfer and transferFrom both use ReentrancyGuard — reentrancy is blocked at the SDK level
  • increaseAllowance/decreaseAllowance are safer than calling approve directly — they prevent the ERC-20 approval race condition
  • transferFrom does not reduce allowance if the allowance is U256::max_value() (unlimited approval)
  • All U256 arithmetic uses manual word-by-word operations — no floating point, no compiler intrinsics, full WASM compatibility