A wrapper for an ERC-20 contract, allowing the code to interact by pulling data from the contract, or sending transaction to it.
Summary
Functions
Performs an eth_call against the given ERC-20 token with the provided
ABI-encoded call_data and zero value/gas. Returns the call's return data
without sending a transaction. call_opts is forwarded to
Cartouche.RPC.call_trx/2 with this module's known error signatures
merged in.
Returns a list of known error codes (ABI signatures), which can be used when parsing error messages from contract calls.
Executes a transaction against the given ERC-20 token, using the provided
ABI-encoded call_data. The configured Cartouche signer signs and submits
the transaction; exec_opts is forwarded to Cartouche.RPC.execute_trx/3
with this module's known error signatures merged in.
Executes a transfer transaction.
Types
Functions
@spec call_trx(Cartouche.contract(), binary(), call_opts()) :: term()
Performs an eth_call against the given ERC-20 token with the provided
ABI-encoded call_data and zero value/gas. Returns the call's return data
without sending a transaction. call_opts is forwarded to
Cartouche.RPC.call_trx/2 with this module's known error signatures
merged in.
@spec errors() :: [String.t()]
Returns a list of known error codes (ABI signatures), which can be used when parsing error messages from contract calls.
@spec exec_trx(Cartouche.contract(), binary(), exec_opts()) :: term()
Executes a transaction against the given ERC-20 token, using the provided
ABI-encoded call_data. The configured Cartouche signer signs and submits
the transaction; exec_opts is forwarded to Cartouche.RPC.execute_trx/3
with this module's known error signatures merged in.
@spec transfer( Cartouche.contract(), Cartouche.address(), non_neg_integer(), exec_opts() ) :: {:ok, binary()} | {:error, term()}
Executes a transfer transaction.
Arguments:
destination: The destination addressamount_wei: The amount, in token wei, to transfer.exec_opts: Execution options, such as the gas price for the transaction.
Examples
iex> {:ok, _trx_id} = Cartouche.Erc20.transfer(<<0xCC>>, <<0xDD>>, 100_000)