Documentation ¶
Index ¶
- Constants
- type AccountService
- func (s *AccountService) CreateWallet(mnenomic string, password string) (Wallet, error)
- func (s *AccountService) GetBalance(tezosAddr string) (float64, error)
- func (s *AccountService) GetBalanceAtAssociatedSnapshotBlock(tezosAddr string, associatedBlockHash string) (float64, error)
- func (s *AccountService) GetBalanceAtBlock(tezosAddr string, id interface{}) (int, error)
- func (s *AccountService) GetBalanceAtSnapshot(tezosAddr string, cycle int) (float64, error)
- func (s *AccountService) ImportEncryptedWallet(pw, encKey string) (Wallet, error)
- func (s *AccountService) ImportWallet(address, public, secret string) (Wallet, error)
- type BakingRights
- type Block
- type BlockService
- type Bootstrap
- type Connections
- type ContentsMetadata
- type ContractService
- type Conts
- type CycleService
- type Delegate
- type DelegateReport
- type DelegateReportWithoutDelegations
- type DelegateService
- func (d *DelegateService) GetAllDelegates() ([]string, error)
- func (d *DelegateService) GetAllDelegatesByHash(hash string) ([]string, error)
- func (d *DelegateService) GetBakingRights(cycle int) (BakingRights, error)
- func (d *DelegateService) GetBakingRightsAtLevel(level, maxPriority int) (BakingRights, error)
- func (d *DelegateService) GetBakingRightsForDelegate(cycle int, delegatePkh string, priority int) (BakingRights, error)
- func (d *DelegateService) GetDelegate(delegatePkh string) (Delegate, error)
- func (d *DelegateService) GetDelegations(delegatePkh string) ([]string, error)
- func (d *DelegateService) GetDelegationsAtCycle(delegatePkh string, cycle int) ([]string, error)
- func (d *DelegateService) GetEndorsingRights(cycle int) (EndorsingRights, error)
- func (d *DelegateService) GetEndorsingRightsAtLevel(level int) (EndorsingRights, error)
- func (d *DelegateService) GetEndorsingRightsForDelegate(cycle int, delegatePkh string) (EndorsingRights, error)
- func (d *DelegateService) GetReport(delegatePkh string, cycle int, fee float64) (*DelegateReport, error)
- func (d *DelegateService) GetReportWithoutDelegations(delegatePkh string, cycle int) (*DelegateReportWithoutDelegations, error)
- func (d *DelegateService) GetRewards(delegatePkh string, cycle int) (FrozenBalanceRewards, error)
- func (d *DelegateService) GetStakingBalance(delegateAddr string, cycle int) (float64, error)
- func (d *DelegateService) GetStakingBalanceAtCycle(address string, cycle int) (string, error)
- type DelegationReport
- type EndorsingRights
- type FrozenBalance
- type FrozenBalanceRewards
- type GoTezos
- type NetworkConstants
- type NetworkService
- type NetworkVersion
- type NetworkVersions
- type NodeService
- type OperationService
- type Payment
- type SnapShot
- type SnapShotQuery
- type SnapShotService
- type StructBalanceUpdates
- type StructContents
- type StructHeader
- type StructLevel
- type StructMaxOperationListLength
- type StructMetadata
- type StructOperations
- type StructTestChainStatus
- type Transfer
- type Wallet
Constants ¶
const MUTEZ = 1000000
MUTEZ is a helper for balance devision
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccountService ¶
type AccountService struct {
// contains filtered or unexported fields
}
AccountService is a struct wrapper for account functions
func (*AccountService) CreateWallet ¶
func (s *AccountService) CreateWallet(mnenomic string, password string) (Wallet, error)
CreateWallet returns Wallet with the mnemonic and password provided
func (*AccountService) GetBalance ¶
func (s *AccountService) GetBalance(tezosAddr string) (float64, error)
GetBalance gets the balance of a public key hash at a specific snapshot for a cycle.
func (*AccountService) GetBalanceAtAssociatedSnapshotBlock ¶
func (s *AccountService) GetBalanceAtAssociatedSnapshotBlock(tezosAddr string, associatedBlockHash string) (float64, error)
GetBalanceAtAssociatedSnapshotBlock gets the balance of a contract at a associated snapshot block.
func (*AccountService) GetBalanceAtBlock ¶
func (s *AccountService) GetBalanceAtBlock(tezosAddr string, id interface{}) (int, error)
GetBalanceAtBlock get the balance of an address at a specific hash
func (*AccountService) GetBalanceAtSnapshot ¶
func (s *AccountService) GetBalanceAtSnapshot(tezosAddr string, cycle int) (float64, error)
GetBalanceAtSnapshot gets the balance of a public key hash at a specific snapshot for a cycle.
func (*AccountService) ImportEncryptedWallet ¶
func (s *AccountService) ImportEncryptedWallet(pw, encKey string) (Wallet, error)
ImportEncryptedWallet imports an encrypted wallet using password provided by caller. Caller should remove any 'encrypted:' scheme prefix.
func (*AccountService) ImportWallet ¶
func (s *AccountService) ImportWallet(address, public, secret string) (Wallet, error)
ImportWallet returns an imported Wallet
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
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) CalculateBlockFees ¶
CalculateBlockFees returns the fees from a block
type BlockService ¶
type BlockService struct {
// contains filtered or unexported fields
}
BlockService is a struct wrapper for all block functions
func (*BlockService) Get ¶
func (b *BlockService) Get(id interface{}) (Block, error)
Get returns a Block at a specific level or hash
func (*BlockService) GetHead ¶
func (b *BlockService) GetHead() (Block, error)
GetHead returns the head block
func (*BlockService) IDToString ¶
func (b *BlockService) IDToString(id interface{}) (string, error)
IDToString returns a queryable block reference for a specific level or hash
type Connections ¶
type Connections []struct { Incoming bool `json:"incoming"` PeerID string `json:"peer_id"` IDPoint struct { Addr string `json:"addr"` Port int `json:"port"` } `json:"id_point"` RemoteSocketPort int `json:"remote_socket_port"` Versions []struct { Name string `json:"name"` Major int `json:"major"` Minor int `json:"minor"` } `json:"versions"` Private bool `json:"private"` LocalMetadata struct { DisableMempool bool `json:"disable_mempool"` PrivateNode bool `json:"private_node"` } `json:"local_metadata"` RemoteMetadata struct { DisableMempool bool `json:"disable_mempool"` PrivateNode bool `json:"private_node"` } `json:"remote_metadata"` }
Connections represents network connections
type ContentsMetadata ¶
type ContentsMetadata struct { BalanceUpdates []StructBalanceUpdates `json:"balance_updates"` Slots []int `json:"slots,omitempty"` Delegate string `json:"delegate,omitempty"` }
ContentsMetadata is the Metadata found in the Contents in a operation of a block returned by the Tezos RPC API.
func (*ContentsMetadata) GetRewards ¶
func (metadata *ContentsMetadata) GetRewards() (int, error)
GetRewards returns the rewards from a StructMetadata of the operation contents
type ContractService ¶
type ContractService struct {
// contains filtered or unexported fields
}
ContractService is a struct wrapper for contract functions
func (*ContractService) GetStorage ¶
func (s *ContractService) GetStorage(contract string) ([]byte, error)
GetStorage gets the contract storage for a contract
type Conts ¶
type Conts struct { Contents []StructContents `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
type CycleService ¶
type CycleService struct {
// contains filtered or unexported fields
}
CycleService is a struct wrapper for cycle functions
func (*CycleService) GetCurrent ¶
func (s *CycleService) GetCurrent() (int, error)
GetCurrent gets the current cycle of the chain
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
type DelegateReport ¶
type DelegateReport struct { DelegatePkh string `json:"delegate_pkh"` Cycle int `json:"cycle"` Delegations []DelegationReport Rewards string `json:"rewards"` Fees string `json:"fees"` TotalFeeRewards string `json:"total_fee_rewards"` SelfBakedRewards string `json:"self_rewards"` TotalRewards string `json:"total_rewards"` }
DelegateReport represents a rewards report for a delegate and all their delegations for a cycle
func (*DelegateReport) GetPayments ¶
func (dr *DelegateReport) GetPayments(minimum int) []Payment
GetPayments will convert a delegate report into payments for batch pay with a minimum requirement in mutez
type DelegateReportWithoutDelegations ¶
type DelegateReportWithoutDelegations struct { DelegatePkh string `json:"delegate_pkh"` Cycle int `json:"cycle"` TotalDelegations int `json:"total_delegators"` Rewards string `json:"rewards"` Fees string `json:"fees"` StakingBalance string `json:"staking_balance"` }
DelegateReportWithoutDelegations represents a rewards report for a delegate for a cycle without the delegations
type DelegateService ¶
type DelegateService struct {
// contains filtered or unexported fields
}
DelegateService is a struct wrapper for delegate related functions
func (*DelegateService) GetAllDelegates ¶
func (d *DelegateService) GetAllDelegates() ([]string, error)
GetAllDelegates a list of all tz1 addresses at the head block
func (*DelegateService) GetAllDelegatesByHash ¶
func (d *DelegateService) GetAllDelegatesByHash(hash string) ([]string, error)
GetAllDelegatesByHash gets a list of all tz1 addresses at a certain hash
func (*DelegateService) GetBakingRights ¶
func (d *DelegateService) GetBakingRights(cycle int) (BakingRights, error)
GetBakingRights gets the baking rights for a specific cycle
func (*DelegateService) GetBakingRightsAtLevel ¶
func (d *DelegateService) GetBakingRightsAtLevel(level, maxPriority int) (BakingRights, error)
GetBakingRightsAtLevel gets the baking rights for a specific Level
func (*DelegateService) GetBakingRightsForDelegate ¶
func (d *DelegateService) GetBakingRightsForDelegate(cycle int, delegatePkh string, priority int) (BakingRights, error)
GetBakingRightsForDelegate gets the baking rights for a delegate at a specific cycle with a certain priority level
func (*DelegateService) GetDelegate ¶
func (d *DelegateService) GetDelegate(delegatePkh string) (Delegate, error)
GetDelegate retrieves information about a delegate at the head block
func (*DelegateService) GetDelegations ¶
func (d *DelegateService) GetDelegations(delegatePkh string) ([]string, error)
GetDelegations retrieves a list of all currently delegated contracts for a delegate.
func (*DelegateService) GetDelegationsAtCycle ¶
func (d *DelegateService) GetDelegationsAtCycle(delegatePkh string, cycle int) ([]string, error)
GetDelegationsAtCycle retrieves a list of all currently delegated contracts for a delegate at a specific cycle.
func (*DelegateService) GetEndorsingRights ¶
func (d *DelegateService) GetEndorsingRights(cycle int) (EndorsingRights, error)
GetEndorsingRights gets the endorsing rights for a specific cycle
func (*DelegateService) GetEndorsingRightsAtLevel ¶
func (d *DelegateService) GetEndorsingRightsAtLevel(level int) (EndorsingRights, error)
GetEndorsingRightsAtLevel gets the endorsing rights for a specific Level
func (*DelegateService) GetEndorsingRightsForDelegate ¶
func (d *DelegateService) GetEndorsingRightsForDelegate(cycle int, delegatePkh string) (EndorsingRights, error)
GetEndorsingRightsForDelegate gets the endorsing rights for a specific cycle
func (*DelegateService) GetReport ¶
func (d *DelegateService) GetReport(delegatePkh string, cycle int, fee float64) (*DelegateReport, error)
GetReport 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 (*DelegateService) GetReportWithoutDelegations ¶
func (d *DelegateService) GetReportWithoutDelegations(delegatePkh string, cycle int) (*DelegateReportWithoutDelegations, error)
GetReportWithoutDelegations gets the total rewards earned by a delegate for a cycle.
func (*DelegateService) GetRewards ¶
func (d *DelegateService) GetRewards(delegatePkh string, cycle int) (FrozenBalanceRewards, error)
GetRewards gets the rewards earned by a delegate for a specific cycle.
func (*DelegateService) GetStakingBalance ¶
func (d *DelegateService) GetStakingBalance(delegateAddr string, cycle int) (float64, error)
GetStakingBalance gets the staking balance for a delegate at a specific snapshot for a cycle.
func (*DelegateService) GetStakingBalanceAtCycle ¶
func (d *DelegateService) GetStakingBalanceAtCycle(address string, cycle int) (string, error)
GetStakingBalanceAtCycle gets the staking balance of a delegate at a specific cycle
type DelegationReport ¶
type DelegationReport struct { DelegationPkh string `json:"delegation_pkh"` Balance float64 `json:"balance"` GrossRewards string `json:"gross_rewards"` Fee string `json:"fee"` NetRewards string `json:"net_rewards"` }
DelegationReport represents a rewards report for a delegation in DelegateReport
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
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
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.
type GoTezos ¶
type GoTezos struct { Constants NetworkConstants Block *BlockService SnapShot *SnapShotService Cycle *CycleService Account *AccountService Delegate *DelegateService Network *NetworkService Operation *OperationService Contract *ContractService Node *NodeService // contains filtered or unexported fields }
GoTezos is the driver of the library, it inludes the several RPC services like Block, SnapSHot, Cycle, Account, Delegate, Operations, Contract, and Network
func NewGoTezos ¶
NewGoTezos is a constructor that returns a GoTezos object
func (*GoTezos) Post ¶
Post takes path endpoint and any arguments and returns the response of the POST
func (*GoTezos) SetHTTPClient ¶
SetHTTPClient allows you to pass your own Go http client, with your own settings
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.
type NetworkService ¶
type NetworkService struct {
// contains filtered or unexported fields
}
NetworkService is wrapper representing network functions
func (*NetworkService) Connections ¶
func (n *NetworkService) Connections() (Connections, error)
Connections gets the network connections
func (*NetworkService) GetChainID ¶
func (n *NetworkService) GetChainID() (string, error)
GetChainID gets the id of the chain with the most fitness
func (*NetworkService) GetConstants ¶
func (n *NetworkService) GetConstants() (NetworkConstants, error)
GetConstants gets the network constants for the Tezos network the client is using.
func (*NetworkService) GetVersions ¶
func (n *NetworkService) GetVersions() ([]NetworkVersion, error)
GetVersions gets the network versions of Tezos network the client is using.
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
type NodeService ¶
type NodeService struct {
// contains filtered or unexported fields
}
NodeService is a service for node related functions
func (*NodeService) Bootstrapped ¶
func (n *NodeService) Bootstrapped() (Bootstrap, error)
Bootstrapped gets the current node bootstrap
func (*NodeService) CommitHash ¶
func (n *NodeService) CommitHash() (string, error)
CommitHash gets the current commit the node is running
func (*NodeService) MonitorHeads ¶
func (n *NodeService) MonitorHeads(chain string, heads chan StructHeader, errc chan error, done chan bool)
MonitorHeads gets the new Head of the chain every time it changes
type OperationService ¶
type OperationService struct {
// contains filtered or unexported fields
}
OperationService is a struct wrapper for operation related functions
func (*OperationService) CreateBatchPayment ¶
func (o *OperationService) CreateBatchPayment(payments []Payment, wallet Wallet, paymentFee int, gaslimit int) ([]string, error)
CreateBatchPayment forges batch payments and returns them ready to inject to a Tezos RPC. PaymentFee must be expressed in mutez.
func (*OperationService) GetBlockOperationHashes ¶
func (o *OperationService) GetBlockOperationHashes(id interface{}) ([]string, error)
GetBlockOperationHashes returns list of operations in block at specific level
func (*OperationService) InjectOperation ¶
func (o *OperationService) InjectOperation(op string) ([]byte, error)
InjectOperation injects an signed operation string and returns the response
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.
type SnapShotService ¶
type SnapShotService struct {
// contains filtered or unexported fields
}
SnapShotService is a struct wrapper for snap shot functions
func (*SnapShotService) Get ¶
func (s *SnapShotService) Get(cycle int) (SnapShot, error)
Get takes a cycle number and returns a helper structure describing a snap shot on the tezos network.
func (*SnapShotService) GetAll ¶
func (s *SnapShotService) GetAll() ([]SnapShot, error)
GetAll gets a list of all known snapshots to the network
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"` Cycle int `json:"cycle,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,omitempty"` Source string `json:"source,omitempty"` Fee string `json:"fee,omitempty"` Counter string `json:"counter,omitempty"` GasLimit string `json:"gas_limit,omitempty"` StorageLimit string `json:"storage_limit,omitempty"` Amount string `json:"amount,omitempty"` Destination string `json:"destination,omitempty"` Delegate string `json:"delegate,omitempty"` Phk string `json:"phk,omitempty"` Secret string `json:"secret,omitempty"` Level int `json:"level,omitempty"` ManagerPublicKey string `json:"managerPubkey,omitempty"` Balance string `json:"balance,omitempty"` Period int `json:"period,omitempty"` Proposal string `json:"proposal,omitempty"` Proposals []string `json:"proposals,omitempty"` Ballot string `json:"ballot,omitempty"` Metadata *ContentsMetadata `json:"metadata,omitempty"` }
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.
func UnmarshalBlockHeader ¶
func UnmarshalBlockHeader(v []byte) (StructHeader, error)
UnmarshalBlockHeader unmarshals the bytes received as a parameter, into the type BlockHeader.
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.
func (*StructMetadata) GetRewards ¶
func (metadata *StructMetadata) GetRewards() (int, error)
GetRewards returns the rewards from a StructMetadata of a block
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.
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.