Skip to content

Units and Globally Available Variables

This section explains how Solidity's standard Ether/Time units and global execution variables (block, tx, msg) map to NeoVM semantics.

For a split reader guide focused on execution globals, see Execution Context.

Ether Units

A literal number can take a suffix of wei, gwei or ether to specify a subdenomination of Ether, where Ether numbers without a postfix are assumed to be Wei.

WARNING

Neo GAS Difference: Ether unit literals (1 ether = 10^18 wei) are parsed for source compatibility but emit a warning. Neo GAS uses 10^8 decimals, not 10^18. You should adjust your constants to match Neo GAS units:

solidity
// ⚠️ EVM units — warning emitted
uint256 fee = 0.1 ether; // 10^17 wei — wrong for Neo

// ✅ Neo GAS units
uint256 fee = 10_000_000; // 0.1 GAS (10^7, since GAS has 10^8 decimals)

Time Units

Suffixes like seconds, minutes, hours, days and weeks after literal numbers can be used to specify units of time where seconds are the base unit. These map perfectly to NeoVM logic.

Block and Transaction Properties

The neo-devpack-solidity compiler auto-maps EVM globals to approximate Neo equivalents. Auto-mapped features compile successfully but emit a compiler warning when the semantic match is not exact.

Solidity / EVMNeoVM / Neo N3Notes
block.timestampSystem.Runtime.GetTimeReturns block time in milliseconds, normalized to seconds by the compiler.
block.numberLedger.currentIndexReturns the current block height.
block.chainidNeo network magicCompile-time constant. Mainnet: 860833102, Testnet: 894710606.
block.coinbaseaddress(0)Auto-mapped with warning. dBFT consensus has no block miner.
block.difficulty / block.prevrandaoRuntime.getRandom()Auto-mapped with warning. Different randomness model.
block.gaslimitPolicy.getExecFeeFactor()Auto-mapped with warning. Different gas accounting model.
block.basefeePolicy.getFeePerByte()Auto-mapped with warning. Different fee model.
blockhash(n)Ledger.getBlockHash(n)Auto-mapped with warning. Returns Neo block hash.
block.sha3Ledger.currentHashAuto-mapped with warning. Deprecated in Solidity 0.8+.
tx.originFirst signer script hashMaps to the first transaction signer. Warning: authorization anti-pattern.
tx.gaspricePolicy.getFeePerByte()Auto-mapped with warning. Different fee model.

Message Properties

Solidity / EVMNeoVM / Neo N3Notes
msg.senderSystem.Runtime.GetCallingScriptHashReturns the script hash of the calling contract or transaction signer.
msg.valueonNEP17Payment amount parameterOnly valid inside NEP-17/NEP-11 payment callbacks. No equivalent outside that context.
msg.dataApproximated as selector || abi.encode(current args) outside onNEP17Payment.
msg.sigApproximated as the current function selector (with warning). Internal-call semantics still differ from EVM.

Contract Context

Solidity / EVMNeoVM / Neo N3Notes
thisSystem.Runtime.GetExecutingScriptHashReturns the script hash of the current contract.
gasleft()System.Runtime.GasLeftReturns remaining GAS for the current invocation.
selfdestruct(addr)ContractManagement.destroy()Auto-mapped with warning. No refund. Permanent and irreversible.
address.codehashContract script hashAuto-mapped with warning. Non-contract addresses return bytes32(0).
address.codeContract script bytesAuto-mapped with warning through ContractManagement.getContract(). Non-contracts return empty bytes.

MIT Licensed