Skip to content

feat: add burn(uint256) to balances-erc20 precompile for native token burning - #399

Open
neutrinoks wants to merge 1 commit into
devfrom
feat/core-768-burn-tokens-on-peaq
Open

neutrinoks wants to merge 1 commit into
devfrom
feat/core-768-burn-tokens-on-peaq

Conversation

@neutrinoks

@neutrinoks neutrinoks commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

CORE-768: Burn native tokens from the EVM

On peaq the native token can already be burned on the Substrate side via pallet_balances::burn
(open to every signed account; BaseFilter only gates Assets::create). EVM users and contracts
had no way to reach it. This PR exposes it in the simplest possible way, on the existing native
ERC20 precompile, instead of introducing a new pallet or precompile.

  • New method burn(uint256 value) (selector 0x42966c68, OpenZeppelin ERC20Burnable) on
    Erc20BalancesPrecompile at 0x0000000000000000000000000000000000000809.
  • Dispatches pallet_balances::burn { value, keep_alive: false } with the caller as origin,
    so only the caller's own balance can be burned. There is no from parameter and no burnFrom.
  • Emits the ERC20-conventional Transfer(msg.sender, address(0), value) log. On the Substrate
    side, Balances::Burned is emitted and TotalIssuance / totalSupply() decrease.
  • New Solidity interface IERC20Burnable in precompiles/balances-erc20/ERC20.sol.
  • spec_version bumped: peaq 113 → 114, peaq-dev 109 → 110. Crate version 0.1.1 → 0.1.2.

Interface changes for the SDK

🔴 Breaking

  • None.

🟡 New behaviour

  • New call burn(uint256) on 0x…0809. It returns nothing and reverts with
    Dispatched call failed with error: … FundsUnavailable if the caller's balance is too low.
  • A burn shows up as Transfer(from, 0x0, value). Indexers and clients that treat transfers to
    the zero address as burns get this right without changes.

🟢 Unchanged

  • transfer, transferFrom, approve, allowance, balanceOf, totalSupply,
    transferToAccountId, deposit / withdraw and EIP-2612 permit keep their selectors and behaviour.
  • The Substrate extrinsic balances.burn is unchanged.

Tests & rollout

  • cargo test -p pallet-evm-precompile-balances-erc20: 35/35 passed, including the new tests:
    • burn: the caller's balance and totalSupply drop and another account stays untouched.
    • burn_not_enough_funds: the call reverts.
    • Selector and modifier checks for burn.
    • The existing Solidity-interface/selector consistency test.
  • cargo check -p peaq-runtime -p peaq-dev-runtime and cargo clippy on the crate are clean.
  • Not deployed yet and not tested manually on a dev node.
  • Rollout is a regular runtime upgrade (peaq-dev first, then peaq). No migration is needed and the
    node is not affected.

🤖 Generated with Claude Code

@neutrinoks neutrinoks self-assigned this Oct 20, 2026

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.

Tip: disable this comment in your organization's Code Review settings.

@neutrinoks neutrinoks changed the title feat: add burn(uint256) to balances-erc20 precompile for native token… feat: add burn(uint256) to balances-erc20 precompile for native token burning Oct 20, 2026
@neutrinoks
neutrinoks requested a review from sfffaaa October 20, 2026 10:03

@sfffaaa sfffaaa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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.

2 participants