gotezos

package module
v0.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 20, 2020 License: MIT Imports: 23 Imported by: 0

README

goTezos: A Tezos Go Library

The purpose of this library is to allow developers to build go driven applications for Tezos of the Tezos RPC. This library is a work in progress, and not complete.

More robust documentation will come soon.

Installation

Get goTezos

go get github.com/DefinitelyNotAGoat/goTezos

goTezos Documentation

GoDoc

The goTezos Library requires you to set the RPC URL for a node to query.

Usage:

package main

import (
	"fmt"
	goTezos "github.com/DefinitelyNotAGoat/go-tezos"
)

func main() {
	gt := goTezos.NewGoTezos()
	gt.AddNewClient(goTezos.NewTezosRPCClient("localhost",":8732"))

	block,_ := gt.GetBlockAtLevel(1000)
	fmt.Println(block.Hash)
}

I will create a wiki shortly describing the functions available.

Contributers

See the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Documentation

Index

Constants

View Source
const MUTEZ = 1000000

MUTEZ is a helper for balance devision

Variables

This section is empty.

Functions

This section is empty.

Types

type BCycles

type BCycles struct {
	Cycle        int          `json:"cycle"`
	BakingRights BakingRights `json:"baking_rights"`
}

BCycles is a structure representing the baking rights in a specific cycle

type BRights

type BRights struct {
	Delegate string    `json:"delegate"`
	Cycles   []BCycles `json:"cycles"`
}

BRights is a structure representing baking rights for a specific delegate between cycles

type BakingRights

type BakingRights []struct {
	Level         int       `json:"level"`
	Delegate      string    `json:"delegate"`
	Priority      int       `json:"priority"`
	EstimatedTime time.Time `json:"estimated_time"`
}

BakingRights a representation of baking rights on the Tezos network

func (*BakingRights) UnmarshalJSON

func (br *BakingRights) UnmarshalJSON(v []byte) (BakingRights, error)

UnmarshalJSON unmarhsels bytes into Baking_Rights

type Block

type Block struct {
	Protocol   string               `json:"protocol"`
	ChainID    string               `json:"chain_id"`
	Hash       string               `json:"hash"`
	Header     StructHeader         `json:"header"`
	Metadata   StructMetadata       `json:"metadata"`
	Operations [][]StructOperations `json:"operations"`
}

Block is a block returned by the Tezos RPC API.

func (*Block) UnmarshalJSON

func (b *Block) UnmarshalJSON(v []byte) (Block, error)

UnmarshalJSON unmarshals the bytes received as a parameter, into the type Block.

type ContentsMetadata

type ContentsMetadata struct {
	BalanceUpdates  []StructBalanceUpdates `json:"balance_updates"`
	Slots           []int                  `json:"slots"`
	OperationResult OperationResult        `json:"operation_result"`
}

ContentsMetadata is the Metadata found in the Contents in a operation of a block returned by the Tezos RPC API.

type Conts

type Conts struct {
	Contents []TransOp `json:"contents"`
	Branch   string    `json:"branch"`
}

Conts is helper structure to build out the contents of a a transfer operation to post to the Tezos RPC

func (Conts) String

func (c Conts) String() string

type Delegate

type Delegate struct {
	Balance              string                 `json:"balance"`
	FrozenBalance        string                 `json:"frozen_balance"`
	FrozenBalanceByCycle []FrozenBalanceByCycle `json:"frozen_balance_by_cycle"`
	StakingBalance       string                 `json:"staking_balance"`
	DelegateContracts    []string               `json:"delegated_contracts"`
	DelegatedBalance     string                 `json:"delegated_balance"`
	Deactivated          bool                   `json:"deactivated"`
	GracePeriod          int                    `json:"grace_period"`
}

Delegate is representation of a delegate on the Tezos Network

func (*Delegate) UnmarshalJSON

func (d *Delegate) UnmarshalJSON(v []byte) (Delegate, error)

UnmarshalJSON unmarshalls bytes into StructDelegate

type DelegateReport

type DelegateReport struct {
	DelegatePhk      string
	Cycle            int
	Delegations      []DelegationReport
	CycleRewards     string
	TotalFeeRewards  string
	SelfBakedRewards string
	TotalRewards     string
}

func (*DelegateReport) GetPayments

func (dr *DelegateReport) GetPayments() []Payment

GetPayments will convert a delegate report into payments for batch pay

type DelegationReport

type DelegationReport struct {
	DelegationPhk string
	Share         float64
	GrossRewards  string
	Fee           string
	NetRewards    string
}

type ECycles

type ECycles struct {
	Cycle           int             `json:"cycle"`
	EndorsingRights EndorsingRights `json:"endorsing_rights"`
}

ECycles is a structure representing the endorsing rights in a specific cycle

type ERights

type ERights struct {
	Delegate string    `json:"delegate"`
	Cycles   []ECycles `json:"cycles"`
}

ERights is a structure representing endorsing rights for a specific delegate between cycles

type EndorsingRights

type EndorsingRights []struct {
	Level         int       `json:"level"`
	Delegate      string    `json:"delegate"`
	Slots         []int     `json:"slots"`
	EstimatedTime time.Time `json:"estimated_time"`
}

EndorsingRights is a representation of endorsing rights on the Tezos network

func (*EndorsingRights) UnmarshalJSON

func (er *EndorsingRights) UnmarshalJSON(v []byte) (EndorsingRights, error)

UnmarshalJSON unmarhsels bytes into Endorsing_Rights

type FrozenBalance

type FrozenBalance struct {
	Deposits string `json:"deposits"`
	Fees     string `json:"fees"`
	Rewards  string `json:"rewards"`
}

FrozenBalance is representation of frozen balance on the Tezos network

func (*FrozenBalance) UnmarshalJSON

func (fb *FrozenBalance) UnmarshalJSON(v []byte) (FrozenBalance, error)

UnmarshalJSON unmarshalls bytes into frozen balance

type FrozenBalanceByCycle

type FrozenBalanceByCycle struct {
	Cycle   int    `json:"cycle"`
	Deposit string `json:"deposit"`
	Fees    string `json:"fees"`
	Rewards string `json:"rewards"`
}

FrozenBalanceByCycle a representation of frozen balance by cycle on the Tezos network

type FrozenBalanceRewards

type FrozenBalanceRewards struct {
	Deposits string `json:"deposits"`
	Fees     string `json:"fees"`
	Rewards  string `json:"rewards"`
}

FrozenBalanceRewards is a FrozenBalanceRewards query returned by the Tezos RPC API.

func (*FrozenBalanceRewards) UnmarshalJSON

func (fb *FrozenBalanceRewards) UnmarshalJSON(v []byte) (FrozenBalanceRewards, error)

UnmarshalJSON unmarshals the bytes received as a parameter, into the type SnapShotQuery.

type GoTezos

type GoTezos struct {
	RPCClients     []*TezClientWrapper
	ActiveRPCCient *TezClientWrapper
	Constants      NetworkConstants
	Versions       []NetworkVersion
	// contains filtered or unexported fields
}

GoTezos manages multiple Clients each Client represents a Connection to a Tezos Node GoTezos manages failover if one Node is down, there are 2 Strategies: failover: always use the same unless it is down -> go to the next - default random: send to each Node equally

func NewGoTezos

func NewGoTezos() *GoTezos

NewGoTezos is a constructor that returns a GoTezos object

func (*GoTezos) AddNewClient

func (gt *GoTezos) AddNewClient(client *TezosRPCClient)

AddNewClient adds an RPC Client to query the tezos network

func (*GoTezos) CreateBatchPayment

func (gt *GoTezos) CreateBatchPayment(payments []Payment, wallet Wallet, paymentFee int, gaslimit int, storageLimit int) ([]string, error)

CreateBatchPayment forges batch payments and returns them ready to inject to a Tezos RPC. PaymentFee must be expressed in mutez.

func (*GoTezos) CreateWallet

func (gt *GoTezos) CreateWallet(mnenomic string, password string) (Wallet, error)

