Skip to content

GAS Token Contract

Back to Native Contracts

GAS is the utility token used to pay transaction fees on Neo N3. It has 8 decimals and is generated by holding NEO.

Methods

MethodSignatureReturnSafeDescription
namename()stringReturns "GAS".
symbolsymbol()stringReturns "GAS".
decimalsdecimals()uint8Returns 8.
totalSupplytotalSupply()uint256Current GAS supply (increases over time).
balanceOfbalanceOf(address)uint256GAS balance of account (in 10^-8 units).
transfertransfer(address,address,uint256,bytes)boolTransfer GAS. Requires witness of from.

Code Example

solidity
import "devpack/contracts/NativeCalls.sol";

contract Treasury {
    function getGasBalance() public view returns (uint256) {
        return NativeCalls.gasBalanceOf(address(this));
    }

    function withdrawGas(address to, uint256 amount) public {
        require(Runtime.checkWitness(msg.sender), "unauthorized");
        bool success = NativeCalls.gasTransfer(address(this), to, amount, "");
        require(success, "transfer failed");
    }
}

TIP

GAS uses 10^8 decimals, not 10^18 like Ether. When porting EVM contracts, adjust your unit constants: 0.1 GAS = 10_000_000 (not 10^17).


MIT Licensed