View Source Ethers (Ethers v0.0.6)
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, fetching current gas prices, and querying event logs.
Summary
Functions
Returns the current block number of the blockchain.
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
Returns the event logs with the given filter
Functions
@spec current_block_number(Keyword.t()) :: {:ok, non_neg_integer()} | {:error, term()}
Returns the current block number of the blockchain.
@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
- contract_module_or_binary: Either the contract module which was already loaded or the compiled binary of the contract. The binary MUST be hex encoded.
- 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
- tx_hash: Hash of the Transaction which created a contract.
- 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