emit

package
v0.108.0 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2025 License: MIT Imports: 12 Imported by: 8

Documentation

Overview

Package emit implements low-level functions for Neo VM script creation.

This package is not intended to be used by applications directly, see smartcontract package for more convenient ways to create standard and well-known scripts. Use this package only if you can't create the script you need in any other way.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Any added in v0.105.0

func Any(w *io.BinWriter, something any)

Any emits element if supported. It accepts elements of the following types:

  • int8, int16, int32, int64, int
  • uint8, uint16, uint32, uint64, uint
  • *big.Int
  • string, []byte
  • util.Uint160, *util.Uint160, util.Uint256, *util.Uint256
  • bool
  • stackitem.Convertible, stackitem.Item
  • nil
  • []any

errors.ErrUnsupported is returned for unsupported types.

func AppCall

func AppCall(w *io.BinWriter, scriptHash util.Uint160, operation string, f callflag.CallFlag, args ...any)

AppCall emits SYSCALL with System.Contract.Call parameter for given contract, operation, call flag and arguments.

func AppCallNoArgs added in v0.93.0

func AppCallNoArgs(w *io.BinWriter, scriptHash util.Uint160, operation string, f callflag.CallFlag)

AppCallNoArgs emits a call to the provided contract.

func Array added in v0.75.0

func Array(w *io.BinWriter, es ...any)

Array emits an array of elements to the given buffer. It accepts everything that Any accepts.

func BigInt added in v0.98.2

func BigInt(w *io.BinWriter, n *big.Int)

BigInt emits a big-integer to the given buffer.

func Bool

func Bool(w *io.BinWriter, ok bool)

Bool emits a bool type to the given buffer.

func Bytes

func Bytes(w *io.BinWriter, b []byte)

Bytes emits a byte array to the given buffer.

func Call

func Call(w *io.BinWriter, op opcode.Opcode, label uint16)

Call emits a call Instruction with the label to the given buffer.

func CheckSig added in v0.99.0

func CheckSig(w *io.BinWriter, key []byte)

CheckSig emits a single-key verification script using given []bytes as a key. It does not check for key correctness, so you can get an invalid script if the data passed is not really a public key.

func Convertible added in v0.102.0

func Convertible(w *io.BinWriter, c stackitem.Convertible)

Convertible converts provided stackitem.Convertible to the stackitem.Item and emits the item to the given buffer.

func InitSlot added in v0.106.0

func InitSlot(w *io.BinWriter, locals, args uint8)

InitSlot emits INITSLOT instruction with the specified size of locals/args slots.

func Instruction

func Instruction(w *io.BinWriter, op opcode.Opcode, b []byte)

Instruction emits a VM Instruction with data to the given buffer.

func Int

func Int(w *io.BinWriter, i int64)

Int emits an int type to the given buffer.

func Jmp

func Jmp(w *io.BinWriter, op opcode.Opcode, label uint16)

Jmp emits a jump Instruction along with the label to the given buffer.

func Opcodes added in v0.92.0

func Opcodes(w *io.BinWriter, ops ...opcode.Opcode)

Opcodes emits a single VM Instruction without arguments to the given buffer.

func StackItem added in v0.102.0

func StackItem(w *io.BinWriter, si stackitem.Item)

StackItem emits provided stackitem.Item to the given buffer. If it can't be emitted errors.ErrUnsupported is returned.

func String

func String(w *io.BinWriter, s string)

String emits a string to the given buffer.

func Syscall

func Syscall(w *io.BinWriter, api string)

Syscall emits the syscall API to the given buffer. Syscall API string cannot be 0.

Types

This section is empty.

Jump to

Keyboard shortcuts

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