Gas and XLG

What is Gas?

Ledgerium adopts the classical Ethereum execution environment on the blockchain called the Ethereum Virtual Machine (EVM). Every node participating in the network runs the EVM as part of the block verification protocol. They go through the transactions listed in the block they are verifying and run the code as triggered by the transaction within the EVM. Each and every full node in the network does the same calculations and stores the same values. Clearly, Ledgerium is not about optimising the efficiency of computation. Its parallel processing is redundantly parallel. This is to offer an efficient way to reach consensus on the system state without needing trusted third parties, oracles or violence monopolies. But importantly they are not there for optimal computation. The fact that contract executions are redundantly replicated across nodes, naturally makes them expensive, which generally creates an incentive not to use the blockchain for computation that can be done off-chain.

When you are running a decentralized application (DApp), it interacts with the blockchain to read and modify its state, but dapps will typically only put the business logic and state that are crucial for consensus on the blockchain.

When a contract is executed as a result of being triggered by a message or transaction, every instruction is executed on every node of the network. This has a cost: for every executed operation there is a specified cost, expressed in a number of gas units.

Gas is the name for the execution fee that senders of transactions need to pay for every operation made on the Ledgerium blockchain. The name gas is inspired by the view that this fee acts as crypto-fuel, driving the motion of smart contracts. Gas is purchased for XLG from the BPs that execute the code. Gas and XLG are decoupled deliberately since units of gas align with computation units having a natural cost, while the price of XLG generally fluctuates as a result of market forces. The two are mediated by a free market: the price of gas is actually decided by the BPs, who can refuse to process a transaction with a lower gas price than their minimum limit. To get gas you simply need to add XLG to your account. The Ledgerium clients automatically purchase gas for your XLG in the amount you specify as your maximum expenditure for the transaction.

The Ledgerium protocol charges a fee per computational step that is executed in a contract or transaction to prevent deliberate attacks and abuse on the Ledgerium network. Every transaction is required to include a gas limit and a fee that it is willing to pay per gas. BPs have the choice of including the transaction and collecting the fee or not. If the total amount of gas used by the computational steps spawned by the transaction, including the original message and any sub-messages that may be triggered, is less than or equal to the gas limit, then the transaction is processed. If the total gas exceeds the gas limit, then all changes are reverted, except that the transaction is still valid and the fee can still be collected by the BP. All excess gas not used by the transaction execution is reimbursed to the sender as XLG. You do not need to worry about overspending since you are only charged for the gas you consume. This means that it is useful as well as safe to send transactions with a gas limit well above the estimates.


Ledgerium has a metric system of denominations used as units of XLG. Each denomination has its own unique name (some bear the family name of seminal figures playing a role in the evolution of computer science and crypto-economics). The smallest denomination aka base unit of XLG is called Wei. Below is a list of the named denominations and their value in Wei. Following a common (although somewhat ambiguous) pattern, XLG also designates a unit (of 1e18 or one quintillion Wei) of the currency.


Wei Value


1 wei

Kwei (babbage)

1,000 wei

Mwei (lovelace)

1,000,000 wei

Gwei (shannon)

1,000,000,000 wei

Microether (szabo)

1,000,000,000,000 wei

Milliether (finney)

1,000,000,000,000,000 wei


1,000,000,000,000,000,000 wei

XLG can also be transferred using the geth console.

var sender = eth.accounts[0];
var receiver = eth.accounts[1];
var amount = web3.toWei(0.01, "XLG")
eth.sendTransaction({from:sender, to:receiver, value: amount})

For more information on XLG transfer transactions, see account-types-gas-and-transactions.

Ledgerium is unique in the realm of cryptocurrencies in that XLG has utility value as a crypto-fuel, commonly referred to as "gas". Beyond transaction fees, gas is a central part of every network request and requires the sender to pay for the computing resources consumed. The gas cost is dynamically calculated, based on the volume and complexity of the request and multiplied by the current gas price. Its value as a crypto-fuel has the effect of increasing the stability and long-term demand for XLG and Ledgerium as a whole. For more information, see account-types-gas-and-transactions.

Gas and XLG

Gas is supposed to be the constant cost of network resources/utilisation. You want the real cost of sending a transaction to always be the same, so you can't really expect Gas to be issued, currencies, in general, are volatile.

So instead, we issue XLG whose value is supposed to vary, but also implement a Gas Price in terms of XLG. If the price of XLG goes up, the Gas Price in terms of XLG should go down to keep the real cost of Gas the same.

