Documentation ¶
Index ¶
Constants ¶
const ( // MethodInit is a name for default initialization method. MethodInit = "_initialize" // MethodDeploy is a name for default method called during contract deployment. MethodDeploy = "_deploy" // MethodVerify is a name for default verification method. MethodVerify = "verify" // MethodOnNEP17Payment is name of the method which is called when contract receives NEP-17 tokens. MethodOnNEP17Payment = "onNEP17Payment" // MethodOnNEP11Payment is the name of the method which is called when contract receives NEP-11 tokens. MethodOnNEP11Payment = "onNEP11Payment" )
const ( // MaxManifestSize is a max length for a valid contract manifest. MaxManifestSize = math.MaxUint16 // NEP10StandardName represents the name of NEP10 smartcontract standard. NEP10StandardName = "NEP-10" // NEP17StandardName represents the name of NEP17 smartcontract standard. NEP17StandardName = "NEP-17" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ABI ¶
ABI represents a contract application binary interface.
func (*ABI) FromStackItem ¶ added in v0.93.0
FromStackItem converts stackitem.Item to ABI.
func (*ABI) ToStackItem ¶ added in v0.93.0
ToStackItem converts ABI to stackitem.Item.
type Event ¶
Event is a description of a single event.
func (*Event) FromStackItem ¶ added in v0.93.0
FromStackItem converts stackitem.Item to Event.
func (*Event) ToStackItem ¶ added in v0.93.0
ToStackItem converts Event to stackitem.Item.
type Group ¶
Group represents a group of smartcontracts identified by a public key. Every SC in a group must provide signature of it's hash to prove it belongs to a group.
func (*Group) FromStackItem ¶ added in v0.93.0
FromStackItem converts stackitem.Item to Group.
func (*Group) IsValid ¶ added in v0.91.0
IsValid checks whether group's signature corresponds to the given hash.
func (*Group) MarshalJSON ¶
MarshalJSON implements json.Marshaler interface.
func (*Group) ToStackItem ¶ added in v0.93.0
ToStackItem converts Group to stackitem.Item.
func (*Group) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler interface.
type Manifest ¶
type Manifest struct { // Name is a contract's name. Name string `json:"name"` // ABI is a contract's ABI. ABI ABI `json:"abi"` // Groups is a set of groups to which a contract belongs. Groups []Group `json:"groups"` Permissions []Permission `json:"permissions"` // SupportedStandards is a list of standards supported by the contract. SupportedStandards []string `json:"supportedstandards"` // Trusts is a set of hashes to a which contract trusts. Trusts WildUint160s `json:"trusts"` // Extra is an implementation-defined user data. Extra json.RawMessage `json:"extra"` }
Manifest represens contract metadata.
func DefaultManifest ¶
DefaultManifest returns default contract manifest.
func NewManifest ¶
NewManifest returns new manifest with necessary fields initialized.
func (*Manifest) CanCall ¶
CanCall returns true is current contract is allowed to call method of another contract with specified hash.
func (*Manifest) FromStackItem ¶ added in v0.93.0
FromStackItem converts stackitem.Item to Manifest.
type Method ¶
type Method struct { Name string `json:"name"` Offset int `json:"offset"` Parameters []Parameter `json:"parameters"` ReturnType smartcontract.ParamType `json:"returntype"` Safe bool `json:"safe"` }
Method represents method's metadata.
func (*Method) FromStackItem ¶ added in v0.93.0
FromStackItem converts stackitem.Item to Method.
func (*Method) ToStackItem ¶ added in v0.93.0
ToStackItem converts Method to stackitem.Item.
type Parameter ¶
type Parameter struct { Name string `json:"name"` Type smartcontract.ParamType `json:"type"` }
Parameter represents smartcontract's parameter's definition.
func NewParameter ¶
func NewParameter(name string, typ smartcontract.ParamType) Parameter
NewParameter returns new parameter of specified name and type.
func (*Parameter) FromStackItem ¶ added in v0.93.0
FromStackItem converts stackitem.Item to Parameter.
func (*Parameter) ToStackItem ¶ added in v0.93.0
ToStackItem converts Parameter to stackitem.Item.
type Parameters ¶ added in v0.93.0
type Parameters []Parameter
Parameters is just an array of Parameter.
func (Parameters) AreValid ¶ added in v0.93.0
func (p Parameters) AreValid() error
AreValid checks all parameters for validity and consistency.
type Permission ¶
type Permission struct { Contract PermissionDesc `json:"contract"` Methods WildStrings `json:"methods"` }
Permission describes which contracts may be invoked and which methods are called.
func NewPermission ¶
func NewPermission(typ PermissionType, args ...interface{}) *Permission
NewPermission returns new permission of a given type.
func (*Permission) FromStackItem ¶ added in v0.93.0
func (p *Permission) FromStackItem(item stackitem.Item) error
FromStackItem converts stackitem.Item to Permission.
func (*Permission) IsValid ¶ added in v0.93.0
func (p *Permission) IsValid() error
IsValid checks if Permission is correct.
func (*Permission) ToStackItem ¶ added in v0.93.0
func (p *Permission) ToStackItem() stackitem.Item
ToStackItem converts Permission to stackitem.Item.
func (*Permission) UnmarshalJSON ¶
func (p *Permission) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.Unmarshaler interface.
type PermissionDesc ¶
type PermissionDesc struct { Type PermissionType Value interface{} }
PermissionDesc is a permission descriptor.
func (*PermissionDesc) Group ¶
func (d *PermissionDesc) Group() *keys.PublicKey
Group returns group's public key for group-permission.
func (*PermissionDesc) Hash ¶
func (d *PermissionDesc) Hash() util.Uint160
Hash returns hash for hash-permission.
func (*PermissionDesc) MarshalJSON ¶
func (d *PermissionDesc) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler interface.
func (*PermissionDesc) UnmarshalJSON ¶
func (d *PermissionDesc) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.Unmarshaler interface.
type PermissionType ¶
type PermissionType uint8
PermissionType represents permission type.
const ( // PermissionWildcard allows everything. PermissionWildcard PermissionType = 0 // PermissionHash restricts called contracts based on hash. PermissionHash PermissionType = 1 // PermissionGroup restricts called contracts based on public key. PermissionGroup PermissionType = 2 )
type Permissions ¶ added in v0.93.0
type Permissions []Permission
Permissions is just an array of Permission.
func (Permissions) AreValid ¶ added in v0.93.0
func (ps Permissions) AreValid() error
AreValid checks each Permission and ensures there are no duplicates.
type WildStrings ¶
type WildStrings struct {
Value []string
}
WildStrings represents string set which can be wildcard.
func (*WildStrings) Contains ¶
func (c *WildStrings) Contains(v string) bool
Contains checks if v is in the container.
func (*WildStrings) IsWildcard ¶
func (c *WildStrings) IsWildcard() bool
IsWildcard returns true iff container is wildcard.
func (WildStrings) MarshalJSON ¶
func (c WildStrings) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler interface.
func (*WildStrings) Restrict ¶
func (c *WildStrings) Restrict()
Restrict transforms container into an empty one.
func (*WildStrings) UnmarshalJSON ¶
func (c *WildStrings) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.Unmarshaler interface.
type WildUint160s ¶
WildUint160s represents Uint160 set which can be wildcard.
func (*WildUint160s) Contains ¶
func (c *WildUint160s) Contains(v util.Uint160) bool
Contains checks if v is in the container.
func (*WildUint160s) IsWildcard ¶
func (c *WildUint160s) IsWildcard() bool
IsWildcard returns true iff container is wildcard.
func (WildUint160s) MarshalJSON ¶
func (c WildUint160s) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler interface.
func (*WildUint160s) Restrict ¶
func (c *WildUint160s) Restrict()
Restrict transforms container into an empty one.
func (*WildUint160s) UnmarshalJSON ¶
func (c *WildUint160s) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.Unmarshaler interface.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package standard contains interfaces for well-defined standards and function for checking if arbitrary manifest complies with them.
|
Package standard contains interfaces for well-defined standards and function for checking if arbitrary manifest complies with them. |