CreateWallet returns Wallet with the mnemonic and password provided

func (*GoTezos) Debug

func (gt *GoTezos) Debug(d bool)

Debug puts go-tezos into debug mode for logging

func (*GoTezos) GetAccountBalance

func (gt *GoTezos) GetAccountBalance(tezosAddr string) (float64, error)

GetAccountBalance gets the balance of a public key hash at a specific snapshot for a cycle.

func (*GoTezos) GetAccountBalanceAtBlock

func (gt *GoTezos) GetAccountBalanceAtBlock(tezosAddr string, hash string) (int, error)

GetAccountBalanceAtBlock get the balance of an address at a specific hash

func (*GoTezos) GetAccountBalanceAtSnapshot

func (gt *GoTezos) GetAccountBalanceAtSnapshot(tezosAddr string, cycle int) (float64, error)

GetAccountBalanceAtSnapshot gets the balance of a public key hash at a specific snapshot for a cycle.

func (*GoTezos) GetAllCurrentSnapShots

func (gt *GoTezos) GetAllCurrentSnapShots() ([]SnapShot, error)

GetAllCurrentSnapShots gets a list of all known snapshots to the network

func (*GoTezos) GetAllDelegates

func (gt *GoTezos) GetAllDelegates() ([]string, error)

GetAllDelegates a list of all tz1 addresses at the head block

func (*GoTezos) GetAllDelegatesByHash

func (gt *GoTezos) GetAllDelegatesByHash(hash string) ([]string, error)

GetAllDelegatesByHash gets a list of all tz1 addresses at a certain hash

func (*GoTezos) GetBakingRights

func (gt *GoTezos) GetBakingRights(cycle int) (BakingRights, error)

GetBakingRights gets the baking rights for a specific cycle

func (*GoTezos) GetBakingRightsForDelegate

func (gt *GoTezos) GetBakingRightsForDelegate(cycle int, delegatePhk string, priority int) (BakingRights, error)

GetBakingRightsForDelegate gets the baking rights for a delegate at a specific cycle with a certain priority level

func (*GoTezos) GetBakingRightsForDelegateForCycles

func (gt *GoTezos) GetBakingRightsForDelegateForCycles(cycleStart int, cycleEnd int, delegatePhk string, priority int) ([]BakingRights, error)

GetBakingRightsForDelegateForCycles gets the baking rights for a delegate at a range of cycles with a certain priority level

func (*GoTezos) GetBlockAtLevel

func (gt *GoTezos) GetBlockAtLevel(level int) (Block, error)

GetBlockAtLevel returns a Block at a specific level

func (*GoTezos) GetBlockByHash

func (gt *GoTezos) GetBlockByHash(hash string) (Block, error)

GetBlockByHash returns a Block by the identifier hash.

func (*GoTezos) GetBlockHashAtLevel

func (gt *GoTezos) GetBlockHashAtLevel(level int) (string, error)

GetBlockHashAtLevel returns the hash of a block at a specific level.

func (*GoTezos) GetBlockLevelHead

func (gt *GoTezos) GetBlockLevelHead() (int, string, error)

GetBlockLevelHead returns the level, and the hash, of the head block.

func (*GoTezos) GetBlockOperationHashes

func (gt *GoTezos) GetBlockOperationHashes(blockHash string) (OperationHashes, error)

GetBlockOperationHashes returns all the operation hashes at specific block hash

func (*GoTezos) GetBlockOperationHashesAtLevel

func (gt *GoTezos) GetBlockOperationHashesAtLevel(level int) (OperationHashes, error)

GetBlockOperationHashesAtLevel returns list of operations in block at specific level

func (*GoTezos) GetBlockOperationHashesHead

func (gt *GoTezos) GetBlockOperationHashesHead() (OperationHashes, error)

GetBlockOperationHashesHead returns list of operations in the head block

func (*GoTezos) GetBlockRawOperationHashes

func (gt *GoTezos) GetBlockRawOperationHashes(blockHash string) (RawOperationHashes, error)

