# `Ethers.Contract`
[🔗](https://github.com/ExWeb3/elixir_ethers/blob/v0.6.12/lib/ethers/contract.ex#L1)

Dynamically creates modules for ABIs at compile time.

## How to use
You can simply create a new module and call `use Ethers.Contract` in it with the desired parameters.

```elixir
# Using an ABI file
defmodule MyProject.Contract do
  use Ethers.Contract, abi_file: "path/to/abi.json"
end

# Providing a default address
defmodule MyProject.Contract do
  use Ethers.Contract, abi_file: "path/to/abi.json", default_address: "0x1234...999"
end

# Using an ABI directly
defmodule MyProject.Contract do
  use Ethers.Contract, abi: [%{"inputs" => [], "type" => "constructor"}, ...]
end
```

After this, the functions in your contracts should be accessible just by calling
```elixir
data = MyProject.Contract.example_function(...)

# Use data to handle eth_call
Ethers.call(data, to: "0xADDRESS", from: "0xADDRESS")
{:ok, [...]}
```

## Valid `use` options
- `abi`: Used to pass in the decoded (or even encoded json binary) ABI of contract.
- `abi_file`: Used to pass in the file path to the json ABI of contract.
- `default_address`: Default contract deployed address to include in the parameters. (Optional)
- `skip_docs`: Determines if Ethers should skip generating docs and typespecs. (Default: false)
  - `true`: Skip docs and typespecs for all functions.
  - `false`: Generate docs and typespecs for all functions.
  - `[{function_name :: atom(), skip_docs :: boolean()}]`: Specify for each function.

---

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