@chainsafe/eth2.0-types
TypeScript icon, indicating that this package has built-in type declarations

0.2.1 • Public • Published

eth2.0-types

npm License

Typescript and SSZ types for Eth2 datastructures

Usage

Using the typescript types

import {BeaconState} from "@chainsafe/eth2.0-types";

const b: BeaconState = {
  slot: 5,
  ...
};

Using the ssz types

// mainnet and minimal types pre-generated under non-default export
import {types as mainnetTypes} from "@chainsafe/eth2.0-types/lib/ssz/presets/mainnet";
import {types as minimaltTypes} from "@chainsafe/eth2.0-types/lib/ssz/presets/mainnet";

import {defaultValue} from "@chainsafe/ssz";

defaultValue(mainnetTypes.BeaconState);
defaultValue(minimalTypes.BeaconState);

...

// create your own IBeaconSSZTypes object from an IBeaconParams
import {createIBeaconSSZTypes} from "@chainsafe/eth2.0-types";
import {IBeaconParams} from "@chainsafe/eth2.0-params";
const testnetParams: IBeaconParams = {
  ...
};

const testnetTypes = createIBeaconSSZTypes(testnetParams);

defaultValue(testnetTypes.BeaconState);

License

Apache-2.0

Package Sidebar

Install

npm i @chainsafe/eth2.0-types

Weekly Downloads

4

Version

0.2.1

License

Apache-2.0

Unpacked Size

81 kB

Total Files

68

Last publish

Collaborators

  • sadiq1971
  • ansermino
  • gregthegreek
  • priom
  • wemeetagain
  • mpetrunic