How to store data of U256 type in Rust

I am into a usecase where i want to store a value 0f U256 in rust. how to do that?kindly help

1 Like

you can probably use zkp_u256 - Rust or ethnum - Rust which implement it as a standard library type.

  1. Hi. I am really stuck at this problem for few days. Kindly help. In a struct { balance: U256 } i want to use U256 type but isn't supported by rust. so I imported primitive_type crates and doing with that. but when i do cargo check i am receiving the below error
  the trait `Serialize` is not implemented for `primitive_types::U256`

I want to serialize the struct with U256 variable

The primitive_types crate has a serde feature flag you can enable. Although it might be worth testing how it works with u256; most serialization targets are not going to support an integer of that size.

1 Like

Yes thank you that error is solved but after that i am facing below issue.

error[E0046]: not all trait items implemented, missing: Pair
--> /home/.cargo/registry/src/
240 | impl $crate::CryptoType for Public {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing Pair in implementation

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.