View Source mix signet.gen (Signet v1.3.8)

signet.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

defmodule SomeContract do
  use Signet.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
    Signet.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:

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

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

Usage

mix signet.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/]