Documentation
¶
Overview ¶
Package native contains Neo native contracts.
Index ¶
- Constants
- Variables
- func Call(ic *interop.Context) error
- func CreateOracleResponseScript(nativeOracleHash util.Uint160) []byte
- func GetContract(d *dao.Simple, managementID int32, hash util.Uint160) (*state.Contract, error)
- func GetContractByID(d *dao.Simple, managementID int32, id int32) (*state.Contract, error)
- func GetContractScriptHash(d *dao.Simple, managementID int32, id int32) (util.Uint160, error)
- func Keccak256(data []byte) util.Uint256
- func MakeContractKey(h util.Uint160) []byte
- func NewDefaultContracts(cfg config.ProtocolConfiguration) []interop.Contract
- func NewDescriptor(name string, ret smartcontract.ParamType, ps ...manifest.Parameter) *manifest.Method
- func NewEvent(desc *manifest.Event, activations ...config.Hardfork) interop.Event
- func NewEventDescriptor(name string, ps ...manifest.Parameter) *manifest.Event
- func NewMethodAndPrice(f interop.Method, cpuFee int64, flags callflag.CallFlag, ...) *interop.MethodAndPrice
- func OnPersist(ic *interop.Context) error
- func PostPersist(ic *interop.Context) error
- func PutContractState(d *dao.Simple, managementID int32, cs *state.Contract) error
- type Contracts
- func (cs *Contracts) ByHash(h util.Uint160) interop.Contract
- func (cs *Contracts) ByName(name string) interop.Contract
- func (cs *Contracts) Designate() IDesignate
- func (cs *Contracts) GAS() IGAS
- func (cs *Contracts) GetPersistScript() []byte
- func (cs *Contracts) GetPostPersistScript() []byte
- func (cs *Contracts) Management() IManagement
- func (cs *Contracts) NEO() INEO
- func (cs *Contracts) Notary() INotary
- func (cs *Contracts) Oracle() IOracle
- func (cs *Contracts) Policy() IPolicy
- type Crypto
- func (c *Crypto) ActiveIn() *config.Hardfork
- func (c *Crypto) Initialize(ic *interop.Context, hf *config.Hardfork, newMD *interop.HFSpecificContractMD) error
- func (c *Crypto) InitializeCache(_ interop.IsHardforkEnabled, blockHeight uint32, d *dao.Simple) error
- func (c *Crypto) Metadata() *interop.ContractMD
- func (c *Crypto) OnPersist(ic *interop.Context) error
- func (c *Crypto) PostPersist(ic *interop.Context) error
- type Designate
- func (s *Designate) ActiveIn() *config.Hardfork
- func (s *Designate) DesignateAsRole(ic *interop.Context, r noderoles.Role, pubs keys.PublicKeys) error
- func (s *Designate) GetDesignatedByRole(d *dao.Simple, r noderoles.Role, index uint32) (keys.PublicKeys, uint32, error)
- func (s *Designate) GetLastDesignatedHash(d *dao.Simple, r noderoles.Role) (util.Uint160, error)
- func (s *Designate) Initialize(ic *interop.Context, hf *config.Hardfork, newMD *interop.HFSpecificContractMD) error
- func (s *Designate) InitializeCache(_ interop.IsHardforkEnabled, blockHeight uint32, d *dao.Simple) error
- func (s *Designate) Metadata() *interop.ContractMD
- func (s *Designate) OnPersist(ic *interop.Context) error
- func (s *Designate) PostPersist(ic *interop.Context) error
- func (s *Designate) SetNotaryService(n NotaryService)
- func (s *Designate) SetOracleService(o OracleService)
- func (s *Designate) SetStateRootService(sr StateRootService)
- type DesignationCache
- type GAS
- func (g *GAS) ActiveIn() *config.Hardfork
- func (g *GAS) BalanceOf(d *dao.Simple, acc util.Uint160) *big.Int
- func (c *GAS) Burn(ic *interop.Context, h util.Uint160, amount *big.Int)
- func (c *GAS) Decimals(_ *interop.Context, _ []stackitem.Item) stackitem.Item
- func (g *GAS) Initialize(ic *interop.Context, hf *config.Hardfork, newMD *interop.HFSpecificContractMD) error
- func (g *GAS) InitializeCache(_ interop.IsHardforkEnabled, blockHeight uint32, d *dao.Simple) error
- func (c *GAS) Metadata() *interop.ContractMD
- func (c *GAS) Mint(ic *interop.Context, h util.Uint160, amount *big.Int, callOnPayment bool)
- 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 HashFunc
- type IDList
- type IDesignate
- type IGAS
- type IManagement
- type INEO
- type INotary
- type IOracle
- type IPolicy
- type Ledger
- func (l *Ledger) ActiveIn() *config.Hardfork
- func (l *Ledger) Initialize(ic *interop.Context, hf *config.Hardfork, newMD *interop.HFSpecificContractMD) error
- func (l *Ledger) InitializeCache(_ interop.IsHardforkEnabled, blockHeight uint32, d *dao.Simple) error
- func (l *Ledger) Metadata() *interop.ContractMD
- func (l *Ledger) OnPersist(ic *interop.Context) error
- func (l *Ledger) PostPersist(ic *interop.Context) error
- type Management
- func (m *Management) ActiveIn() *config.Hardfork
- func (m *Management) Deploy(ic *interop.Context, sender util.Uint160, neff *nef.File, ...) (*state.Contract, error)
- func (m *Management) Destroy(d *dao.Simple, hash util.Uint160) error
- func (m *Management) GetNEP11Contracts(d *dao.Simple) []util.Uint160
- func (m *Management) GetNEP17Contracts(d *dao.Simple) []util.Uint160
- func (m *Management) Initialize(ic *interop.Context, hf *config.Hardfork, newMD *interop.HFSpecificContractMD) error
- func (m *Management) InitializeCache(_ interop.IsHardforkEnabled, blockHeight uint32, d *dao.Simple) 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) Update(ic *interop.Context, hash util.Uint160, neff *nef.File, ...) (*state.Contract, error)
- type ManagementCache
- type NEO
- func (n *NEO) ActiveIn() *config.Hardfork
- func (n *NEO) BalanceOf(d *dao.Simple, acc util.Uint160) (*big.Int, uint32)
- func (c *NEO) Burn(ic *interop.Context, h util.Uint160, amount *big.Int)
- func (n *NEO) CalculateBonus(ic *interop.Context, acc util.Uint160, end uint32) (*big.Int, error)
- func (n *NEO) CalculateNEOHolderReward(d *dao.Simple, value *big.Int, start, end uint32) (*big.Int, error)
- func (n *NEO) CheckCommittee(ic *interop.Context) bool
- func (n *NEO) ComputeNextBlockValidators(d *dao.Simple) keys.PublicKeys
- func (c *NEO) Decimals(_ *interop.Context, _ []stackitem.Item) stackitem.Item
- func (n *NEO) GetCandidates(d *dao.Simple) ([]state.Validator, error)
- func (n *NEO) GetCommitteeAddress(d *dao.Simple) util.Uint160
- func (n *NEO) GetCommitteeMembers(d *dao.Simple) keys.PublicKeys
- func (n *NEO) GetGASPerBlock(d *dao.Simple, index uint32) *big.Int
- func (n *NEO) GetNextBlockValidatorsInternal(d *dao.Simple) keys.PublicKeys
- func (n *NEO) Initialize(ic *interop.Context, hf *config.Hardfork, newMD *interop.HFSpecificContractMD) error
- func (n *NEO) InitializeCache(_ interop.IsHardforkEnabled, blockHeight uint32, d *dao.Simple) error
- func (c *NEO) Metadata() *interop.ContractMD
- func (c *NEO) Mint(ic *interop.Context, h util.Uint160, amount *big.Int, callOnPayment bool)
- func (n *NEO) ModifyAccountVotes(acc *state.NEOBalance, d *dao.Simple, 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 NamedCurveHash
- type NeoCache
- type NodeList
- type Notary
- func (n *Notary) ActiveIn() *config.Hardfork
- func (n *Notary) BalanceOf(dao *dao.Simple, acc util.Uint160) *big.Int
- func (n *Notary) ExpirationOf(dao *dao.Simple, acc util.Uint160) uint32
- func (n *Notary) GetDepositFor(dao *dao.Simple, acc util.Uint160) *state.Deposit
- func (n *Notary) GetMaxNotValidBeforeDelta(dao *dao.Simple) uint32
- func (n *Notary) GetNotaryNodes(d *dao.Simple) (keys.PublicKeys, error)
- func (n *Notary) Initialize(ic *interop.Context, hf *config.Hardfork, newMD *interop.HFSpecificContractMD) error
- func (n *Notary) InitializeCache(_ interop.IsHardforkEnabled, blockHeight uint32, d *dao.Simple) error
- func (n *Notary) Metadata() *interop.ContractMD
- func (n *Notary) OnPersist(ic *interop.Context) error
- func (n *Notary) PostPersist(ic *interop.Context) error
- type NotaryCache
- type NotaryService
- type Oracle
- func (o *Oracle) ActiveIn() *config.Hardfork
- func (o *Oracle) FinishInternal(ic *interop.Context) error
- func (o *Oracle) GetIDListInternal(d *dao.Simple, url string) (*IDList, error)
- func (o *Oracle) GetOracleNodes(d *dao.Simple) (keys.PublicKeys, error)
- func (o *Oracle) GetOracleResponseScript() []byte
- func (o *Oracle) GetRequestInternal(d *dao.Simple, id uint64) (*state.OracleRequest, error)
- func (o *Oracle) GetRequests(d *dao.Simple) (map[uint64]*state.OracleRequest, error)
- func (o *Oracle) GetScriptHash(d *dao.Simple) (util.Uint160, error)
- func (o *Oracle) Initialize(ic *interop.Context, hf *config.Hardfork, newMD *interop.HFSpecificContractMD) error
- func (o *Oracle) InitializeCache(_ interop.IsHardforkEnabled, blockHeight uint32, d *dao.Simple) 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.Simple) error
- func (o *Oracle) RequestInternal(ic *interop.Context, url string, filter *string, cb string, ...) error
- func (o *Oracle) SetService(s OracleService)
- type OracleCache
- type OracleService
- type Policy
- func (p *Policy) ActiveIn() *config.Hardfork
- func (p *Policy) BlockAccountInternal(d *dao.Simple, hash util.Uint160) bool
- func (p *Policy) CheckPolicy(d *dao.Simple, tx *transaction.Transaction) error
- func (p *Policy) GetAttributeFeeInternal(d *dao.Simple, t transaction.AttrType) int64
- func (p *Policy) GetExecFeeFactorInternal(d *dao.Simple) int64
- func (p *Policy) GetFeePerByteInternal(dao *dao.Simple) int64
- func (p *Policy) GetMaxTraceableBlocksInternal(d *dao.Simple) uint32
- func (p *Policy) GetMaxValidUntilBlockIncrementFromCache(d *dao.Simple) uint32
- func (p *Policy) GetMaxValidUntilBlockIncrementInternal(ic *interop.Context) uint32
- func (p *Policy) GetMaxVerificationGas(dao *dao.Simple) int64
- func (p *Policy) GetMillisecondsPerBlockInternal(d *dao.Simple) uint32
- func (p *Policy) GetStoragePriceInternal(d *dao.Simple) int64
- func (p *Policy) Initialize(ic *interop.Context, hf *config.Hardfork, newMD *interop.HFSpecificContractMD) error
- func (p *Policy) InitializeCache(isHardforkEnabled interop.IsHardforkEnabled, blockHeight uint32, d *dao.Simple) error
- func (p *Policy) IsBlocked(dao *dao.Simple, 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 PolicyCache
- type StateRootService
- type Std
- func (s *Std) ActiveIn() *config.Hardfork
- func (s *Std) Initialize(ic *interop.Context, hf *config.Hardfork, newMD *interop.HFSpecificContractMD) error
- func (s *Std) InitializeCache(_ interop.IsHardforkEnabled, blockHeight uint32, d *dao.Simple) error
- func (s *Std) Metadata() *interop.ContractMD
- func (s *Std) OnPersist(ic *interop.Context) error
- func (s *Std) PostPersist(ic *interop.Context) error
Constants ¶
const ( // NEOTotalSupply is the total amount of NEO in the system. NEOTotalSupply = 100000000 // DefaultRegisterPrice is the default price for candidate register. DefaultRegisterPrice = 1000 * GASFactor )
const ( // DefaultOracleRequestPrice is the default amount GAS needed for an oracle request. DefaultOracleRequestPrice = 5000_0000 // MinimumResponseGas is the minimum response fee permitted for a request. MinimumResponseGas = 10_000_000 )
const (
// DefaultStoragePrice is the price to pay for 1 byte of storage.
DefaultStoragePrice = 100000
)
const (
// DesignationEventName is the name of the designation event.
DesignationEventName = "Designation"
)
const GASFactor = NEOTotalSupply
GASFactor is a divisor for finding GAS integral value.
const (
// PrefixContract is a prefix used to store contract states inside Management native contract.
PrefixContract = 8
)
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") ErrLowResponseGas = errors.New("not enough gas for response") ErrNotEnoughGas = errors.New("gas limit exceeded") ErrRequestNotFound = errors.New("oracle request not found") ErrResponseNotFound = errors.New("oracle response not found") )
Various validation errors.
var ( // ErrInvalidBase is returned when the base is invalid. ErrInvalidBase = errors.New("invalid base") // ErrInvalidFormat is returned when the string is not a number. ErrInvalidFormat = errors.New("invalid format") // ErrTooBigInput is returned when the input exceeds the size limit. ErrTooBigInput = errors.New("input is too big") )
var ( // MaxTraceableBlocksKey is a key used to store the maximum number of traceable blocks. MaxTraceableBlocksKey = []byte{23} )
Functions ¶
func CreateOracleResponseScript ¶ added in v0.99.0
CreateOracleResponseScript returns a script that is used to create the native Oracle response.
func GetContract ¶ added in v0.100.0
GetContract returns a contract with the given hash from the given DAO.
func GetContractByID ¶ added in v0.100.0
GetContractByID returns a contract with the given ID from the given DAO.
func GetContractScriptHash ¶ added in v0.100.0
GetContractScriptHash returns a contract hash associated with the given ID from the given DAO.
func Keccak256 ¶ added in v0.106.0
Keccak256 hashes the incoming byte slice using the keccak256 algorithm.
func MakeContractKey ¶ added in v0.97.3
MakeContractKey creates a key from the account script hash.
func NewDefaultContracts ¶ added in v0.112.0
func NewDefaultContracts(cfg config.ProtocolConfiguration) []interop.Contract
NewDefaultContracts returns a new set of default native contracts.
func NewDescriptor ¶ added in v0.112.0
func NewEvent ¶ added in v0.112.0
NewEvent builds event with the provided descriptor and ActiveFrom/ActiveTill hardfork values consequently specified via activations.
func NewEventDescriptor ¶ added in v0.112.0
func NewMethodAndPrice ¶ added in v0.112.0
func NewMethodAndPrice(f interop.Method, cpuFee int64, flags callflag.CallFlag, activations ...config.Hardfork) *interop.MethodAndPrice
NewMethodAndPrice builds method with the provided descriptor and ActiveFrom/ActiveTill hardfork values consequently specified via activations. config.HFDefault specfied as ActiveFrom is treated as active starting from the genesis block.
func PostPersist ¶ added in v0.92.0
PostPersist calls PostPersist methods for all native contracts.
Types ¶
type Contracts ¶
Contracts is a convenient wrapper around an arbitrary set of native contracts providing common helper contract accessors.
func NewContracts ¶
NewContracts initializes a wrapper around the provided set of native contracts.
func (*Contracts) ByName ¶ added in v0.92.0
ByName returns a native contract with the specified name.
func (*Contracts) Designate ¶ added in v0.92.0
func (cs *Contracts) Designate() IDesignate
Designate returns native IDesignate contract implementation. It panics if there's no contract with proper name in cs.
func (*Contracts) GAS ¶
GAS returns native IGAS contract implementation. It panics if there's no contract with proper name in cs.
func (*Contracts) GetPersistScript ¶
GetPersistScript returns a VM script calling "onPersist" syscall for native contracts.
func (*Contracts) GetPostPersistScript ¶ added in v0.92.0
GetPostPersistScript returns a VM script calling "postPersist" syscall for native contracts.
func (*Contracts) Management ¶ added in v0.92.0
func (cs *Contracts) Management() IManagement
Management returns native IManagement implementation. It panics if there's no contract with proper name in cs.
func (*Contracts) NEO ¶
NEO returns native INEO contract implementation. It panics if there's no contract with proper name in cs.
func (*Contracts) Notary ¶ added in v0.92.0
Notary returns native INotary contract implementation. It returns nil if there's no contract with proper name in cs.
type Crypto ¶ added in v0.94.0
type Crypto struct {
interop.ContractMD
}
Crypto represents CryptoLib contract.
func (*Crypto) Initialize ¶ added in v0.94.0
func (c *Crypto) Initialize(ic *interop.Context, hf *config.Hardfork, newMD *interop.HFSpecificContractMD) error
Initialize implements the Contract interface.
func (*Crypto) InitializeCache ¶ added in v0.101.4
func (c *Crypto) InitializeCache(_ interop.IsHardforkEnabled, blockHeight uint32, d *dao.Simple) error
InitializeCache implements the Contract interface.
func (*Crypto) Metadata ¶ added in v0.94.0
func (c *Crypto) Metadata() *interop.ContractMD
Metadata implements the Contract interface.
type Designate ¶ added in v0.92.0
type Designate struct { interop.ContractMD NEO INEO // OracleService represents an Oracle node module. OracleService atomic.Value // NotaryService represents a Notary node module. NotaryService atomic.Value // StateRootService represents a StateRoot node module. StateRootService atomic.Value // contains filtered or unexported fields }
Designate represents a designation contract.
func NewDesignate ¶ added in v0.112.0
func NewDesignate(initialNodeRoles map[noderoles.Role]keys.PublicKeys) *Designate
NewDesignate creates a new RoleManagement contract.
func (*Designate) DesignateAsRole ¶ added in v0.92.0
func (s *Designate) DesignateAsRole(ic *interop.Context, r noderoles.Role, pubs keys.PublicKeys) error
DesignateAsRole sets nodes for role r.
func (*Designate) GetDesignatedByRole ¶ added in v0.92.0
func (s *Designate) GetDesignatedByRole(d *dao.Simple, r noderoles.Role, index uint32) (keys.PublicKeys, uint32, error)
GetDesignatedByRole returns nodes for role r.
func (*Designate) GetLastDesignatedHash ¶ added in v0.93.0
GetLastDesignatedHash returns the last designated hash of the given role.
func (*Designate) Initialize ¶ added in v0.92.0
func (s *Designate) Initialize(ic *interop.Context, hf *config.Hardfork, newMD *interop.HFSpecificContractMD) error
Initialize initializes Designation contract. It is called once at native Management's OnPersist at the genesis block, and we can't properly fill the cache at this point, as there are no roles data in the storage.
func (*Designate) InitializeCache ¶ added in v0.97.3
func (s *Designate) InitializeCache(_ interop.IsHardforkEnabled, blockHeight uint32, d *dao.Simple) error
InitializeCache fills native Designate cache from DAO. It is called at non-zero height, thus we can fetch the roles data right from the storage.
func (*Designate) Metadata ¶ added in v0.92.0
func (s *Designate) Metadata() *interop.ContractMD
Metadata returns contract metadata.
func (*Designate) PostPersist ¶ added in v0.92.0
PostPersist implements the Contract interface.
func (*Designate) SetNotaryService ¶ added in v0.112.0
func (s *Designate) SetNotaryService(n NotaryService)
SetNotaryService implements IDesignate interface.
func (*Designate) SetOracleService ¶ added in v0.112.0
func (s *Designate) SetOracleService(o OracleService)
SetOracleService implements IDesignate interface.
func (*Designate) SetStateRootService ¶ added in v0.112.0
func (s *Designate) SetStateRootService(sr StateRootService)
SetStateRootService implements IDesignate interface.
type DesignationCache ¶ added in v0.99.0
type DesignationCache struct {
// contains filtered or unexported fields
}
func (*DesignationCache) Copy ¶ added in v0.99.0
func (c *DesignationCache) Copy() dao.NativeContractCache
Copy implements NativeContractCache interface.
type GAS ¶
GAS represents GAS native contract.
func (*GAS) Initialize ¶
func (g *GAS) Initialize(ic *interop.Context, hf *config.Hardfork, newMD *interop.HFSpecificContractMD) error
Initialize initializes a GAS contract.
func (*GAS) InitializeCache ¶ added in v0.101.4
InitializeCache implements the Contract interface.
func (*GAS) Metadata ¶
func (c *GAS) Metadata() *interop.ContractMD
func (*GAS) PostPersist ¶ added in v0.92.0
PostPersist implements the Contract interface.
func (*GAS) TotalSupply ¶
type HashFunc ¶ added in v0.106.0
HashFunc is a delegate representing a hasher function with 256 bytes output length.
type IDList ¶ added in v0.92.0
type IDList []uint64
IDList is a list of oracle request IDs.
func (*IDList) FromStackItem ¶ added in v0.96.0
FromStackItem implements stackitem.Convertible.
type IDesignate ¶ added in v0.112.0
type IDesignate interface { interop.Contract GetDesignatedByRole(d *dao.Simple, r noderoles.Role, index uint32) (keys.PublicKeys, uint32, error) GetLastDesignatedHash(d *dao.Simple, r noderoles.Role) (util.Uint160, error) SetOracleService(o OracleService) SetNotaryService(n NotaryService) SetStateRootService(s StateRootService) }
IDesignate is an interface required from native RoleManagement contract for interaction with Blockchain and other native contracts.
type IGAS ¶ added in v0.112.0
type IGAS interface { interop.Contract BalanceOf(d *dao.Simple, acc util.Uint160) *big.Int // Methods required for proper cross-native communication. Burn(ic *interop.Context, h util.Uint160, amount *big.Int) Mint(ic *interop.Context, h util.Uint160, amount *big.Int, callOnPayment bool) }
IGAS is an interface required from native GasToken contract for interaction with Blockchain and other native contracts.
type IManagement ¶ added in v0.112.0
type IManagement interface { interop.Contract GetNEP11Contracts(d *dao.Simple) []util.Uint160 GetNEP17Contracts(d *dao.Simple) []util.Uint160 }
IManagement is an interface required from native ContractManagement contract for interaction with Blockchain and other native contracts.
type INEO ¶ added in v0.112.0
type INEO interface { interop.Contract GetCommitteeAddress(d *dao.Simple) util.Uint160 GetNextBlockValidatorsInternal(d *dao.Simple) keys.PublicKeys BalanceOf(d *dao.Simple, acc util.Uint160) (*big.Int, uint32) CalculateBonus(ic *interop.Context, acc util.Uint160, endHeight uint32) (*big.Int, error) GetCommitteeMembers(d *dao.Simple) keys.PublicKeys ComputeNextBlockValidators(d *dao.Simple) keys.PublicKeys GetCandidates(d *dao.Simple) ([]state.Validator, error) // Methods required for proper cross-native communication. CheckCommittee(ic *interop.Context) bool }
INEO is an interface required from native NeoToken contract for interaction with Blockchain and other native contracts.
type INotary ¶ added in v0.112.0
type INotary interface { interop.Contract BalanceOf(dao *dao.Simple, acc util.Uint160) *big.Int ExpirationOf(dao *dao.Simple, acc util.Uint160) uint32 GetMaxNotValidBeforeDelta(dao *dao.Simple) uint32 }
INotary is an interface required from native Notary contract for interaction with Blockchain and other native contracts.
type IOracle ¶ added in v0.112.0
type IOracle interface { interop.Contract GetOracleResponseScript() []byte GetRequests(d *dao.Simple) (map[uint64]*state.OracleRequest, error) GetScriptHash(d *dao.Simple) (util.Uint160, error) GetRequestInternal(d *dao.Simple, id uint64) (*state.OracleRequest, error) SetService(o OracleService) }
IOracle is an interface required from native OracleContract contract for interaction with Blockchain and other native contracts.
type IPolicy ¶ added in v0.112.0
type IPolicy interface { interop.Contract GetStoragePriceInternal(d *dao.Simple) int64 GetMaxVerificationGas(d *dao.Simple) int64 GetExecFeeFactorInternal(d *dao.Simple) int64 GetMaxTraceableBlocksInternal(d *dao.Simple) uint32 GetMillisecondsPerBlockInternal(d *dao.Simple) uint32 GetMaxValidUntilBlockIncrementFromCache(d *dao.Simple) uint32 GetAttributeFeeInternal(d *dao.Simple, attrType transaction.AttrType) int64 CheckPolicy(d *dao.Simple, tx *transaction.Transaction) error GetFeePerByteInternal(d *dao.Simple) int64 // Methods required for proper cross-native communication. BlockAccountInternal(d *dao.Simple, hash util.Uint160) bool IsBlocked(dao *dao.Simple, hash util.Uint160) bool GetMaxValidUntilBlockIncrementInternal(ic *interop.Context) uint32 }
IPolicy is an interface required from native PolicyContract contract for interaction with Blockchain and other native contracts.
type Ledger ¶ added in v0.93.0
type Ledger struct { interop.ContractMD Policy IPolicy }
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 NewLedger ¶ added in v0.112.0
func NewLedger() *Ledger
NewLedger creates a new Ledger native contract.
func (*Ledger) Initialize ¶ added in v0.93.0
func (l *Ledger) Initialize(ic *interop.Context, hf *config.Hardfork, newMD *interop.HFSpecificContractMD) error
Initialize implements the Contract interface.
func (*Ledger) InitializeCache ¶ added in v0.101.4
func (l *Ledger) InitializeCache(_ interop.IsHardforkEnabled, blockHeight uint32, d *dao.Simple) error
InitializeCache implements the Contract interface.
func (*Ledger) Metadata ¶ added in v0.93.0
func (l *Ledger) Metadata() *interop.ContractMD
Metadata implements the Contract interface.
type Management ¶ added in v0.92.0
type Management struct { interop.ContractMD NEO INEO Policy IPolicy }
Management is a contract-managing native contract.
func NewManagement ¶ added in v0.112.0
func NewManagement() *Management
NewManagement creates a new Management native contract.
func (*Management) ActiveIn ¶ added in v0.104.0
func (m *Management) ActiveIn() *config.Hardfork
ActiveIn implements the Contract interface.
func (*Management) Deploy ¶ added in v0.92.0
func (m *Management) Deploy(ic *interop.Context, sender util.Uint160, neff *nef.File, manif *manifest.Manifest) (*state.Contract, error)
Deploy creates a contract's hash/ID and saves a 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 the given contract from DAO along with its storage. It doesn't emit notification.
func (*Management) GetNEP11Contracts ¶ added in v0.98.0
func (m *Management) GetNEP11Contracts(d *dao.Simple) []util.Uint160
GetNEP11Contracts returns hashes of all deployed contracts that support NEP-11 standard. The list is updated every PostPersist, so until PostPersist is called, the result for the previous block is returned.
func (*Management) GetNEP17Contracts ¶ added in v0.97.1
func (m *Management) GetNEP17Contracts(d *dao.Simple) []util.Uint160
GetNEP17Contracts returns hashes of all deployed contracts that support NEP-17 standard. The list is updated every PostPersist, so until PostPersist is called, the result for the previous block is returned.
func (*Management) Initialize ¶ added in v0.92.0
func (m *Management) Initialize(ic *interop.Context, hf *config.Hardfork, newMD *interop.HFSpecificContractMD) error
Initialize implements the Contract interface.
func (*Management) InitializeCache ¶ added in v0.92.0
func (m *Management) InitializeCache(_ interop.IsHardforkEnabled, blockHeight uint32, d *dao.Simple) error
InitializeCache initializes contract cache with the proper values from storage. Cache initialization 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 the Contract interface.
func (*Management) OnPersist ¶ added in v0.92.0
func (m *Management) OnPersist(ic *interop.Context) error
OnPersist implements the Contract interface.
func (*Management) PostPersist ¶ added in v0.92.0
func (m *Management) PostPersist(ic *interop.Context) error
PostPersist implements the Contract interface.
func (*Management) Update ¶ added in v0.92.0
func (m *Management) Update(ic *interop.Context, hash util.Uint160, neff *nef.File, manif *manifest.Manifest) (*state.Contract, error)
Update updates contract's script and/or manifest in the given DAO. It doesn't run _deploy method and doesn't emit notification.
type ManagementCache ¶ added in v0.99.0
type ManagementCache struct {
// contains filtered or unexported fields
}
func (*ManagementCache) Copy ¶ added in v0.99.0
func (c *ManagementCache) Copy() dao.NativeContractCache
Copy implements NativeContractCache interface.
type NEO ¶
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.Simple, 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) CheckCommittee ¶ added in v0.112.0
func (*NEO) ComputeNextBlockValidators ¶ added in v0.92.0
func (n *NEO) ComputeNextBlockValidators(d *dao.Simple) keys.PublicKeys
ComputeNextBlockValidators computes an actual list of current validators that is relevant for the latest processed dBFT epoch and based on the changes made by register/unregister/vote calls during the latest epoch. Note: this method isn't actually "computes" new committee list and calculates new validators list from it. Instead, it uses cache, and the cache itself is updated during the PostPersist of the last block of every epoch.
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(d *dao.Simple) 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(d *dao.Simple) keys.PublicKeys
GetNextBlockValidatorsInternal returns next block validators.
func (*NEO) Initialize ¶
func (n *NEO) Initialize(ic *interop.Context, hf *config.Hardfork, newMD *interop.HFSpecificContractMD) error
Initialize initializes a NEO contract.
func (*NEO) InitializeCache ¶ added in v0.92.0
InitializeCache initializes all NEO cache with the proper values from the storage. Cache initialization should be done apart from Initialize because Initialize is called only when deploying native contracts. InitializeCache implements the Contract interface.
func (*NEO) Metadata ¶
func (c *NEO) Metadata() *interop.ContractMD
func (*NEO) ModifyAccountVotes ¶
func (n *NEO) ModifyAccountVotes(acc *state.NEOBalance, d *dao.Simple, 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 the Contract interface.
func (*NEO) RegisterCandidateInternal ¶ added in v0.91.0
RegisterCandidateInternal registers pub as a new candidate. This method must not be called outside of VM since it panics on critical errors.
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 across accounts.
func (*NEO) UnregisterCandidateInternal ¶ added in v0.91.0
UnregisterCandidateInternal unregisters pub as a candidate. This method must not be called outside of VM since it panics on critical errors.
type NamedCurveHash ¶ added in v0.106.0
type NamedCurveHash byte
NamedCurveHash identifies a pair of named elliptic curve and hash function.
const ( Secp256k1Sha256 NamedCurveHash = 22 Secp256r1Sha256 NamedCurveHash = 23 Secp256k1Keccak256 NamedCurveHash = 122 Secp256r1Keccak256 NamedCurveHash = 123 )
Various pairs of named elliptic curves and hash functions.
type NeoCache ¶ added in v0.99.0
type NeoCache struct {
// contains filtered or unexported fields
}
func (*NeoCache) Copy ¶ added in v0.99.0
func (c *NeoCache) Copy() dao.NativeContractCache
Copy implements NativeContractCache interface.
type NodeList ¶ added in v0.92.0
type NodeList keys.PublicKeys
NodeList represents a list of oracle nodes.
func (*NodeList) FromStackItem ¶ added in v0.96.0
FromStackItem implements stackitem.Convertible.
type Notary ¶ added in v0.92.0
type Notary struct { interop.ContractMD GAS IGAS NEO INEO Desig IDesignate Policy IPolicy }
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 the deposit is not found in the 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
func (n *Notary) Initialize(ic *interop.Context, hf *config.Hardfork, newMD *interop.HFSpecificContractMD) error
Initialize initializes Notary native contract and implements the Contract interface.
func (*Notary) InitializeCache ¶ added in v0.99.0
func (*Notary) Metadata ¶ added in v0.92.0
func (n *Notary) Metadata() *interop.ContractMD
Metadata implements the Contract interface.
type NotaryCache ¶ added in v0.99.0
type NotaryCache struct {
// contains filtered or unexported fields
}
func (*NotaryCache) Copy ¶ added in v0.99.0
func (c *NotaryCache) Copy() dao.NativeContractCache
Copy implements NativeContractCache interface.
type NotaryService ¶ added in v0.99.1
type NotaryService interface {
UpdateNotaryNodes(pubs keys.PublicKeys)
}
NotaryService is a Notary module interface.
type Oracle ¶ added in v0.92.0
type Oracle struct { interop.ContractMD GAS IGAS NEO INEO Desig IDesignate // 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 an oracle response.
func (*Oracle) GetIDListInternal ¶ added in v0.92.0
GetIDListInternal returns the 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 a script for the transaction with an oracle response.
func (*Oracle) GetRequestInternal ¶ added in v0.92.0
GetRequestInternal returns the request by ID and key under which it is stored.
func (*Oracle) GetRequests ¶ added in v0.99.2
GetRequests returns all requests which have not been finished yet.
func (*Oracle) GetScriptHash ¶ added in v0.92.0
GetScriptHash returns script hash of oracle nodes.
func (*Oracle) Initialize ¶ added in v0.92.0
func (o *Oracle) Initialize(ic *interop.Context, hf *config.Hardfork, newMD *interop.HFSpecificContractMD) error
Initialize initializes an Oracle contract.
func (*Oracle) InitializeCache ¶ added in v0.99.0
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 the oracle request with the specified id to d.
func (*Oracle) RequestInternal ¶ added in v0.92.0
func (o *Oracle) RequestInternal(ic *interop.Context, url string, filter *string, cb string, userData stackitem.Item, gas *big.Int) error
RequestInternal processes an oracle request.
func (*Oracle) SetService ¶ added in v0.112.0
func (o *Oracle) SetService(s OracleService)
SetService implements IOracle interface.
type OracleCache ¶ added in v0.99.0
type OracleCache struct {
// contains filtered or unexported fields
}
func (*OracleCache) Copy ¶ added in v0.99.0
func (c *OracleCache) Copy() dao.NativeContractCache
Copy implements NativeContractCache interface.
type OracleService ¶ added in v0.99.1
type OracleService interface { // AddRequests processes new requests. AddRequests(map[uint64]*state.OracleRequest) // RemoveRequests removes already processed requests. RemoveRequests([]uint64) // UpdateOracleNodes updates oracle nodes. UpdateOracleNodes(keys.PublicKeys) // UpdateNativeContract updates oracle contract native script and hash. UpdateNativeContract([]byte, []byte, util.Uint160, int) // Start runs oracle module. Start() // Shutdown shutdowns oracle module. Shutdown() }
OracleService specifies oracle module interface.
type Policy ¶
type Policy struct { interop.ContractMD NEO INEO }
Policy represents Policy native contract.
func (*Policy) BlockAccountInternal ¶ added in v0.112.0
func (*Policy) CheckPolicy ¶
func (p *Policy) CheckPolicy(d *dao.Simple, tx *transaction.Transaction) error
CheckPolicy checks whether a transaction conforms to the current policy restrictions, like not being signed by a blocked account or not exceeding the block-level system fee limit.
func (*Policy) GetAttributeFeeInternal ¶ added in v0.104.0
GetAttributeFeeInternal returns required transaction's attribute fee.
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) GetMaxTraceableBlocksInternal ¶ added in v0.109.0
GetMaxTraceableBlocksInternal returns current MaxValidUntilBlockIncrement.
func (*Policy) GetMaxValidUntilBlockIncrementFromCache ¶ added in v0.109.0
GetMaxValidUntilBlockIncrementFromCache returns current MaxValidUntilBlockIncrement. It doesn't check neither Echidna enabling height nor cache initialization, so it's the caller's duty to ensure that Echidna is enabled before a call to this method.
func (*Policy) GetMaxValidUntilBlockIncrementInternal ¶ added in v0.109.0
GetMaxValidUntilBlockIncrementInternal returns current MaxValidUntilBlockIncrement. It respects Echidna enabling height.
func (*Policy) GetMaxVerificationGas ¶ added in v0.91.0
GetMaxVerificationGas returns the maximum gas allowed to be burned during verification.
func (*Policy) GetMillisecondsPerBlockInternal ¶ added in v0.109.0
GetMillisecondsPerBlockInternal returns current block generation time in milliseconds.
func (*Policy) GetStoragePriceInternal ¶ added in v0.92.0
GetStoragePriceInternal returns current execution fee factor.
func (*Policy) Initialize ¶
func (p *Policy) Initialize(ic *interop.Context, hf *config.Hardfork, newMD *interop.HFSpecificContractMD) error
Initialize initializes Policy native contract and implements the Contract interface.
func (*Policy) InitializeCache ¶ added in v0.99.0
func (*Policy) IsBlocked ¶ added in v0.99.0
IsBlocked checks whether provided account is blocked. Normally it uses Policy cache, falling back to the DB queries when Policy cache is not available yet (the only case is native cache initialization pipeline, where native Neo cache is being initialized before the Policy's one).
func (*Policy) Metadata ¶
func (p *Policy) Metadata() *interop.ContractMD
Metadata implements the Contract interface.
type PolicyCache ¶ added in v0.99.0
type PolicyCache struct {
// contains filtered or unexported fields
}
func (*PolicyCache) Copy ¶ added in v0.99.0
func (c *PolicyCache) Copy() dao.NativeContractCache
Copy implements NativeContractCache interface.
type StateRootService ¶ added in v0.112.0
type StateRootService interface { // UpdateStateValidators updates state validator nodes. UpdateStateValidators(uint32, keys.PublicKeys) }
StateRootService specifies state root module interface.
type Std ¶ added in v0.94.0
type Std struct {
interop.ContractMD
}
Std represents an StdLib contract.
func (*Std) Initialize ¶ added in v0.94.0
func (s *Std) Initialize(ic *interop.Context, hf *config.Hardfork, newMD *interop.HFSpecificContractMD) error
Initialize implements the Contract interface.
func (*Std) InitializeCache ¶ added in v0.101.4
InitializeCache implements the Contract interface.
func (*Std) Metadata ¶ added in v0.94.0
func (s *Std) Metadata() *interop.ContractMD
Metadata implements the Contract interface.
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
native_test
|
|
package nativehashes contains hashes of all native contracts in their LE and Uint160 representation.
|
package nativehashes contains hashes of all native contracts in their LE and Uint160 representation. |
package nativeids contains IDs of all native contracts.
|
package nativeids contains IDs of all native contracts. |