State methods
The State methods are used to query, inspect, and interact with chain state. All methods take a TipSetKey as a parameter. The state looked up is the state at that tipset. A nil TipSetKey can be provided as a param, this will cause the heaviest tipset in the chain to be used.
The state methods can be used after you instantiate a LotusClient.
The methods cand be found here.
Setup example
Node JavaScript/TypeScript:
import { HttpJsonRpcConnector, HttpJsonRpcWalletProvider } from 'filecoin.js';
(async () => {
const connector = new HttpJsonRpcConnector({ url: __LOTUS_RPC_ENDPOINT__, token: __LOTUS_AUTH_TOKEN__ });
const lotusClient = new LotusClient(connector);
const networkName = await lotusClient.state.networkName();
})().then().catch();
Browser:
<script type="text/javascript" src="https://unpkg.com/filecoin.js"></script>
<script type="text/javascript">
(async () => {
const connector = new FilecoinJs.HttpJsonRpcConnector({ url: __LOTUS_RPC_ENDPOINT__, token: __LOTUS_AUTH_TOKEN__ });
const lotusClient = new FilecoinJs.LotusClient(connector);
const networkName = await lotusClient.state.networkName();
})().then().catch();
</script>