diff --git a/cli/state.go b/cli/state.go index 31537cc89..7db7fa719 100644 --- a/cli/state.go +++ b/cli/state.go @@ -72,6 +72,7 @@ var stateCmd = &cli.Command{ stateMinerInfo, stateMarketCmd, stateExecTraceCmd, + stateNtwkVersionCmd, }, } @@ -1831,3 +1832,32 @@ var stateMarketBalanceCmd = &cli.Command{ return nil }, } + +var stateNtwkVersionCmd = &cli.Command{ + Name: "network-version", + Usage: "Returns the network version", + Action: func(cctx *cli.Context) error { + if cctx.Args().Present() { + return ShowHelp(cctx, fmt.Errorf("doesn't expect any arguments")) + } + + api, closer, err := GetFullNodeAPI(cctx) + if err != nil { + return err + } + defer closer() + + ctx := ReqContext(cctx) + + ts, err := LoadTipSet(ctx, cctx, api) + if err != nil { + return err + } + + nv, err := api.StateNetworkVersion(ctx, ts.Key()) + + fmt.Printf("Network Version: %d\n", nv) + + return nil + }, +}