neo
- class NEO
Bases:
object
A class used to represent the NEO native contract.
Check out Neo’s Documentation to learn more about the NEO class.
- classmethod symbol() str
Gets the symbol of NEO.
>>> NEO.symbol() 'NEO'
- Returns:
the NEO string.
- Return type:
- classmethod decimals() int
Gets the amount of decimals used by NEO.
>>> NEO.decimals() 0
- Returns:
the number 0.
- Return type:
- classmethod totalSupply() int
Gets the total token supply deployed in the system.
>>> NEO.totalSupply() 100000000
- Returns:
the total token supply deployed in the system.
- Return type:
- classmethod balanceOf(account: UInt160) int
Get the current balance of an address.
>>> NEO.balanceOf(UInt160(bytes(20))) 0
>>> NEO.balanceOf(UInt160(b'\xabv\xe2\xcb\xb0\x16,vG\x2f\x44Va\x10\x14\x19\xf3\xff\xa1\xe6')) 100
- 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.
>>> NEO.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'), ... 10, None) True
>>> NEO.transfer(UInt160(bytes(20)), ... UInt160(b'\xabv\xe2\xcb\xb0\x16,vG\x2f\x44Va\x10\x14\x19\xf3\xff\xa1\xe6'), ... 10, None) False
>>> NEO.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:
- Returns:
whether the transfer was successful
- Return type:
- Raises:
Exception – raised if from_address or to_address length is not 20 or if amount is less than zero.
- classmethod get_gas_per_block() int
Gets the amount of GAS generated in each block.
>>> NEO.get_gas_per_block() 500000000
- Returns:
the amount of GAS generated
- Return type:
- classmethod unclaimed_gas(account: UInt160, end: int) int
Gets the amount of unclaimed GAS in the specified account.
>>> NEO.unclaimed_gas(UInt160(b'\xc9F\x17\xba!\x99\x07\xc1\xc5\xd6 #\xe1\x9096\x89U\xac\x13'), 0) 100000000
>>> NEO.unclaimed_gas(UInt160(bytes(20), 0) 100000000
- classmethod register_candidate(pubkey: ECPoint) bool
Registers as a candidate.
>>> NEO.register_candidate(ECPoint(b'\x03\x5a\x92\x8f\x20\x16\x39\x20\x4e\x06\xb4\x36\x8b\x1a\x93\x36\x54\x62\xa8\xeb\xbf\xf0\xb8\x81\x81\x51\xb7\x4f\xaa\xb3\xa2\xb6\x1a')) False
- classmethod unregister_candidate(pubkey: ECPoint) bool
Unregisters as a candidate.
>>> NEO.unregister_candidate(ECPoint(b'\x03\x5a\x92\x8f\x20\x16\x39\x20\x4e\x06\xb4\x36\x8b\x1a\x93\x36\x54\x62\xa8\xeb\xbf\xf0\xb8\x81\x81\x51\xb7\x4f\xaa\xb3\xa2\xb6\x1a')) False
- classmethod vote(account: UInt160, vote_to: ECPoint) bool
Votes for a candidate.
>>> NEO.vote(UInt160(b'\xc9F\x17\xba!\x99\x07\xc1\xc5\xd6 #\xe1\x9096\x89U\xac\x13'), ECPoint(b'\x03\x5a\x92\x8f\x20\x16\x39\x20\x4e\x06\xb4\x36\x8b\x1a\x93\x36\x54\x62\xa8\xeb\xbf\xf0\xb8\x81\x81\x51\xb7\x4f\xaa\xb3\xa2\xb6\x1a')) False
- classmethod get_all_candidates() Iterator
Gets the registered candidates iterator.
>>> NEO.get_all_candidates() []
- Returns:
all registered candidates
- Return type:
- classmethod un_vote(account: UInt160) bool
Removes the vote of the candidate voted. It would be the same as calling vote(account, None).
>>> NEO.un_vote(UInt160(b'\xc9F\x17\xba!\x99\x07\xc1\xc5\xd6 #\xe1\x9096\x89U\xac\x13')) False
- Parameters:
account (UInt160) – the account that is removing the vote
- classmethod get_candidates() list[tuple[boa3.builtin.type.ECPoint, int]]
Gets the list of all registered candidates.
>>> NEO.get_candidates() []
- classmethod get_candidate_vote(pubkey: ECPoint) int
Gets votes from specific candidate.
>>> NEO.get_candidate_vote(ECPoint(b'\x03\x5a\x92\x8f\x20\x16\x39\x20\x4e\x06\xb4\x36\x8b\x1a\x93\x36\x54\x62\xa8\xeb\xbf\xf0\xb8\x81\x81\x51\xb7\x4f\xaa\xb3\xa2\xb6\x1a')) 100
>>> NEO.get_candidate_vote(ECPoint(bytes(32))) -1
- Returns:
Votes or -1 if it was not found.
- Return type:
- classmethod get_committee() list[boa3.builtin.type.ECPoint]
Gets all committee members list.
>>> NEO.get_committee() [ b'\x02|\x84\xb0V\xc2j{$XG\x1em\xcfgR\xed\xd9k\x96\x88}x34\xe3Q\xdd\xfe\x13\xc4\xbc\xa2' ]
- classmethod get_next_block_validators() list[boa3.builtin.type.ECPoint]
Gets validators list of the next block.
>>> NEO.get_next_block_validators() [ b'\x02|\x84\xb0V\xc2j{$XG\x1em\xcfgR\xed\xd9k\x96\x88}x34\xe3Q\xdd\xfe\x13\xc4\xbc\xa2' ]
- classmethod get_account_state(account: UInt160) NeoAccountState
Gets the latest votes of the specified account.
>>> NEO.get_account_state(UInt160(b'\xc9F\x17\xba!\x99\x07\xc1\xc5\xd6 #\xe1\x9096\x89U\xac\x13')) { 'balance': 100, 'height': 2, 'vote_to': None, }
- Parameters:
account (UInt160) – the specified account
- Returns:
the state of the account
- Return type: