Documentation ¶
Overview ¶
Package standard contains interfaces for well-defined standards and a function for checking if an arbitrary manifest complies with them.
Index ¶
Constants ¶
const MethodRoyaltyInfo = "royaltyInfo"
MethodRoyaltyInfo is the name of the method that returns royalty information.
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.
var Nep24 = &Standard{ Manifest: manifest.Manifest{ ABI: manifest.ABI{ Methods: []manifest.Method{ { Name: MethodRoyaltyInfo, Parameters: []manifest.Parameter{ {Name: "tokenId", Type: smartcontract.ByteArrayType}, {Name: "royaltyToken", Type: smartcontract.Hash160Type}, {Name: "salePrice", Type: smartcontract.IntegerType}, }, ReturnType: smartcontract.ArrayType, Safe: true, }, }, }, }, Required: []string{manifest.NEP11StandardName}, }
Nep24 is a NEP-24 Standard for NFT royalties.
var Nep24Payable = &Standard{ Manifest: manifest.Manifest{ ABI: manifest.ABI{ Events: []manifest.Event{ { Name: "RoyaltiesTransferred", Parameters: []manifest.Parameter{ {Name: "royaltyToken", Type: smartcontract.Hash160Type}, {Name: "royaltyRecipient", Type: smartcontract.Hash160Type}, {Name: "buyer", Type: smartcontract.Hash160Type}, {Name: "tokenId", Type: smartcontract.ByteArrayType}, {Name: "amount", Type: smartcontract.IntegerType}, }, }, }, }, }, }
Nep24Payable contains an event that MUST be triggered after marketplaces transferring royalties to the royalty recipient if royaltyInfo method is implemented.
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 // Required contains standards that are required for this standard. Required []string }
Standard represents smart-contract standard.