solabi
Solidity ABI implementation in Rust.
Introduction
This crate aims to provide a comprehensive toolkit for working with the Solidity ABI in Rust, including encoding and decoding values as well as parsing JSON ABI generated by the Solidity complier.
Usage
Future Work
While the core components of the Solidity ABI implementation are mostly
complete, there are a couple of features that expected to be implemented before
v1 of this crate, namely:
-
Procedural macros for Solidity ABI item generation. This includes generating types for encoding and decoding Solidity contract items. While the exact API is not yet determined, it is expected to look something like:
```rust #[derive(solabi::Function)] #[function("transferFrom(address, address, uint256) returns (bool)")] struct TransferFrom; #[derive(solabi::Event)] struct Transfer { #[indexed] pub from: Address, #[indexed] pub to: Address, pub value: U256, } fn main() { TransferFrom.encode_params(...); TransferFrom.decode_result(...); Transfer { ... }.encode(); Transfer::decode(Log { topics: ..., data: ..., }) } ``` -
Derive macro for
EncodeandDecode```rust #[derive(solabi::Decode, solabi::Encode)] struct MyStruct { name: String, age: uint256, occupation: Occupation, } #[derive(solabi::Decode, solabi::Encode)] enum Occupation { Crypto, Other, } ```