Class Erc20
java.lang.Object
com.codename1.crypto.evm.Erc20
Call data for ERC-20 tokens (USDC, USDT, DAI...). A token transfer is a transaction to the token contract with value 0 and this call data; the recipient is inside it.
EvmAddress recipient = EvmAddress.parse("0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed");
EvmAddress usdc = EvmAddress.parse("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48");
long nonce = 0;
UInt256 tip = UInt256.parseUnits("1", 9);
UInt256 maxFee = UInt256.parseUnits("30", 9);
byte[] data = Erc20.transfer(recipient, UInt256.parseUnits("25", 6)); // 25 USDC
EvmTransaction tx = EvmTransaction.eip1559(1, nonce, tip, maxFee, 65000, usdc, UInt256.ZERO, data);
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringTopic 0 ofTransfer(address,address,uint256). -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]allowance(EvmAddress owner, EvmAddress spender) allowance(owner, spender), foreth_call.static byte[]approve(EvmAddress spender, UInt256 amount) approve(spender, amount).static byte[]balanceOf(EvmAddress owner) balanceOf(owner), foreth_call.static byte[]decimals()decimals(), foreth_call.static StringdecodeString(byte[] returned) Reads astringreturned bynameorsymbol.static Erc20.TransferdecodeTransfer(List<String> topics, byte[] data) Decodes aTransferlog from its topics and data, or answersnullfor any other log.static UInt256decodeUint(byte[] returned) Reads auint256returned bybalanceOf,allowance,decimalsortotalSupply.static byte[]name()name(), foreth_call.static byte[]symbol()symbol(), foreth_call.static byte[]totalSupply(), foreth_call.static byte[]transfer(EvmAddress to, UInt256 amount) transfer(to, amount).static byte[]transferFrom(EvmAddress from, EvmAddress to, UInt256 amount) transferFrom(from, to, amount).
-
Field Details
-
TRANSFER_TOPIC
-
-
Method Details
-
transfer
transfer(to, amount). -
approve
approve(spender, amount). -
transferFrom
transferFrom(from, to, amount). -
balanceOf
balanceOf(owner), foreth_call. -
allowance
allowance(owner, spender), foreth_call. -
decimals
public static byte[] decimals()decimals(), foreth_call. -
symbol
public static byte[] symbol()symbol(), foreth_call. -
name
public static byte[] name()name(), foreth_call. -
totalSupply
public static byte[] totalSupply()totalSupply(), foreth_call. -
decodeUint
Reads auint256returned bybalanceOf,allowance,decimalsortotalSupply. -
decodeString
Reads astringreturned bynameorsymbol. -
decodeTransfer
Decodes a
Transferlog from its topics and data, or answersnullfor any other log.Parameters
-
topics: the log's topics as0xhex, aseth_getLogsreturns them -
data: the log's data
-
-