Codec library for protobuf3 in Solidity. This library provides encoding and decoding functions for core protobuf3 types.
npm install --save @lazyledger/protobuf3-solidity-lib
Import the library in Solidity:
pragma solidity >=0.6.0 <8.0.0;
import "@lazyledger/protobuf3-solidity-lib/contracts/ProtobufLib.sol";
Install dependencies:
npm install
Build:
npm run build
Test:
npm run test
Code coverage:
npm run coverage
type | decode | encode |
---|---|---|
key | ✔️ | ✔️ |
varint | ✔️ | ✔️ |
int32 |
✔️ | ✔️ |
int64 |
✔️ | ✔️ |
uint32 |
✔️ | ✔️ |
uint64 |
✔️ | ✔️ |
sint32 |
✔️ | ✔️ |
sint64 |
✔️ | ✔️ |
fixed32 |
✔️ | ✔️ |
sfixed32 |
✔️ | ✔️ |
fixed64 |
✔️ | ✔️ |
sfixed64 |
✔️ | ✔️ |
bool |
✔️ | ✔️ |
enum | ✔️ | ✔️ |
string |
✔️ | ✔️ |
bytes |
✔️ | ✔️ |
embedded messages | ✔️ | ✔️ |
packed repeated | ✔️ | ✔️ |
Start and end group deprecated wire types, float
, double
field types.