GAS Token Contract
GAS is the utility token used to pay transaction fees on Neo N3. It has 8 decimals and is generated by holding NEO.
Methods
| Method | Signature | Return | Safe | Description |
|---|---|---|---|---|
name | name() | string | ✅ | Returns "GAS". |
symbol | symbol() | string | ✅ | Returns "GAS". |
decimals | decimals() | uint8 | ✅ | Returns 8. |
totalSupply | totalSupply() | uint256 | ✅ | Current GAS supply (increases over time). |
balanceOf | balanceOf(address) | uint256 | ✅ | GAS balance of account (in 10^-8 units). |
transfer | transfer(address,address,uint256,bytes) | bool | ❌ | Transfer 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).
