tezos

package module
Version: v0.0.0-...-5c56789 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2020 License: MIT Imports: 17 Imported by: 4

README

go-tezos

go-tezos is a Go client library that is used to interact with a Tezos' nodes RPC methods.

CII Best Practices GitHub Actions Maintainability Test Coverage

Work in progress, contributions welcome.

This client RPC library is in development and should be considered alpha. Contributors are welcome. We will start to tag releases of this library in November 2018.

The library will be useful to anyone wanting to build tools, products or services on top of the Tezos RPC API in go.

The library will be:

  • Well tested
  • Nightly Integration tests against official Tezos docker images
  • Written in Idiomatic Go
  • Aim to have complete coverage of the Tezos API and stay up to date with new RPCs or changes to existing RPCs

Documentation

Library documentation lives in the code as godoc comments. Readers can view up-to-date documentation here: https://godoc.org/github.com/ecadlabs/go-tezos

Contributions

Reporting issues/feature requests

Please use the GitHub issue tracker to report bugs or request features.

Contribution

To contribute, please check the issue tracker to see if an existing issue exists for your planned contribution. If there's no Issue, please create one first, and then submit a pull request with your contribution.

For a contribution to be merged, it must be well documented, come with unit tests, and integration tests where appropriate. Submitting a "Work in progress" pull request is welcome!

Reporting Security Issues

If a security vulnerabiltiy in this project is discovered, please report the issue to go-tezos@ecadlabs.com or to jevonearth on keybase.io

Reports may be encrypted using keys published on keybase.io

Tezos RPC API documentation

The best known RPC API docs are available here: http://tezos.gitlab.io/mainnet/

Users of go-tezos

Development

Running a tezos RPC node using docker-compose

To run a local tezos RPC node using docker, run the following command:

docker-compose up

The node will generate an identity and then, it will the chain from other nodes on the network. The process of synchronizing or downloading the chain can take some time, but most of the RPC will work while this process completes.

The alphanet image tag means you are not interacting with the live mainnet. You can connect to mainnet with the tezos/tezos:mainnet image, but it takes longer to sync.

The docker-compose.yml file uses volumes, so when you restart the node, it won't have to regenerate an identity, or sync the entire chain.

Running a tezos RPC node using docker

If you want to run a tezos node quickly, without using docker-compose try:

docker run -it --rm --name tezos_node -p 8732:8732 tezos/tezos:alphanet tezos-node

Interacting with tezos RPC

With the tezos-node docker image, you can test that the RPC interface is working:

curl localhost:8732/network/stat

The tezos-client cli is available in the docker image, and can be run as follows:

docker exec -it tezos_node tezos-client -A 0.0.0.0 man

docker exec -it tezos_node tezos-client -A 0.0.0.0 rpc list

Create a shell alias that you can run from your docker host for convenience;

alias tezos-client='sudo docker exec -it -e TEZOS_CLIENT_UNSAFE_DISABLE_DISCLAIMER=Y tezos_node tezos-client -A 0.0.0.0'

Documentation

Index

Constants

