provider

package
v3.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2023 License: GPL-3.0 Imports: 11 Imported by: 1

Documentation

Overview

* Copyright (C) 2019 Zilliqa * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>.

* Copyright (C) 2019 Zilliqa * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Data

type Data struct {
	Tag    string  `json:"_tag"`
	Params []Value `json:"params"`
}

type Init

type Init struct {
	Version   int           `json:"version"`
	Nonce     int           `json:"nonce"`
	ToAddr    string        `json:"toAddr"`
	Amount    int64         `json:"amount"`
	PubKey    string        `json:"pubKey"`
	GasPrice  int64         `json:"gasPrice"`
	GasLimit  int64         `json:"gasLimit"`
	Code      string        `json:"code"`
	Data      []interface{} `json:"data"`
	Signature string        `json:"signature"`
}

type Payment

type Payment struct {
	Version   int    `json:"version"`
	Nonce     int    `json:"nonce"`
	ToAddr    string `json:"toAddr"`
	Amount    int64  `json:"amount"`
	PubKey    string `json:"pubKey"`
	GasPrice  int64  `json:"gasPrice"`
	GasLimit  int64  `json:"gasLimit"`
	Code      string `json:"code"`
	Data      string `json:"data"`
	Signature string `json:"signature"`
}

type Provider

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

func NewProvider

func NewProvider(host string) *Provider

func (*Provider) CreateTransaction

func (provider *Provider) CreateTransaction(payload TransactionPayload) (*jsonrpc.RPCResponse, error)

Create a new Transaction object and send it to the network to be process.

func (*Provider) CreateTransactionBatch

func (provider *Provider) CreateTransactionBatch(payloads [][]TransactionPayload) (jsonrpc.RPCResponses, error)

func (*Provider) CreateTransactionRaw

func (provider *Provider) CreateTransactionRaw(payload []byte) (*jsonrpc.RPCResponse, error)

func (*Provider) DSBlockListing

func (provider *Provider) DSBlockListing(ds_block_listing int) (*core.BlockList, error)

Returns a paginated list of up to 10 Directory Service (DS) blocks and their block hashes for a specified page. The maxPages variable that specifies the maximum number of pages available is also returned.

func (*Provider) GetBalance

func (provider *Provider) GetBalance(user_address string) (*core.BalanceAndNonce, error)

Returns the current balance of an account, measured in the smallest accounting unit Qa (or 10^-12 Zil). This is represented as a String Returns the current nonce of an account. This is represented as an Number.

func (*Provider) GetBlockchainInfo

func (provider *Provider) GetBlockchainInfo() (*core.BlockchainInfo, error)

Returns the current network statistics for the specified network.

func (*Provider) GetContractAddressFromTransactionID

func (provider *Provider) GetContractAddressFromTransactionID(transaction_id string) (string, error)

Returns a smart contract address of 20 bytes. This is represented as a String. NOTE: This only works for contract deployment transactions.

func (*Provider) GetCurrentDSComm

func (provider *Provider) GetCurrentDSComm() (*core.DSComm, error)

func (*Provider) GetCurrentDSEpoch

func (provider *Provider) GetCurrentDSEpoch() (string, error)

Returns the current number of DS blocks in the network. This is represented as a String.

func (*Provider) GetCurrentMiniEpoch

func (provider *Provider) GetCurrentMiniEpoch() (string, error)

Returns the current TX block number of the network. This is represented as a String.

func (*Provider) GetDSBlockRate

func (provider *Provider) GetDSBlockRate() (float64, error)

Returns the current Directory Service blockrate per second.

func (*Provider) GetDsBlock

func (provider *Provider) GetDsBlock(block_number string) (*core.DsBlockT, error)

Returns the details of a specified Directory Service block.

func (*Provider) GetDsBlockVerbose

func (provider *Provider) GetDsBlockVerbose(block_number string) (*core.DsBlockT, error)

