#blockchain #eos #antelope #data-model

kudu

Library for interacting with Antelope blockchains

1 unstable release

new 0.1.0-alpha Mar 20, 2025

#236 in Magic Beans


Used in 2 crates

MIT/Apache

185KB
4K SLoC

This library provides data types and functions to interact with Antelope blockchains.

The basic types can be found in the types module, and the variant type used to represent values handled by Antelope blockchains is AntelopeValue.

There is a to-do list of items needing to be completed before a first release here: To-Do list, and a list of notes and resources here: Notes

You can also read an overview of the architecture and design decisions.

Feature flags

  • detailed-error: activate this to enable the [macro@with_location] macro. If not enabled, the [macro@with_location] macro will be a no-op.
  • hardened: implement safeguards to check for execution time and recursion depth when validating ABIs. (NOT IMPLEMENTED YET!)
  • float128: add support for a native float128 type. This currently needs a nightly Rust version as f128 support is still experimental. If this is not active, the Float128 will still be available but as a [u8; 16] wrapper.

Antelope data model

![Antelope data model][datamodel]

Data used in the Antelope blockchains can be found in a variety of formats, namely:

  • Rust native data types (structs defined in this library)
  • JSON Value (serde_json::Value) (also called variant in Antelope terminology)
  • JSON string representation
  • binary data

The diagram above shows those types and the different ways to convert between them.

  • most of the conversions are handled via the serde::Serialize and serde::Deserialize traits.
  • to convert between a JSON value and a binary stream you need to use an instance of the [ABI] class which has been initialized with a data schema (ABIDefinition).
  • to convert between a Rust native value and a binary stream you need to use the ABISerializable trait, which you can automatically derive using the ABISerializable derive macro.

Traits implemented for native types

Wherever possible, the following traits are implemented for the base types:

Warnings / pitfalls

  • when defining your own types, make sure to use the Bytes type instead of Vec<u8> otherwise the JSON serialization will not be correct.
  • when defining a variant type using a Rust enum, you need to use the SerializeEnum derive macro instead of serde::Serialize and serde::Deserialize. This is because the discriminant needs to be encoded in a specific way which cannot be achieved with the serde::Serialize trait.

Differences between this library and the Antelope C++ library

  • hex numbers here are lowercase whereas C++ outputs hex data in upper case
  • C++ outputs i64 and u64 as double-quoted, this library doesn't

Dependencies

~24–35MB
~623K SLoC