View Source
const (
	// ErrorKindPermanent Tezos RPC error kind.
	ErrorKindPermanent = "permanent"
	// ErrorKindTemporary Tezos RPC error kind.
	ErrorKindTemporary = "temporary"
	// ErrorKindBranch Tezos RPC error kind.
	ErrorKindBranch = "branch"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ActivateAccountOperationElem

type ActivateAccountOperationElem struct {
	GenericOperationElem `yaml:",inline"`
	PKH                  string                          `json:"pkh" yaml:"pkh"`
	Secret               string                          `json:"secret" yaml:"secret"`
	Metadata             BalanceUpdatesOperationMetadata `json:"metadata" yaml:"metadata"`
}

ActivateAccountOperationElem represents activate_account operation

func (*ActivateAccountOperationElem) BalanceUpdates

func (el *ActivateAccountOperationElem) BalanceUpdates() BalanceUpdates

BalanceUpdates implements BalanceUpdateOperation

type BalanceUpdate

type BalanceUpdate interface {
	BalanceUpdateKind() string
}

BalanceUpdate is a variable structure depending on the Kind field

type BalanceUpdates

type BalanceUpdates []BalanceUpdate

BalanceUpdates is a list of balance update operations

func (*BalanceUpdates) UnmarshalJSON

func (b *BalanceUpdates) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler

type BalanceUpdatesOperation

type BalanceUpdatesOperation interface {
	BalanceUpdates() BalanceUpdates
}

BalanceUpdatesOperation is implemented by operations providing balance updates

type BalanceUpdatesOperationMetadata

type BalanceUpdatesOperationMetadata struct {
	BalanceUpdates BalanceUpdates `json:"balance_updates" yaml:"balance_updates"`
}

BalanceUpdatesOperationMetadata contains balance updates only

type Ballot

type Ballot struct {
	PKH    string `json:"pkh" yaml:"pkh"`
	Ballot string `json:"ballot" yaml:"ballot"`
}

Ballot holds information about a Tezos ballot

type BallotListing

type BallotListing struct {
	PKH   string `json:"pkh" yaml:"pkh"`
	Rolls int64  `json:"rolls" yaml:"rolls"`
}

BallotListing holds information about a Tezos delegate and his voting weight in rolls

type BallotOperationElem

type BallotOperationElem struct {
	GenericOperationElem `yaml:",inline"`
	Source               string                 `json:"source" yaml:"source"`
	Period               int                    `json:"period" yaml:"period"`
	Proposal             string                 `json:"proposal" yaml:"proposal"`
	Ballot               string                 `json:"ballot" yaml:"ballot"`
	Metadata             map[string]interface{} `json:"metadata" yaml:"metadata"`
}

BallotOperationElem represents a ballot operation

type Ballots

type Ballots struct {
	Yay  int64 `json:"yay" yaml:"yay"`
	Nay  int64 `json:"nay" yaml:"nay"`
	Pass int64 `json:"pass" yaml:"pass"`
}

Ballots holds summary data about a voting period

type BigInt

type BigInt struct {
	big.Int
}

BigInt overrides UnmarshalJSON for big.Int

func (*BigInt) MarshalYAML

func (z *BigInt) MarshalYAML() (interface{}, error)

MarshalYAML implements yaml.Marshaler

func (*BigInt) UnmarshalJSON

func (z *BigInt) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler

type Block

type Block struct {
	Protocol   string              `json:"protocol" yaml:"protocol"`
	ChainID    string              `json:"chain_id" yaml:"chain_id"`
	Hash       string              `json:"hash" yaml:"hash"`
	Header     RawBlockHeader      `json:"header" yaml:"header"`
	Metadata   BlockHeaderMetadata `json:"metadata" yaml:"metadata"`
	Operations [][]*Operation      `json:"operations" yaml:"operations"`
}

Block holds information about a Tezos block

type BlockHeaderMetadata

type BlockHeaderMetadata struct {
	Protocol               string                    `json:"protocol" yaml:"protocol"`
	NextProtocol           string                    `json:"next_protocol" yaml:"next_protocol"`
	TestChainStatus        TestChainStatus           `json:"-" yaml:"-"`
	MaxOperationsTTL       int                       `json:"max_operations_ttl" yaml:"max_operations_ttl"`
	MaxOperationDataLength int                       `json:"max_operation_data_length" yaml:"max_operation_data_length"`
	MaxBlockHeaderLength   int                       `json:"max_block_header_length" yaml:"max_block_header_length"`
	MaxOperationListLength []*MaxOperationListLength `json:"max_operation_list_length" yaml:"max_operation_list_length"`
	Baker                  string                    `json:"baker" yaml:"baker"`
	Level                  BlockHeaderMetadataLevel  `json:"level" yaml:"level"`
	VotingPeriodKind       string                    `json:"voting_period_kind" yaml:"voting_period_kind"`
	NonceHash              string                    `json:"nonce_hash" yaml:"nonce_hash"`
	ConsumedGas            *BigInt                   `json:"consumed_gas" yaml:"consumed_gas"`
	Deactivated            []string                  `json:"deactivated" yaml:"deactivated"`
	BalanceUpdates         BalanceUpdates            `json:"balance_updates" yaml:"balance_updates"`
}

BlockHeaderMetadata is a part of the Tezos block data

func (*BlockHeaderMetadata) UnmarshalJSON

func (bhm *BlockHeaderMetadata) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals the BlockHeaderMetadata JSON

type BlockHeaderMetadataLevel

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

BlockHeaderMetadataLevel is a part of BlockHeaderMetadata

type BlockInfo

type BlockInfo struct {
	Hash           string     `json:"hash" yaml:"hash"`
	Level          int        `json:"level" yaml:"level"`
	Proto          int        `json:"proto" yaml:"proto"`
	Predecessor    string     `json:"predecessor" yaml:"predecessor"`
	Timestamp      time.Time  `json:"timestamp" yaml:"timestamp"`
	ValidationPass int        `json:"validation_pass" yaml:"validation_pass"`
	OperationsHash string     `json:"operations_hash" yaml:"operations_hash"`
	Fitness        []HexBytes `json:"fitness" yaml:"fitness,flow"`
	Context        string     `json:"context" yaml:"context"`
	ProtocolData   string     `json:"protocol_data" yaml:"protocol_data"`
}

BlockInfo holds information about block returned by monitor heads endpoint

type BootstrappedBlock

type BootstrappedBlock struct {
	Block     string    `json:"block"`
	Timestamp time.Time `json:"timestamp"`
}

BootstrappedBlock represents bootstrapped block stream message

type ContractBalanceUpdate

type ContractBalanceUpdate struct {
	GenericBalanceUpdate `yaml:",inline"`
	Contract             string `json:"contract" yaml:"contract"`
}

ContractBalanceUpdate is a BalanceUpdatesType variant for Kind=contract

type DelegationOperationElem

type DelegationOperationElem struct {
	GenericOperationElem `yaml:",inline"`
	Source               string                      `json:"source" yaml:"source"`
	Fee                  *BigInt                     `json:"fee" yaml:"fee"`
	Counter              *BigInt                     `json:"counter" yaml:"counter"`
	GasLimit             *BigInt                     `json:"gas_limit" yaml:"gas_limit"`
	StorageLimit         *BigInt                     `json:"storage_limit" yaml:"storage_limit"`
	ManagerPubKey        string                      `json:"managerPubkey" yaml:"managerPubkey"`
	Balance              *BigInt                     `json:"balance" yaml:"balance"`
	Spendable            *bool                       `json:"spendable,omitempty" yaml:"spendable,omitempty"`
	Delegatable          *bool                       `json:"delegatable,omitempty" yaml:"delegatable,omitempty"`
	Delegate             string                      `json:"delegate,omitempty" yaml:"delegate,omitempty"`
	Script               *ScriptedContracts          `json:"script,omitempty" yaml:"script,omitempty"`
	Metadata             DelegationOperationMetadata `json:"metadata" yaml:"metadata"`
}

DelegationOperationElem represents a delegation operation

func (*DelegationOperationElem) BalanceUpdates

func (el *DelegationOperationElem) BalanceUpdates() BalanceUpdates

BalanceUpdates implements BalanceUpdateOperation

func (*DelegationOperationElem) OperationFee

func (el *DelegationOperationElem) OperationFee() *big.Int

OperationFee implements OperationWithFee

type DelegationOperationMetadata

type DelegationOperationMetadata struct {
	BalanceUpdates  BalanceUpdates            `json:"balance_updates" yaml:"balance_updates"`
	OperationResult DelegationOperationResult `json:"operation_result" yaml:"operation_result"`
}

DelegationOperationMetadata represents a delegation operation metadata

type DelegationOperationResult

type DelegationOperationResult struct {
	Status string `json:"status" yaml:"status"`
	Errors Errors `json:"errors" yaml:"errors"`
}

DelegationOperationResult represents a delegation operation result

type DoubleBakingEvidenceOperationElem

type DoubleBakingEvidenceOperationElem struct {
	GenericOperationElem `yaml:",inline"`
	BlockHeader1         RawBlockHeader                  `json:"bh1" yaml:"bh1"`
	BlockHeader2         RawBlockHeader                  `json:"bh2" yaml:"bh2"`
	Metadata             BalanceUpdatesOperationMetadata `json:"metadata" yaml:"metadata"`
}

DoubleBakingEvidenceOperationElem represents double_baking_evidence operation

func (*DoubleBakingEvidenceOperationElem) BalanceUpdates

BalanceUpdates implements BalanceUpdateOperation

type DoubleEndorsementEvidenceOperationElem

type DoubleEndorsementEvidenceOperationElem struct {
	GenericOperationElem `yaml:",inline"`
	Operation1           InlinedEndorsement              `json:"op1" yaml:"op1"`
	Operation2           InlinedEndorsement              `json:"op2" yaml:"op2"`
	Metadata             BalanceUpdatesOperationMetadata `json:"metadata" yaml:"metadata"`
}

DoubleEndorsementEvidenceOperationElem represents double_endorsement_evidence operation

func (*DoubleEndorsementEvidenceOperationElem) BalanceUpdates

BalanceUpdates implements BalanceUpdateOperation

type EndorsementOperationElem

type EndorsementOperationElem struct {
	GenericOperationElem `yaml:",inline"`
	Level                int                          `json:"level" yaml:"level"`
	Metadata             EndorsementOperationMetadata `json:"metadata" yaml:"metadata"`
}

EndorsementOperationElem represents an endorsement operation

func (*EndorsementOperationElem) BalanceUpdates

func (el *EndorsementOperationElem) BalanceUpdates() BalanceUpdates

BalanceUpdates implements BalanceUpdateOperation

type EndorsementOperationMetadata

type EndorsementOperationMetadata struct {
	BalanceUpdates BalanceUpdates `json:"balance_updates" yaml:"balance_updates"`
	Delegate       string         `json:"delegate" yaml:"delegate"`
	Slots          []int          `json:"slots" yaml:"slots,flow"`
}

EndorsementOperationMetadata represents an endorsement operation metadata

type Error

type Error interface {
	error
	ErrorID() string
	ErrorKind() string
}

Error is a Tezos error as documented on http://tezos.gitlab.io/mainnet/api/errors.html.

type Errors

type Errors []Error

Errors is a slice of Error with custom JSON unmarshaller

func (Errors) Error

func (e Errors) Error() string

func (Errors) ErrorID

func (e Errors) ErrorID() string

ErrorID returns Tezos error id

func (Errors) ErrorKind

func (e Errors) ErrorKind() string

ErrorKind returns Tezos error kind

func (*Errors) UnmarshalJSON

func (e *Errors) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler

type ForkingTestChainStatus

type ForkingTestChainStatus struct {
	GenericTestChainStatus
	Protocol   string `json:"protocol" yaml:"protocol"`
	Expiration string `json:"expiration" yaml:"expiration"`
}

ForkingTestChainStatus is a TestChainStatus variant for Status=forking

type FreezerBalanceUpdate

type FreezerBalanceUpdate struct {
	GenericBalanceUpdate `yaml:",inline"`
	Category             string `json:"category" yaml:"category"`
	Delegate             string `json:"delegate" yaml:"delegate"`
	Level                int    `json:"level" yaml:"level"`
}

FreezerBalanceUpdate is a BalanceUpdatesType variant for Kind=freezer

type GenericBalanceUpdate

type GenericBalanceUpdate struct {
	Kind   string `json:"kind" yaml:"kind"`
	Change int64  `json:"change,string" yaml:"change"`
}

GenericBalanceUpdate holds the common values among all BalanceUpdatesType variants

func (*GenericBalanceUpdate) BalanceUpdateKind

func (g *GenericBalanceUpdate) BalanceUpdateKind() string

BalanceUpdateKind returns the BalanceUpdateType's Kind field

type GenericError

type GenericError struct {
	ID   string `json:"id"`
	Kind string `json:"kind"`
}

GenericError is a basic error type

func (*GenericError) Error

func (e *GenericError) Error() string

func (*GenericError) ErrorID

func (e *GenericError) ErrorID() string

ErrorID returns Tezos error id

func (*GenericError) ErrorKind

func (e *GenericError) ErrorKind() string

ErrorKind returns Tezos error kind

type GenericOperationElem

type GenericOperationElem struct {
	Kind string `json:"kind" yaml:"kind"`
}

GenericOperationElem is a most generic element type

func (*GenericOperationElem) OperationElemKind

func (e *GenericOperationElem) OperationElemKind() string

OperationElemKind implements OperationElem

type GenericTestChainStatus

type GenericTestChainStatus struct {
	Status string `json:"status" yaml:"status"`
}

GenericTestChainStatus holds the common values among all TestChainStatus variants

func (*GenericTestChainStatus) TestChainStatus

func (t *GenericTestChainStatus) TestChainStatus() string

TestChainStatus gets the TestChainStatus's Status field

type HTTPError

type HTTPError interface {
	error
	HTTPStatus
}

HTTPError retains HTTP status

type HTTPStatus

type HTTPStatus interface {
	Response() *http.Response
	Status() string  // e.g. "200 OK"
	StatusCode() int // e.g. 200
	Body() []byte
}

HTTPStatus interface represents an unprocessed HTTP reply

type HexBytes

type HexBytes []byte

HexBytes represents bytes as a JSON string of hexadecimal digits

func (*HexBytes) UnmarshalText

func (hb *HexBytes) UnmarshalText(data []byte) error

UnmarshalText umarshalls a hex string to bytes

type IDTimestamp

type IDTimestamp struct {
	ID        string
	Timestamp time.Time
}

IDTimestamp represents peer id with timestamp

func (*IDTimestamp) UnmarshalJSON

func (i *IDTimestamp) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler

type InlinedEndorsement

type InlinedEndorsement struct {
	Branch     string                     `json:"branch" yaml:"branch"`
	Operations InlinedEndorsementContents `json:"operations" yaml:"operations"`
	Signature  string                     `json:"signature" yaml:"signature"`
}

InlinedEndorsement corresponds to $inlined.endorsement

type InlinedEndorsementContents

type InlinedEndorsementContents struct {
	Kind  string `json:"endorsement" yaml:"endorsement"`
	Level int    `json:"level" yaml:"level"`
}

InlinedEndorsementContents corresponds to $inlined.endorsement.contents

type InvalidBlock

type InvalidBlock struct {
	Block string `json:"block"`
	Level int    `json:"level"`
	Error Errors `json:"error"`
}

InvalidBlock represents invalid block hash along with the errors that led to it being declared invalid

type Logger

type Logger interface {
	log.FieldLogger
	Writer() *io.PipeWriter
	WriterLevel(level log.Level) *io.PipeWriter
}

Logger is an extension to logrus.FieldLogger

type MaxOperationListLength

type MaxOperationListLength struct {
	MaxSize int `json:"max_size" yaml:"max_size"`
	MaxOp   int `json:"max_op" yaml:"max_op"`
}

MaxOperationListLength is a part of the BlockHeaderMetadata

type MempoolOperations

type MempoolOperations struct {
	Applied       []*Operation             `json:"applied"`
	Refused       []*OperationWithErrorAlt `json:"refused"`
	BranchRefused []*OperationWithErrorAlt `json:"branch_refused"`
	BranchDelayed []*OperationWithErrorAlt `json:"branch_delayed"`
	Unprocessed   []*OperationAlt          `json:"unprocessed"`
}

MempoolOperations represents mempool operations

type NetworkAddress

type NetworkAddress struct {
	Addr string `json:"addr"`
	Port uint16 `json:"port"`
}

NetworkAddress models a point's address and port.

type NetworkConnection

type NetworkConnection struct {
	Incoming         bool              `json:"incoming"`
	PeerID           string            `json:"peer_id"`
	IDPoint          NetworkAddress    `json:"id_point"`
	RemoteSocketPort uint16            `json:"remote_socket_port"`
	Versions         []*NetworkVersion `json:"versions"`
	Private          bool              `json:"private"`
	LocalMetadata    NetworkMetadata   `json:"local_metadata"`
	RemoteMetadata   NetworkMetadata   `json:"remote_metadata"`
}

NetworkConnection models detailed information for one network connection.

type NetworkConnectionTimestamp

type NetworkConnectionTimestamp struct {
	NetworkAddress
	Timestamp time.Time
}

NetworkConnectionTimestamp represents peer address with timestamp added

func (*NetworkConnectionTimestamp) UnmarshalJSON

func (n *NetworkConnectionTimestamp) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler

type NetworkMetadata

type NetworkMetadata struct {
	DisableMempool bool `json:"disable_mempool"`
	PrivateNode    bool `json:"private_node"`
}

NetworkMetadata models metadata of a node.

type NetworkPeer

type NetworkPeer struct {
	PeerID                    string                      `json:"-"`
	Score                     int64                       `json:"score"`
	Trusted                   bool                        `json:"trusted"`
	ConnMetadata              *NetworkMetadata            `json:"conn_metadata"`
	State                     string                      `json:"state"`
	ReachableAt               *NetworkAddress             `json:"reachable_at"`
	Stat                      NetworkStats                `json:"stat"`
	LastEstablishedConnection *NetworkConnectionTimestamp `json:"last_established_connection"`
	LastSeen                  *NetworkConnectionTimestamp `json:"last_seen"`
	LastFailedConnection      *NetworkConnectionTimestamp `json:"last_failed_connection"`
	LastRejectedConnection    *NetworkConnectionTimestamp `json:"last_rejected_connection"`
	LastDisconnection         *NetworkConnectionTimestamp `json:"last_disconnection"`
	LastMiss                  *NetworkConnectionTimestamp `json:"last_miss"`
}

NetworkPeer represents peer info

type NetworkPeerLogEntry

type NetworkPeerLogEntry struct {
	NetworkAddress
	Kind      string    `json:"kind"`
	Timestamp time.Time `json:"timestamp"`
}

NetworkPeerLogEntry represents peer log entry

type NetworkPoint

type NetworkPoint struct {
	Address                   string            `json:"-"`
	Trusted                   bool              `json:"trusted"`
	GreylistedUntil           time.Time         `json:"greylisted_until"`
	State                     NetworkPointState `json:"state"`
	P2PPeerID                 string            `json:"p2p_peer_id"`
	LastFailedConnection      time.Time         `json:"last_failed_connection"`
	LastRejectedConnection    *IDTimestamp      `json:"last_rejected_connection"`
	LastEstablishedConnection *IDTimestamp      `json:"last_established_connection"`
	LastDisconnection         *IDTimestamp      `json:"last_disconnection"`
	LastSeen                  *IDTimestamp      `json:"last_seen"`
	LastMiss                  time.Time         `json:"last_miss"`
}

NetworkPoint represents network point info

type NetworkPointLogEntry

type NetworkPointLogEntry struct {
	Kind      NetworkPointState `json:"kind"`
	Timestamp time.Time         `json:"timestamp"`
}

NetworkPointLogEntry represents point's log entry

type NetworkPointState

type NetworkPointState struct {
	EventKind string `json:"event_kind"`
	P2PPeerID string `json:"p2p_peer_id"`
}

NetworkPointState represents point state

type NetworkStats

type NetworkStats struct {
	TotalBytesSent int64 `json:"total_sent,string"`
	TotalBytesRecv int64 `json:"total_recv,string"`
	CurrentInflow  int64 `json:"current_inflow"`
	CurrentOutflow int64 `json:"current_outflow"`
}

NetworkStats models global network bandwidth totals and usage in B/s.

type NetworkVersion

type NetworkVersion struct {
	Name  string `json:"name"`
	Major uint16 `json:"major"`
	Minor uint16 `json:"minor"`
}

NetworkVersion models a network-layer version of a node.

type NotRunningTestChainStatus

type NotRunningTestChainStatus struct {
	GenericTestChainStatus
}

NotRunningTestChainStatus is a TestChainStatus variant for Status=not_running

type Operation

type Operation struct {
	Protocol  string            `json:"protocol" yaml:"protocol"`
	ChainID   string            `json:"chain_id" yaml:"chain_id"`
	Hash      string            `json:"hash" yaml:"hash"`
	Branch    string            `json:"branch" yaml:"branch"`
	Contents  OperationElements `json:"contents" yaml:"contents"`
	Signature string            `json:"signature" yaml:"signature"`
}

Operation represents an operation included into block

type OperationAlt

type OperationAlt Operation

OperationAlt is a heterogeneously encoded Operation with hash as a first array member, i.e.

[
	"...", // hash
	{
		"protocol": "...",
		...
	}
]

instead of

{
	"protocol": "...",
	"hash": "...",
	...
}

func (*OperationAlt) UnmarshalJSON

func (o *OperationAlt) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler

type OperationElem

type OperationElem interface {
	OperationElemKind() string
}

OperationElem must be implemented by all operation elements

type OperationElements

type OperationElements []OperationElem

OperationElements is a slice of OperationElem with custom JSON unmarshaller

func (*OperationElements) UnmarshalJSON

func (e *OperationElements) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler

type OperationWithError

type OperationWithError struct {
	Operation
	Error Errors `json:"error" yaml:"error"`
}

OperationWithError represents unsuccessful operation

type OperationWithErrorAlt

type OperationWithErrorAlt OperationWithError

OperationWithErrorAlt is a heterogeneously encoded OperationWithError with hash as a first array member. See OperationAlt for details

func (*OperationWithErrorAlt) UnmarshalJSON

func (o *OperationWithErrorAlt) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler

type OperationWithFee

type OperationWithFee interface {
	OperationFee() *big.Int
}

OperationWithFee is implemented by operations with fees

type OriginationOperationElem

type OriginationOperationElem struct {
	GenericOperationElem `yaml:",inline"`
	Source               string                       `json:"source" yaml:"source"`
	Fee                  *BigInt                      `json:"fee" yaml:"fee"`
	Counter              *BigInt                      `json:"counter" yaml:"counter"`
	GasLimit             *BigInt                      `json:"gas_limit" yaml:"gas_limit"`
	StorageLimit         *BigInt                      `json:"storage_limit" yaml:"storage_limit"`
	ManagerPubKey        string                       `json:"managerPubkey" yaml:"managerPubkey"`
	Balance              *BigInt                      `json:"balance" yaml:"balance"`
	Spendable            *bool                        `json:"spendable,omitempty" yaml:"spendable,omitempty"`
	Delegatable          *bool                        `json:"delegatable,omitempty" yaml:"delegatable,omitempty"`
	Delegate             string                       `json:"delegate,omitempty" yaml:"delegate,omitempty"`
	Script               *ScriptedContracts           `json:"script,omitempty" yaml:"script,omitempty"`
	Metadata             OriginationOperationMetadata `json:"metadata" yaml:"metadata"`
}

OriginationOperationElem represents a origination operation

func (*OriginationOperationElem) BalanceUpdates

func (el *OriginationOperationElem) BalanceUpdates() BalanceUpdates

BalanceUpdates implements BalanceUpdateOperation

func (*OriginationOperationElem) OperationFee

func (el *OriginationOperationElem) OperationFee() *big.Int

OperationFee implements OperationWithFee

type OriginationOperationMetadata

type OriginationOperationMetadata struct {
	BalanceUpdates  BalanceUpdates             `json:"balance_updates" yaml:"balance_updates"`
	OperationResult OriginationOperationResult `json:"operation_result" yaml:"operation_result"`
}

OriginationOperationMetadata represents a origination operation metadata

type OriginationOperationResult

type OriginationOperationResult struct {
	Status              string         `json:"status" yaml:"status"`
	BalanceUpdates      BalanceUpdates `json:"balance_updates,omitempty" yaml:"balance_updates,omitempty"`
	OriginatedContracts []string       `json:"originated_contracts,omitempty" yaml:"originated_contracts,omitempty"`
	ConsumedGas         *BigInt        `json:"consumed_gas,omitempty" yaml:"consumed_gas,omitempty"`
	StorageSize         *BigInt        `json:"storage_size,omitempty" yaml:"storage_size,omitempty"`
	PaidStorageSizeDiff *BigInt        `json:"paid_storage_size_diff,omitempty" yaml:"paid_storage_size_diff,omitempty"`
	Errors              Errors         `json:"errors,omitempty" yaml:"errors,omitempty"`
}

OriginationOperationResult represents a origination operation result

type PeriodKind

type PeriodKind string

PeriodKind contains information about tezos voting period kind

func (PeriodKind) IsPromotionVote

func (p PeriodKind) IsPromotionVote() bool

IsPromotionVote true if period kind is promotion vote

func (PeriodKind) IsProposal

func (p PeriodKind) IsProposal() bool

IsProposal return true if period kind is proposal

func (PeriodKind) IsTesting

func (p PeriodKind) IsTesting() bool

IsTesting return true if period kind is testing

func (PeriodKind) IsTestingVote

func (p PeriodKind) IsTestingVote() bool

IsTestingVote return true if period kind is testing vote

type Proposal

type Proposal struct {
	ProposalHash   string
	SupporterCount int
}

Proposal holds summary data about a proposal and his number of supporter

type ProposalOperationElem

type ProposalOperationElem struct {
	GenericOperationElem `yaml:",inline"`
	Source               string                 `json:"source" yaml:"source"`
	Period               int                    `json:"period" yaml:"period"`
	Proposals            []string               `json:"proposals" yaml:"proposals"`
	Metadata             map[string]interface{} `json:"metadata" yaml:"metadata"`
}

ProposalOperationElem represents a proposal operation

type RPCClient

type RPCClient struct {
	// Logger
	Logger Logger
	// HTTP transport used to communicate with the Tezos node API. Can be used for side effects.
	Transport http.RoundTripper
	// Base URL for API requests.
	BaseURL *url.URL
	// User agent name for client.
	UserAgent string
}

RPCClient manages communication with a Tezos RPC server.

func NewRPCClient

func NewRPCClient(baseURL string) (*RPCClient, error)

NewRPCClient returns a new Tezos RPC client.

func (*RPCClient) Do

func (c *RPCClient) Do(req *http.Request, v interface{}) (err error)

Do retrieves values from the API and marshals them into the provided interface.

func (*RPCClient) NewRequest

func (c *RPCClient) NewRequest(ctx context.Context, method, urlStr string, body interface{}) (*http.Request, error)

NewRequest creates a Tezos RPC request.

type RPCError

type RPCError interface {
	Error
	HTTPStatus
	Errors() []Error // returns all errors as a slice
}

RPCError is a Tezos RPC error as documented on http://tezos.gitlab.io/mainnet/api/errors.html.

type RawBlockHeader

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

RawBlockHeader is a part of the Tezos block data

type RevealOperationElem

type RevealOperationElem struct {
	GenericOperationElem `yaml:",inline"`
	Source               string                  `json:"source" yaml:"source"`
	Fee                  *BigInt                 `json:"fee" yaml:"fee"`
	Counter              *BigInt                 `json:"counter" yaml:"counter"`
	GasLimit             *BigInt                 `json:"gas_limit" yaml:"gas_limit"`
	StorageLimit         *BigInt                 `json:"storage_limit" yaml:"storage_limit"`
	PublicKey            string                  `json:"public_key" yaml:"public_key"`
	Metadata             RevealOperationMetadata `json:"metadata" yaml:"metadata"`
}

RevealOperationElem represents a reveal operation

func (*RevealOperationElem) BalanceUpdates

func (el *RevealOperationElem) BalanceUpdates() BalanceUpdates

BalanceUpdates implements BalanceUpdateOperation

func (*RevealOperationElem) OperationFee

func (el *RevealOperationElem) OperationFee() *big.Int

OperationFee implements OperationWithFee

type RevealOperationMetadata

type RevealOperationMetadata DelegationOperationMetadata

RevealOperationMetadata represents a reveal operation metadata

type RunningTestChainStatus

type RunningTestChainStatus struct {
	GenericTestChainStatus
	ChainID    string `json:"chain_id" yaml:"chain_id"`
	Genesis    string `json:"genesis" yaml:"genesis"`
	Protocol   string `json:"protocol" yaml:"protocol"`
	Expiration string `json:"expiration" yaml:"expiration"`
}

RunningTestChainStatus is a TestChainStatus variant for Status=running

type ScriptedContracts

type ScriptedContracts struct {
	Code    map[string]interface{} `json:"code" yaml:"code"`
	Storage map[string]interface{} `json:"storage" yaml:"storage"`
}

ScriptedContracts corresponds to $scripted.contracts

type SeedNonceRevelationOperationElem

type SeedNonceRevelationOperationElem struct {
	GenericOperationElem `yaml:",inline"`
	Level                int32                           `json:"level" yaml:"level"`
	Nonce                string                          `json:"nonce" yaml:"nonce"`
	Metadata             BalanceUpdatesOperationMetadata `json:"metadata" yaml:"metadata"`
}

SeedNonceRevelationOperationElem represents seed_nonce_revelation operation

func (*SeedNonceRevelationOperationElem) BalanceUpdates

func (el *SeedNonceRevelationOperationElem) BalanceUpdates() BalanceUpdates

BalanceUpdates implements BalanceUpdateOperation

type Service

type Service struct {
	Client *RPCClient
}

Service implements fetching of information from Tezos nodes via JSON.

func (*Service) BanNetworkPeer

func (s *Service) BanNetworkPeer(ctx context.Context, peerID string) error

BanNetworkPeer blacklists the given peer. https://tezos.gitlab.io/mainnet/api/rpc.html#get-network-peers-peer-id-ban

func (*Service) BanNetworkPoint

func (s *Service) BanNetworkPoint(ctx context.Context, address string) error

BanNetworkPoint blacklists the given address. https://tezos.gitlab.io/mainnet/api/rpc.html#get-network-points-point-ban

func (*Service) ConnectToNetworkPoint

func (s *Service) ConnectToNetworkPoint(ctx context.Context, address string, timeout time.Duration) error

ConnectToNetworkPoint used to connect to a peer. https://tezos.gitlab.io/mainnet/api/rpc.html#put-network-points-point

func (*Service) GetBallotList

func (s *Service) GetBallotList(ctx context.Context, chainID, blockID string) ([]*Ballot, error)

GetBallotList returns ballots casted so far during a voting period. https://tezos.gitlab.io/alphanet/api/rpc.html#get-block-id-votes-ballot-list

func (*Service) GetBallotListings

func (s *Service) GetBallotListings(ctx context.Context, chainID, blockID string) ([]*BallotListing, error)

GetBallotListings returns a list of delegates with their voting weight, in number of rolls. https://tezos.gitlab.io/alphanet/api/rpc.html#get-block-id-votes-listings

func (*Service) GetBallots

func (s *Service) GetBallots(ctx context.Context, chainID, blockID string) (*Ballots, error)

GetBallots returns sum of ballots casted so far during a voting period. https://tezos.gitlab.io/alphanet/api/rpc.html#get-block-id-votes-ballots

func (*Service) GetBlock

func (s *Service) GetBlock(ctx context.Context, chainID, blockID string) (*Block, error)

GetBlock returns information about a Tezos block https://tezos.gitlab.io/alphanet/api/rpc.html#get-block-id

func (*Service) GetContractBalance

func (s *Service) GetContractBalance(ctx context.Context, chainID string, blockID string, contractID string) (*big.Int, error)

GetContractBalance returns a contract's balance http://tezos.gitlab.io/mainnet/api/rpc.html#get-block-id-context-contracts-contract-id-balance

func (*Service) GetCurrentPeriodKind

func (s *Service) GetCurrentPeriodKind(ctx context.Context, chainID, blockID string) (PeriodKind, error)

GetCurrentPeriodKind returns the current period kind https://tezos.gitlab.io/alphanet/api/rpc.html#get-block-id-votes-current-period-kind

func (*Service) GetCurrentProposals

func (s *Service) GetCurrentProposals(ctx context.Context, chainID, blockID string) (string, error)

GetCurrentProposals returns the current proposal under evaluation. https://tezos.gitlab.io/alphanet/api/rpc.html#get-block-id-votes-current-proposal

func (*Service) GetCurrentQuorum

func (s *Service) GetCurrentQuorum(ctx context.Context, chainID, blockID string) (int, error)

GetCurrentQuorum returns the current expected quorum. https://tezos.gitlab.io/alphanet/api/rpc.html#get-block-id-votes-current-quorum

func (*Service) GetDelegateBalance

func (s *Service) GetDelegateBalance(ctx context.Context, chainID string, blockID string, pkh string) (*big.Int, error)

GetDelegateBalance returns a delegate's balance http://tezos.gitlab.io/mainnet/api/rpc.html#get-block-id-context-delegates-pkh-balance

func (*Service) GetInvalidBlocks

func (s *Service) GetInvalidBlocks(ctx context.Context, chainID string) ([]*InvalidBlock, error)

GetInvalidBlocks lists blocks that have been declared invalid along with the errors that led to them being declared invalid. https://tezos.gitlab.io/alphanet/api/rpc.html#get-chains-chain-id-invalid-blocks

func (*Service) GetMempoolPendingOperations

func (s *Service) GetMempoolPendingOperations(ctx context.Context, chainID string) (*MempoolOperations, error)

GetMempoolPendingOperations returns mempool pending operations

func (*Service) GetNetworkConnections

func (s *Service) GetNetworkConnections(ctx context.Context) ([]*NetworkConnection, error)

GetNetworkConnections returns all network connections http://tezos.gitlab.io/mainnet/api/rpc.html#get-network-connections

func (*Service) GetNetworkPeer

func (s *Service) GetNetworkPeer(ctx context.Context, peerID string) (*NetworkPeer, error)

GetNetworkPeer returns details about a given peer. https://tezos.gitlab.io/mainnet/api/rpc.html#get-network-peers-peer-id

func (*Service) GetNetworkPeerBanned

func (s *Service) GetNetworkPeerBanned(ctx context.Context, peerID string) (bool, error)

GetNetworkPeerBanned checks if a given peer is blacklisted or greylisted. https://tezos.gitlab.io/mainnet/api/rpc.html#get-network-peers-peer-id-banned

func (*Service) GetNetworkPeerLog

func (s *Service) GetNetworkPeerLog(ctx context.Context, peerID string) ([]*NetworkPeerLogEntry, error)

GetNetworkPeerLog monitors network events related to a given peer. https://tezos.gitlab.io/mainnet/api/rpc.html#get-network-peers-peer-id-log

func (*Service) GetNetworkPeers

func (s *Service) GetNetworkPeers(ctx context.Context, filter string) ([]*NetworkPeer, error)

GetNetworkPeers returns the list the peers the node ever met. https://tezos.gitlab.io/mainnet/api/rpc.html#get-network-peers

func (*Service) GetNetworkPoint

func (s *Service) GetNetworkPoint(ctx context.Context, address string) (*NetworkPoint, error)

GetNetworkPoint returns details about a given `IP:addr`. https://tezos.gitlab.io/mainnet/api/rpc.html#get-network-points-point

func (*Service) GetNetworkPointBanned

func (s *Service) GetNetworkPointBanned(ctx context.Context, address string) (bool, error)

GetNetworkPointBanned check is a given address is blacklisted or greylisted. https://tezos.gitlab.io/mainnet/api/rpc.html#get-network-points-point-banned

func (*Service) GetNetworkPointLog

func (s *Service) GetNetworkPointLog(ctx context.Context, address string) ([]*NetworkPointLogEntry, error)

GetNetworkPointLog monitors network events related to an `IP:addr`. https://tezos.gitlab.io/mainnet/api/rpc.html#get-network-peers-peer-id-log

func (*Service) GetNetworkPoints

func (s *Service) GetNetworkPoints(ctx context.Context, filter string) ([]*NetworkPoint, error)

GetNetworkPoints returns list the pool of known `IP:port` used for establishing P2P connections. https://tezos.gitlab.io/mainnet/api/rpc.html#get-network-points

func (*Service) GetNetworkStats

func (s *Service) GetNetworkStats(ctx context.Context) (*NetworkStats, error)

GetNetworkStats returns current network stats https://tezos.gitlab.io/betanet/api/rpc.html#get-network-stat

func (*Service) GetProposals

func (s *Service) GetProposals(ctx context.Context, chainID, blockID string) ([]*Proposal, error)

GetProposals returns a list of proposals with number of supporters. https://tezos.gitlab.io/alphanet/api/rpc.html#get-block-id-votes-proposals

func (*Service) MonitorBootstrapped

func (s *Service) MonitorBootstrapped(ctx context.Context, results chan<- *BootstrappedBlock) error

MonitorBootstrapped reads from the bootstrapped blocks stream http://tezos.gitlab.io/mainnet/api/rpc.html#get-monitor-bootstrapped

func (*Service) MonitorHeads

func (s *Service) MonitorHeads(ctx context.Context, chainID string, results chan<- *BlockInfo) error

MonitorHeads reads from the heads blocks stream https://tezos.gitlab.io/mainnet/api/rpc.html#get-monitor-heads-chain-id

func (*Service) MonitorMempoolOperations

func (s *Service) MonitorMempoolOperations(ctx context.Context, chainID, filter string, results chan<- []*Operation) error

MonitorMempoolOperations monitors mempool pending operations. The connection is closed after every new block.

func (*Service) MonitorNetworkPeerLog

func (s *Service) MonitorNetworkPeerLog(ctx context.Context, peerID string, results chan<- []*NetworkPeerLogEntry) error

MonitorNetworkPeerLog monitors network events related to a given peer. https://tezos.gitlab.io/mainnet/api/rpc.html#get-network-peers-peer-id-log

func (*Service) MonitorNetworkPointLog

func (s *Service) MonitorNetworkPointLog(ctx context.Context, address string, results chan<- []*NetworkPointLogEntry) error

MonitorNetworkPointLog monitors network events related to an `IP:addr`. https://tezos.gitlab.io/mainnet/api/rpc.html#get-network-peers-peer-id-log

func (*Service) TrustNetworkPeer

func (s *Service) TrustNetworkPeer(ctx context.Context, peerID string) error

TrustNetworkPeer used to trust a given peer permanently: the peer cannot be blocked (but its host IP still can). https://tezos.gitlab.io/mainnet/api/rpc.html#get-network-peers-peer-id-trust

func (*Service) TrustNetworkPoint

func (s *Service) TrustNetworkPoint(ctx context.Context, address string) error

TrustNetworkPoint used to trust a given address permanently. Connections from this address can still be closed on authentication if the peer is blacklisted or greylisted. https://tezos.gitlab.io/mainnet/api/rpc.html#get-network-points-point-trust

type TestChainStatus

type TestChainStatus interface {
	TestChainStatus() string
}

TestChainStatus is a variable structure depending on the Status field

type TransactionOperationElem

type TransactionOperationElem struct {
	GenericOperationElem `yaml:",inline"`
	Source               string                       `json:"source" yaml:"source"`
	Fee                  *BigInt                      `json:"fee" yaml:"fee"`
	Counter              *BigInt                      `json:"counter" yaml:"counter"`
	GasLimit             *BigInt                      `json:"gas_limit" yaml:"gas_limit"`
	StorageLimit         *BigInt                      `json:"storage_limit" yaml:"storage_limit"`
	Amount               *BigInt                      `json:"amount" yaml:"amount"`
	Destination          string                       `json:"destination" yaml:"destination"`
	Parameters           map[string]interface{}       `json:"parameters,omitempty" yaml:"parameters,omitempty"`
	Metadata             TransactionOperationMetadata `json:"metadata" yaml:"metadata"`
}

TransactionOperationElem represents a transaction operation

func (*TransactionOperationElem) BalanceUpdates

func (el *TransactionOperationElem) BalanceUpdates() BalanceUpdates

BalanceUpdates implements BalanceUpdateOperation

func (*TransactionOperationElem) OperationFee

func (el *TransactionOperationElem) OperationFee() *big.Int

OperationFee implements OperationWithFee

type TransactionOperationMetadata

type TransactionOperationMetadata struct {
	BalanceUpdates  BalanceUpdates             `json:"balance_updates" yaml:"balance_updates"`
	OperationResult TransactionOperationResult `json:"operation_result" yaml:"operation_result"`
}

TransactionOperationMetadata represents a transaction operation metadata

type TransactionOperationResult

type TransactionOperationResult struct {
	Status              string                 `json:"status" yaml:"status"`
	Storage             map[string]interface{} `json:"storage,omitempty" yaml:"storage,omitempty"`
	BalanceUpdates      BalanceUpdates         `json:"balance_updates,omitempty" yaml:"balance_updates,omitempty"`
	OriginatedContracts []string               `json:"originated_contracts,omitempty" yaml:"originated_contracts,omitempty"`
	ConsumedGas         *BigInt                `json:"consumed_gas,omitempty" yaml:"consumed_gas,omitempty"`
	StorageSize         *BigInt                `json:"storage_size,omitempty" yaml:"storage_size,omitempty"`
	PaidStorageSizeDiff *BigInt                `json:"paid_storage_size_diff,omitempty" yaml:"paid_storage_size_diff,omitempty"`
	Errors              Errors                 `json:"errors,omitempty" yaml:"errors,omitempty"`
}

TransactionOperationResult represents a transaction operation result

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to