nef

package
v0.97.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 18, 2021 License: MIT Imports: 9 Imported by: 3

Documentation

Index

Constants

View Source
const (
	// Magic is a magic File header constant.
	Magic uint32 = 0x3346454E
	// MaxScriptLength is the maximum allowed contract script length.
	MaxScriptLength = 512 * 1024
)

Variables

This section is empty.

Functions

This section is empty.

Types

type File

type File struct {
	Header
	Tokens   []MethodToken `json:"tokens"`
	Script   []byte        `json:"script"`
	Checksum uint32        `json:"checksum"`
}

File represents compiled contract file structure according to the NEF3 standard.

func FileFromBytes

func FileFromBytes(source []byte) (File, error)

FileFromBytes returns NEF File deserialized from given bytes.

func NewFile

func NewFile(script []byte) (*File, error)

NewFile returns new NEF3 file with script specified.

func (File) Bytes

func (n File) Bytes() ([]byte, error)

Bytes returns byte array with serialized NEF File.

func (*File) CalculateChecksum added in v0.92.0

func (n *File) CalculateChecksum() uint32

CalculateChecksum returns first 4 bytes of double-SHA256(Header) converted to uint32.

func (*File) DecodeBinary

func (n *File) DecodeBinary(r *io.BinReader)

DecodeBinary implements io.Serializable interface.

func (*File) EncodeBinary

func (n *File) EncodeBinary(w *io.BinWriter)

EncodeBinary implements io.Serializable interface.

type Header struct {
	Magic    uint32 `json:"magic"`
	Compiler string `json:"compiler"`
}

Header represents File header.

func (*Header) DecodeBinary

func (h *Header) DecodeBinary(r *io.BinReader)

DecodeBinary implements io.Serializable interface.

func (*Header) EncodeBinary

func (h *Header) EncodeBinary(w *io.BinWriter)

EncodeBinary implements io.Serializable interface.

type MethodToken added in v0.93.0

type MethodToken struct {
	// Hash is contract hash.
	Hash util.Uint160 `json:"hash"`
	// Method is method name.
	Method string `json:"method"`
	// ParamCount is method parameter count.
	ParamCount uint16 `json:"paramcount"`
	// HasReturn is true if method returns value.
	HasReturn bool `json:"hasreturnvalue"`
	// CallFlag is a set of call flags the method will be called with.
	CallFlag callflag.CallFlag `json:"callflags"`
}

MethodToken is contract method description.

func (*MethodToken) DecodeBinary added in v0.93.0

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

DecodeBinary implements io.Serializable.

func (*MethodToken) EncodeBinary added in v0.93.0

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

EncodeBinary implements io.Serializable.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL