The transaction fee module is used to manage the transaction fee pool. Distribution of Transaction Gas Fees:
- RoochNetwork 40%
- Before Mainnet launch: Used to repay the debt from Gas airdrops
- After Mainnet launch: Used to buy back Mainnet tokens
- Sequencer 30%
- Application Developers 30%
- Goes to the developer of the entry function contract called by the transaction
- If the entry contract is a system Framework contract, this portion goes to the Rooch network
- Resource
TransactionFeePool
- Constants
- Function
genesis_init
- Function
get_gas_factor
- Function
calculate_gas
- Function
withdraw_fee
- Function
deposit_fee
- Function
distribute_fee
- Function
withdraw_gas_revenue
- Function
withdraw_gas_revenue_entry
- Function
gas_revenue_balance
use 0x2::core_addresses;
use 0x2::object;
use 0x2::signer;
use 0x3::account_coin_store;
use 0x3::coin;
use 0x3::coin_store;
use 0x3::gas_coin;
struct TransactionFeePool has key
Error code for invalid gas used in transaction
const ErrorInvalidGasUsed: u64 = 1;
const SystemFeeAddress: address = 0x3;
public(friend) fun genesis_init(_genesis_account: &signer)
Returns the gas factor of gas.
public fun get_gas_factor(): u64
public fun calculate_gas(gas_amount: u64): u256
public(friend) fun withdraw_fee(amount: u256): coin::Coin<gas_coin::RGas>
public(friend) fun deposit_fee(gas_coin: coin::Coin<gas_coin::RGas>)
public(friend) fun distribute_fee(total_paid_gas: u256, gas_used: u256, contract_address: address, sequencer_address: address): coin::Coin<gas_coin::RGas>
Withdraw the gas revenue for the sender
The contract address can use moveos_std::signer::module_signer
to get the signer
public fun withdraw_gas_revenue(sender: &signer, amount: u256): coin::Coin<gas_coin::RGas>
The entry function to withdraw the gas revenue for the sender
public entry fun withdraw_gas_revenue_entry(sender: &signer, amount: u256)
Get the gas revenue balance for the given address
public fun gas_revenue_balance(addr: address): u256