Class Abi
java.lang.Object
com.codename1.crypto.evm.Abi
The Solidity contract ABI: function selectors, call data and return values.
EvmAddress recipient = EvmAddress.parse("0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed");
UInt256 amount = UInt256.parseUnits("25", 6);
byte[] data = Abi.encodeCall("transfer(address,uint256)", recipient, amount);
byte[] returned = new byte[32]; // what eth_call answered
List<Object> out = Abi.decode("(uint256)", returned); // [UInt256]
Types are written as in a Solidity signature: uint8..uint256, int8..int256,
address, bool, bytes1..bytes32, bytes, string, arrays T[] and T[k], and
tuples (T1,T2). Values map to Java as:
| ABI | encode accepts | decode answers |
|---|---|---|
uintN |
UInt256, Long, Integer, decimal or 0x String |
UInt256 |
intN |
Long, Integer, decimal String |
Long up to 64 bits, decimal String above |
address |
EvmAddress or its String |
EvmAddress |
bool |
Boolean |
Boolean |
bytesN, bytes |
byte[] |
byte[] |
string |
String |
String |
| arrays, tuples | List or Object[] |
List<Object> |
-
Method Summary
Modifier and TypeMethodDescriptionDecodes ABI bytes against a tuple type, answering one value per member.static byte[]Encodes values against a tuple type such as(address,uint256[],string).static byte[]encodeCall(String signature, Object... args) The call data for a function: its selector followed by the encoded arguments.static byte[]eventTopic(String signature) The topic 0 of an event signature such asTransfer(address,address,uint256).static byte[]The 4-byte selector of a function signature such astransfer(address,uint256).
-
Method Details
-
selector
The 4-byte selector of a function signature such astransfer(address,uint256). -
eventTopic
The topic 0 of an event signature such asTransfer(address,address,uint256). -
encodeCall
-
encode
-
decode
-
decodeHex
-