GetBlockRawOperationHashes returns all the operation hashes at specific block hash as returned by RPC method

func (*GoTezos) GetBranchHash

func (gt *GoTezos) GetBranchHash() (string, error)

GetBranchHash returns the current branches hash

func (*GoTezos) GetBranchProtocol

func (gt *GoTezos) GetBranchProtocol() (string, error)

GetBranchProtocol returns the current Tezos protocol hash

func (*GoTezos) GetChainHead

func (gt *GoTezos) GetChainHead() (Block, error)

GetChainHead returns the head block from the Tezos RPC.

func (*GoTezos) GetChainID

func (gt *GoTezos) GetChainID() (string, error)

GetChainID gets the id of the chain with the most fitness

func (*GoTezos) GetContractBigMap

func (gt *GoTezos) GetContractBigMap(contract string, args MichelineExpr) ([]byte, error)

GetContractBigMap gets a contract big map value for a contract

func (*GoTezos) GetContractStorage

func (gt *GoTezos) GetContractStorage(contract string) ([]byte, error)

GetContractStorage gets the contract storage for a contract

func (*GoTezos) GetCurrentCycle

func (gt *GoTezos) GetCurrentCycle() (int, error)

GetCurrentCycle gets the current cycle of the chain

func (*GoTezos) GetCycleRewardsForDelegate

func (gt *GoTezos) GetCycleRewardsForDelegate(delegatePhk string, cycle int) (string, error)

GetCycleRewardsForDelegate gets the rewards earned by a delegate for a specific cycle.

func (*GoTezos) GetDelegate

func (gt *GoTezos) GetDelegate(delegatePhk string) (Delegate, error)

GetDelegate retrieves information about a delegate at the head block

func (*GoTezos) GetDelegateStakingBalance

func (gt *GoTezos) GetDelegateStakingBalance(delegateAddr string, cycle int) (float64, error)

GetDelegateStakingBalance gets the staking balance for a delegate at a specific snapshot for a cycle.

func (*GoTezos) GetDelegationsForDelegate

func (gt *GoTezos) GetDelegationsForDelegate(delegatePhk string) ([]string, error)

GetDelegationsForDelegate retrieves a list of all currently delegated contracts for a delegate.

func (*GoTezos) GetDelegationsForDelegateByCycle

func (gt *GoTezos) GetDelegationsForDelegateByCycle(delegatePhk string, cycle int) ([]string, error)

GetDelegationsForDelegateByCycle retrieves a list of all currently delegated contracts for a delegate at a specific cycle.

func (*GoTezos) GetEndorsingRights

func (gt *GoTezos) GetEndorsingRights(cycle int) (EndorsingRights, error)

GetEndorsingRights gets the endorsing rights for a specific cycle

func (*GoTezos) GetEndorsingRightsForDelegate

func (gt *GoTezos) GetEndorsingRightsForDelegate(cycle int, delegatePhk string) (EndorsingRights, error)

GetEndorsingRightsForDelegate gets the endorsing rights for a specific cycle

func (*GoTezos) GetEndorsingRightsForDelegateForCycles

func (gt *GoTezos) GetEndorsingRightsForDelegateForCycles(cycleStart int, cycleEnd int, delegatePhk string) ([]EndorsingRights, error)

GetEndorsingRightsForDelegateForCycles gets the endorsing rights for a delegate for a range of cycles

func (*GoTezos) GetNetworkConstants

func (gt *GoTezos) GetNetworkConstants() (NetworkConstants, error)

GetNetworkConstants gets the network constants for the Tezos network the client is using.

func (*GoTezos) GetNetworkVersions

func (gt *GoTezos) GetNetworkVersions() ([]NetworkVersion, error)

GetNetworkVersions gets the network versions of Tezos network the client is using.

func (*GoTezos) GetResponse

func (gt *GoTezos) GetResponse(path string, args string) (ResponseRaw, error)

GetResponse takes path endpoint and any arguments and returns the raw response of the query

func (*GoTezos) GetRewardsForDelegateForCycle

