#move #byte-array #macro #aptos #sui

static-address

A macro used for compile-time parsing of Move account addresses into byte arrays for near 0-cost static addresses

4 releases

0.2.2 Jul 22, 2022
0.2.0 Jul 22, 2022
0.1.2 Jul 3, 2022
0.1.1 Jul 3, 2022

#3 in #aptos

Download history 10/week @ 2024-07-24 10/week @ 2024-07-31 5/week @ 2024-08-07 4/week @ 2024-08-14 2/week @ 2024-09-18 9/week @ 2024-09-25 11/week @ 2024-10-02

81 downloads per month
Used in 10 crates (5 directly)

Apache-2.0

5KB

static-address

Crates.io License Build Status Contributors

The static-address crate provides a macro static_address!, used for compile-time parsing of strings into a static address. This provides an efficient way of declaring Move account addresses in source code while incurring almost no runtime cost in programs, without having to declare the byte array yourself. The actual code is adapted from here.

Usage

let key =
    static_address!("0x80809acd8d3bc3d30aea82e5506f45951e3eb53e2fda39da6d772647e52c25cd");
assert_eq!(
    key.to_hex_literal(),
    "0x80809acd8d3bc3d30aea82e5506f45951e3eb53e2fda39da6d772647e52c25cd"
);

An example of using this for an Aptos project is available at crates/static-address-example-aptos.

License

static-address is licensed under the Apache License, version 2.0.

Dependencies

~3.5MB
~72K SLoC