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()string✅Returns "NEO".
symbolsymbol()string✅Returns "NEO".
decimalsdecimals()uint8✅Returns 0 (indivisible).
totalSupplytotalSupply()uint256✅Returns 100000000.
balanceOfbalanceOf(address)uint256✅NEO balance of account.
transfertransfer(address,address,uint256,bytes)bool❌Transfer NEO tokens. Requires witness of from.
votevote(address,bytes)bool❌Vote for a validator candidate. Pass null pubkey to cancel.
getCandidatesgetCandidates()NeoCandidate[]✅First 256 registered candidates with vote counts.
getAllCandidatesgetAllCandidates()Iterator✅Iterator over all registered candidates.
getCandidateVotegetCandidateVote(bytes)int256✅Vote count for a public key. Returns -1 if not found.
registerCandidateregisterCandidate(bytes)bool❌Register a public key as validator candidate.
unregisterCandidateunregisterCandidate(bytes)bool❌Remove candidate registration.
getCommitteegetCommittee()bytes[]✅Current committee member public keys.
getNextBlockValidatorsgetNextBlockValidators()address[]✅Validators for the next block.
getGasPerBlockgetGasPerBlock()uint256✅GAS generated per block.
setGasPerBlocksetGasPerBlock(uint256)void❌Set GAS per block (committee only).
getRegisterPricegetRegisterPrice()uint256✅GAS cost to register as candidate.
setRegisterPricesetRegisterPrice(uint256)void❌Set registration price (committee only).
getAccountStategetAccountState(address)AccountState✅Balance, vote target, and last GAS claim height.
unclaimedGasunclaimedGas(address,uint256)uint256✅Unclaimed 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