func (gt *GoTezos) GetRewardsForDelegateForCycle(delegatePhk string, cycle int, fee float64) (DelegateReport, error)

GetRewardsForDelegateForCycle gets the total rewards for a delegate earned and calculates the gross rewards earned by each delegation for a single cycle. Also includes the share of each delegation.

func (*GoTezos) GetShareOfContract

func (gt *GoTezos) GetShareOfContract(delegatePhk, delegationPhk string, cycle int) (float64, float64, error)

GetShareOfContract returns the share of a delegation for a specific cycle.

func (*GoTezos) GetSnapShot

func (gt *GoTezos) GetSnapShot(cycle int) (SnapShot, error)

GetSnapShot takes a cycle number and returns a helper structure describing a snap shot on the tezos network.

func (*GoTezos) GetStakingBalanceAtCycle

func (gt *GoTezos) GetStakingBalanceAtCycle(delegateAddr string, cycle int) (string, error)

GetStakingBalanceAtCycle gets the staking balance of a delegate at a specific cycle

func (*GoTezos) HandleResponse

func (gt *GoTezos) HandleResponse(method string, path string, args string) (ResponseRaw, error)

HandleResponse takes the method (GET/POST ... etc), the query path, any arguments, and returns the raw response of the query

func (*GoTezos) ImportEncryptedWallet

func (gt *GoTezos) ImportEncryptedWallet(pw, encKey string) (Wallet, error)

ImportEncryptedWallet imports an encrypted wallet using password provided by caller. Caller should remove any 'encrypted:' scheme prefix.

func (*GoTezos) ImportWallet

func (gt *GoTezos) ImportWallet(address, public, secret string) (Wallet, error)

ImportWallet returns an imported Wallet

func (*GoTezos) InjectOperation

func (gt *GoTezos) InjectOperation(op string) ([]byte, error)

InjectOperation injects an signed operation string and returns the response

func (*GoTezos) IsAlphanet

func (gt *GoTezos) IsAlphanet() bool

IsAlphanet checks whether the current network used is the IsAlphanet

func (*GoTezos) IsMainnet

func (gt *GoTezos) IsMainnet() bool

IsMainnet checks whether the current network used is the Mainnet

func (*GoTezos) IsZeronet

func (gt *GoTezos) IsZeronet() bool

IsZeronet checks whether the current network used is the IsZeronet

func (*GoTezos) PostResponse

func (gt *GoTezos) PostResponse(path string, args string) (ResponseRaw, error)

PostResponse takes path endpoint and any arguments and returns the raw response of the POST query

func (*GoTezos) SetLogger

func (gt *GoTezos) SetLogger(log *log.Logger)

SetLogger sets the logging functionality

func (*GoTezos) UseBalancerStrategyFailover

func (gt *GoTezos) UseBalancerStrategyFailover()

UseBalancerStrategyFailover tells the client side failover to use the balancer strategy

func (*GoTezos) UseBalancerStrategyRandom

func (gt *GoTezos) UseBalancerStrategyRandom()

UseBalancerStrategyRandom tells the client side failover to use the balancer random strategy

func (*GoTezos) WatchOperationReceipt

func (gt *GoTezos) WatchOperationReceipt(watchedOpHash string, receiptChannel chan<- StructOperations, logChannel chan<- error)

WatchOperationReceipt watches for maximum an hour every newly mined blocks and if it finds the wanted operation, it writes its receipt on a dedicated channel

type KeyPair

type KeyPair struct {
	PrivKey []byte
	PubKey  []byte
}

Key Pair Storage

type MichelineExpr

type MichelineExpr map[string]interface{}

MichelineExpr gather Michelson expressions

type NetworkConstants

