xrpl-address-macro
A compile-time macro for converting XRPL classic addresses (r-addresses) to 20-byte arrays.
Features
- Zero runtime overhead: Address decoding happens at compile time
- Type safe: Invalid addresses cause compilation errors
- No binary bloat: The final WASM contains only the raw 20-byte array, no decoding logic
Usage
use r_address;
// Convert r-address to [u8; 20] at compile time
const ACCOUNT: = r_address!;
// Multiple accounts can be defined
const NOTARY: = r_address!;
const ADMIN: = r_address!;
Comparison with Build Script Approach
Using this macro (compile-time constant):
use r_address;
const NOTARY_ACCOUNT: = r_address!;
Using build script (environment variable):
// build.rs decodes NOTARY_ACCOUNT_R env var at build time
include!;
Both approaches result in the same efficient WASM output - the choice depends on whether you need:
- Macro: Fixed addresses known at development time
- Build script: Addresses configurable via environment variables at build time