func (*Provider) GetLatestDsBlock

func (provider *Provider) GetLatestDsBlock() (*core.DSBlock, error)

Returns the details of the most recent Directory Service block.

func (*Provider) GetLatestTxBlock

func (provider *Provider) GetLatestTxBlock() (*core.TxBlockT, error)

Returns the details of the most recent Transaction block.

func (*Provider) GetMinerInfo

func (provider *Provider) GetMinerInfo(dsNumber string) (*core.MinerInfo, error)

Returns the mining nodes (i.e., the members of the DS committee and shards) at the specified DS block. Notes: 1. Nodes owned by Zilliqa Research are omitted. 2. dscommittee has no size field since the DS committee size is fixed for a given chain. 3. For the Zilliqa Mainnet, this API is only available from DS block 5500 onwards.

func (*Provider) GetMinimumGasPrice

func (provider *Provider) GetMinimumGasPrice() (string, error)

Returns the minimum gas price for this DS epoch, measured in the smallest price unit Qa (or 10^-12 Zil) in Zilliqa. This is represented as a String.

func (*Provider) GetNetworkId

func (provider *Provider) GetNetworkId() (string, error)

Returns the CHAIN_ID of the specified network. This is represented as a String.

func (*Provider) GetNumDSBlocks

func (provider *Provider) GetNumDSBlocks() (string, error)

Returns the current number of validated Directory Service blocks in the network. This is represented as a String.

func (*Provider) GetNumTransactions

func (provider *Provider) GetNumTransactions() (string, error)

Returns the current number of validated Transactions in the network. This is represented as a String.

func (*Provider) GetNumTxBlocks

func (provider *Provider) GetNumTxBlocks() (string, error)

Returns the current number of Transaction blocks in the network. This is represented as a String.

func (*Provider) GetNumTxnsDSEpoch

func (provider *Provider) GetNumTxnsDSEpoch() (string, error)

Returns the number of validated transactions included in this DS epoch. This is represented as String.

func (*Provider) GetNumTxnsTxEpoch

func (provider *Provider) GetNumTxnsTxEpoch() (string, error)

Returns the number of validated transactions included in this Transaction epoch. This is represented as String.

func (*Provider) GetPendingTxn

func (provider *Provider) GetPendingTxn(tx string) (*core.PendingTxnResult, error)

Returns the pending status of a specified Transaction.

func (*Provider) GetPendingTxns

func (provider *Provider) GetPendingTxns() (*core.PendingTxns, error)

Returns the pending status of all unvalidated Transactions.

func (*Provider) GetPrevDSDifficulty

func (provider *Provider) GetPrevDSDifficulty() (int64, error)

Returns the minimum DS difficulty of the previous block. This is represented as an Number.

func (*Provider) GetPrevDifficulty

func (provider *Provider) GetPrevDifficulty() (int64, error)

Returns the minimum shard difficulty of the previous block. This is represented as an Number.

func (*Provider) GetRecentTransactions

func (provider *Provider) GetRecentTransactions() (*core.Transactions, error)

Returns the most recent 100 transactions that are validated by the Zilliqa network.

func (*Provider) GetShardingStructure

func (provider *Provider) GetShardingStructure() (*core.ShardingStructure, error)

func (*Provider) GetSmartContractCode

func (provider *Provider) GetSmartContractCode(contract_address string) (string, error)

Returns the Scilla code associated with a smart contract address. This is represented as a String.

func (*Provider) GetSmartContractInit

func (provider *Provider) GetSmartContractInit(contract_address string) ([]core.ContractValue, error)

Returns the initialization (immutable) parameters of a given smart contract, represented in a JSON format.

func (*Provider) GetSmartContractState

func (provider *Provider) GetSmartContractState(contract_address string) (*jsonrpc.RPCResponse, error)

Returns the state (mutable) variables of a smart contract address, represented in a JSON format.

