statePkg

package
v0.0.0-...-3f8eaf4 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: GPL-3.0 Imports: 28 Imported by: 0

README

chifra state

The chifra state tool retrieves the balance of an address (or list of addresses) at the given block (or blocks). Specify multiple addresses and/or multiple blocks if you wish, but you must specify at least one address. If no block is specified, the latest block is reported.

You may also query to see if an address is a smart contract as well as retrieve a contract's byte code.

Purpose:
  Retrieve account balance(s) for one or more addresses at given block(s).

Usage:
  chifra state [flags] <address> [address...] [block...]

Arguments:
  addrs - one or more addresses (0x...) from which to retrieve balances (required)
  blocks - an optional list of one or more blocks at which to report balances, defaults to 'latest'

Flags:
  -p, --parts strings      control which state to export
                           One or more of [ none | some | all | balance | nonce | code | proxy | deployed | accttype ]
  -c, --changes            only report a balance when it changes from one block to the next
  -z, --no_zero            suppress the display of zero balance accounts
  -l, --call string        call a smart contract with a solidity syntax, a four-byte and parameters, or encoded call data
  -a, --articulate         for the --call option only, articulate the retrieved data if ABIs can be found
  -r, --proxy_for string   for the --call option only, redirects calls to this implementation
  -H, --ether              specify value in ether
  -o, --cache              force the results of the query into the cache
  -D, --decache            removes related items from the cache
  -x, --fmt string         export format, one of [none|json*|txt|csv]
  -v, --verbose            enable verbose output
  -h, --help               display this help screen

Notes:
  - An address must be either an ENS name or start with '0x' and be forty-two characters long.
  - Blocks is a space-separated list of values, a start-end range, a special, or any combination.
  - If the queried node does not store historical state, the results are undefined.
  - Special blocks are detailed under chifra when --list.
  - Balance is the default mode. To select a single mode use none first, followed by that mode.
  - Valid parameters for --call include Solidity-like syntax: balanceOf(0x316b...183d), a four-byte followed by parameters: 0x70a08231(0x316b...183d), or encoded input data.
  - You may specify multiple modes on a single line.

Data models produced by this tool:

Other Options

All tools accept the following additional flags, although in some cases, they have no meaning.

  -v, --version         display the current version of the tool
      --output string   write the results to file 'fn' and return the filename
      --append          for --output command only append to instead of replace contents of file
      --file string     specify multiple sets of command line options in a file

Note: For the --file string option, you may place a series of valid command lines in a file using any valid flags. In some cases, this may significantly improve performance. A semi-colon at the start of any line makes it a comment.

Note: If you use --output --append option and at the same time the --file option, you may not switch export formats in the command file. For example, a command file with two different commands, one with --fmt csv and the other with --fmt json will produce both invalid CSV and invalid JSON.

Documentation

Overview

Package statePkg handles the chifra state command. It The tool retrieves the balance of an address (or list of addresses) at the given block (or blocks). Specify multiple addresses and/or multiple blocks if you wish, but you must specify at least one address. If no block is specified, the latest block is reported. You may also query to see if an address is a smart contract as well as retrieve a contract's byte code.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ResetOptions

func ResetOptions(testMode bool)

func RunState

func RunState(cmd *cobra.Command, args []string) error

RunState handles the state command for the command line. Returns error only as per cobra.

func ServeState

func ServeState(w http.ResponseWriter, r *http.Request) error

ServeState handles the state command for the API. Returns an error.

Types

type StateOptions

type StateOptions struct {
	Addrs      []string                 `json:"addrs,omitempty"`      // One or more addresses (0x...) from which to retrieve balances
	Blocks     []string                 `json:"blocks,omitempty"`     // An optional list of one or more blocks at which to report balances, defaults to 'latest'
	BlockIds   []identifiers.Identifier `json:"blockIds,omitempty"`   // Block identifiers
	Parts      []string                 `json:"parts,omitempty"`      // Control which state to export
	Changes    bool                     `json:"changes,omitempty"`    // Only report a balance when it changes from one block to the next
	NoZero     bool                     `json:"noZero,omitempty"`     // Suppress the display of zero balance accounts
	Call       string                   `json:"call,omitempty"`       // Call a smart contract with a solidity syntax, a four-byte and parameters, or encoded call data
	Articulate bool                     `json:"articulate,omitempty"` // For the --call option only, articulate the retrieved data if ABIs can be found
	ProxyFor   string                   `json:"proxyFor,omitempty"`   // For the --call option only, redirects calls to this implementation
	Globals    globals.GlobalOptions    `json:"globals,omitempty"`    // The global options
	Conn       *rpc.Connection          `json:"conn,omitempty"`       // The connection to the RPC server
	BadFlag    error                    `json:"badFlag,omitempty"`    // An error flag if needed
	// EXISTING_CODE
	ProxyForAddr base.Address `json:"-"`
}

StateOptions provides all command options for the chifra state command.

func GetOptions

func GetOptions() *StateOptions

func GetStateOptions

func GetStateOptions(args []string, g *globals.GlobalOptions) *StateOptions

GetStateOptions returns the options for this tool so other tools may use it.

func (*StateOptions) HandleCall

func (opts *StateOptions) HandleCall() error

func (*StateOptions) HandleDecache

func (opts *StateOptions) HandleDecache() error

func (*StateOptions) HandleShow

func (opts *StateOptions) HandleShow() error

func (*StateOptions) StateInternal

func (opts *StateOptions) StateInternal() error

StateInternal handles the internal workings of the state command. Returns an error.

func (*StateOptions) String

func (opts *StateOptions) String() string

String implements the Stringer interface

Jump to

Keyboard shortcuts

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