Web3 can be installed from the package manager hex as follows.
-
Add
web3
to your list of dependencies inmix.exs
:def deps do [{:web3, "~> 0.1.6"}] end
-
Fetch mix dependencies:
$ mix deps.get
-
Define a Application module for your app.
defmodule MyApp.Application do use web3, rpc_endpoint: "<PATH_TO_RPC_ENDPOINT>" end
-
Then you can use the following APIs
- Infura Eth Method of the same name: Eth API.
- Includes a number of convenient utility functions: Base API.
iex> MyApp.Application.eth_blockNumber {:ok, 15034908}