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

`cartouche.gen` generates wrapper modules from Solidity artifacts.

This module will auto-generate code that can be used to easily call into
a contract. You can pass in either the ABI output or the full Solidity
output. If you pass in the Solidity artifacts, you'll get wrappers for
the bytecode.

For example, `some_contract.ex`

```elixir
defmodule SomeContract do
  use Cartouche.Hex

  def contract_name do
    "SomeContract"
  end

  def encode_some_function(val) do
    ABI.encode("some_function(uint256)", [val])
  end

  def execute_some_function(contract, val, opts \\ []) do
    Cartouche.RPC.execute_trx(contract, encode_some_function(val), opts)
  end

  def bytecode(), do: ~h[0x...]

  def deployed_bytecode(), do: ~h[0x...]
end
```

These stubs are useful, since you can easily then call:

```iex
{:ok, tx_id} = Contract.SomeContract.execute_some_function(addr, 55, priority_fee: {55, :gwei})
```

🐉🌊🌊🌊🌊🌊🐉   HERE BE DRAGONS    🐉🌊🌊🌊🌊🌊🐉

# Usage

`mix cartouche.gen "out/**/*.json"`

 * `--prefix`: Prefix for the outputed modules
   - E.g. `my_app` -> `MyApp.SomeContract` in `my_app/some_contract.ex`
   - E.g. `my_app/contract` -> `MyApp.Contract.SomeContract` in `my_app/contract/some_contract.ex`
 * `--out`: Out directory, e.g. `lib/my_app/` [default `lib/`]

---

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