Fetch information on the active era
On-chain name of method: staking_activeEra
Parameters
- None
Returns
index
: The index of the active erastart
: The timestamp when the active era started
Minimal example (Fetch the active era)
-
You will need to set up the dev enviornment required to run this example. For instructions, check out our docs here.
-
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.
- 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()
- Run the code using:
ts-node your-file-name.ts