コード例 #1
0
ファイル: cli.go プロジェクト: eris-ltd/eth-client
func cliAccount(cmd *cobra.Command, args []string) {
	if len(args) == 0 {
		common.Exit(fmt.Errorf("must specify an account"))
	}

	addr := args[0]
	acc := new(Account)
	acc.Address = addr

	r, err := client.RequestResponse("eth", "blockNumber")
	common.IfExit(err)
	blockNum := utils.HexToInt(r.(string))

	r, err = client.RequestResponse("eth", "getBalance", addr, blockNum)
	common.IfExit(err)
	acc.Balance = r.(string)

	r, err = client.RequestResponse("eth", "getTransactionCount", addr, blockNum)
	common.IfExit(err)
	acc.Nonce = uint64(utils.HexToInt(r.(string)))

	r, err = client.RequestResponse("eth", "getCode", addr, blockNum)
	common.IfExit(err)
	acc.Code = r.(string)

	b, err := json.MarshalIndent(acc, "", "\t")
	common.IfExit(err)
	fmt.Println(string(b))
}
コード例 #2
0
ファイル: cli.go プロジェクト: eris-ltd/eth-client
func cliStorage(cmd *cobra.Command, args []string) {
	if len(args) == 0 {
		common.Exit(fmt.Errorf("must specify an account"))
	}

	addr := args[0]
	var storageKey string
	if len(args) > 1 {
		storageKey = args[1]
	}

	r, err := client.RequestResponse("eth", "blockNumber")
	common.IfExit(err)
	blockNum := utils.HexToInt(r.(string))

	if storageKey == "" {
		// get all the storage
		r, err = client.RequestResponse("eth", "getStorage", addr, blockNum)
		common.IfExit(err)
		sortPrintMap(r.(map[string]interface{}))
	} else {
		// only grab one storage entry
		r, err = client.RequestResponse("eth", "getStorageAt", addr, storageKey, blockNum)
		common.IfExit(err)
		fmt.Println(r)
	}
}
コード例 #3
0
ファイル: cli.go プロジェクト: eris-ltd/eth-client
// TODO: this should be able to read off stdin too
func cliBroadcast(cmd *cobra.Command, args []string) {
	if len(args) == 0 {
		common.Exit(fmt.Errorf("must pass some transaction bytes"))
	}

	txHex := args[0]
	r, err := client.RequestResponse("eth", "sendRawTransaction", txHex)
	common.IfExit(err)
	fmt.Println(r)
}
コード例 #4
0
ファイル: cli.go プロジェクト: eris-ltd/eth-client
func cliReceipt(cmd *cobra.Command, args []string) {
	if len(args) == 0 {
		common.Exit(fmt.Errorf("must specify tx hash"))
	}

	txHash := args[0]

	r, err := client.RequestResponse("eth", "getTransactionReceipt", txHash)
	common.IfExit(err)
	sortPrintMap(r.(map[string]interface{}))

}