Gas has multiple associated terms with it: Gas Prices, Gas Cost, Gas Limit, and Gas Fees. The principle behind Gas is to have a stable value for how much a transaction or computation costs on the Ledgerium network.

  • Gas Cost is a static value for how much a computation costs in terms of Gas, and the intent is that the real value of the Gas never changes, so this cost should always stay stable over time.

  • Gas Price is how much Gas costs in terms of another currency or token like XLG. To stabilise the value of gas, the Gas Price is a floating value such that if the cost of tokens or currency fluctuates, the Gas Price changes to keep the same real value. The Gas Price is set by the equilibrium price of how much users are willing to spend, and how much processing nodes are willing to accept.

  • Gas Limit is the maximum amount of Gas that can be used per block, it is considered the maximum computational load, transaction volume, or block size of a block, and BPs can slowly change this value over time.

  • Gas Fee is effectively the amount of Gas needed to be paid to run a particular transaction or program (called a contract). The Gas Fees of a block can be used to imply the computational load, transaction volume, or size of a block. The gas fees are paid to the block producers.

Estimating transaction costs

The total XLG cost of a transaction is based on 2 factors:

  • gasUsed is the total gas that is consumed by the transaction

  • gasPrice price (in XLG) of one unit of gas specified in the transaction

Total cost = gasUsed * gasPrice


Each operation in the EVM was assigned a number of how much gas it consumes. gasUsed is the sum of all the gas for all the operations executed. Below is the list given showing some of the analysis behind this.

For estimating gasUsed, there is an estimateGas API that can be used but has some caveats.


A user constructs and signs a transaction, and each user may specify whatever gasPrice they desire, which can be zero. However, the Ledgerium clients launched at Toorak had a default gasPrice of 1 Shannon. As BPs optimize it for their revenue, if most transactions are being submitted with a gasPrice of 1 Shannon, it would be difficult to convince a BP to accept a transaction that specified a lower, or zero gasPrice.

Example transaction cost

Let’s take a contract that just adds 2 numbers. The EVM OPCODE ADD consumes 3 gas.

The approximate cost, using the default gas price (as of Setember 2019), would be:

3 * 1e9 = 3e9 wei

Since 1 XLG is 1e18 wei, the total cost would be 0.000000003 XLG.

sloadGas 50 //Multiplied by the number of 32-byte words that are copied (round-up) for any *COPY operation and added.
CallValueTransferGas 9000 // Paid for CALL when the value transfer is non-zero.
CallNewAccountGas 25000 // Paid for CALL when the destination address didn't exist prior.
TxGas 21000 // Per transaction not creating a contract. NOTE: Not payable on data of calls between transactions.
TxGasContractCreation 53000 // Per transaction that creates a contract. NOTE: Not payable on data of calls between transactions.
TxDataZeroGas 4 // Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions
SstoreSetGas 20000 // Once per SLOAD operation.
LogDataGas 8 // Per byte in a LOG* operation's data.
CallStipend 2300 // Free gas given at beginning of call.
Sha3Gas 30 // Once per SHA3 operation.
Sha3WordGas 6 // Once per word of the SHA3 operation's data.
SstoreResetGas 5000 // Once per SSTORE operation if the zeroness changes from zero.
SstoreClearGas 5000 // Once per SSTORE operation if the zeroness doesn't change.
SstoreRefundGas 15000 // Once per SSTORE operation if the zeroness changes to zero.
JumpdestGas 1 // Refunded gas, once per SSTORE operation if the zeroness changes to zero.
CallGas 40 // Once per CALL operation & message call transaction.
CreateDataGas 200 //
CallCreateDepth 1024 // Maximum depth of call/create stack.
ExpGas 10 // Once per EXP instruction
LogGas 375 // Per LOG* operation.
CopyGas 3 //
TierStepGas 0 // Once per operation, for a selection of them.
LogTopicGas 375 // Multiplied by the * of the LOG*, per LOG transaction. e.g. LOG0 incurs 0 * c_txLogTopicGas, LOG4 incurs 4 * c_txLogTopicGas.
CreateGas 32000 // Once per CREATE operation & contract-creation transaction.
SuicideRefundGas 24000 // Refunded following a suicide operation.
MemoryGas 3 // Times the address of the (highest referenced byte in memory + 1). NOTE: referencing happens on read, write and in instructions such as RETURN and CALL.
TxDataNonZeroGas 68 // Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions.
// Precompiled contract gas prices
EcrecoverGas 3000 // Elliptic curve sender recovery gas price
Sha256BaseGas 60 // Base price for a SHA256 operation
Sha256PerWordGas 12 // Per-word price for a SHA256 operation
Ripemd160BaseGas 600 // Base price for a RIPEMD160 operation
Ripemd160PerWordGas 120 // Per-word price for a RIPEMD160 operation
IdentityBaseGas 15 // Base price for a data copy operation
IdentityPerWordGas 3 // Per-work price for a data copy operation
ModExpQuadCoeffDiv 20 // Divisor for the quadratic particle of the big int modular exponentiation
Bn256AddGas 500 // Gas needed for an elliptic curve addition
Bn256ScalarMulGas 40000 // Gas needed for an elliptic curve scalar multiplication
Bn256PairingBaseGas 100000 // Base price for an elliptic curve pairing check
Bn256PairingPerPointGas 80000 // Per-point price for an elliptic curve pairing check