TIP-20 token function selectors, ABI calldata encoders, and Tempo constants.
TIP-20 is Tempo's token standard (compatible with ERC-20, with extensions
like transferWithMemo). This module provides the function selectors and
calldata builders needed for constructing and matching Tempo transaction calls.
Selectors
All selectors are 4-byte binaries (keccak256 of the function signature):
Onchain.Tempo.TIP20.transfer_selector()
#=> <<0xA9, 0x05, 0x9C, 0xBB>>Calldata
Calldata functions accept raw 20-byte binaries (not hex strings):
recipient = <<0x74, 0x2D, ...::binary-size(18)>>
Onchain.Tempo.TIP20.transfer_calldata(recipient, 1_000_000)Constants
Onchain.Tempo.TIP20.stablecoin_dex_address()
#=> <<0xDE, 0xC0, ...>> # 20-byte binary
Summary
Functions
ABI-encode approve(address,uint256) calldata.
Returns the approve(address,uint256) function selector.
Decode a hex address string (with or without 0x prefix) to a 20-byte binary.
Returns the canonical Tempo stablecoin DEX contract address (20-byte binary).
Returns the swapExactAmountOut(address,address,uint128,uint128) function selector.
ABI-encode transfer(address,uint256) calldata.
Returns the transfer(address,uint256) function selector.
ABI-encode transferWithMemo(address,uint256,bytes32) calldata.
Returns the transferWithMemo(address,uint256,bytes32) function selector.
Functions
@spec approve_calldata(<<_::160>>, non_neg_integer()) :: binary()
ABI-encode approve(address,uint256) calldata.
Parameters
spender— 20-byte binary addressamount— approval amount as non-negative integer
@spec approve_selector() :: <<_::32>>
Returns the approve(address,uint256) function selector.
Decode a hex address string (with or without 0x prefix) to a 20-byte binary.
Examples
Onchain.Tempo.TIP20.decode_address("0xdec0000000000000000000000000000000000000")
#=> <<0xDE, 0xC0, 0x00, ...>>
@spec stablecoin_dex_address() :: <<_::160>>
Returns the canonical Tempo stablecoin DEX contract address (20-byte binary).
@spec swap_exact_amount_out_selector() :: <<_::32>>
Returns the swapExactAmountOut(address,address,uint128,uint128) function selector.
@spec transfer_calldata(<<_::160>>, non_neg_integer()) :: binary()
ABI-encode transfer(address,uint256) calldata.
Parameters
recipient— 20-byte binary addressamount— transfer amount as non-negative integer
@spec transfer_selector() :: <<_::32>>
Returns the transfer(address,uint256) function selector.
@spec transfer_with_memo_calldata(<<_::160>>, non_neg_integer(), <<_::256>>) :: binary()
ABI-encode transferWithMemo(address,uint256,bytes32) calldata.
Parameters
recipient— 20-byte binary addressamount— transfer amount as non-negative integermemo— 32-byte binary memo
@spec transfer_with_memo_selector() :: <<_::32>>
Returns the transferWithMemo(address,uint256,bytes32) function selector.