Documentation ¶
Overview ¶
Package nemgo is a pure golang implementation of an SDK for interacting with the NEM blockchain through the NEM Infrastructure Server (NIS) api.
Index ¶
- Constants
- type AccountInfo
- type AccountMetadata
- type AccountMetadataPair
- type Address
- type Block
- type Client
- func (c Client) AccountData(acc accountName) (AccountMetadataPair, error)
- func (c Client) AccountStatus(address string) (AccountMetadata, error)
- func (c Client) AllTransactions(address string) ([]TransactionMetadataPair, error)
- func (c Client) BlockInfo(height int) (Block, error)
- func (c Client) CreateTransaction(toAct string, xemAmt int, opts ...Option) (TransactionMetadataPair, error)
- func (c Client) GetBatchAccountData(addresses []string) ([]AccountMetadataPair, error)
- func (c Client) GetDelegated(address string) (AccountMetadataPair, error)
- func (c Client) Harvested(address string, hash string) ([]HarvestInfo, error)
- func (c Client) Height() (int, error)
- func (c Client) IncomingTransactions(address string) ([]TransactionMetadataPair, error)
- func (c Client) LastBlock() (Block, error)
- func (c Client) MosaicsOwned(address string) ([]OwnedMosaic, error)
- func (c Client) Namespace(namespace string) (NamespaceInfo, error)
- func (c Client) NodeInfo() (NodeInfo, error)
- func (c Client) OutgoingTransactions(address string) ([]TransactionMetadataPair, error)
- func (c Client) RootNamespace(ID int, PageSize int) ([]NamespaceMetadataPair, error)
- func (c Client) Score() (string, error)
- func (c Client) SubscribeConfirmedTX(address string) (chan StreamMessage, error)
- func (c Client) SubscribeData(address string) (chan StreamMessage, error)
- func (c Client) SubscribeErrors() (chan StreamMessage, error)
- func (c Client) SubscribeHeight() (chan StreamMessage, error)
- func (c Client) SubscribeMoasaicData(address string) (chan StreamMessage, error)
- func (c Client) SubscribeMosaics(address string) (chan StreamMessage, error)
- func (c Client) SubscribeNamespaces(address string) (chan StreamMessage, error)
- func (c Client) SubscribeRecentTX(address string) (chan StreamMessage, error)
- func (c Client) SubscribeUnconfirmedTX(address string) (chan StreamMessage, error)
- type HarvestInfo
- type NamespaceInfo
- type NamespaceMetadata
- type NamespaceMetadataPair
- type Node
- type NodeInfo
- type Option
- type OwnedMosaic
- type PublicKey
- type StreamMessage
- type Transaction
- type TransactionMetadata
- type TransactionMetadataPair
- Bugs
Examples ¶
Constants ¶
const ( // Testnet is a helper const to connect to the testnet Testnet = byte(0x98) // Mainnet is a helper const to connect to the mainnet Mainnet = byte(0x68) )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccountInfo ¶
type AccountInfo struct { // Each account has a unique address. First letter of an address // indicate the network the account belongs to. Currently two networks // are defined: the test network whose account addresses start with a // capital T and the main network whose account addresses always start // with a capital N. Addresses have always a length of 40 characters // and are base-32 encoded. Address string // Each account has a balance which is an integer greater or equal to // zero and denotes the number of micro NEMs which the account owns. // Thus a balance of 123456789 means the account owns 123.456789 NEM. // A balance is split into its vested and unvested part. // Only the vested part is relevant for the importance calculation. // For transfers from one account to another only the balance itself // is relevant. Balance int // vestedBalance contains the vested part of the balance of the account // in micro NEM. VestedBalance float64 // Each account is assigned an importance. The importance is a decimal // number between 0 and 1. It denotes the probability of an account to // harvest the next block in case the account has harvesting turned on // and all other accounts are harvesting too. The exact formula for // calculating the importance is not public yet. // Accounts need at least 10k vested NEM to be included // in the importance calculation. Importance float64 // The public key of an account can be used to verify signatures of the // account. Only accounts that have already published a transaction have // a public key assigned to the account. Otherwise the field is null. PublicKey string // Label has the label of the account (not used, always null). Label string // Harvesting is the process of generating new blocks. The field // denotes the number of blocks that the account harvested so far. // For a new account the number is 0. HarvestedBlocks int }
AccountInfo describes basic information for an account.
type AccountMetadata ¶
type AccountMetadata struct { // Status contains the harvesting status of a queried account. // The harvesting status can be one of the following values: // "UNKNOWN": The harvesting status of the account is not known. // "LOCKED": The account is not harvesting. // "UNLOCKED": The account is harvesting. Status string // RemoteStatus contains the status of teh remote harvesting of a queried account. // The remote harvesting status can be one of the following values: // "REMOTE": The account is a remote account and therefore remoteStatus is not applicable for it. // "ACTIVATING": The account has activated remote harvesting but it is not yet active. // "ACTIVE": The account has activated remote harvesting and remote harvesting is active. // "DEACTIVATING": The account has deactivated remote harvesting but remote harvesting is still active. // "INACTIVE": The account has inactive remote harvesting, or it has deactivated remote harvesting // and deactivation is operational. RemoteStatus string // CosignatoryOf is a JSON array of AccountInfo structures. // The account is cosignatory for each of the accounts in the array. CosignatoryOf []AccountInfo // Cosignatories is a JSON array of AccountInfo structures. // The array holds all accounts that are a cosignatory for this account. Cosignatories []AccountInfo }
AccountMetadata describes additional information for the account.
type AccountMetadataPair ¶
type AccountMetadataPair struct { // Account contains the account object. Account AccountInfo `json:"account"` // Meta contain the account meta data object. Meta AccountMetadata `json:"meta"` }
AccountMetadataPair includes durable information for an account and additional information about its state.
type Block ¶
type Block struct { // BUG(tyler): All float64 in Block should be int TimeStamp float64 Signature string PrevBlockHash string Type float64 Transactions []Transaction Version float64 Signer string Height float64 }
Block objects are generated by accounts. If an account generates a block and the block gets included in the block chain, the generating account, called the harvester, gets all the transaction fees for transactions that are included in the block. A harvester will therefore usually include as many transactions as possible. Transactions reflect all account activities. In order for a client to have an up to date balance for every account it is crucial to know about every transaction that occurred and therefore the client must have knowledge about every single block in the chain (one says: the client must be synchronized with the block chain). Whenever timestamps are used, the time reflects the network time. NEM has a time synchronization mechanism which lets all node agree on how many seconds since the nemesis have elapsed. This common time is called network time.
func (*Block) UnmarshalJSON ¶
UnmarshalJSON implements a custom JSON unmarshaller for Blocks
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is used to interact with a NIS
func New ¶
New will return a Client object ready to be used defaulting to the NEM mainnet
Example ¶
ExampleNew shows how to create a new NEM client
c := New() // use c // you can also create a client using a custom NIS c = New(WithNIS("YOUR.CUSTOM.NIS.HERE:7890", Mainnet)) // use c fmt.Println(c)
Output:
func (Client) AccountData ¶
func (c Client) AccountData(acc accountName) (AccountMetadataPair, error)
AccountData gets all information for a given address
func (Client) AccountStatus ¶
func (c Client) AccountStatus(address string) (AccountMetadata, error)
AccountStatus gets the current metadata about an account
func (Client) AllTransactions ¶
func (c Client) AllTransactions(address string) ([]TransactionMetadataPair, error)
AllTransactions will list the most recent transactions either incoming or outgoing
func (Client) CreateTransaction ¶
func (c Client) CreateTransaction(toAct string, xemAmt int, opts ...Option) (TransactionMetadataPair, error)
CreateTransaction will initialize a transaction on the nem blockchain
func (Client) GetBatchAccountData ¶
func (c Client) GetBatchAccountData(addresses []string) ([]AccountMetadataPair, error)
GetBatchAccountData gets the AccountMetaDataPair of an array of accounts
func (Client) GetDelegated ¶
func (c Client) GetDelegated(address string) (AccountMetadataPair, error)
GetDelegated returns the account meta and data info for the account for which the given account is the delegate account
func (Client) Harvested ¶
func (c Client) Harvested(address string, hash string) ([]HarvestInfo, error)
Harvested gets an array of harvest info objects for an account
func (Client) IncomingTransactions ¶
func (c Client) IncomingTransactions(address string) ([]TransactionMetadataPair, error)
IncomingTransactions withh list all current pending transactions for a given address. This method is likely to be used in conjunction with the StreamingUnconfirmedTX method to get additional details about the transactions.
func (Client) LastBlock ¶
LastBlock will get the most recent confirmed block on NEM and return information about the block
func (Client) MosaicsOwned ¶
func (c Client) MosaicsOwned(address string) ([]OwnedMosaic, error)
MosaicsOwned will find information about what mosaics an address currently holds
func (Client) Namespace ¶
func (c Client) Namespace(namespace string) (NamespaceInfo, error)
Namespace will return a NamespaceInfo about a namespace
func (Client) OutgoingTransactions ¶
func (c Client) OutgoingTransactions(address string) ([]TransactionMetadataPair, error)
OutgoingTransactions will list all current pending outgoing transactions for a given address. This method is likely to be used in the conjunction with StreamingUnconfirmedTX method to get additional details about the transactions.
func (Client) RootNamespace ¶
func (c Client) RootNamespace(ID int, PageSize int) ([]NamespaceMetadataPair, error)
RootNamespace will get all the root namespaces in batch of a specified PageSize.
func (Client) Score ¶
Score gets the current score of the blockchain. The higher the score, the better the chain. During synchronization, nodes try to get the best block chain in the network.
func (Client) SubscribeConfirmedTX ¶
func (c Client) SubscribeConfirmedTX(address string) (chan StreamMessage, error)
SubscribeConfirmedTX will take an account address and subscribe to all confirmed transactions at that address
func (Client) SubscribeData ¶
func (c Client) SubscribeData(address string) (chan StreamMessage, error)
SubscribeData will take an account address and subscribe to all account data changes at that address
func (Client) SubscribeErrors ¶
func (c Client) SubscribeErrors() (chan StreamMessage, error)
SubscribeErrors will return a channel subscribed to error messages
func (Client) SubscribeHeight ¶
func (c Client) SubscribeHeight() (chan StreamMessage, error)
SubscribeHeight will return a channel subscribed to block heights
func (Client) SubscribeMoasaicData ¶
func (c Client) SubscribeMoasaicData(address string) (chan StreamMessage, error)
SubscribeMoasaicData will take an account address and subscribe to all mosaic definition changes for that address
func (Client) SubscribeMosaics ¶
func (c Client) SubscribeMosaics(address string) (chan StreamMessage, error)
SubscribeMosaics will take an account address and subscribe to all mosaic changes for that address
func (Client) SubscribeNamespaces ¶
func (c Client) SubscribeNamespaces(address string) (chan StreamMessage, error)
SubscribeNamespaces will take an account address and subscribe to all namespace changes for that address
func (Client) SubscribeRecentTX ¶
func (c Client) SubscribeRecentTX(address string) (chan StreamMessage, error)
SubscribeRecentTX will take an account address and subscribe to all recent transactions at that address
func (Client) SubscribeUnconfirmedTX ¶
func (c Client) SubscribeUnconfirmedTX(address string) (chan StreamMessage, error)
SubscribeUnconfirmedTX will take an account address and subscribe to all unconfirmed transactions at that address
type HarvestInfo ¶
HarvestInfo is information about harvested blocks
type NamespaceInfo ¶
NamespaceInfo contains information about a namespace
type NamespaceMetadata ¶
type NamespaceMetadata struct {
ID int
}
NamespaceMetadata contains meta information about a namespace
type NamespaceMetadataPair ¶
type NamespaceMetadataPair struct { NamespaceInfo NamespaceInfo NamespaceMetaData NamespaceMetadata }
NamespaceMetadataPair contains info and metadata about a namespace
type Node ¶
type Node struct { MetaData metadata Endpoint endpoint Identity identity }
Node is a node on the Nem blockchain
type NodeInfo ¶
type NodeInfo struct { Node Node NISInfo nisInfo }
NodeInfo contains extended information about the current node
type Option ¶
type Option func(*Client)
Option can be passed into New() to enable additional configuration of the returned Client
type OwnedMosaic ¶
OwnedMosaic is an array of basic information about a mosaic
type StreamMessage ¶
type StreamMessage struct { Command string Headers struct { ContentLength string `json:"content-length,omitempty"` ContentType string `json:"content-type,omitempty"` Destination string `json:"destination,omitempty"` Receipt string `json:"receipt,omitempty"` Subscription string `json:"subscription,omitempty"` MessageID string `json:"message-id,omitempty"` Version string `json:"version,omitempty"` HeartBeat string `json:"heart-beat,omitempty"` } Body interface{} }
StreamMessage returns the Command, Headers, and Body of a stomp message
type Transaction ¶
type Transaction struct { TimeStamp int Amount int Signature string Fee int Recipient string Type int Deadline int Message message Version int Signer string }
Transaction contains information about a transaction
type TransactionMetadata ¶
type TransactionMetadata struct { ID int Height int // TODO(tyler): This need custom unmarshal Hash hash }
TransactionMetadata contains metadata about a transaction
type TransactionMetadataPair ¶
type TransactionMetadataPair struct { Meta TransactionMetadata Transaction Transaction }
TransactionMetadataPair is a set of metadata and transaction details about a specific transaction
Notes ¶
Bugs ¶
All float64 in Block should be int