View Source Ethers (Ethers v0.0.3)
high-level module providing a convenient and efficient interface for interacting with the Ethereum blockchain using Elixir.
This module offers a simple API for common Ethereum operations such as deploying contracts, estimating gas, fetching current gas prices, and querying event logs.
Link to this section Summary
Functions
Returns the current gas price from the RPC API
Deploys a contract to the blockchain.
Returns the address of the deployed contract if the deployment is finished and successful
Estimates gas for a eth_call
Returns the event logs with the given filter
Link to this section Functions
@spec current_gas_price() :: {:ok, non_neg_integer()}
Returns the current gas price from the RPC API
deploy(contract_module_or_binary, contract_init, params, opts \\ [])
View Source@spec deploy(atom() | binary(), binary(), Keyword.t(), Keyword.t()) :: {:ok, Ethers.Types.t_hash()} | {:error, atom()}
Deploys a contract to the blockchain.
This will return the transaction hash for the deployment transaction.
To get the address of your deployed contract, use Ethers.deployed_address/2
.
To deploy a cotract you must have the binary related to it. It can either be a part of the ABI File you have or as a separate file.
parameters
Parameters
- contract_module_or_binary: Either the contract module which was already loaded or the compiled binary of the contract.
- contract_init: Constructor value for contract deployment. Use
CONTRACT_MODULE.constructor
function's output. If your contract does not have a constructor, you can pass an empty binary here. - params: Parameters for the transaction creating the contract.
- opts: RPC and account options.
@spec deployed_address(binary(), Keyword.t()) :: {:ok, Ethers.Types.t_address()} | {:error, :no_contract_address | :transaction_not_found | atom()}
Returns the address of the deployed contract if the deployment is finished and successful
parameters
Parameters
- tx_hash: Hash of the Transaction which created a contract.
- opts: RPC and account options.
@spec estimate_gas(map(), Keyword.t()) :: {:ok, non_neg_integer()} | {:error, :gas_estimation_failed}
Estimates gas for a eth_call
parameters
Parameters
- params
- opts: RPC and account options.
@spec get_logs(map(), Keyword.t(), Keyword.t()) :: {:ok, [Ethers.Event.t()]} | {:error, atom()}
Returns the event logs with the given filter