Minter Docsv3.3.0
Protocol / Execution, gas and fees
Protocol

Execution, gas and fees

ExecutorV3 transaction validation and execution pipeline, Gas counter formula, USDTE fee calculation, FailedTx rule without Nonce increment, non-BIP gas coins, and all 48 tariff fields.

ExecutorV3 (coreV2/transaction/executor_v3.go) separates mempool admission (CheckTx) from sequential block state application (DeliverTx). The computational Gas counter and the monetary commission are calculated by distinct formulas.

ExecutorV3 preconditions and FailedTx semantics

Before calling a handler, ExecutorV3 validates outer envelope limits (executor_v3.go:28-175):

  • serialized transaction length len(rawSignedTxBytes) <= 16,144 bytes (maxTxLength);
  • len(Payload) <= 10,000 bytes and len(ServiceData) <= 128 bytes;
  • ChainID == CurrentChainID, GasPrice >= 1 (>= minGasPrice in CheckTx), and GasCoin existence in state;
  • tx.Nonce == Accounts.GetNonce(sender) + 1;
  • for multisig (0x02), len(signatures) <= 32, unique recovered signer addresses (DuplicatedAddresses on duplicates), membership on the multisig account, and sum(weights) >= Threshold.
Stage and outcomeFee deductedNonce changeState effect
Envelope, signature, or Nonce rejection before handler.Run0 pipUnchangedNo IAVL or mempool change
Handler failure in CheckTx0 pipUnchangedRejected from mempool; sender mempool slot stays free
Handler failure in DeliverTx (FailedTx, code != 0)min(balance, (price.FailedTx + bytes * price.PayloadByte) * GasPrice)Unchanged (executor_v3.go:212)Operation state does not apply; emits tx.fail="1" and tx.fail_fee
Successful DeliverTx (code == 0)Full operation tariff in CommissionCoinSetNonce(tx.Nonce) (+1)Mutations commit to IAVL; commission enters rewardPool
FailedTx does not increment sender Nonce

When a transaction passes CheckTx and fails during DeliverTx (code != 0, for instance MinimumValueToBuyReached after an earlier swap in the same block), ExecutorV3 deducts the FailedTx fee and skips SetNonce. Clients must reuse the same Nonce or re-read transaction_count from GET /v2/address/{address} before retrying. Pass ?failed_txs=true to GET /v2/block/{height} to include failed block transactions. For RedeemCheck (0x09), issuer pays FailedTx when the check decodes and the issuer signature recovers.

Gas counter and monetary fee formulas

The Gas counter (executor_v3.go:177) bounds per-block computational weight (MaxGas) and does not multiply the monetary fee:

text
bytes = len(Payload) + len(ServiceData)
Gas   = 15 + handler.Gas + (1 if CommissionCoin != 0 else 0) + floor(bytes / 1000) + 20 * len(multisigSignatures)

Monetary cost is first computed in the schedule anchor coin price.Coin (USDTE, CoinID = 1993 on Mainnet; on the W2.2 public Testnet genesis.commission.coin = 0, so tariffs are denominated directly in MNT, CoinID = 0):

text
totalPriceInTariffCoin = (handler.CommissionData(price) + bytes * price.PayloadByte) * GasPrice

If handler.Run fails in DeliverTx, price.FailedTx replaces handler.CommissionData(price):

text
failedFeeInTariffCoin = (price.FailedTx + bytes * price.PayloadByte) * GasPrice
chargedFailedFee      = min(senderBalanceInCommissionCoin, convertToCommissionCoin(failedFeeInTariffCoin))

Paying fees in non-BIP coins

