Documentation ¶
Index ¶
- Constants
- Variables
- func BlockToStackItem(b *block.Block) stackitem.Item
- func Call(ic *interop.Context) error
- func OnPersist(ic *interop.Context) error
- func PostPersist(ic *interop.Context) error
- func ShouldUpdateCommittee(h uint32, bc blockchainer.Blockchainer) bool
- func TransactionToStackItem(t *transaction.Transaction) stackitem.Item
- type Contracts
- type Designate
- func (s *Designate) DesignateAsRole(ic *interop.Context, r Role, pubs keys.PublicKeys) error
- func (s *Designate) GetDesignatedByRole(d dao.DAO, r Role, index uint32) (keys.PublicKeys, uint32, error)
- func (s *Designate) GetLastDesignatedHash(d dao.DAO, r Role) (util.Uint160, error)
- func (s *Designate) Initialize(ic *interop.Context) error
- func (s *Designate) Metadata() *interop.ContractMD
- func (s *Designate) OnPersist(ic *interop.Context) error
- func (s *Designate) PostPersist(ic *interop.Context) error
- type GAS
- func (c *GAS) Decimals(_ *interop.Context, _ []stackitem.Item) stackitem.Item
- func (g *GAS) Initialize(ic *interop.Context) error
- func (c *GAS) Metadata() *interop.ContractMD
- func (g *GAS) OnPersist(ic *interop.Context) error
- func (g *GAS) PostPersist(ic *interop.Context) error
- func (c *GAS) Symbol(_ *interop.Context, _ []stackitem.Item) stackitem.Item
- func (c *GAS) TotalSupply(ic *interop.Context, _ []stackitem.Item) stackitem.Item
- func (c *GAS) Transfer(ic *interop.Context, args []stackitem.Item) stackitem.Item
- func (c *GAS) TransferInternal(ic *interop.Context, from, to util.Uint160, amount *big.Int, ...) error
- type IDList
- type Ledger
- type Management
- func (m *Management) Deploy(d dao.DAO, sender util.Uint160, neff *nef.File, manif *manifest.Manifest) (*state.Contract, error)
- func (m *Management) Destroy(d dao.DAO, hash util.Uint160) error
- func (m *Management) GetContract(d dao.DAO, hash util.Uint160) (*state.Contract, error)
- func (m *Management) GetMinimumDeploymentFee(dao dao.DAO) int64
- func (m *Management) Initialize(ic *interop.Context) error
- func (m *Management) InitializeCache(d dao.DAO) error
- func (m *Management) Metadata() *interop.ContractMD
- func (m *Management) OnPersist(ic *interop.Context) error
- func (m *Management) PostPersist(ic *interop.Context) error
- func (m *Management) PutContractState(d dao.DAO, cs *state.Contract) error
- func (m *Management) Update(d dao.DAO, hash util.Uint160, neff *nef.File, manif *manifest.Manifest) (*state.Contract, error)
- type NEO
- func (n *NEO) CalculateBonus(d dao.DAO, acc util.Uint160, end uint32) (*big.Int, error)
- func (n *NEO) CalculateNEOHolderReward(d dao.DAO, value *big.Int, start, end uint32) (*big.Int, error)
- func (n *NEO) ComputeNextBlockValidators(bc blockchainer.Blockchainer, d dao.DAO) (keys.PublicKeys, error)
- func (c *NEO) Decimals(_ *interop.Context, _ []stackitem.Item) stackitem.Item
- func (n *NEO) GetCandidates(d dao.DAO) ([]state.Validator, error)
- func (n *NEO) GetCommitteeAddress() util.Uint160
- func (n *NEO) GetCommitteeMembers() keys.PublicKeys
- func (n *NEO) GetGASPerBlock(d dao.DAO, index uint32) *big.Int
- func (n *NEO) GetNextBlockValidatorsInternal() keys.PublicKeys
- func (n *NEO) Initialize(ic *interop.Context) error
- func (n *NEO) InitializeCache(bc blockchainer.Blockchainer, d dao.DAO) error
- func (c *NEO) Metadata() *interop.ContractMD
- func (n *NEO) ModifyAccountVotes(acc *state.NEOBalanceState, d dao.DAO, value *big.Int, isNewVote bool) error
- func (n *NEO) OnPersist(ic *interop.Context) error
- func (n *NEO) PostPersist(ic *interop.Context) error
- func (n *NEO) RegisterCandidateInternal(ic *interop.Context, pub *keys.PublicKey) error
- func (n *NEO) SetGASPerBlock(ic *interop.Context, index uint32, gas *big.Int) error
- func (c *NEO) Symbol(_ *interop.Context, _ []stackitem.Item) stackitem.Item
- func (c *NEO) TotalSupply(ic *interop.Context, _ []stackitem.Item) stackitem.Item
- func (c *NEO) Transfer(ic *interop.Context, args []stackitem.Item) stackitem.Item
- func (c *NEO) TransferInternal(ic *interop.Context, from, to util.Uint160, amount *big.Int, ...) error
- func (n *NEO) UnregisterCandidateInternal(ic *interop.Context, pub *keys.PublicKey) error
- func (n *NEO) VoteInternal(ic *interop.Context, h util.Uint160, pub *keys.PublicKey) error
- type NameService
- func (n *NameService) BalanceOf(ic *interop.Context, args []stackitem.Item) stackitem.Item
- func (n *NameService) Initialize(ic *interop.Context) error
- func (n *NameService) Metadata() *interop.ContractMD
- func (n *NameService) OnPersist(ic *interop.Context) error
- func (n *NameService) OwnerOf(ic *interop.Context, args []stackitem.Item) stackitem.Item
- func (n *NameService) PostPersist(ic *interop.Context) error
- func (n *NameService) Properties(ic *interop.Context, args []stackitem.Item) stackitem.Item
- func (n *NameService) TotalSupply(d dao.DAO) *big.Int
- type NodeList
- type Notary
- func (n *Notary) BalanceOf(dao dao.DAO, acc util.Uint160) *big.Int
- func (n *Notary) ExpirationOf(dao dao.DAO, acc util.Uint160) uint32
- func (n *Notary) GetDepositFor(dao dao.DAO, acc util.Uint160) *state.Deposit
- func (n *Notary) GetMaxNotValidBeforeDelta(dao dao.DAO) uint32
- func (n *Notary) GetNotaryNodes(d dao.DAO) (keys.PublicKeys, error)
- func (n *Notary) Initialize(ic *interop.Context) error
- func (n *Notary) Metadata() *interop.ContractMD
- func (n *Notary) OnPersist(ic *interop.Context) error
- func (n *Notary) PostPersist(ic *interop.Context) error
- type Oracle
- func (o *Oracle) FinishInternal(ic *interop.Context) error
- func (o *Oracle) GetIDListInternal(d dao.DAO, url string) (*IDList, error)
- func (o *Oracle) GetOracleNodes(d dao.DAO) (keys.PublicKeys, error)
- func (o *Oracle) GetOracleResponseScript() []byte
- func (o *Oracle) GetRequestInternal(d dao.DAO, id uint64) (*state.OracleRequest, error)
- func (o *Oracle) GetScriptHash(d dao.DAO) (util.Uint160, error)
- func (o *Oracle) Initialize(ic *interop.Context) error
- func (o *Oracle) Metadata() *interop.ContractMD
- func (o *Oracle) OnPersist(ic *interop.Context) error
- func (o *Oracle) PostPersist(ic *interop.Context) error
- func (o *Oracle) PutRequestInternal(id uint64, req *state.OracleRequest, d dao.DAO) error
- func (o *Oracle) RequestInternal(ic *interop.Context, url string, filter *string, cb string, ...) error
- type Policy
- func (p *Policy) CheckPolicy(d dao.DAO, tx *transaction.Transaction) error
- func (p *Policy) GetExecFeeFactorInternal(d dao.DAO) int64
- func (p *Policy) GetFeePerByteInternal(dao dao.DAO) int64
- func (p *Policy) GetMaxBlockSizeInternal(dao dao.DAO) uint32
- func (p *Policy) GetMaxBlockSystemFeeInternal(dao dao.DAO) int64
- func (p *Policy) GetMaxTransactionsPerBlockInternal(dao dao.DAO) uint32
- func (p *Policy) GetMaxVerificationGas(_ dao.DAO) int64
- func (p *Policy) GetStoragePriceInternal(d dao.DAO) int64
- func (p *Policy) Initialize(ic *interop.Context) error
- func (p *Policy) IsBlockedInternal(dao dao.DAO, hash util.Uint160) bool
- func (p *Policy) Metadata() *interop.ContractMD
- func (p *Policy) OnPersist(ic *interop.Context) error
- func (p *Policy) PostPersist(ic *interop.Context) error
- type RecordType
- type Role
Constants ¶
const ( // DefaultDomainPrice is the default price of register method. DefaultDomainPrice = 10_00000000 // MinDomainNameLength is minimum domain length. MinDomainNameLength = 3 // MaxDomainNameLength is maximum domain length. MaxDomainNameLength = 255 )
const (
// DefaultStoragePrice is the price to pay for 1 byte of storage.
DefaultStoragePrice = 100000
)
const GASFactor = NEOTotalSupply
GASFactor is a divisor for finding GAS integral value.
const (
// NEOTotalSupply is the total amount of NEO in the system.
NEOTotalSupply = 100000000
)
const (
// NotaryVerificationPrice is the price of `verify` Notary method.
NotaryVerificationPrice = 100_0000
)
Variables ¶
var ( ErrAlreadyDesignated = errors.New("already designated given role at current block") ErrEmptyNodeList = errors.New("node list is empty") ErrInvalidIndex = errors.New("invalid index") ErrInvalidRole = errors.New("invalid role") ErrLargeNodeList = errors.New("node list is too large") ErrNoBlock = errors.New("no persisting block in the context") )
Various errors.
var ( ErrBigArgument = errors.New("some of the arguments are invalid") ErrInvalidWitness = errors.New("witness check failed") ErrNotEnoughGas = errors.New("gas limit exceeded") ErrRequestNotFound = errors.New("oracle request not found") ErrResponseNotFound = errors.New("oracle response not found") )
Various validation errors.
Functions ¶
func BlockToStackItem ¶ added in v0.93.0
BlockToStackItem converts block.Block to stackitem.Item
func PostPersist ¶ added in v0.92.0
PostPersist calls PostPersist methods for all native contracts.
func ShouldUpdateCommittee ¶ added in v0.92.0
func ShouldUpdateCommittee(h uint32, bc blockchainer.Blockchainer) bool
ShouldUpdateCommittee returns true if committee is updated at block h.
func TransactionToStackItem ¶ added in v0.93.0
func TransactionToStackItem(t *transaction.Transaction) stackitem.Item
TransactionToStackItem converts transaction.Transaction to stackitem.Item
Types ¶
type Contracts ¶
type Contracts struct { Management *Management Ledger *Ledger NEO *NEO GAS *GAS Policy *Policy Oracle *Oracle Designate *Designate NameService *NameService Notary *Notary Contracts []interop.Contract // contains filtered or unexported fields }
Contracts is a set of registered native contracts.
func NewContracts ¶
NewContracts returns new set of native contracts with new GAS, NEO, Policy, Oracle, Designate and (optional) Notary contracts.
func (*Contracts) GetPersistScript ¶
GetPersistScript returns VM script calling "onPersist" syscall for native contracts.
func (*Contracts) GetPostPersistScript ¶ added in v0.92.0
GetPostPersistScript returns VM script calling "postPersist" syscall for native contracts.
type Designate ¶ added in v0.92.0
type Designate struct { interop.ContractMD NEO *NEO OracleService atomic.Value // NotaryService represents Notary node module. NotaryService atomic.Value // contains filtered or unexported fields }
Designate represents designation contract.
func (*Designate) DesignateAsRole ¶ added in v0.92.0
DesignateAsRole sets nodes for role r.
func (*Designate) GetDesignatedByRole ¶ added in v0.92.0
func (s *Designate) GetDesignatedByRole(d dao.DAO, r Role, index uint32) (keys.PublicKeys, uint32, error)
GetDesignatedByRole returns nodes for role r.
func (*Designate) GetLastDesignatedHash ¶ added in v0.93.0
GetLastDesignatedHash returns last designated hash of a given role.
func (*Designate) Initialize ¶ added in v0.92.0
Initialize initializes Oracle contract.
func (*Designate) Metadata ¶ added in v0.92.0
func (s *Designate) Metadata() *interop.ContractMD
Metadata returns contract metadata.
type GAS ¶
type GAS struct { NEO *NEO // contains filtered or unexported fields }
GAS represents GAS native contract.
func (*GAS) Initialize ¶
Initialize initializes GAS contract.
func (*GAS) Metadata ¶
func (c *GAS) Metadata() *interop.ContractMD
func (*GAS) PostPersist ¶ added in v0.92.0
PostPersist implements Contract interface.
func (*GAS) TotalSupply ¶
type IDList ¶ added in v0.92.0
type IDList []uint64
IDList is a list of oracle request IDs.
func (*IDList) DecodeBinary ¶ added in v0.92.0
DecodeBinary implements io.Serializable.
func (IDList) EncodeBinary ¶ added in v0.92.0
EncodeBinary implements io.Serializable.
type Ledger ¶ added in v0.93.0
type Ledger struct {
interop.ContractMD
}
Ledger provides an interface to blocks/transactions storage for smart contracts. It's not a part of the proper chain's state, so it's just a proxy between regular Blockchain/DAO interface and smart contracts.
func (*Ledger) Initialize ¶ added in v0.93.0
Initialize implements Contract interface.
func (*Ledger) Metadata ¶ added in v0.93.0
func (l *Ledger) Metadata() *interop.ContractMD
Metadata implements Contract interface.
type Management ¶ added in v0.92.0
type Management struct { interop.ContractMD NEO *NEO // contains filtered or unexported fields }
Management is contract-managing native contract.
func (*Management) Deploy ¶ added in v0.92.0
func (m *Management) Deploy(d dao.DAO, sender util.Uint160, neff *nef.File, manif *manifest.Manifest) (*state.Contract, error)
Deploy creates contract's hash/ID and saves new contract into the given DAO. It doesn't run _deploy method and doesn't emit notification.
func (*Management) Destroy ¶ added in v0.92.0
Destroy drops given contract from DAO along with its storage. It doesn't emit notification.
func (*Management) GetContract ¶ added in v0.92.0
GetContract returns contract with given hash from given DAO.
func (*Management) GetMinimumDeploymentFee ¶ added in v0.92.0
func (m *Management) GetMinimumDeploymentFee(dao dao.DAO) int64
GetMinimumDeploymentFee returns the minimum required fee for contract deploy.
func (*Management) Initialize ¶ added in v0.92.0
func (m *Management) Initialize(ic *interop.Context) error
Initialize implements Contract interface.
func (*Management) InitializeCache ¶ added in v0.92.0
func (m *Management) InitializeCache(d dao.DAO) error
InitializeCache initializes contract cache with the proper values from storage. Cache initialisation should be done apart from Initialize because Initialize is called only when deploying native contracts.
func (*Management) Metadata ¶ added in v0.92.0
func (m *Management) Metadata() *interop.ContractMD
Metadata implements Contract interface.
func (*Management) OnPersist ¶ added in v0.92.0
func (m *Management) OnPersist(ic *interop.Context) error
OnPersist implements Contract interface.
func (*Management) PostPersist ¶ added in v0.92.0
func (m *Management) PostPersist(ic *interop.Context) error
PostPersist implements Contract interface.
func (*Management) PutContractState ¶ added in v0.92.0
PutContractState saves given contract state into given DAO.
type NEO ¶
type NEO struct { GAS *GAS // contains filtered or unexported fields }
NEO represents NEO native contract.
func (*NEO) CalculateBonus ¶ added in v0.92.0
CalculateBonus calculates amount of gas generated for holding value NEO from start to end block and having voted for active committee member.
func (*NEO) CalculateNEOHolderReward ¶ added in v0.92.0
func (n *NEO) CalculateNEOHolderReward(d dao.DAO, value *big.Int, start, end uint32) (*big.Int, error)
CalculateNEOHolderReward return GAS reward for holding `value` of NEO from start to end block.
func (*NEO) ComputeNextBlockValidators ¶ added in v0.92.0
func (n *NEO) ComputeNextBlockValidators(bc blockchainer.Blockchainer, d dao.DAO) (keys.PublicKeys, error)
ComputeNextBlockValidators returns an actual list of current validators.
func (*NEO) GetCandidates ¶ added in v0.91.0
GetCandidates returns current registered validators list with keys and votes.
func (*NEO) GetCommitteeAddress ¶ added in v0.92.0
GetCommitteeAddress returns address of the committee.
func (*NEO) GetCommitteeMembers ¶ added in v0.92.0
func (n *NEO) GetCommitteeMembers() keys.PublicKeys
GetCommitteeMembers returns public keys of nodes in committee using cached value.
func (*NEO) GetGASPerBlock ¶ added in v0.92.0
GetGASPerBlock returns gas generated for block with provided index.
func (*NEO) GetNextBlockValidatorsInternal ¶
func (n *NEO) GetNextBlockValidatorsInternal() keys.PublicKeys
GetNextBlockValidatorsInternal returns next block validators.
func (*NEO) Initialize ¶
Initialize initializes NEO contract.
func (*NEO) InitializeCache ¶ added in v0.92.0
func (n *NEO) InitializeCache(bc blockchainer.Blockchainer, d dao.DAO) error
InitializeCache initializes all NEO cache with the proper values from storage. Cache initialisation should be done apart from Initialize because Initialize is called only when deploying native contracts.
func (*NEO) Metadata ¶
func (c *NEO) Metadata() *interop.ContractMD
func (*NEO) ModifyAccountVotes ¶
func (n *NEO) ModifyAccountVotes(acc *state.NEOBalanceState, d dao.DAO, value *big.Int, isNewVote bool) error
ModifyAccountVotes modifies votes of the specified account by value (can be negative). typ specifies if this modify is occurring during transfer or vote (with old or new validator).
func (*NEO) PostPersist ¶ added in v0.92.0
PostPersist implements Contract interface.
func (*NEO) RegisterCandidateInternal ¶ added in v0.91.0
RegisterCandidateInternal registers pub as a new candidate.
func (*NEO) SetGASPerBlock ¶ added in v0.92.0
SetGASPerBlock sets gas generated for blocks after index.
func (*NEO) TotalSupply ¶
func (*NEO) TransferInternal ¶ added in v0.91.0
func (c *NEO) TransferInternal(ic *interop.Context, from, to util.Uint160, amount *big.Int, data stackitem.Item) error
TransferInternal transfers NEO between accounts.
func (*NEO) UnregisterCandidateInternal ¶ added in v0.91.0
UnregisterCandidateInternal unregisters pub as a candidate.
type NameService ¶ added in v0.93.0
type NameService struct { NEO *NEO // contains filtered or unexported fields }
NameService represents native NameService contract.
func (*NameService) Initialize ¶ added in v0.93.0
func (n *NameService) Initialize(ic *interop.Context) error
Initialize implements interop.Contract interface.
func (*NameService) Metadata ¶ added in v0.93.0
func (n *NameService) Metadata() *interop.ContractMD
Metadata implements interop.Contract interface.
func (*NameService) OnPersist ¶ added in v0.93.0
func (n *NameService) OnPersist(ic *interop.Context) error
OnPersist implements interop.Contract interface.
func (*NameService) PostPersist ¶ added in v0.93.0
func (n *NameService) PostPersist(ic *interop.Context) error
PostPersist implements interop.Contract interface.
func (*NameService) Properties ¶ added in v0.93.0
type NodeList ¶ added in v0.92.0
type NodeList keys.PublicKeys
NodeList represents list or oracle nodes.
func (*NodeList) DecodeBinary ¶ added in v0.92.0
DecodeBinary implements io.Serializable.
func (NodeList) EncodeBinary ¶ added in v0.92.0
EncodeBinary implements io.Serializable.
type Notary ¶ added in v0.92.0
type Notary struct { interop.ContractMD GAS *GAS NEO *NEO Desig *Designate // contains filtered or unexported fields }
Notary represents Notary native contract.
func (*Notary) BalanceOf ¶ added in v0.92.0
BalanceOf is an internal representation of `balanceOf` Notary method.
func (*Notary) ExpirationOf ¶ added in v0.92.0
ExpirationOf is an internal representation of `expirationOf` Notary method.
func (*Notary) GetDepositFor ¶ added in v0.92.0
GetDepositFor returns state.Deposit for the account specified. It returns nil in case if deposit is not found in storage and panics in case of any other error.
func (*Notary) GetMaxNotValidBeforeDelta ¶ added in v0.92.0
GetMaxNotValidBeforeDelta is an internal representation of Notary getMaxNotValidBeforeDelta method.
func (*Notary) GetNotaryNodes ¶ added in v0.92.0
GetNotaryNodes returns public keys of notary nodes.
func (*Notary) Initialize ¶ added in v0.92.0
Initialize initializes Notary native contract and implements Contract interface.
func (*Notary) Metadata ¶ added in v0.92.0
func (n *Notary) Metadata() *interop.ContractMD
Metadata implements Contract interface.
type Oracle ¶ added in v0.92.0
type Oracle struct { interop.ContractMD GAS *GAS NEO *NEO Desig *Designate // Module is an oracle module capable of talking with the external world. Module atomic.Value // contains filtered or unexported fields }
Oracle represents Oracle native contract.
func (*Oracle) FinishInternal ¶ added in v0.92.0
FinishInternal processes oracle response.
func (*Oracle) GetIDListInternal ¶ added in v0.92.0
GetIDListInternal returns request by ID and key under which it is stored.
func (*Oracle) GetOracleNodes ¶ added in v0.92.0
GetOracleNodes returns public keys of oracle nodes.
func (*Oracle) GetOracleResponseScript ¶ added in v0.93.0
GetOracleResponseScript returns script for transaction with oracle response.
func (*Oracle) GetRequestInternal ¶ added in v0.92.0
GetRequestInternal returns request by ID and key under which it is stored.
func (*Oracle) GetScriptHash ¶ added in v0.92.0
GetScriptHash returns script hash or oracle nodes.
func (*Oracle) Initialize ¶ added in v0.92.0
Initialize initializes Oracle contract.
func (*Oracle) Metadata ¶ added in v0.92.0
func (o *Oracle) Metadata() *interop.ContractMD
Metadata returns contract metadata.
func (*Oracle) PostPersist ¶ added in v0.92.0
PostPersist represents `postPersist` method.
func (*Oracle) PutRequestInternal ¶ added in v0.92.0
PutRequestInternal puts oracle request with the specified id to d.
type Policy ¶
type Policy struct { interop.ContractMD NEO *NEO // contains filtered or unexported fields }
Policy represents Policy native contract.
func (*Policy) CheckPolicy ¶
func (p *Policy) CheckPolicy(d dao.DAO, tx *transaction.Transaction) error
CheckPolicy checks whether transaction conforms to current policy restrictions like not being signed by blocked account or not exceeding block-level system fee limit.
func (*Policy) GetExecFeeFactorInternal ¶ added in v0.92.0
GetExecFeeFactorInternal returns current execution fee factor.
func (*Policy) GetFeePerByteInternal ¶
GetFeePerByteInternal returns required transaction's fee per byte.
func (*Policy) GetMaxBlockSizeInternal ¶ added in v0.91.0
GetMaxBlockSizeInternal returns maximum block size.
func (*Policy) GetMaxBlockSystemFeeInternal ¶ added in v0.91.0
GetMaxBlockSystemFeeInternal the maximum overall system fee per block.
func (*Policy) GetMaxTransactionsPerBlockInternal ¶
GetMaxTransactionsPerBlockInternal returns the upper limit of transactions per block.
func (*Policy) GetMaxVerificationGas ¶ added in v0.91.0
GetMaxVerificationGas returns maximum gas allowed to be burned during verificaion.
func (*Policy) GetStoragePriceInternal ¶ added in v0.92.0
GetStoragePriceInternal returns current execution fee factor.
func (*Policy) Initialize ¶
Initialize initializes Policy native contract and implements Contract interface.
func (*Policy) IsBlockedInternal ¶ added in v0.92.0
IsBlockedInternal checks whether provided account is blocked
func (*Policy) Metadata ¶
func (p *Policy) Metadata() *interop.ContractMD
Metadata implements Contract interface.
type RecordType ¶ added in v0.93.0
type RecordType byte
RecordType represents name record type.
const ( RecordTypeA RecordType = 1 RecordTypeCNAME RecordType = 5 RecordTypeTXT RecordType = 16 RecordTypeAAAA RecordType = 28 )
Pre-defined record types.