management

package
v0.0.0-...-dc6c195 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2024 License: MIT Imports: 4 Imported by: 40

Documentation

Overview

Package management provides an interface to ContractManagement native contract. It allows to get/deploy/update contracts as well as get/set deployment fee.

Index

Constants

View Source
const Hash = "\xfd\xa3\xfa\x43\x46\xea\x53\x2a\x25\x8f\xc4\x97\xdd\xad\xdb\x64\x37\xc9\xfd\xff"

Hash represents Management contract hash.

Variables

This section is empty.

Functions

func Destroy

func Destroy()

Destroy represents `destroy` method of Management native contract.

func GetContractHashes

func GetContractHashes() iterator.Iterator

GetContractHashes represents `getContractHashes` method of the Management native contract. It returns an Iterator over the list of non-native contract hashes. Each iterator value can be cast to IDHash. Use iterator interop package to work with the returned Iterator.

func GetMinimumDeploymentFee

func GetMinimumDeploymentFee() int

GetMinimumDeploymentFee represents `getMinimumDeploymentFee` method of Management native contract.

func HasMethod

func HasMethod(hash interop.Hash160, method string, pcount int) bool

HasMethod represents `hasMethod` method of Management native contract. It allows to check if the "hash" contract has a method named "method" with parameters number equal to "pcount".

func SetMinimumDeploymentFee

func SetMinimumDeploymentFee(value int)

SetMinimumDeploymentFee represents `setMinimumDeploymentFee` method of Management native contract.

func Update

func Update(script, manifest []byte)

Update represents `update` method of Management native contract.

func UpdateWithData

func UpdateWithData(script, manifest []byte, data any)

UpdateWithData represents `update` method of Management native contract.

Types

type ABI

type ABI struct {
	Methods []Method
	Events  []Event
}

ABI represents contract's ABI.

type Contract

type Contract struct {
	ID            int
	UpdateCounter int
	Hash          interop.Hash160
	NEF           []byte
	Manifest      Manifest
}

Contract represents a deployed contract.

func Deploy

func Deploy(script, manifest []byte) *Contract

Deploy represents `deploy` method of Management native contract.

func DeployWithData

func DeployWithData(script, manifest []byte, data any) *Contract

DeployWithData represents `deploy` method of Management native contract.

func GetContract

func GetContract(addr interop.Hash160) *Contract

GetContract represents `getContract` method of Management native contract.

func GetContractByID

func GetContractByID(id int) *Contract

GetContractByID represents `getContractById` method of the Management native contract.

type Event

type Event struct {
	Name   string
	Params []Parameter
}

Event represents a contract event.

type Group

type Group struct {
	PublicKey interop.PublicKey
	Signature interop.Signature
}

Group represents a manifest group.

type IDHash

type IDHash struct {
	// ID is a 32-bit number, but it's represented in big endian form
	// natively, because that's the key scheme used by ContractManagement.
	ID   []byte
	Hash interop.Hash160
}

IDHash is an ID/Hash pair returned by the iterator from the GetContractHashes method.

type Manifest

type Manifest struct {
	Name               string
	Groups             []Group
	Features           map[string]string
	SupportedStandards []string
	ABI                ABI
	Permissions        []Permission
	Trusts             []interop.Hash160
	Extra              any
}

Manifest represents contract's manifest.

type Method

type Method struct {
	Name       string
	Params     []Parameter
	ReturnType ParameterType
	Offset     int
	Safe       bool
}

Method represents a contract method.

type Parameter

type Parameter struct {
	Name string
	Type ParameterType
}

Parameter represents a method parameter.

type ParameterType

type ParameterType byte

ParameterType represents smartcontract parameter type.

const (
	AnyType              ParameterType = 0x00
	BoolType             ParameterType = 0x10
	IntegerType          ParameterType = 0x11
	ByteArrayType        ParameterType = 0x12
	StringType           ParameterType = 0x13
	Hash160Type          ParameterType = 0x14
	Hash256Type          ParameterType = 0x15
	PublicKeyType        ParameterType = 0x16
	SignatureType        ParameterType = 0x17
	ArrayType            ParameterType = 0x20
	MapType              ParameterType = 0x22
	InteropInterfaceType ParameterType = 0x30
	VoidType             ParameterType = 0xff
)

Various parameter types.

type Permission

type Permission struct {
	Contract interop.Hash160
	Methods  []string
}

Permission represents contract permission.

Jump to

Keyboard shortcuts

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