Ethereum abi.encodePacked() in Rust
This project allows data serialization and packing in Rust as it's being done in Solidity with abi.encodePacked()
Example usage
packing an uint24
let input = vec!;
let = encode_packed;
let hash = format!;
let expected = "0x000fa1";
assert_eq!;
Packing a lot of data
Solidity
function packer(
uint24 uint24_data,
uint256 tokenId,
string calldata ipfsURI,
address sample,
uint256 id
) public pure returns (bytes memory ){
bytes memory res = abi.encodePacked(uint24_data, tokenId, ipfsURI, sample, id);
return res;
}
Rust
let address = decode.unwrap;
let address: = address.try_into.unwrap;
let input = vec!;
let = encode_packed;
let hash = format!;
let expected = "0x000efe0000000000000000000000000000000000000000000000000000000000000fa1746869732d69732d612d73616d706c652d737472696e67d8b934580fce35a11b58c6d73adee468a2833fa80000000000000000000000000000000000000000000000000000000000000001";
assert_eq!;