type NetworkConstants struct {
	ProofOfWorkNonceSize         int      `json:"proof_of_work_nonce_size"`
	NonceLength                  int      `json:"nonce_length"`
	MaxRevelationsPerBlock       int      `json:"max_revelations_per_block"`
	MaxOperationDataLength       int      `json:"max_operation_data_length"`
	MaxProposalsPerDelegate      int      `json:"max_proposals_per_delegate"`
	PreservedCycles              int      `json:"preserved_cycles"`
	BlocksPerCycle               int      `json:"blocks_per_cycle"`
	BlocksPerCommitment          int      `json:"blocks_per_commitment"`
	BlocksPerRollSnapshot        int      `json:"blocks_per_roll_snapshot"`
	BlocksPerVotingPeriod        int      `json:"blocks_per_voting_period"`
	TimeBetweenBlocks            []string `json:"time_between_blocks"`
	EndorsersPerBlock            int      `json:"endorsers_per_block"`
	HardGasLimitPerOperation     string   `json:"hard_gas_limit_per_operation"`
	HardGasLimitPerBlock         string   `json:"hard_gas_limit_per_block"`
	ProofOfWorkThreshold         string   `json:"proof_of_work_threshold"`
	TokensPerRoll                string   `json:"tokens_per_roll"`
	MichelsonMaximumTypeSize     int      `json:"michelson_maximum_type_size"`
	SeedNonceRevelationTip       string   `json:"seed_nonce_revelation_tip"`
	OriginationSize              int      `json:"origination_size"`
	BlockSecurityDeposit         string   `json:"block_security_deposit"`
	EndorsementSecurityDeposit   string   `json:"endorsement_security_deposit"`
	BlockReward                  string   `json:"block_reward"`
	EndorsementReward            string   `json:"endorsement_reward"`
	CostPerByte                  string   `json:"cost_per_byte"`
	HardStorageLimitPerOperation string   `json:"hard_storage_limit_per_operation"`
}

NetworkConstants represents the network constants returned by the Tezos network.

func (*NetworkConstants) UnmarshalJSON

func (nc *NetworkConstants) UnmarshalJSON(v []byte) (NetworkConstants, error)

UnmarshalJSON unmarshals bytes received as a parameter, into the type NetworkConstants.

type NetworkVersion

type NetworkVersion struct {
	Name    string `json:"name"`
	Major   int    `json:"major"`
	Minor   int    `json:"minor"`
	Network string // Human readable network name
}

NetworkVersion represents the network version returned by the Tezos network.

type NetworkVersions

type NetworkVersions []NetworkVersion

NetworkVersions is an array of NetworkVersion

func (*NetworkVersions) UnmarshalJSON

func (nvs *NetworkVersions) UnmarshalJSON(v []byte) (NetworkVersions, error)

UnmarshalJSON unmarshals the bytes received as a parameter, into the type NetworkVersion.

type NoClientError

type NoClientError struct {
}

NoClientError is a helper structure for error handling

func (NoClientError) Error

func (gt NoClientError) Error() string

type OperationHashes

type OperationHashes []string

OperationHashes slice

func (*OperationHashes) UnmarshalJSON

func (oh *OperationHashes) UnmarshalJSON(v []byte) (OperationHashes, error)

UnmarshalJSON unmarhsels bytes into OperationHashes

type OperationResult

type OperationResult struct {
	Status string `json:"status"`
}

OperationResult is the metadata OperationResult found in the Contents in a operation of a block returned by the Tezos RPC API.

type Payment

type Payment struct {
	Address    string
	Amount     float64
	Parameters MichelineExpr
}

Payment is a helper struct for transfers

type RPCGenericError

type RPCGenericError struct {
	Kind  string `json:"kind"`
	Error string `json:"error"`
}

RPCGenericError is an Error helper for the RPC

type RPCGenericErrors

type RPCGenericErrors []RPCGenericError

RPCGenericErrors and array of RPCGenericErrors

func (*RPCGenericErrors) UnmarshalJSON

func (ge *RPCGenericErrors) UnmarshalJSON(v []byte) (RPCGenericErrors, error)

UnmarshalJSON unmarhsels bytes into RPCGenericErrors

type RawBlockHashes

type RawBlockHashes [][]string

slice of RawBlockHashes slice, as returned by GET /chains/<chain_id>/blocks

func (*RawBlockHashes) UnmarshalJSON

func (bh *RawBlockHashes) UnmarshalJSON(v []byte) (RawBlockHashes, error)

