Lodestar Eth Consensus API
This package is part of ChainSafe's Lodestar project
Typescript REST client for the Ethereum Consensus API spec
Usage
We use more typesafe approach for the API client, where all the errors are returned not thrown. This approach is more easy to document and better to handle all possible error cases.
import {getClient, HttpError} from "@lodestar/api";
import {config} from "@lodestar/config/default";
const api = getClient({baseUrl: "http://localhost:9596"}, {config});
api.beacon
.getStateValidator(
"head",
"0x933ad9491b62059dd065b560d256d8957a8c402cc6e8d8ee7290ae11e8f7329267a8811c397529dac52ae1342ba58c95"
)
.then((res) => {
if(res.ok) {
console.log("Your balance is:", res.response.data.balance, res.ok, res.status);
} else {
console.error(res.status, res.error.code, res.error.message);
}
});
Prerequisites
What you need
You will need to go over the specification. You will also need to have a basic understanding of sharding.
Getting started
- Follow the installation guide to install Lodestar.
- Quickly try out the whole stack by starting a local testnet.
Contributors
Read our contributors document, submit an issue or talk to us on our discord!
License
Apache-2.0 ChainSafe Systems