bcs library
Binary Canonical Serialization (BCS) for Dart.
Build schemas with the factories on Bcs, then use them to serialize and deserialize BCS-encoded data:
import 'package:bcs/bcs.dart';
final coin = Bcs.struct('Coin', {
'value': Bcs.u64(),
'owner': Bcs.string(),
});
final bytes = coin.serialize({'value': 1000000, 'owner': 'Alice'}).toBytes();
final decoded = coin.parse(bytes);
Classes
- Bcs
- Factories for building BCS schemas.
- BcsReader
- Reads BCS primitives from a byte buffer, advancing an internal cursor.
-
BcsType<
T, Input> -
A BCS schema for values of type
T. -
BcsTypeOptions<
T, Input> -
Extra options accepted by the
Bcstype factories. - BcsWriter
- Writes BCS primitives into a growable byte buffer.
- BcsWriterOptions
- Options controlling the buffer of a BcsWriter.
-
SerializedBcs<
T, Input> - The result of serializing a value: raw bytes plus the schema that produced them, convertible to common string encodings.
Functions
-
base58Decode(
String input) → Uint8List - Decodes a base58 string (Bitcoin alphabet) into bytes.
-
base58Encode(
List< int> bytes) → String -
Encodes
bytesas a base58 string using the Bitcoin alphabet. -
hexDecode(
String hex) → Uint8List - Decodes a hexadecimal string into bytes.
-
hexEncode(
List< int> bytes) → String -
Encodes
bytesas a lowercase hexadecimal string without a0xprefix.