UnmarshalJSON unmarshals bytes into RawBlockHashes

type RawOperationHashes

type RawOperationHashes [][]string

slice of OperationHashes slice, as returned by GET /chains/<chain_id>/blocks/:block_ih/operation_hashes

func (*RawOperationHashes) UnmarshalJSON

func (bh *RawOperationHashes) UnmarshalJSON(v []byte) (RawOperationHashes, error)

UnmarshalJSON unmarshals bytes into RawOperationHashes

type ResponseRaw

type ResponseRaw struct {
	Bytes []byte
}

ResponseRaw represents a raw RPC/HTTP response

type SnapShot

type SnapShot struct {
	Cycle           int
	Number          int
	AssociatedHash  string
	AssociatedBlock int
}

SnapShot is a SnapShot on the Tezos Network.

type SnapShotQuery

type SnapShotQuery struct {
	RandomSeed   string `json:"random_seed"`
	RollSnapShot int    `json:"roll_snapshot"`
}

SnapShotQuery is a SnapShot returned by the Tezos RPC API.

func (*SnapShotQuery) UnmarshalJSON

func (sq *SnapShotQuery) UnmarshalJSON(v []byte) (SnapShotQuery, error)

UnmarshalJSON unmarshals the bytes received as a parameter, into the type SnapShotQuery.

type StructBalanceUpdates

type StructBalanceUpdates struct {
	Kind     string `json:"kind"`
	Contract string `json:"contract,omitempty"`
	Change   string `json:"change"`
	Category string `json:"category,omitempty"`
	Delegate string `json:"delegate,omitempty"`
	Level    int    `json:"level,omitempty"`
}

StructBalanceUpdates is the BalanceUpdates found in the Metadata of a block returned by the Tezos RPC API.

type StructContents

type StructContents struct {
	Kind             string           `json:"kind"`
	Source           string           `json:"source"`
	Fee              string           `json:"fee"`
	Counter          string           `json:"counter"`
	GasLimit         string           `json:"gas_limit"`
	StorageLimit     string           `json:"storage_limit"`
	Amount           string           `json:"amount"`
	Destination      string           `json:"destination"`
	Delegate         string           `json:"delegate"`
	Phk              string           `json:"phk"`
	Secret           string           `json:"secret"`
	Level            int              `json:"level"`
	ManagerPublicKey string           `json:"managerPubkey"`
	Balance          string           `json:"balance"`
	Metadata         ContentsMetadata `json:"metadata"`
}

StructContents is the Contents found in a operation of a block returned by the Tezos RPC API.

type StructHeader

type StructHeader struct {
	Level            int       `json:"level"`
	Proto            int       `json:"proto"`
	Predecessor      string    `json:"Predecessor"`
	Timestamp        time.Time `json:"timestamp"`
	ValidationPass   int       `json:"validation_pass"`
	OperationsHash   string    `json:"operations_hash"`
	Fitness          []string  `json:"fitness"`
	Context          string    `json:"context"`
	Priority         int       `json:"priority"`
	ProofOfWorkNonce string    `json:"proof_of_work_nonce"`
	Signature        string    `json:"signature"`
}

StructHeader is a header in a block returned by the Tezos RPC API.

type StructLevel

type StructLevel struct {
	Level                int  `json:"level"`
	LevelPosition        int  `json:"level_position"`
	Cycle                int  `json:"cycle"`
	CyclePosition        int  `json:"cycle_position"`
	VotingPeriod         int  `json:"voting_period"`
	VotingPeriodPosition int  `json:"voting_period_position"`
	ExpectedCommitment   bool `json:"expected_commitment"`
}

StructLevel the Level found in the Metadata of a block returned by the Tezos RPC API.

type StructMaxOperationListLength

type StructMaxOperationListLength struct {
	MaxSize int `json:"max_size"`
	MaxOp   int `json:"max_op,omitempty"`
}

StructMaxOperationListLength is the MaxOperationListLength found in the Metadata of a block returned by the Tezos RPC API.

type StructMetadata

