gas

class GAS

Bases: object

A class used to represent the GAS native contract.

Check out Neo’s Documentation to learn more about the GAS class.

hash: UInt160
classmethod symbol() str

Gets the symbol of GAS.

>>> GAS.symbol()
'GAS'
Returns:

the GAS string.

Return type:

str

classmethod decimals() int

Gets the amount of decimals used by GAS.

>>> GAS.decimals()
8
Returns:

the number 8.

Return type:

int

classmethod totalSupply() int

Gets the total token supply deployed in the system.

>>> GAS.totalSupply()
5199999098939320
>>> GAS.totalSupply()
5522957322800300
Returns:

the total token supply deployed in the system.

Return type:

int

classmethod balanceOf(account: UInt160) int

Get the current balance of an address.

>>> GAS.balanceOf(UInt160(bytes(20)))
0
>>> GAS.balanceOf(UInt160(b'\xabv\xe2\xcb\xb0\x16,vG\x2f\x44Va\x10\x14\x19\xf3\xff\xa1\xe6'))
1000000000
Parameters:

account (UInt160) – the account’s address to retrieve the balance for

Returns:

the account’s balance

Return type:

int

classmethod transfer(from_address: UInt160, to_address: UInt160, amount: int, data: Any = None) bool

Transfers an amount of GAS from one account to another.

If the method succeeds, it will fire the Transfer event and must return true, even if the amount is 0, or from and to are the same address.

>>> GAS.transfer(UInt160(b'\xc9F\x17\xba!\x99\x07\xc1\xc5\xd6   #\xe1\x9096\x89U\xac\x13'),     # this script hash needs to have signed the transaction or block
...              UInt160(b'\xabv\xe2\xcb\xb0\x16,vG\x2f\x44Va\x10\x14\x19\xf3\xff\xa1\xe6'),
...              10000, None)
True
>>> GAS.transfer(UInt160(bytes(20)),
...              UInt160(b'\xabv\xe2\xcb\xb0\x16,vG\x2f\x44Va\x10\x14\x19\xf3\xff\xa1\xe6'),
...              10000, None)
False
>>> GAS.transfer(UInt160(b'\xc9F\x17\xba!\x99\x07\xc1\xc5\xd6   #\xe1\x9096\x89U\xac\x13'),
...              UInt160(b'\xabv\xe2\xcb\xb0\x16,vG\x2f\x44Va\x10\x14\x19\xf3\xff\xa1\xe6'),
...              -1, None)
False
Parameters:
  • from_address (UInt160) – the address to transfer from

  • to_address (UInt160) – the address to transfer to

  • amount (int) – the amount of GAS to transfer

  • data (Any) – whatever data is pertinent to the onNEP17Payment method

Returns:

whether the transfer was successful

Return type:

bool

Raises:

Exception – raised if from_address or to_address length is not 20 or if amount is less than zero.