Skip to content

Conversation

@Jim8y
Copy link
Contributor

@Jim8y Jim8y commented Dec 24, 2025

Summary

  • add System.Runtime.MintGas syscall (HF_Faun) to mint GAS to calling contract and increase system fee
  • add unit tests for minting behavior

Testing

  • not run (not requested)

@github-actions github-actions bot added the N3 label Dec 24, 2025
@Jim8y Jim8y marked this pull request as draft December 24, 2025 09:56
@Jim8y Jim8y changed the title Add Runtime.MintGas syscall feat: Custom Contract Fees with ABI Declaration and Runtime Enforcement Dec 24, 2025
@erikzhang
Copy link
Member

Transferring 0 NEO to self can achieve the same effect.

Copy link
Contributor

@roman-khimov roman-khimov left a comment

Choose a reason for hiding this comment

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

I don't understand why this complexity for a very simple thing. We have a (pretty much useless) System.Runtime.BurnGas() syscall, what we need is System.Runtime.MintGas() that would add it to the system fee and mint to caller (contract) address, that's about it. Then this fee is a part of the system fee, the user knows how much he spends for the overall transaction and contract gets the amount it needs.

/// <summary>
/// The contract owner (deployer) script hash.
/// </summary>
public UInt160? Owner { get; set; }
Copy link
Contributor

Choose a reason for hiding this comment

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

Why?

Copy link
Contributor Author

@Jim8y Jim8y Dec 26, 2025

Choose a reason for hiding this comment

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

I might misunderstand what we have discussed in the meeting, the first version i did is like what you mentioned, then i checked the NEP from chris again, and updated this pr accordingly. Will refactor this pr again based on your comments.

if (amount.Sign < 0)
throw new InvalidOperationException("Fee amount cannot be negative.");

UInt160 beneficiary = fee.Beneficiary ?? contract.Manifest.Owner
Copy link
Contributor

Choose a reason for hiding this comment

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

Contract requires some fee, contract should be the receiver of it.

@Jim8y Jim8y changed the title feat: Custom Contract Fees with ABI Declaration and Runtime Enforcement feat: Add Runtime MintGas syscall Dec 26, 2025
@Jim8y
Copy link
Contributor Author

Jim8y commented Dec 26, 2025

@roman-khimov i think this one now addressed all your comments, may you please check again? now it only adds MintGas


var state = CurrentContext!.GetState<ExecutionContextState>();
var wasWhitelisted = state.WhiteListed;
state.WhiteListed = false;
Copy link
Member

Choose a reason for hiding this comment

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

Why change WhiteList here?

Copy link
Member

Choose a reason for hiding this comment

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

Ping @Jim8y

/// Minting GAS to benefit the current contract.
/// </summary>
/// <param name="amount">The amount of GAS to mint, in the unit of datoshi, 1 datoshi = 1e-8 GAS</param>
protected internal void MintGas(BigInteger amount)
Copy link
Member

Choose a reason for hiding this comment

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

Technically, it's not a minted, as it will only be used in this script. It can be considered minted, but it will be claimed and burned

Copy link
Member

Choose a reason for hiding this comment

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

I think the syscall should be renamed to "ChargeGas"

Copy link
Member

Choose a reason for hiding this comment

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

Minting gas would also be used in here neo-project/proposals#208

{
state.WhiteListed = wasWhitelisted;
}
NativeContract.GAS.Mint(this, contract.Hash, amount, false).GetAwaiter().GetResult();
Copy link
Member

Choose a reason for hiding this comment

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

This looks acceptable for N3, but not for N4 in my opnion

@cschuchardt88
Copy link
Member

Seems related to neo-project/proposals#208

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants