Documentation ¶
Index ¶
- Constants
- Variables
- func ArrayFromStackItem(param stackitem.Item) ([]stackitem.Item, error)
- func BigIntFromStackItem(param stackitem.Item) (*big.Int, error)
- func BoolFromStackItem(param stackitem.Item) (bool, error)
- func BytesFromStackItem(param stackitem.Item) ([]byte, error)
- func IntFromStackItem(param stackitem.Item) (int64, error)
- func StringFromStackItem(param stackitem.Item) (string, error)
- type Client
- func (c *Client) Invoke(contract util.Uint160, fee fixedn.Fixed8, method string, args ...interface{}) error
- func (c *Client) TestInvoke(contract util.Uint160, method string, args ...interface{}) ([]stackitem.Item, error)
- func (c *Client) TransferGas(receiver util.Uint160, amount fixedn.Fixed8) error
- type Option
- type StaticClient
Constants ¶
const HaltState = "HALT"
HaltState returned if TestInvoke function processed without panic.
Variables ¶
var ErrNilClient = errors.New("client is nil")
ErrNilClient is returned by functions that expect a non-nil Client pointer, but received nil.
var ErrNilStaticClient = errors.New("static client is nil")
ErrNilStaticClient is returned by functions that expect a non-nil StaticClient pointer, but received nil.
Functions ¶
func ArrayFromStackItem ¶ added in v0.12.0
ArrayFromStackItem returns the slice contract parameters from passed parameter.
If passed parameter carries boolean false value, (nil, nil) returns.
func BigIntFromStackItem ¶ added in v0.12.0
BigIntFromStackItem receives numerical value from the value of a smart contract parameter.
func BoolFromStackItem ¶ added in v0.12.0
BoolFromStackItem receives boolean value from the value of a smart contract parameter.
func BytesFromStackItem ¶ added in v0.12.0
BytesFromStackItem receives binary value from the value of a smart contract parameter.
func IntFromStackItem ¶ added in v0.12.0
IntFromStackItem receives numerical value from the value of a smart contract parameter.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a neo-go wrapper that provides smart-contract invocation interface.
Working client must be created via constructor New. Using the Client that has been created with new(Client) expression (or just declaring a Client variable) is unsafe and can lead to panic.
func New ¶
New creates, initializes and returns the Client instance.
If private key is nil, crypto.ErrEmptyPrivateKey is returned.
Other values are set according to provided options, or by default:
- client context: Background;
- dial timeout: 5s;
- blockchain network type: netmode.PrivNet;
- logger: zap.L().
If desired option satisfies the default value, it can be omitted. If multiple options of the same config value are supplied, the option with the highest index in the arguments will be used.
func (*Client) Invoke ¶
func (c *Client) Invoke(contract util.Uint160, fee fixedn.Fixed8, method string, args ...interface{}) error
Invoke invokes contract method by sending transaction into blockchain. Supported args types: int64, string, util.Uint160, []byte and bool.
type Option ¶
type Option func(*cfg)
Option is a client configuration change function.
func WithContext ¶
WithContext returns a client constructor option that specifies the neo-go client context.
Ignores nil value.
If option not provided, context.Background() is used.
func WithDialTimeout ¶
WithDialTimeout returns a client constructor option that specifies neo-go client dial timeout duration.
Ignores non-positive value.
If option not provided, 5s timeout is used.
func WithGasContract ¶
WithGasContract returns a client constructor option that specifies native gas contract script hash.
If option not provided, empty script hash is used.
func WithLogger ¶
WithLogger returns a client constructor option that specifies the component for writing log messages.
Ignores nil value.
If option not provided, zap.L() is used.
type StaticClient ¶
type StaticClient struct {
// contains filtered or unexported fields
}
StaticClient is a wrapper over Neo:Morph client that invokes single smart contract methods with fixed fee.
Working static client must be created via constructor NewStatic. Using the StaticClient that has been created with new(StaticClient) expression (or just declaring a StaticClient variable) is unsafe and can lead to panic.
func NewStatic ¶
NewStatic creates, initializes and returns the StaticClient instance.
If provided Client instance is nil, ErrNilClient is returned.
func (StaticClient) Invoke ¶
func (s StaticClient) Invoke(method string, args ...interface{}) error
Invoke calls Invoke method of Client with static internal script hash and fee. Supported args types are the same as in Client.
func (StaticClient) TestInvoke ¶
func (s StaticClient) TestInvoke(method string, args ...interface{}) ([]stackitem.Item, error)
TestInvoke calls TestInvoke method of Client with static internal script hash.