Documentation ¶
Overview ¶
Package standard contains interfaces for well-defined standards and a function for checking if an arbitrary manifest complies with them.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrMethodMissing = errors.New("method missing") ErrEventMissing = errors.New("event missing") ErrInvalidReturnType = errors.New("invalid return type") ErrInvalidParameterCount = errors.New("invalid parameter count") ErrInvalidParameterName = errors.New("invalid parameter name") ErrInvalidParameterType = errors.New("invalid parameter type") ErrSafeMethodMismatch = errors.New("method has wrong safe flag") )
Various validation errors.
var DecimalTokenBase = &Standard{ Manifest: manifest.Manifest{ ABI: manifest.ABI{ Methods: []manifest.Method{ { Name: "decimals", ReturnType: smartcontract.IntegerType, Safe: true, }, { Name: "symbol", ReturnType: smartcontract.StringType, Safe: true, }, { Name: "totalSupply", ReturnType: smartcontract.IntegerType, Safe: true, }, }, }, }, }
DecimalTokenBase contains methods common to NEP-11 and NEP-17 token standards.
var Nep11Base = &Standard{ Base: DecimalTokenBase, Manifest: manifest.Manifest{ ABI: manifest.ABI{ Methods: []manifest.Method{ { Name: "balanceOf", Parameters: []manifest.Parameter{ {Name: "owner", Type: smartcontract.Hash160Type}, }, ReturnType: smartcontract.IntegerType, Safe: true, }, { Name: "tokensOf", Parameters: []manifest.Parameter{ {Name: "owner", Type: smartcontract.Hash160Type}, }, ReturnType: smartcontract.InteropInterfaceType, Safe: true, }, { Name: "transfer", Parameters: []manifest.Parameter{ {Name: "to", Type: smartcontract.Hash160Type}, {Name: "tokenId", Type: smartcontract.ByteArrayType}, {Name: "data", Type: smartcontract.AnyType}, }, ReturnType: smartcontract.BoolType, }, }, Events: []manifest.Event{ { Name: "Transfer", Parameters: []manifest.Parameter{ {Name: "from", Type: smartcontract.Hash160Type}, {Name: "to", Type: smartcontract.Hash160Type}, {Name: "amount", Type: smartcontract.IntegerType}, {Name: "tokenId", Type: smartcontract.ByteArrayType}, }, }, }, }, }, Optional: []manifest.Method{ { Name: "properties", Parameters: []manifest.Parameter{ {Name: "tokenId", Type: smartcontract.ByteArrayType}, }, ReturnType: smartcontract.MapType, Safe: true, }, { Name: "tokens", ReturnType: smartcontract.InteropInterfaceType, Safe: true, }, }, }
Nep11Base is a Standard containing common NEP-11 methods.
var Nep11Divisible = &Standard{ Base: Nep11Base, Manifest: manifest.Manifest{ ABI: manifest.ABI{ Methods: []manifest.Method{ { Name: "balanceOf", Parameters: []manifest.Parameter{ {Name: "owner", Type: smartcontract.Hash160Type}, {Name: "tokenId", Type: smartcontract.ByteArrayType}, }, ReturnType: smartcontract.IntegerType, Safe: true, }, { Name: "ownerOf", Parameters: []manifest.Parameter{ {Name: "tokenId", Type: smartcontract.ByteArrayType}, }, ReturnType: smartcontract.InteropInterfaceType, Safe: true, }, { Name: "transfer", Parameters: []manifest.Parameter{ {Name: "from", Type: smartcontract.Hash160Type}, {Name: "to", Type: smartcontract.Hash160Type}, {Name: "amount", Type: smartcontract.IntegerType}, {Name: "tokenId", Type: smartcontract.ByteArrayType}, {Name: "data", Type: smartcontract.AnyType}, }, ReturnType: smartcontract.BoolType, }, }, }, }, }
Nep11Divisible is a NEP-11 divisible Standard.
var Nep11NonDivisible = &Standard{ Base: Nep11Base, Manifest: manifest.Manifest{ ABI: manifest.ABI{ Methods: []manifest.Method{ { Name: "ownerOf", Parameters: []manifest.Parameter{ {Name: "tokenId", Type: smartcontract.ByteArrayType}, }, ReturnType: smartcontract.Hash160Type, Safe: true, }, }, }, }, }
Nep11NonDivisible is a NEP-11 non-divisible Standard.
var Nep11Payable = &Standard{ Manifest: manifest.Manifest{ ABI: manifest.ABI{ Methods: []manifest.Method{{ Name: manifest.MethodOnNEP11Payment, Parameters: []manifest.Parameter{ {Name: "from", Type: smartcontract.Hash160Type}, {Name: "amount", Type: smartcontract.IntegerType}, {Name: "tokenid", Type: smartcontract.ByteArrayType}, {Name: "data", Type: smartcontract.AnyType}, }, ReturnType: smartcontract.VoidType, }}, }, }, }
Nep11Payable contains NEP-11's onNEP11Payment method definition.
var Nep17 = &Standard{ Base: DecimalTokenBase, Manifest: manifest.Manifest{ ABI: manifest.ABI{ Methods: []manifest.Method{ { Name: "balanceOf", Parameters: []manifest.Parameter{ {Name: "account", Type: smartcontract.Hash160Type}, }, ReturnType: smartcontract.IntegerType, Safe: true, }, { Name: "transfer", Parameters: []manifest.Parameter{ {Name: "from", Type: smartcontract.Hash160Type}, {Name: "to", Type: smartcontract.Hash160Type}, {Name: "amount", Type: smartcontract.IntegerType}, {Name: "data", Type: smartcontract.AnyType}, }, ReturnType: smartcontract.BoolType, }, }, Events: []manifest.Event{ { Name: "Transfer", Parameters: []manifest.Parameter{ {Name: "from", Type: smartcontract.Hash160Type}, {Name: "to", Type: smartcontract.Hash160Type}, {Name: "amount", Type: smartcontract.IntegerType}, }, }, }, }, }, }
Nep17 is a NEP-17 Standard.
var Nep17Payable = &Standard{ Manifest: manifest.Manifest{ ABI: manifest.ABI{ Methods: []manifest.Method{{ Name: manifest.MethodOnNEP17Payment, Parameters: []manifest.Parameter{ {Name: "from", Type: smartcontract.Hash160Type}, {Name: "amount", Type: smartcontract.IntegerType}, {Name: "data", Type: smartcontract.AnyType}, }, ReturnType: smartcontract.VoidType, }}, }, }, }
Nep17Payable contains NEP-17's onNEP17Payment method definition.
Functions ¶
func Check ¶
Check checks if the manifest complies with all provided standards. Currently, only NEP-17 is supported.
Types ¶
type Standard ¶ added in v0.94.0
type Standard struct { // Manifest describes mandatory methods and events. manifest.Manifest // Base contains base standard. Base *Standard // Optional contains optional contract methods. // If contract contains method with the same name and parameter count, // it must have signature declared by this contract. Optional []manifest.Method }
Standard represents smart-contract standard.