Registry / serialization / borsh-construct

borsh-construct

JSON →
library0.1.0pypypi✓ verified 80d ago

Python implementation of Borsh serialization, built on the Construct library. Version 0.1.0. Low release cadence.

pip install borsh-construct
INSTALL
IMPORT
SIG · BORSH-CONSTRUCT
B
borsh-construct
serializationpythonv0.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

CStruct
from borsh_construct import CStruct
from borsh_construct import BorshStruct
Enum
from borsh_construct import Enum
String
from borsh_construct import String

Define a Borsh-serializable struct, encode, and decode.

from borsh_construct import BorshStruct, U8, U32, String, Vec # Define a simple Borsh schema class Person(BorshStruct): name = String age = U32 hobbies = Vec(String) # Encode an instance data = Person.encode({'name': 'Alice', 'age': 30, 'hobbies': ['reading', 'coding']}) print('Encoded:', data.hex()) # Decode back decoded = Person.decode(data) print('Decoded:', decoded)
Debug
Known issues
gotchaborsh-construct uses the Construct library under the hood. If you mix borsh_construct types with pure construct types, serialization may fail silently or produce non-Borsh-compatible output.
fix
Always use types imported from borsh_construct rather than construct directly when working with Borsh serialization.
affects: all
gotchaBorsh is strict about field order. When subclassing BorshStruct, field order in class definition matters and must match the schema exactly.
fix
Define fields in the same order as the schema you are conforming to. Do not assume alphabetical or insertion order.
affects: all
Upgrade
Version history
0.1.0latest on PyPI · released Oct 20, 2021
Audit
Dependencies
constructrequiredCore dependency; borsh-construct is built on top of construct.
Agent activity
15 hits · last 30 days
node
12
Amazon
1
OpenAI (training)
1
Resources
borsh-construct — pip install borsh-construct · libregistry