API reference
Fetch information on the active era

Fetch information on the active era

On-chain name of method: staking_activeEra

Parameters

  • None

Returns

  • index: The index of the active era
  • start: The timestamp when the active era started

Minimal example (Fetch the active era)

  1. You will need to set up the dev enviornment required to run this example. For instructions, check out our docs here.

  2. If you're sending an extrinsic (i.e conducting a transaction) you will need to replace the demo seed phrase with your own seed phrase. The rest of the code should work as is.

  1. Inside your-file-name.ts, add the following code:
avail-js
import { SDK } from "avail-js-sdk"
 
const main = async () => {
  const providerEndpoint = "wss://turing-rpc.avail.so/ws"
  const sdk = await SDK.New(providerEndpoint)
 
  const value = await sdk.api.query.staking.activeEra()
  console.log(value.toHuman())
 
  process.exit()
}
 
main()
  1. Run the code using:
ts-node your-file-name.ts