#xdr #stellar #alloc #std

bin+lib stellar-xdr

Stellar XDR types, encoding, and decoding

13 releases

0.0.16 May 4, 2023
0.0.15 Mar 22, 2023
0.0.14 Feb 14, 2023
0.0.11 Dec 8, 2022
0.0.1 Jul 29, 2022

#37 in Memory management

Download history 1473/week @ 2023-02-10 1152/week @ 2023-02-17 664/week @ 2023-02-24 317/week @ 2023-03-03 168/week @ 2023-03-10 205/week @ 2023-03-17 239/week @ 2023-03-24 330/week @ 2023-03-31 181/week @ 2023-04-07 237/week @ 2023-04-14 174/week @ 2023-04-21 199/week @ 2023-04-28 108/week @ 2023-05-05 183/week @ 2023-05-12 307/week @ 2023-05-19 329/week @ 2023-05-26

992 downloads per month
Used in 15 crates (5 directly)


72K SLoC


Library and CLI containing types and functionality for working with Stellar XDR.

Types are generated from XDR definitions hosted at stellar/stellar-xdr using xdrgen.

This repository contains code that is in early development, incomplete, not tested, and not recommended for use. The API is unstable, experimental, and is receiving breaking changes frequently.



To use the library, include in your toml:

stellar-xdr = { version = "...", default-features = true, features = [] }

The crate has several features, tiers of functionality, ancillary functionality, and channels of XDR.

Default features: std, curr.

Teirs of functionality:

  1. std – The std feature provides all functionality (types, encode, decode), and is the default feature set.
  2. alloc – The alloc feature uses Box and Vec types for recursive references and arrays, and is automatically enabled if the std feature is enabled. The default global allocator is used. Support for a custom allocator will be added in #39. No encode or decode capability exists, only types. Encode and decode capability will be added in #46.
  3. If std or alloc are not enabled recursive and array types requires static lifetime values. No encode or decode capability exists. Encode and decode capability will be added in #47.

Ancillary functionality:

  1. base64 – Enables support for base64 encoding and decoding.
  2. serde – Enables support for serializing and deserializing types with the serde crate.
  3. arbitrary – Enables support for interop with the arbitrary crate.

Channels of XDR:

  • curr – XDR types built from the stellar/stellar-xdr curr branch.
  • next – XDR types built from the stellar/stellar-xdr next branch.

If a single channel is enabled the types are available at the root of the crate. If multiple channels are enabled they are available in modules at the root of the crate.


To use the CLI:

cargo install --locked stellar-xdr --version ... --features cli

Parse a TransactionEnvelope:

stellar-xdr decode --type TransactionEnvelope << -

Parse a ScSpecEntry stream from a contract:

stellar-xdr +next decode --type ScSpecEntry --input stream-base64 --output json-formatted << -

Parse a BucketEntry framed stream from a bucket file:

stellar-xdr decode --type BucketEntry --input stream-framed --output json-formatted bucket.xdr

License: Apache-2.0


~43K SLoC