View Source Ethers.Contract (Ethers v0.0.1-dev)
Dynamically creates modules for ABIs at compile time.
how-to-use
How to use
You can simply create a new module and call use Ethers.Contract
in it with the desired parameters.
defmodule MyProject.Contract do
use Ethers.Contract, abi_file: "path/to/abi.json"
end
After this, the functions in your contracts should be accessible just by calling
data = MyProject.Contract.example_function(...)
# Use data to handle eth_call
Ethers.Contract.call(data, to: "0xADDRESS", from: "0xADDRESS")
{:ok, [...]}
valid-use-options
Valid use
options
- abi: Used to pass in the encoded/decoded json ABI of contract.
- abi_file: Used to pass in the file path to the json ABI of contract.
Link to this section Summary
Link to this section Types
@type action() :: :call | :send | :prepare
@type t_event_output() :: %{ topics: [binary()], address: Ethers.Types.t_address(), selector: ABI.FunctionSelector.t() }
@type t_function_output() :: %{ data: binary(), to: Ethers.Types.t_address(), selector: ABI.FunctionSelector.t() }