![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
@polkadot/types
Advanced tools
Implementation of the types and their (de-)serialisation via SCALE codec.
On the Rust side, the codec types and primitive types are implemented via the parity-codec.
These are the base types of the codec. They are typically not used directly, but rather inherited from to create specific types. They are the building blocks for declaring custom types:
Types | |
---|---|
[[Compact]] | A compact length-encoding codec wrapper. Mostly used by other types to add length-prefixed encoding |
[[Enum]] | A codec wrapper for an enum. Enums are encoded as a single byte, where the byte is a zero-indexed value |
[[Int]] | A generic signed integer codec |
[[Option]] | An Option is an optional field. The first byte indicates that there is a value to follow |
[[Set]] | An Set is an array of string values, represented an an encoded type by a bitwise representation of the values |
[[Struct]] | A Struct defines an Object with key-value pairs - where the values are Codec values. |
[[Tuple]] | A Tuple defines an anonymous fixed-length array, where each element has its own type |
[[Raw]] | A basic wrapper around Uint8Array. It will consume the full Uint8Array as passed to it |
[[U8aFixed]] | A U8a that manages a a sequence of bytes up to the specified bitLength |
[[UInt]] | A generic unsigned integer codec. It handles the encoding and decoding of Little Endian encoded numbers in Substrate |
[[Vec]] | This manages codec arrays. Internally it keeps track of the length (as decoded) |
[[VecAny]] | This manages codec arrays, assuming that the inputs are already of type Codec |
These primitive types are available:
Types | |
---|---|
[[AccountId]] | A wrapper around an AccountId/PublicKey representation |
[[AccountIndex]] | A wrapper around an AccountIndex, which is a shortened, variable-length encoding for an Account |
[[Address]] | A wrapper around an AccountId and/or AccountIndex that is encoded with a prefix |
[[bool]] | Representation for a boolean value in the system |
[[Bytes]] | A Bytes wrapper for Vec<u8> |
[[Call]] | Extrinsic function descriptor, as defined in the extrinsic format for a node |
[[Event]] | Wrapper for the actual data that forms part of an [[Event]] |
[[EventRecord]] | A record for an [[Event]] (as specified by [[Metadata]]) with the specific [[Phase]] of application |
[[Extrinsic]] | Representation of an Extrinsic in the system |
[[ExtrinsicEra]] | The era for an extrinsic, indicating either a mortal or immortal extrinsic |
[[ExtrinsicPayload]] | A signing payload for an [[Extrinsic]]. For the final encoding, it is variable length based on the contents included |
[[H160]] | Hash containing 160 bits (20 bytes), typically used in blocks, extrinsics and as a sane default |
[[H256]] | Hash containing 256 bits (32 bytes), typically used in blocks, extrinsics and as a sane default |
[[H512]] | Hash containing 512 bits (64 bytes), typically used for signatures |
[[Hash]] | The default hash that is used accross the system. It is just a thin wrapper around [[H256]] |
[[i8]] | An 8-bit signed integer |
[[i16]] | A 16-bit signed integer |
[[i32]] | A 32-bit signed integer |
[[i64]] | A 64-bit signed integer |
[[i128]] | A 128-bit signed integer |
[[i256]] | A 256-bit signed integer |
[[Moment]] | A wrapper around seconds/timestamps. Internally the representation only has second precicion (aligning with Rust) |
[[Null]] | Implements a type that does not contain anything (apart from null ) |
[[Signature]] | The default signature that is used accross the system |
[[StorageData]] | Data retrieved via Storage queries and data for key-value pairs |
[[StorageKey]] | A representation of a storage key (typically hashed) in the system |
[[Text]] | This is a string wrapper, along with the length. |
[[Type]] | This is a extended version of String, specifically to handle types |
[[u8]] | An 8-bit unsigned integer |
[[u16]] | A 16-bit unsigned integer |
[[u32]] | A 32-bit unsigned integer |
[[u64]] | A 64-bit unsigned integer |
[[u128]] | A 128-bit unsigned integer |
[[u256]] | A 256-bit unsigned integer |
FAQs
Implementation of the Parity codec
The npm package @polkadot/types receives a total of 105,856 weekly downloads. As such, @polkadot/types popularity was classified as popular.
We found that @polkadot/types demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.