func (*Provider) GetSmartContractSubState

func (provider *Provider) GetSmartContractSubState(contractAddress string, params ...interface{}) (string, error)

Returns the state (or a part specified) of a smart contract address, represented in a JSON format.

func (*Provider) GetSmartContracts

func (provider *Provider) GetSmartContracts(user_address string) (*jsonrpc.RPCResponse, error)

Returns the list of smart contract addresses created by an User's account and the contracts' latest states.

func (*Provider) GetStateProof

func (provider *Provider) GetStateProof(contractAddress string, hashedStorageKey string, blockNum *string) (*core.StateProof, error)

func (*Provider) GetTotalCoinSupply

func (provider *Provider) GetTotalCoinSupply() (string, error)

Returns the total supply (ZIL) of coins in the network. This is represented as a String.

func (*Provider) GetTransaction

func (provider *Provider) GetTransaction(transaction_hash string) (*core.Transaction, error)

Returns the details of a specified Transaction. Note: If the transaction had an data field or code field, it will be displayed

func (*Provider) GetTransactionBatch

func (provider *Provider) GetTransactionBatch(transactionHashes []string) ([]*core.Transaction, error)

func (*Provider) GetTransactionRate

func (provider *Provider) GetTransactionRate() (float64, error)

Returns the current Transaction rate per second (TPS) of the network. This is represented as an Number.

func (*Provider) GetTransactionStatus

func (provider *Provider) GetTransactionStatus(transactionHash string) (*core.TransactionStatus, error)

func (*Provider) GetTransactionsForTxBlock

func (provider *Provider) GetTransactionsForTxBlock(tx_block_number string) ([][]string, error)

Returns the validated transactions included within a specfied final transaction block as an array of length i, where i is the number of shards plus the DS committee. The transactions are grouped based on the group that processed the transaction. The first element of the array refers to the first shard. The last element of the array at index, i, refers to the transactions processed by the DS Committee.

func (*Provider) GetTxBlock

func (provider *Provider) GetTxBlock(tx_block string) (*core.TxBlockT, error)

Returns the details of a specified Transaction block.

func (*Provider) GetTxBlockRate

func (provider *Provider) GetTxBlockRate() (float64, error)

Returns the current Transaction blockrate per second for the network.

func (*Provider) GetTxBlockVerbose

func (provider *Provider) GetTxBlockVerbose(tx_block string) (*core.TxBlockT, error)

func (*Provider) GetTxnBodiesForTxBlock

func (provider *Provider) GetTxnBodiesForTxBlock(tx_block_number string) ([]core.Transaction, error)

func (*Provider) TxBlockListing

func (provider *Provider) TxBlockListing(page int) (*core.BlockList, error)

Returns a paginated list of up to 10 Transaction blocks and their block hashes for a specified page. The maxPages variable that specifies the maximum number of pages available is also returned.

type TransactionPayload

type TransactionPayload struct {
	Version   int    `json:"version"`
	Nonce     int    `json:"nonce"`
	ToAddr    string `json:"toAddr"`
	Amount    string `json:"amount"`
	PubKey    string `json:"pubKey"`
	GasPrice  string `json:"gasPrice"`
	GasLimit  string `json:"gasLimit"`
	Code      string `json:"code"`
	Data      string `json:"data"`
	Signature string `json:"signature"`
	Priority  bool   `json:"priority"`
}

func NewFromJson

func NewFromJson(data []byte) (*TransactionPayload, error)

some data fields don't match, so we need middle map see the unit test

func NewFromMap

func NewFromMap(middle map[string]interface{}) (*TransactionPayload, error)

func (*TransactionPayload) ToJson

func (pl *TransactionPayload) ToJson() ([]byte, error)

type Value

type Value struct {
	VName string      `json:"vname"`
	Type  string      `json:"type"`
	Value interface{} `json:"value"`
}

Jump to

Keyboard shortcuts

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