Repository navigation
feat: add burn(uint256) to balances-erc20 precompile for native token burning - #399
Open
neutrinoks wants to merge 1 commit into
Open
neutrinoks wants to merge 1 commit into
neutrinoks wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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;
BaseFilteronly gatesAssets::create). EVM users and contractshad 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.
burn(uint256 value)(selector0x42966c68, OpenZeppelinERC20Burnable) onErc20BalancesPrecompileat0x0000000000000000000000000000000000000809.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
fromparameter and noburnFrom.Transfer(msg.sender, address(0), value)log. On the Substrateside,
Balances::Burnedis emitted andTotalIssuance/totalSupply()decrease.IERC20Burnableinprecompiles/balances-erc20/ERC20.sol.spec_versionbumped: peaq 113 → 114, peaq-dev 109 → 110. Crate version 0.1.1 → 0.1.2.Interface changes for the SDK
🔴 Breaking
🟡 New behaviour
burn(uint256)on0x…0809. It returns nothing and reverts withDispatched call failed with error: … FundsUnavailableif the caller's balance is too low.Transfer(from, 0x0, value). Indexers and clients that treat transfers tothe zero address as burns get this right without changes.
🟢 Unchanged
transfer,transferFrom,approve,allowance,balanceOf,totalSupply,transferToAccountId,deposit/withdrawand EIP-2612permitkeep their selectors and behaviour.balances.burnis unchanged.Tests & rollout
cargo test -p pallet-evm-precompile-balances-erc20: 35/35 passed, including the new tests:burn: the caller's balance andtotalSupplydrop and another account stays untouched.burn_not_enough_funds: the call reverts.burn.cargo check -p peaq-runtime -p peaq-dev-runtimeandcargo clippyon the crate are clean.node is not affected.
🤖 Generated with Claude Code