Filecoin.js

Filecoin.js

  • Documentation
  • API Reference
  • GitHub

›Extra

Getting started

  • Introduction
  • Adding Filecoin.js
  • Guides example
  • WS vs HTTP

Setup Wallet Providers

  • Setup lotus provider
  • Setup mnemonic provider
  • Setup metamask provider

Using a provider

  • Send message
  • Sign message
  • Verify message
  • Check if message is mined

Extra

  • Payment channels
  • State methods
  • Multisig Wallets

Contributing

  • How to contribute
  • Development workflow

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>
← Payment channelsMultisig Wallets →
  • Setup example
Docs
Getting StartedAPI Reference
Community
Slack
More
BlogGitHubStar
Copyright © 2022 Filecoin