Documentation ¶
Overview ¶
Package nns contains RPC wrappers for NameService contract.
Code generated by neo-go contract generate-rpcwrapper --manifest <file.json> --out <file.go> [--hash <hash>] [--config <config>]; DO NOT EDIT.
Index ¶
- Constants
- Variables
- func InferHash(sg ContractStateGetter) (util.Uint160, error)
- type Actor
- type Contract
- func (c *Contract) AddRecord(name string, typ *big.Int, data string) (util.Uint256, uint32, error)
- func (c *Contract) AddRecordTransaction(name string, typ *big.Int, data string) (*transaction.Transaction, error)
- func (c *Contract) AddRecordUnsigned(name string, typ *big.Int, data string) (*transaction.Transaction, error)
- func (c *Contract) DeleteRecords(name string, typ *big.Int) (util.Uint256, uint32, error)
- func (c *Contract) DeleteRecordsTransaction(name string, typ *big.Int) (*transaction.Transaction, error)
- func (c *Contract) DeleteRecordsUnsigned(name string, typ *big.Int) (*transaction.Transaction, error)
- func (c *Contract) Register(name string, owner util.Uint160, email string, refresh *big.Int, ...) (util.Uint256, uint32, error)
- func (c *Contract) RegisterTLD(name string, email string, refresh *big.Int, retry *big.Int, expire *big.Int, ...) (util.Uint256, uint32, error)
- func (c *Contract) RegisterTLDTransaction(name string, email string, refresh *big.Int, retry *big.Int, expire *big.Int, ...) (*transaction.Transaction, error)
- func (c *Contract) RegisterTLDUnsigned(name string, email string, refresh *big.Int, retry *big.Int, expire *big.Int, ...) (*transaction.Transaction, error)
- func (c *Contract) RegisterTransaction(name string, owner util.Uint160, email string, refresh *big.Int, ...) (*transaction.Transaction, error)
- func (c *Contract) RegisterUnsigned(name string, owner util.Uint160, email string, refresh *big.Int, ...) (*transaction.Transaction, error)
- func (c *Contract) Renew(name string) (util.Uint256, uint32, error)
- func (c *Contract) RenewTransaction(name string) (*transaction.Transaction, error)
- func (c *Contract) RenewUnsigned(name string) (*transaction.Transaction, error)
- func (c *Contract) SetAdmin(name string, admin util.Uint160) (util.Uint256, uint32, error)
- func (c *Contract) SetAdminTransaction(name string, admin util.Uint160) (*transaction.Transaction, error)
- func (c *Contract) SetAdminUnsigned(name string, admin util.Uint160) (*transaction.Transaction, error)
- func (c *Contract) SetPrice(price *big.Int) (util.Uint256, uint32, error)
- func (c *Contract) SetPriceTransaction(price *big.Int) (*transaction.Transaction, error)
- func (c *Contract) SetPriceUnsigned(price *big.Int) (*transaction.Transaction, error)
- func (c *Contract) SetRecord(name string, typ *big.Int, id *big.Int, data string) (util.Uint256, uint32, error)
- func (c *Contract) SetRecordTransaction(name string, typ *big.Int, id *big.Int, data string) (*transaction.Transaction, error)
- func (c *Contract) SetRecordUnsigned(name string, typ *big.Int, id *big.Int, data string) (*transaction.Transaction, error)
- func (c *Contract) Update(nef []byte, manifest string, data any) (util.Uint256, uint32, error)
- func (c *Contract) UpdateSOA(name string, email string, refresh *big.Int, retry *big.Int, expire *big.Int, ...) (util.Uint256, uint32, error)
- func (c *Contract) UpdateSOATransaction(name string, email string, refresh *big.Int, retry *big.Int, expire *big.Int, ...) (*transaction.Transaction, error)
- func (c *Contract) UpdateSOAUnsigned(name string, email string, refresh *big.Int, retry *big.Int, expire *big.Int, ...) (*transaction.Transaction, error)
- func (c *Contract) UpdateTransaction(nef []byte, manifest string, data any) (*transaction.Transaction, error)
- func (c *Contract) UpdateUnsigned(nef []byte, manifest string, data any) (*transaction.Transaction, error)
- type ContractReader
- func (c *ContractReader) GetAllRecords(name string) (uuid.UUID, result.Iterator, error)
- func (c *ContractReader) GetAllRecordsExpanded(name string, _numOfIteratorItems int) ([]stackitem.Item, error)
- func (c *ContractReader) GetPrice() (*big.Int, error)
- func (c *ContractReader) GetRecords(name string, typ *big.Int) ([]string, error)
- func (c *ContractReader) IsAvailable(name string) (bool, error)
- func (c *ContractReader) Resolve(name string, typ *big.Int) ([]string, error)
- func (c *ContractReader) ResolveFSContract(name string) (util.Uint160, error)
- func (c *ContractReader) Roots() (uuid.UUID, result.Iterator, error)
- func (c *ContractReader) RootsExpanded(_numOfIteratorItems int) ([]stackitem.Item, error)
- func (c *ContractReader) Version() (*big.Int, error)
- type ContractStateGetter
- type Invoker
- type NnsNameState
Examples ¶
Constants ¶
const ( // NameAlphabetPrefix differs from other names in this list, because // in reality there will be multiple alphabets contract deployed to // a network named alphabet0, alphabet1, alphabet2, etc. NameAlphabetPrefix = "alphabet" NameAudit = "audit" NameBalance = "balance" NameContainer = "container" NameNeoFSID = "neofsid" NameNetmap = "netmap" NameProxy = "proxy" NameReputation = "reputation" )
A set of standard contract names deployed into NeoFS sidechain.
const ContractTLD = "neofs"
ContractTLD is the default TLD for NeoFS contracts. It's a convention that is not likely to be used by any non-NeoFS networks, but for NeoFS ones it allows to find contract hashes more easily.
const ID = 1
ID is the default NNS contract ID in all NeoFS networks. NeoFS networks always deploy NNS first and can't work without it, therefore it always gets an ID of 1.
Variables ¶
var ( // A represents address record type. A = big.NewInt(1) // CNAME represents canonical name record type. CNAME = big.NewInt(5) // SOA represents start of authority record type. SOA = big.NewInt(6) // TXT represents text record type. TXT = big.NewInt(16) )
Record types are defined in [RFC 1035](https://tools.ietf.org/html/rfc1035) These variables are provided to be used with autogenerated NNS wrapper that accepts *big.Int for record type parameters, values MUST NOT be changed.
var ( // AAAA represents IPv6 address record type. AAAA = big.NewInt(28) )
Record types are defined in [RFC 3596](https://tools.ietf.org/html/rfc3596) These variables are provided to be used with autogenerated NNS wrapper that accepts *big.Int for record type parameters, values MUST NOT be changed.
Functions ¶
Types ¶
type Actor ¶
type Actor interface { Invoker nep11.Actor MakeCall(contract util.Uint160, method string, params ...any) (*transaction.Transaction, error) MakeRun(script []byte) (*transaction.Transaction, error) MakeUnsignedCall(contract util.Uint160, method string, attrs []transaction.Attribute, params ...any) (*transaction.Transaction, error) MakeUnsignedRun(script []byte, attrs []transaction.Attribute) (*transaction.Transaction, error) SendCall(contract util.Uint160, method string, params ...any) (util.Uint256, uint32, error) SendRun(script []byte) (util.Uint256, uint32, error) }
Actor is used by Contract to call state-changing methods.
type Contract ¶
type Contract struct { ContractReader nep11.BaseWriter // contains filtered or unexported fields }
Contract implements all contract methods.
func (*Contract) AddRecord ¶
AddRecord creates a transaction invoking `addRecord` method of the contract. This transaction is signed and immediately sent to the network. The values returned are its hash, ValidUntilBlock value and error if any.
func (*Contract) AddRecordTransaction ¶
func (c *Contract) AddRecordTransaction(name string, typ *big.Int, data string) (*transaction.Transaction, error)
AddRecordTransaction creates a transaction invoking `addRecord` method of the contract. This transaction is signed, but not sent to the network, instead it's returned to the caller.
func (*Contract) AddRecordUnsigned ¶
func (c *Contract) AddRecordUnsigned(name string, typ *big.Int, data string) (*transaction.Transaction, error)
AddRecordUnsigned creates a transaction invoking `addRecord` method of the contract. This transaction is not signed, it's simply returned to the caller. Any fields of it that do not affect fees can be changed (ValidUntilBlock, Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
func (*Contract) DeleteRecords ¶
DeleteRecords creates a transaction invoking `deleteRecords` method of the contract. This transaction is signed and immediately sent to the network. The values returned are its hash, ValidUntilBlock value and error if any.
func (*Contract) DeleteRecordsTransaction ¶
func (c *Contract) DeleteRecordsTransaction(name string, typ *big.Int) (*transaction.Transaction, error)
DeleteRecordsTransaction creates a transaction invoking `deleteRecords` method of the contract. This transaction is signed, but not sent to the network, instead it's returned to the caller.
func (*Contract) DeleteRecordsUnsigned ¶
func (c *Contract) DeleteRecordsUnsigned(name string, typ *big.Int) (*transaction.Transaction, error)
DeleteRecordsUnsigned creates a transaction invoking `deleteRecords` method of the contract. This transaction is not signed, it's simply returned to the caller. Any fields of it that do not affect fees can be changed (ValidUntilBlock, Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
func (*Contract) Register ¶
func (c *Contract) Register(name string, owner util.Uint160, email string, refresh *big.Int, retry *big.Int, expire *big.Int, ttl *big.Int) (util.Uint256, uint32, error)
Register creates a transaction invoking `register` method of the contract. This transaction is signed and immediately sent to the network. The values returned are its hash, ValidUntilBlock value and error if any.
func (*Contract) RegisterTLD ¶
func (c *Contract) RegisterTLD(name string, email string, refresh *big.Int, retry *big.Int, expire *big.Int, ttl *big.Int) (util.Uint256, uint32, error)
RegisterTLD creates a transaction invoking `registerTLD` method of the contract. This transaction is signed and immediately sent to the network. The values returned are its hash, ValidUntilBlock value and error if any.
func (*Contract) RegisterTLDTransaction ¶
func (c *Contract) RegisterTLDTransaction(name string, email string, refresh *big.Int, retry *big.Int, expire *big.Int, ttl *big.Int) (*transaction.Transaction, error)
RegisterTLDTransaction creates a transaction invoking `registerTLD` method of the contract. This transaction is signed, but not sent to the network, instead it's returned to the caller.
func (*Contract) RegisterTLDUnsigned ¶
func (c *Contract) RegisterTLDUnsigned(name string, email string, refresh *big.Int, retry *big.Int, expire *big.Int, ttl *big.Int) (*transaction.Transaction, error)
RegisterTLDUnsigned creates a transaction invoking `registerTLD` method of the contract. This transaction is not signed, it's simply returned to the caller. Any fields of it that do not affect fees can be changed (ValidUntilBlock, Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
func (*Contract) RegisterTransaction ¶
func (c *Contract) RegisterTransaction(name string, owner util.Uint160, email string, refresh *big.Int, retry *big.Int, expire *big.Int, ttl *big.Int) (*transaction.Transaction, error)
RegisterTransaction creates a transaction invoking `register` method of the contract. This transaction is signed, but not sent to the network, instead it's returned to the caller.
func (*Contract) RegisterUnsigned ¶
func (c *Contract) RegisterUnsigned(name string, owner util.Uint160, email string, refresh *big.Int, retry *big.Int, expire *big.Int, ttl *big.Int) (*transaction.Transaction, error)
RegisterUnsigned creates a transaction invoking `register` method of the contract. This transaction is not signed, it's simply returned to the caller. Any fields of it that do not affect fees can be changed (ValidUntilBlock, Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
func (*Contract) Renew ¶
Renew creates a transaction invoking `renew` method of the contract. This transaction is signed and immediately sent to the network. The values returned are its hash, ValidUntilBlock value and error if any.
func (*Contract) RenewTransaction ¶
func (c *Contract) RenewTransaction(name string) (*transaction.Transaction, error)
RenewTransaction creates a transaction invoking `renew` method of the contract. This transaction is signed, but not sent to the network, instead it's returned to the caller.
func (*Contract) RenewUnsigned ¶
func (c *Contract) RenewUnsigned(name string) (*transaction.Transaction, error)
RenewUnsigned creates a transaction invoking `renew` method of the contract. This transaction is not signed, it's simply returned to the caller. Any fields of it that do not affect fees can be changed (ValidUntilBlock, Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
func (*Contract) SetAdmin ¶
SetAdmin creates a transaction invoking `setAdmin` method of the contract. This transaction is signed and immediately sent to the network. The values returned are its hash, ValidUntilBlock value and error if any.
func (*Contract) SetAdminTransaction ¶
func (c *Contract) SetAdminTransaction(name string, admin util.Uint160) (*transaction.Transaction, error)
SetAdminTransaction creates a transaction invoking `setAdmin` method of the contract. This transaction is signed, but not sent to the network, instead it's returned to the caller.
func (*Contract) SetAdminUnsigned ¶
func (c *Contract) SetAdminUnsigned(name string, admin util.Uint160) (*transaction.Transaction, error)
SetAdminUnsigned creates a transaction invoking `setAdmin` method of the contract. This transaction is not signed, it's simply returned to the caller. Any fields of it that do not affect fees can be changed (ValidUntilBlock, Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
func (*Contract) SetPrice ¶
SetPrice creates a transaction invoking `setPrice` method of the contract. This transaction is signed and immediately sent to the network. The values returned are its hash, ValidUntilBlock value and error if any.
func (*Contract) SetPriceTransaction ¶
func (c *Contract) SetPriceTransaction(price *big.Int) (*transaction.Transaction, error)
SetPriceTransaction creates a transaction invoking `setPrice` method of the contract. This transaction is signed, but not sent to the network, instead it's returned to the caller.
func (*Contract) SetPriceUnsigned ¶
func (c *Contract) SetPriceUnsigned(price *big.Int) (*transaction.Transaction, error)
SetPriceUnsigned creates a transaction invoking `setPrice` method of the contract. This transaction is not signed, it's simply returned to the caller. Any fields of it that do not affect fees can be changed (ValidUntilBlock, Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
func (*Contract) SetRecord ¶
func (c *Contract) SetRecord(name string, typ *big.Int, id *big.Int, data string) (util.Uint256, uint32, error)
SetRecord creates a transaction invoking `setRecord` method of the contract. This transaction is signed and immediately sent to the network. The values returned are its hash, ValidUntilBlock value and error if any.
func (*Contract) SetRecordTransaction ¶
func (c *Contract) SetRecordTransaction(name string, typ *big.Int, id *big.Int, data string) (*transaction.Transaction, error)
SetRecordTransaction creates a transaction invoking `setRecord` method of the contract. This transaction is signed, but not sent to the network, instead it's returned to the caller.
func (*Contract) SetRecordUnsigned ¶
func (c *Contract) SetRecordUnsigned(name string, typ *big.Int, id *big.Int, data string) (*transaction.Transaction, error)
SetRecordUnsigned creates a transaction invoking `setRecord` method of the contract. This transaction is not signed, it's simply returned to the caller. Any fields of it that do not affect fees can be changed (ValidUntilBlock, Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
func (*Contract) Update ¶
Update creates a transaction invoking `update` method of the contract. This transaction is signed and immediately sent to the network. The values returned are its hash, ValidUntilBlock value and error if any.
func (*Contract) UpdateSOA ¶
func (c *Contract) UpdateSOA(name string, email string, refresh *big.Int, retry *big.Int, expire *big.Int, ttl *big.Int) (util.Uint256, uint32, error)
UpdateSOA creates a transaction invoking `updateSOA` method of the contract. This transaction is signed and immediately sent to the network. The values returned are its hash, ValidUntilBlock value and error if any.
func (*Contract) UpdateSOATransaction ¶
func (c *Contract) UpdateSOATransaction(name string, email string, refresh *big.Int, retry *big.Int, expire *big.Int, ttl *big.Int) (*transaction.Transaction, error)
UpdateSOATransaction creates a transaction invoking `updateSOA` method of the contract. This transaction is signed, but not sent to the network, instead it's returned to the caller.
func (*Contract) UpdateSOAUnsigned ¶
func (c *Contract) UpdateSOAUnsigned(name string, email string, refresh *big.Int, retry *big.Int, expire *big.Int, ttl *big.Int) (*transaction.Transaction, error)
UpdateSOAUnsigned creates a transaction invoking `updateSOA` method of the contract. This transaction is not signed, it's simply returned to the caller. Any fields of it that do not affect fees can be changed (ValidUntilBlock, Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
func (*Contract) UpdateTransaction ¶
func (c *Contract) UpdateTransaction(nef []byte, manifest string, data any) (*transaction.Transaction, error)
UpdateTransaction creates a transaction invoking `update` method of the contract. This transaction is signed, but not sent to the network, instead it's returned to the caller.
func (*Contract) UpdateUnsigned ¶
func (c *Contract) UpdateUnsigned(nef []byte, manifest string, data any) (*transaction.Transaction, error)
UpdateUnsigned creates a transaction invoking `update` method of the contract. This transaction is not signed, it's simply returned to the caller. Any fields of it that do not affect fees can be changed (ValidUntilBlock, Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
type ContractReader ¶
type ContractReader struct { nep11.NonDivisibleReader // contains filtered or unexported fields }
ContractReader implements safe contract methods.
func NewReader ¶
func NewReader(invoker Invoker, hash util.Uint160) *ContractReader
NewReader creates an instance of ContractReader using provided contract hash and the given Invoker.
func (*ContractReader) GetAllRecords ¶
GetAllRecords invokes `getAllRecords` method of contract.
func (*ContractReader) GetAllRecordsExpanded ¶
func (c *ContractReader) GetAllRecordsExpanded(name string, _numOfIteratorItems int) ([]stackitem.Item, error)
GetAllRecordsExpanded is similar to GetAllRecords (uses the same contract method), but can be useful if the server used doesn't support sessions and doesn't expand iterators. It creates a script that will get the specified number of result items from the iterator right in the VM and return them to you. It's only limited by VM stack and GAS available for RPC invocations.
func (*ContractReader) GetPrice ¶
func (c *ContractReader) GetPrice() (*big.Int, error)
GetPrice invokes `getPrice` method of contract.
func (*ContractReader) GetRecords ¶
GetRecords invokes `getRecords` method of contract.
func (*ContractReader) IsAvailable ¶
func (c *ContractReader) IsAvailable(name string) (bool, error)
IsAvailable invokes `isAvailable` method of contract.
func (*ContractReader) ResolveFSContract ¶
func (c *ContractReader) ResolveFSContract(name string) (util.Uint160, error)
ResolveFSContract is a convenience method that doesn't exist in the NNS contract itself (it doesn't care which data is stored there). It assumes that contracts follow the ContractTLD convention, gets simple contract names (like "container" or "netmap") and extracts the hash for the respective NNS record in any of the formats (of which historically there's been a few).
Example ¶
Resolve addresses of NeoFS smart contracts deployed in a particular NeoFS sidechain by their NNS domain names.
package main import ( "context" "fmt" "log" "github.com/nspcc-dev/neo-go/pkg/rpcclient" "github.com/nspcc-dev/neo-go/pkg/rpcclient/invoker" "github.com/nspcc-dev/neofs-contract/rpc/nns" ) func main() { const sidechainRPCEndpoint = "https://rpc1.morph.fs.neo.org:40341" c, err := rpcclient.New(context.Background(), sidechainRPCEndpoint, rpcclient.Options{}) if err != nil { log.Fatal(err) } err = c.Init() if err != nil { log.Fatal(err) } nnsAddress, err := nns.InferHash(c) if err != nil { log.Fatal(err) } nnsContract := nns.NewReader(invoker.New(c, nil), nnsAddress) for _, name := range []string{ nns.NameAudit, nns.NameBalance, nns.NameContainer, nns.NameNeoFSID, nns.NameNetmap, nns.NameProxy, nns.NameReputation, } { addr, err := nnsContract.ResolveFSContract(name) if err != nil { log.Fatal(err) } fmt.Printf("%s: %s\n", name, addr) } }
Output:
func (*ContractReader) RootsExpanded ¶
func (c *ContractReader) RootsExpanded(_numOfIteratorItems int) ([]stackitem.Item, error)
RootsExpanded is similar to Roots (uses the same contract method), but can be useful if the server used doesn't support sessions and doesn't expand iterators. It creates a script that will get the specified number of result items from the iterator right in the VM and return them to you. It's only limited by VM stack and GAS available for RPC invocations.
type ContractStateGetter ¶
ContractStateGetter is the interface required for contract state resolution using a known contract ID.
type NnsNameState ¶
NnsNameState is a contract-specific nns.NameState type used by its methods.
func (*NnsNameState) FromStackItem ¶
func (res *NnsNameState) FromStackItem(item stackitem.Item) error
FromStackItem retrieves fields of NnsNameState from the given stackitem.Item or returns an error if it's not possible to do to so.