Skip to content

NEO Token Contract

Back to Native Contracts

The NEO token is the governance token of the Neo N3 network. It is indivisible (0 decimals), has a fixed supply of 100,000,000, and is used for voting, validator election, and GAS generation.

Methods

MethodSignatureReturnSafeDescription
namename()stringReturns "NEO".
symbolsymbol()stringReturns "NEO".
decimalsdecimals()uint8Returns 0 (indivisible).
totalSupplytotalSupply()uint256Returns 100000000.
balanceOfbalanceOf(address)uint256NEO balance of account.
transfertransfer(address,address,uint256,bytes)boolTransfer NEO tokens. Requires witness of from.
votevote(address,bytes)boolVote for a validator candidate. Pass null pubkey to cancel.
getCandidatesgetCandidates()NeoCandidate[]First 256 registered candidates with vote counts.
getAllCandidatesgetAllCandidates()IteratorIterator over all registered candidates.
getCandidateVotegetCandidateVote(bytes)int256Vote count for a public key. Returns -1 if not found.
registerCandidateregisterCandidate(bytes)boolRegister a public key as validator candidate.
unregisterCandidateunregisterCandidate(bytes)boolRemove candidate registration.
getCommitteegetCommittee()bytes[]Current committee member public keys.
getNextBlockValidatorsgetNextBlockValidators()address[]Validators for the next block.
getGasPerBlockgetGasPerBlock()uint256GAS generated per block.
setGasPerBlocksetGasPerBlock(uint256)voidSet GAS per block (committee only).
getRegisterPricegetRegisterPrice()uint256GAS cost to register as candidate.
setRegisterPricesetRegisterPrice(uint256)voidSet registration price (committee only).
getAccountStategetAccountState(address)AccountStateBalance, vote target, and last GAS claim height.
unclaimedGasunclaimedGas(address,uint256)uint256Unclaimed GAS for account at block height.

Code Example

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

contract Governance {
    function getMyNeoBalance() public view returns (uint256) {
        return NativeCalls.neoBalanceOf(address(this));
    }

    function voteForCandidate(bytes memory publicKey) public {
        require(Runtime.checkWitness(msg.sender), "unauthorized");
        NativeCalls.vote(msg.sender, publicKey);
    }

    function claimableGas(address account) public view returns (uint256) {
        uint256 height = NativeCalls.currentIndex();
        return NativeCalls.unclaimedGas(account, height);
    }
}

MIT Licensed