The GasCoin (uint32) envelope field allows paying transaction fees with 0 BIP balance:

  1. On Mainnet, price.Coin is USDTE (1993) (!= 0), so the node first converts totalPriceInTariffCoin into BIP through the order-aware USDTE / BIP pool (PairV2). On the public Testnet (chainId = 2), price.Coin is the native base coin MNT (CoinID = 0), so tariffs are already denominated in MNT without a USDTE conversion hop (while USDTE (1993) and the MNT/USDTE pool are seeded in genesis for DEX testing).
  2. When CommissionCoin == 0 (BIP on Mainnet, MNT on Testnet), that base coin amount is deducted directly from the sender and added to rewardPool.
  3. When CommissionCoin != 0, CalculateCommission (sell_all_swap_pool_v230.go:275) compares the cost of buying the required BIP via the order-aware {CommissionCoin, BIP} pool against the coin's CRR reserve (when both exist, the lower cost in CommissionCoin is selected; ties prefer the pool). Non-reserve tokens without a direct {token, BIP} pool are rejected during fee estimation.
  4. When a swap or liquidity transaction pays fees through the same {CommissionCoin, BIP} pool it trades against, the reserve change from fee deduction applies first (AddLastSwapStepWithOrders / DummyCoin).
  5. SellAllCoin (0x03) and SellAllSwapPool (0x19) always deduct commission from the sold coin (CoinToSell or Coins[0]) regardless of tx.GasCoin. RedeemCheck (0x09) deducts price.RedeemCheck in check.GasCoin from issuer.
Testnet monthly reset and Nonce restart

On the public Testnet (chainId = 2, base coin 0 = MNT, https://gate-api.testnet.minter.network/v2), all state resets on the 1st of every month to a new epoch minter-testnet-YYYYMM (https://testnet.minter.network/status.json). Because ChainID stays 2 while every user account's Nonce resets to 0, previously signed transactions for a reused user Mx... address can be replayed across epochs once funded again; rotate test mnemonics each month.

Interactive gas and fee estimator

∑ExecutorV3 gas and fee estimator (48 PriceCommission parameters)
1 coin = 1000000000000000000 pip
GAS UNITS (executor_v3.go:177)
16 gas
15 + 1 + 0 + 0 + 20×0
TARIFF IN USDTE (1993)
$0.01
10000000000000000 pip
AMM POOL BIP QUOTE (snapshot)
97.9416 BIP
97941527472768918655 pip
FAILEDTX FALLBACK (NONCE UNCHANGED)
$0.01
10000000000000000 pip
Exact coin deduction accounting for resting limit orders in the USDTE/BIP pool is returned by GET /v2/estimate_tx_commission/{tx}.

Complete 48 tariff fields of VoteCommissionDataV3 (USDTE)

On Mainnet, GET /v2/price_commissions quotes tariffs in USDTE (coin.id = "1993", 1 USDTE = 10^18 pip); on the W2.2 public Testnet it quotes tariffs in MNT (coin.id = "0", 1 MNT = 10^18 pip). All 48 tariff fields below appear in their exact RLP struct order inside VoteCommissionDataV3 (0x20, RLP indices 3..50 following PubKey, Height, Coin):

# (RLP)JSON key (/v2/price_commissions)Go price.* fieldUSDTE valueExact pip (10^18)Applies to
1 (3)payload_bytePayloadByte$0.0002200000000000000Per byte of Payload + ServiceData
2 (4)sendSend$0.01100000000000000000x01 Send
3 (5)buy_bancorBuyBancor$0.03300000000000000000x04 BuyCoin
4 (6)sell_bancorSellBancor$0.03300000000000000000x02 SellCoin
5 (7)sell_all_bancorSellAllBancor$0.03300000000000000000x03 SellAllCoin
6 (8)buy_pool_baseBuyPoolBase$0.03300000000000000000x18 BuySwapPool (1 pool)
7 (9)buy_pool_deltaBuyPoolDelta$0.00550000000000000000x18 per extra pool hop
8 (10)sell_pool_baseSellPoolBase$0.03300000000000000000x17 SellSwapPool (1 pool)
9 (11)sell_pool_deltaSellPoolDelta$0.00550000000000000000x17 per extra pool hop
10 (12)sell_all_pool_baseSellAllPoolBase$0.03300000000000000000x19 SellAllSwapPool (1 pool)
11 (13)sell_all_pool_deltaSellAllPoolDelta$0.00550000000000000000x19 per extra pool hop
12 (14)create_ticker3CreateTicker3$50,000500000000000000000000000x05 / 0x1E (3-char symbol)
13 (15)create_ticker4CreateTicker4$10,000100000000000000000000000x05 / 0x1E (4-char symbol)
14 (16)create_ticker5CreateTicker5$2,00020000000000000000000000x05 / 0x1E (5-char symbol)
15 (17)create_ticker6CreateTicker6$4004000000000000000000000x05 / 0x1E (6-char symbol)
16 (18)create_ticker7_10CreateTicker7to10$1001000000000000000000000x05 / 0x1E (7..10-char symbol)
17 (19)create_coinCreateCoin$00Added to PayForSymbol in 0x05 and 0x1E (create_token.go:90)
18 (20)create_tokenCreateToken$00Present in Price struct (unused in create_token.go:90)
19 (21)recreate_coinRecreateCoin$1001000000000000000000000x10 RecreateCoin
20 (22)recreate_tokenRecreateToken$1001000000000000000000000x1F RecreateToken
21 (23)declare_candidacyDeclareCandidacy$10100000000000000000000x06 DeclareCandidacy
22 (24)delegateDelegate$0.101000000000000000000x07 Delegate
23 (25)unbondUnbond$0.101000000000000000000x08 Unbond
24 (26)redeem_checkRedeemCheck$0.03300000000000000000x09 RedeemCheck (paid by issuer)
25 (27)set_candidate_onSetCandidateOn$0.101000000000000000000x0A SetCandidateOn
26 (28)set_candidate_offSetCandidateOff$0.101000000000000000000x0B SetCandidateOff
27 (29)create_multisigCreateMultisig$0.101000000000000000000x0C CreateMultisig
28 (30)multisend_baseMultisendBase$0.01100000000000000000x0D Multisend (1st recipient)
29 (31)multisend_deltaMultisendDelta$0.00550000000000000000x0D per additional recipient (N - 1)
30 (32)edit_candidateEditCandidate$0.101000000000000000000x0E EditCandidate
31 (33)set_halt_blockSetHaltBlock$0.101000000000000000000x0F SetHaltBlock
32 (34)edit_ticker_ownerEditTickerOwner$1001000000000000000000000x11 EditCoinOwner
33 (35)edit_multisigEditMultisig$0.101000000000000000000x12 EditMultisig
34 (36)edit_candidate_public_keyEditCandidatePublicKey$1,00010000000000000000000000x14 EditCandidatePublicKey
35 (37)create_swap_poolCreateSwapPool$10100000000000000000000x22 CreateSwapPool
36 (38)add_liquidityAddLiquidity$0.101000000000000000000x15 AddLiquidity
37 (39)remove_liquidityRemoveLiquidity$0.101000000000000000000x16 RemoveLiquidity
38 (40)edit_candidate_commissionEditCandidateCommission$10100000000000000000000x1A EditCandidateCommission
39 (41)mint_tokenMintToken$0.101000000000000000000x1C MintToken
40 (42)burn_tokenBurnToken$0.101000000000000000000x1D BurnToken
41 (43)vote_commissionVoteCommission$0.101000000000000000000x20 VoteCommission
42 (44)vote_updateVoteUpdate$0.101000000000000000000x21 VoteUpdate
43 (45)failed_txFailedTx$0.0110000000000000000handler.Run failure in DeliverTx
44 (46)add_limit_orderAddLimitOrder$0.101000000000000000000x23 AddLimitOrder
45 (47)remove_limit_orderRemoveLimitOrder$0.01100000000000000000x24 RemoveLimitOrder
46 (48)move_stakeMoveStake$0.101000000000000000000x1B MoveStake
47 (49)lock_stakeLockStake$0.101000000000000000000x25 LockStake
48 (50)lockLock$0.01100000000000000000x26 Lock