# `Cartouche.Erc20`
[🔗](https://github.com/zenhive/cartouche/blob/main/lib/cartouche/erc_20.ex#L1)

A wrapper for an [ERC-20 contract](https://eips.ethereum.org/EIPS/eip-20),
allowing the code to interact by pulling data from the contract, or sending
transaction to it.

# `call_opts`

```elixir
@type call_opts() :: Keyword.t()
```

# `exec_opts`

```elixir
@type exec_opts() :: Keyword.t()
```

# `call_trx`

```elixir
@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.

# `errors`

```elixir
@spec errors() :: [String.t()]
```

Returns a list of known error codes (ABI signatures), which can be used
when parsing error messages from contract calls.

# `exec_trx`

```elixir
@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.

# `transfer`

```elixir
@spec transfer(
  Cartouche.contract(),
  Cartouche.address(),
  non_neg_integer(),
  exec_opts()
) ::
  {:ok, binary()} | {:error, term()}
```

Executes a `transfer` transaction.

Arguments:
  - `destination`: The destination address
  - `amount_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)

---

*Consult [api-reference.md](api-reference.md) for complete listing*