type StructMetadata struct {
	Protocol               string                         `json:"protocol"`
	NextProtocol           string                         `json:"next_protocol"`
	TestChainStatus        StructTestChainStatus          `json:"test_chain_status"`
	MaxOperationsTTL       int                            `json:"max_operations_ttl"`
	MaxOperationDataLength int                            `json:"max_operation_data_length"`
	MaxBlockHeaderLength   int                            `json:"max_block_header_length"`
	MaxOperationListLength []StructMaxOperationListLength `json:"max_operation_list_length"`
	Baker                  string                         `json:"baker"`
	Level                  StructLevel                    `json:"level"`
	VotingPeriodKind       string                         `json:"voting_period_kind"`
	NonceHash              interface{}                    `json:"nonce_hash"`
	ConsumedGas            string                         `json:"consumed_gas"`
	Deactivated            []string                       `json:"deactivated"`
	BalanceUpdates         []StructBalanceUpdates         `json:"balance_updates"`
}

StructMetadata is the Metadata in a block returned by the Tezos RPC API.

type StructOperations

type StructOperations struct {
	Protocol  string           `json:"protocol"`
	ChainID   string           `json:"chain_id"`
	Hash      string           `json:"hash"`
	Branch    string           `json:"branch"`
	Contents  []StructContents `json:"contents"`
	Signature string           `json:"signature"`
}

StructOperations is the Operations found in a block returned by the Tezos RPC API.

func (*StructOperations) UnmarshalJSON

func (op *StructOperations) UnmarshalJSON(v []byte) (StructOperations, error)

UnmarshalJSON unmarshals bytes into StructOperations

type StructTestChainStatus

type StructTestChainStatus struct {
	Status string `json:"status"`
}

StructTestChainStatus is the TestChainStatus found in the Metadata of a block returned by the Tezos RPC API.

type TezClientWrapper

type TezClientWrapper struct {
	// contains filtered or unexported fields
}

TezClientWrapper is a wrapper for the TezosRPCClient

type TezosRPCClient

type TezosRPCClient struct {
	Host string
	Port string
	// contains filtered or unexported fields
}

TezosRPCClient is a struct to represent the client to reach a Tezos node

func NewTezosRPCClient

func NewTezosRPCClient(hostname string, port string) *TezosRPCClient

NewTezosRPCClient creates a new RPC client using the specified hostname and port. Also acceptable is the hostname of a web-endpoint that supports https.

func (*TezosRPCClient) GetResponse

func (gt *TezosRPCClient) GetResponse(method string, path string, args string) (ResponseRaw, error)

GetResponse gets the raw response using TezosRPCClient with the path and args to query

func (*TezosRPCClient) Healthcheck

func (gt *TezosRPCClient) Healthcheck() bool

Healthcheck a function just to perform a query to see if an RPC Client's endpoint is alive (heartbeat)

func (*TezosRPCClient) IsWebClient

func (gt *TezosRPCClient) IsWebClient(b bool)

IsWebClient tells the TezosRPCClient calling it that it is a web client

func (*TezosRPCClient) SetLogger

func (gt *TezosRPCClient) SetLogger(log *log.Logger)

SetLogger set the logger for the RPC Client

type TransOp

type TransOp struct {
	Kind         string        `json:"kind"`
	Amount       string        `json:"amount"`
	Source       string        `json:"source"`
	Destination  string        `json:"destination"`
	StorageLimit string        `json:"storage_limit"`
	GasLimit     string        `json:"gas_limit"`
	Fee          string        `json:"fee"`
	Counter      string        `json:"counter"`
	Parameters   MichelineExpr `json:"parameters"`
}

TransOp is a helper structure to build out a transfer operation to post to the Tezos RPC

type Transfer

type Transfer struct {
	Conts
	Protocol  string `json:"protocol"`
	Signature string `json:"signature"`
}

Transfer a complete transfer request

type Wallet

type Wallet struct {
	Address  string
	Mnemonic string
	Seed     []byte
	Kp       KeyPair
	Sk       string
	Pk       string
}

Wallet needed for signing operations

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL