Documentation

Index

Constants

View Source
const NEP17TransferBatchSize = 128

    NEP17TransferBatchSize is the maximum number of entries for NEP17TransferLog.

    Variables

    This section is empty.

    Functions

    func CreateContractHash

    func CreateContractHash(sender util.Uint160, checksum uint32, name string) util.Uint160

      CreateContractHash creates deployed contract hash from transaction sender and contract script.

      func CreateNativeContractScript

      func CreateNativeContractScript(id int32) []byte

        CreateNativeContractScript returns script for the native contract.

        Types

        type AppExecResult

        type AppExecResult struct {
        	Container util.Uint256
        	Execution
        }

          AppExecResult represent the result of the script execution, gathering together all resulting notifications, state, stack and other metadata.

          func (*AppExecResult) DecodeBinary

          func (aer *AppExecResult) DecodeBinary(r *io.BinReader)

            DecodeBinary implements the Serializable interface.

            func (*AppExecResult) EncodeBinary

            func (aer *AppExecResult) EncodeBinary(w *io.BinWriter)

              EncodeBinary implements the Serializable interface.

              func (*AppExecResult) MarshalJSON

              func (aer *AppExecResult) MarshalJSON() ([]byte, error)

                MarshalJSON implements implements json.Marshaler interface.

                func (*AppExecResult) UnmarshalJSON

                func (aer *AppExecResult) UnmarshalJSON(data []byte) error

                  UnmarshalJSON implements implements json.Unmarshaler interface.

                  type Contract

                  type Contract struct {
                  	ContractBase
                  	UpdateCounter uint16 `json:"updatecounter"`
                  }

                    Contract holds information about a smart contract in the NEO blockchain.

                    func (*Contract) DecodeBinary

                    func (c *Contract) DecodeBinary(r *io.BinReader)

                      DecodeBinary implements Serializable interface.

                      func (*Contract) EncodeBinary

                      func (c *Contract) EncodeBinary(w *io.BinWriter)

                        EncodeBinary implements Serializable interface.

                        func (*Contract) FromStackItem

                        func (c *Contract) FromStackItem(item stackitem.Item) error

                          FromStackItem fills Contract's data from given stack itemized contract representation.

                          func (*Contract) ToStackItem

                          func (c *Contract) ToStackItem() (stackitem.Item, error)

                            ToStackItem converts state.Contract to stackitem.Item

                            type ContractBase

                            type ContractBase struct {
                            	ID       int32             `json:"id"`
                            	Hash     util.Uint160      `json:"hash"`
                            	NEF      nef.File          `json:"nef"`
                            	Manifest manifest.Manifest `json:"manifest"`
                            }

                              ContractBase represents part shared by native and user-deployed contracts.

                              type Deposit

                              type Deposit struct {
                              	Amount *big.Int
                              	Till   uint32
                              }

                                Deposit represents GAS deposit from Notary contract.

                                func (*Deposit) DecodeBinary

                                func (d *Deposit) DecodeBinary(r *io.BinReader)

                                  DecodeBinary implements io.Serializable interface.

                                  func (*Deposit) EncodeBinary

                                  func (d *Deposit) EncodeBinary(w *io.BinWriter)

                                    EncodeBinary implements io.Serializable interface.

                                    type Execution

                                    type Execution struct {
                                    	Trigger        trigger.Type
                                    	VMState        vm.State
                                    	GasConsumed    int64
                                    	Stack          []stackitem.Item
                                    	Events         []NotificationEvent
                                    	FaultException string
                                    }

                                      Execution represents the result of a single script execution, gathering together all resulting notifications, state, stack and other metadata.

                                      func (Execution) MarshalJSON

                                      func (e Execution) MarshalJSON() ([]byte, error)

                                        MarshalJSON implements implements json.Marshaler interface.

                                        func (*Execution) UnmarshalJSON

                                        func (e *Execution) UnmarshalJSON(data []byte) error

                                          UnmarshalJSON implements implements json.Unmarshaler interface.

                                          type MPTRoot

                                          type MPTRoot struct {
                                          	MPTRootBase
                                          	Witness *transaction.Witness `json:"witness,omitempty"`
                                          }

                                            MPTRoot represents storage state root together with sign info.

                                            func (*MPTRoot) DecodeBinary

                                            func (s *MPTRoot) DecodeBinary(r *io.BinReader)

                                              DecodeBinary implements io.Serializable.

                                              func (*MPTRoot) EncodeBinary

                                              func (s *MPTRoot) EncodeBinary(w *io.BinWriter)

                                                EncodeBinary implements io.Serializable.

                                                type MPTRootBase

                                                type MPTRootBase struct {
                                                	Version  byte         `json:"version"`
                                                	Index    uint32       `json:"index"`
                                                	PrevHash util.Uint256 `json:"prehash"`
                                                	Root     util.Uint256 `json:"stateroot"`
                                                }

                                                  MPTRootBase represents storage state root.

                                                  func (*MPTRootBase) DecodeBinary

                                                  func (s *MPTRootBase) DecodeBinary(r *io.BinReader)

                                                    DecodeBinary implements io.Serializable.

                                                    func (*MPTRootBase) EncodeBinary

                                                    func (s *MPTRootBase) EncodeBinary(w *io.BinWriter)

                                                      EncodeBinary implements io.Serializable.

                                                      func (*MPTRootBase) Equals

                                                      func (s *MPTRootBase) Equals(other *MPTRootBase) bool

                                                        Equals checks if s == other.

                                                        func (*MPTRootBase) GetSignedHash

                                                        func (s *MPTRootBase) GetSignedHash() util.Uint256

                                                          GetSignedHash returns hash of MPTRootBase which needs to be signed.

                                                          func (*MPTRootBase) GetSignedPart

                                                          func (s *MPTRootBase) GetSignedPart() []byte

                                                            GetSignedPart returns part of MPTRootBase which needs to be signed.

                                                            func (*MPTRootBase) Hash

                                                            func (s *MPTRootBase) Hash() util.Uint256

                                                              Hash returns hash of s.

                                                              type MPTRootState

                                                              type MPTRootState struct {
                                                              	MPTRoot `json:"stateroot"`
                                                              	Flag    MPTRootStateFlag `json:"flag"`
                                                              }

                                                                MPTRootState represents state root together with its verification state.

                                                                func (*MPTRootState) DecodeBinary

                                                                func (s *MPTRootState) DecodeBinary(r *io.BinReader)

                                                                  DecodeBinary implements io.Serializable.

                                                                  func (*MPTRootState) EncodeBinary

                                                                  func (s *MPTRootState) EncodeBinary(w *io.BinWriter)

                                                                    EncodeBinary implements io.Serializable.

                                                                    type MPTRootStateFlag

                                                                    type MPTRootStateFlag byte

                                                                      MPTRootStateFlag represents verification state of the state root.

                                                                      const (
                                                                      	Unverified MPTRootStateFlag = 0x00
                                                                      	Verified   MPTRootStateFlag = 0x01
                                                                      	Invalid    MPTRootStateFlag = 0x03
                                                                      )

                                                                        Possible verification states of MPTRoot.

                                                                        func (MPTRootStateFlag) MarshalJSON

                                                                        func (f MPTRootStateFlag) MarshalJSON() ([]byte, error)

                                                                          MarshalJSON implements json.Marshaler.

                                                                          func (MPTRootStateFlag) String

                                                                          func (f MPTRootStateFlag) String() string

                                                                            String implements fmt.Stringer.

                                                                            func (*MPTRootStateFlag) UnmarshalJSON

                                                                            func (f *MPTRootStateFlag) UnmarshalJSON(data []byte) error

                                                                              UnmarshalJSON implements json.Unmarshaler.

                                                                              type NEOBalanceState

                                                                              type NEOBalanceState struct {
                                                                              	NEP17BalanceState
                                                                              	BalanceHeight uint32
                                                                              	VoteTo        *keys.PublicKey
                                                                              }

                                                                                NEOBalanceState represents balance state of a NEO-token.

                                                                                func NEOBalanceStateFromBytes

                                                                                func NEOBalanceStateFromBytes(b []byte) (*NEOBalanceState, error)

                                                                                  NEOBalanceStateFromBytes converts serialized NEOBalanceState to structure.

                                                                                  func (*NEOBalanceState) Bytes

                                                                                  func (s *NEOBalanceState) Bytes() []byte

                                                                                    Bytes returns serialized NEOBalanceState.

                                                                                    func (*NEOBalanceState) DecodeBinary

                                                                                    func (s *NEOBalanceState) DecodeBinary(r *io.BinReader)

                                                                                      DecodeBinary implements io.Serializable interface.

                                                                                      func (*NEOBalanceState) EncodeBinary

                                                                                      func (s *NEOBalanceState) EncodeBinary(w *io.BinWriter)

                                                                                        EncodeBinary implements io.Serializable interface.

                                                                                        type NEP17BalanceState

                                                                                        type NEP17BalanceState struct {
                                                                                        	Balance big.Int
                                                                                        }

                                                                                          NEP17BalanceState represents balance state of a NEP17-token.

                                                                                          func NEP17BalanceStateFromBytes

                                                                                          func NEP17BalanceStateFromBytes(b []byte) (*NEP17BalanceState, error)

                                                                                            NEP17BalanceStateFromBytes converts serialized NEP17BalanceState to structure.

                                                                                            func (*NEP17BalanceState) Bytes

                                                                                            func (s *NEP17BalanceState) Bytes() []byte

                                                                                              Bytes returns serialized NEP17BalanceState.

                                                                                              func (*NEP17BalanceState) DecodeBinary

                                                                                              func (s *NEP17BalanceState) DecodeBinary(r *io.BinReader)

                                                                                                DecodeBinary implements io.Serializable interface.

                                                                                                func (*NEP17BalanceState) EncodeBinary

                                                                                                func (s *NEP17BalanceState) EncodeBinary(w *io.BinWriter)

                                                                                                  EncodeBinary implements io.Serializable interface.

                                                                                                  type NEP17Balances

                                                                                                  type NEP17Balances struct {
                                                                                                  	Trackers map[int32]NEP17Tracker
                                                                                                  	// NextTransferBatch stores an index of the next transfer batch.
                                                                                                  	NextTransferBatch uint32
                                                                                                  }

                                                                                                    NEP17Balances is a map of the NEP17 contract IDs to the corresponding structures.

                                                                                                    func NewNEP17Balances

                                                                                                    func NewNEP17Balances() *NEP17Balances

                                                                                                      NewNEP17Balances returns new NEP17Balances.

                                                                                                      func (*NEP17Balances) DecodeBinary

                                                                                                      func (bs *NEP17Balances) DecodeBinary(r *io.BinReader)

                                                                                                        DecodeBinary implements io.Serializable interface.

                                                                                                        func (*NEP17Balances) EncodeBinary

                                                                                                        func (bs *NEP17Balances) EncodeBinary(w *io.BinWriter)

                                                                                                          EncodeBinary implements io.Serializable interface.

                                                                                                          type NEP17Tracker

                                                                                                          type NEP17Tracker struct {
                                                                                                          	// Balance is the current balance of the account.
                                                                                                          	Balance big.Int
                                                                                                          	// LastUpdatedBlock is a number of block when last `transfer` to or from the
                                                                                                          	// account occurred.
                                                                                                          	LastUpdatedBlock uint32
                                                                                                          }

                                                                                                            NEP17Tracker contains info about a single account in a NEP17 contract.

                                                                                                            func (*NEP17Tracker) DecodeBinary

                                                                                                            func (t *NEP17Tracker) DecodeBinary(r *io.BinReader)

                                                                                                              DecodeBinary implements io.Serializable interface.

                                                                                                              func (*NEP17Tracker) EncodeBinary

                                                                                                              func (t *NEP17Tracker) EncodeBinary(w *io.BinWriter)

                                                                                                                EncodeBinary implements io.Serializable interface.

                                                                                                                type NEP17Transfer

                                                                                                                type NEP17Transfer struct {
                                                                                                                	// Asset is a NEP17 contract ID.
                                                                                                                	Asset int32
                                                                                                                	// Address is the address of the sender.
                                                                                                                	From util.Uint160
                                                                                                                	// To is the address of the receiver.
                                                                                                                	To util.Uint160
                                                                                                                	// Amount is the amount of tokens transferred.
                                                                                                                	// It is negative when tokens are sent and positive if they are received.
                                                                                                                	Amount big.Int
                                                                                                                	// Block is a number of block when the event occurred.
                                                                                                                	Block uint32
                                                                                                                	// Timestamp is the timestamp of the block where transfer occurred.
                                                                                                                	Timestamp uint64
                                                                                                                	// Tx is a hash the transaction.
                                                                                                                	Tx util.Uint256
                                                                                                                }

                                                                                                                  NEP17Transfer represents a single NEP17 Transfer event.

                                                                                                                  func (*NEP17Transfer) DecodeBinary

                                                                                                                  func (t *NEP17Transfer) DecodeBinary(r *io.BinReader)

                                                                                                                    DecodeBinary implements io.Serializable interface.

                                                                                                                    func (*NEP17Transfer) EncodeBinary

                                                                                                                    func (t *NEP17Transfer) EncodeBinary(w *io.BinWriter)

                                                                                                                      EncodeBinary implements io.Serializable interface.

                                                                                                                      type NEP17TransferLog

                                                                                                                      type NEP17TransferLog struct {
                                                                                                                      	Raw []byte
                                                                                                                      }

                                                                                                                        NEP17TransferLog is a log of NEP17 token transfers for the specific command.

                                                                                                                        func (*NEP17TransferLog) Append

                                                                                                                        func (lg *NEP17TransferLog) Append(tr *NEP17Transfer) error

                                                                                                                          Append appends single transfer to a log.

                                                                                                                          func (*NEP17TransferLog) ForEach

                                                                                                                          func (lg *NEP17TransferLog) ForEach(f func(*NEP17Transfer) (bool, error)) (bool, error)

                                                                                                                            ForEach iterates over transfer log returning on first error.

                                                                                                                            func (*NEP17TransferLog) Size

                                                                                                                            func (lg *NEP17TransferLog) Size() int

                                                                                                                              Size returns an amount of transfer written in log.

                                                                                                                              type NFTAccountState

                                                                                                                              type NFTAccountState struct {
                                                                                                                              	NEP17BalanceState
                                                                                                                              	Tokens [][]byte
                                                                                                                              }

                                                                                                                                NFTAccountState represents state of nonfunglible account.

                                                                                                                                func (*NFTAccountState) Add

                                                                                                                                func (s *NFTAccountState) Add(tokenID []byte) bool

                                                                                                                                  Add adds token id to the set of account tokens and returns true on success.

                                                                                                                                  func (*NFTAccountState) DecodeBinary

                                                                                                                                  func (s *NFTAccountState) DecodeBinary(r *io.BinReader)

                                                                                                                                    DecodeBinary implements io.Serializable.

                                                                                                                                    func (*NFTAccountState) EncodeBinary

                                                                                                                                    func (s *NFTAccountState) EncodeBinary(w *io.BinWriter)

                                                                                                                                      EncodeBinary implements io.Serializable.

                                                                                                                                      func (*NFTAccountState) FromStackItem

                                                                                                                                      func (s *NFTAccountState) FromStackItem(item stackitem.Item) error

                                                                                                                                        FromStackItem converts stackitem to NFTAccountState.

                                                                                                                                        func (*NFTAccountState) Remove

                                                                                                                                        func (s *NFTAccountState) Remove(tokenID []byte) bool

                                                                                                                                          Remove removes token id to the set of account tokens and returns true on success.

                                                                                                                                          func (*NFTAccountState) ToStackItem

                                                                                                                                          func (s *NFTAccountState) ToStackItem() stackitem.Item

                                                                                                                                            ToStackItem converts NFTAccountState to stackitem.

                                                                                                                                            type NFTTokenState

                                                                                                                                            type NFTTokenState struct {
                                                                                                                                            	Owner       util.Uint160
                                                                                                                                            	Name        string
                                                                                                                                            	Description string
                                                                                                                                            }

                                                                                                                                              NFTTokenState represents state of nonfungible token.

                                                                                                                                              func (*NFTTokenState) Base

                                                                                                                                              func (s *NFTTokenState) Base() *NFTTokenState

                                                                                                                                                Base returns base class.

                                                                                                                                                func (*NFTTokenState) DecodeBinary

                                                                                                                                                func (s *NFTTokenState) DecodeBinary(r *io.BinReader)

                                                                                                                                                  DecodeBinary implements io.Serializable.

                                                                                                                                                  func (*NFTTokenState) EncodeBinary

                                                                                                                                                  func (s *NFTTokenState) EncodeBinary(w *io.BinWriter)

                                                                                                                                                    EncodeBinary implements io.Serializable.

                                                                                                                                                    func (*NFTTokenState) FromStackItem

                                                                                                                                                    func (s *NFTTokenState) FromStackItem(item stackitem.Item) error

                                                                                                                                                      FromStackItem converts stackitem to NFTTokenState.

                                                                                                                                                      func (*NFTTokenState) ID

                                                                                                                                                      func (s *NFTTokenState) ID() []byte

                                                                                                                                                        ID returns token id.

                                                                                                                                                        func (*NFTTokenState) ToMap

                                                                                                                                                        func (s *NFTTokenState) ToMap() *stackitem.Map

                                                                                                                                                          ToMap converts NFTTokenState to Map stackitem.

                                                                                                                                                          func (*NFTTokenState) ToStackItem

                                                                                                                                                          func (s *NFTTokenState) ToStackItem() stackitem.Item

                                                                                                                                                            ToStackItem converts NFTTokenState to stackitem.

                                                                                                                                                            type NativeContract

                                                                                                                                                            type NativeContract struct {
                                                                                                                                                            	ContractBase
                                                                                                                                                            	ActiveBlockIndex uint32 `json:"activeblockindex"`
                                                                                                                                                            }

                                                                                                                                                              NativeContract holds information about native contract.

                                                                                                                                                              type NotificationEvent

                                                                                                                                                              type NotificationEvent struct {
                                                                                                                                                              	ScriptHash util.Uint160     `json:"contract"`
                                                                                                                                                              	Name       string           `json:"eventname"`
                                                                                                                                                              	Item       *stackitem.Array `json:"state"`
                                                                                                                                                              }

                                                                                                                                                                NotificationEvent is a tuple of scripthash that emitted the Item as a notification and that item itself.

                                                                                                                                                                func (*NotificationEvent) DecodeBinary

                                                                                                                                                                func (ne *NotificationEvent) DecodeBinary(r *io.BinReader)

                                                                                                                                                                  DecodeBinary implements the Serializable interface.

                                                                                                                                                                  func (*NotificationEvent) EncodeBinary

                                                                                                                                                                  func (ne *NotificationEvent) EncodeBinary(w *io.BinWriter)

                                                                                                                                                                    EncodeBinary implements the Serializable interface.

                                                                                                                                                                    func (NotificationEvent) MarshalJSON

                                                                                                                                                                    func (ne NotificationEvent) MarshalJSON() ([]byte, error)

                                                                                                                                                                      MarshalJSON implements implements json.Marshaler interface.

                                                                                                                                                                      func (*NotificationEvent) UnmarshalJSON

                                                                                                                                                                      func (ne *NotificationEvent) UnmarshalJSON(data []byte) error

                                                                                                                                                                        UnmarshalJSON implements json.Unmarshaler interface.

                                                                                                                                                                        type OracleRequest

                                                                                                                                                                        type OracleRequest struct {
                                                                                                                                                                        	OriginalTxID     util.Uint256
                                                                                                                                                                        	GasForResponse   uint64
                                                                                                                                                                        	URL              string
                                                                                                                                                                        	Filter           *string
                                                                                                                                                                        	CallbackContract util.Uint160
                                                                                                                                                                        	CallbackMethod   string
                                                                                                                                                                        	UserData         []byte
                                                                                                                                                                        }

                                                                                                                                                                          OracleRequest represents oracle request.

                                                                                                                                                                          func (*OracleRequest) Bytes

                                                                                                                                                                          func (o *OracleRequest) Bytes() []byte

                                                                                                                                                                            Bytes return o serizalized to a byte-slice.

                                                                                                                                                                            func (*OracleRequest) DecodeBinary

                                                                                                                                                                            func (o *OracleRequest) DecodeBinary(r *io.BinReader)

                                                                                                                                                                              DecodeBinary implements io.Serializable.

                                                                                                                                                                              func (*OracleRequest) EncodeBinary

                                                                                                                                                                              func (o *OracleRequest) EncodeBinary(w *io.BinWriter)

                                                                                                                                                                                EncodeBinary implements io.Serializable.

                                                                                                                                                                                type StorageItem

                                                                                                                                                                                type StorageItem struct {
                                                                                                                                                                                	Value   []byte
                                                                                                                                                                                	IsConst bool
                                                                                                                                                                                }

                                                                                                                                                                                  StorageItem is the value to be stored with read-only flag.

                                                                                                                                                                                  func (*StorageItem) DecodeBinary

                                                                                                                                                                                  func (si *StorageItem) DecodeBinary(r *io.BinReader)

                                                                                                                                                                                    DecodeBinary implements Serializable interface.

                                                                                                                                                                                    func (*StorageItem) EncodeBinary

                                                                                                                                                                                    func (si *StorageItem) EncodeBinary(w *io.BinWriter)

                                                                                                                                                                                      EncodeBinary implements Serializable interface.

                                                                                                                                                                                      type Validator

                                                                                                                                                                                      type Validator struct {
                                                                                                                                                                                      	Key   *keys.PublicKey
                                                                                                                                                                                      	Votes *big.Int
                                                                                                                                                                                      }

                                                                                                                                                                                        Validator holds the state of a validator (its key and votes balance).