This library presents a convenient interface to control one or more Harmony nodes using the Elixir programming language. It abstracts away the need to deal with the JSON-RPC API directly and handles hex encoding/decoding when needed.
Functions return the idiomatic {:ok, data} | {:error, reason}
tuples whenever possible. The goal is to cover the entire JSON-RPC API of the standard Geth implemetation.
This project aims to have @specs for every function and is using Dialyzer + ExUnit for testing/linting.
Recent Updates:
- Ability to set proc name of contract manager so we can run several simulatenously
iex> Harmony.client_version
{:ok, "v1.6.5-stable-cf87713d/darwin-amd64/go1.8.3"}
iex> Harmony.sha3("0x68656c6c6f20776f726c64")
{:ok, "47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad"}
iex> Harmony.net_version
{:ok, "1"}
iex> Harmony.peer_count
{:ok, "19"}
iex> Harmony.listening
{:ok, true}
iex> Harmony.protocol_version
{:ok, 63}
iex> Harmony.syncing
{:ok, false}
iex> Harmony.coinbase
{:ok, "78fc2b9b6cf9b18f91037a5e0e074a479be9dca1"}
iex> Harmony.mining
{:ok, true}
iex> Harmony.hashrate
{:ok, "0"}
iex> Harmony.gas_price
{:ok, 22061831512}
iex> Harmony.accounts
{:ok, ["0x78fc2b9b6cf9b18f91037a5e0e074a479be9dca1",
"0x141feb71895530f537c847d62f039d9be895bd35",
"0xe55c5bb9d42307e03fb4aa39ccb878c16f6f901e",
"0x50172f916cb2e64172919090af4ff0ba4638d8dd"]}
iex> Harmony.block_number
{:ok, 3858216}
iex> Harmony.get_balance("0xfE8bf4ca8A6170E759E89EDB5cc9adec3e33493f") # Donations accepted :-)
{:ok, 0.4650075166583676}
iex> Harmony.transaction_count("0xfE8bf4ca8A6170E759E89EDB5cc9adec3e33493f")
{:ok, 3858216}
iex> Harmony.new_account("h4ck3r", "h4ck3r")
{:ok, "50172f916cb2e64172919090af4ff0ba4638d8dd"}
iex> Harmony.unlock_account("0xe55c5bb9d42307e03fb4aa39ccb878c16f6f901e", "h4ck3r")
{:ok, true}
iex> Harmony.lock_account("0xe55c5bb9d42307e03fb4aa39ccb878c16f6f901e")
{:ok, true}
iex> Harmony.send_transaction("0xe55c5bb9d42307e03fb4aa39ccb878c16f6f901e", "0xfE8bf4ca8A6170E759E89EDB5cc9adec3e33493f", 0.00043, "h4ck3r")
{:ok, "88c646f79ecb2b596f6e51f7d5db2abd67c79ff1f554e9c6cd2915f486f34dcb"}
- defdelegate get_transaction_by_hash(hash), to: Eth
- defdelegate get_transaction_receipt_by_hash(hash), to: Eth
- defdelegate get_block_by_hash(hash, full_txns), to: Eth
- defdelegate get_block_by_number(number, full \\ false), to: Eth
- defdelegate get_balance(account_hash), to: Eth
- defdelegate protocol_version(), to: Eth
- defdelegate syncing(), to: Eth
- defdelegate coinbase(), to: Eth
- defdelegate mining(), to: Eth
- defdelegate hashrate(), to: Eth
- defdelegate gas_price(), to: Eth
- defdelegate accounts(), to: Eth
- defdelegate block_number(), to: Eth
- defdelegate transaction_count(hash), to: Eth
- defdelegate get_filter_changes(hash), to: Eth
- defdelegate eth_call(params), to: Eth
- defdelegate eth_send(transaction), to: Eth, as: - :eth_send_transaction
- defdelegate uninstall_filter(id), to: Eth
- defdelegate new_filter(map), to: Eth
- defdelegate client_version(), to: Web3
- defdelegate sha3(str), to: Web3
- defdelegate version(), to: Net
- defdelegate peer_count(), to: Net
- defdelegate listening(), to: Net
- defdelegate new_account(password, password_confirmation), to: Personal
- defdelegate unlock_account(account, password), to: Personal
- defdelegate lock_account(account), to: Personal
- defdelegate send_transaction(from, to, amount, password), to: Personal
- defdelegate get_recent_averages(sample_size), to: Aggregates
- defdelegate get_recent_blocks(sample_size), to: Aggregates
- defdelegate get_recent_blocktimes(sample_size), to: Aggregates
- defdelegate get_recent_blocks_with_blocktimes(sample_size), to: Aggregates
- defdelegate get_recent_transactions_per_block(sample_size), to: Aggregates
- defdelegate get_average_blocktime(blocks), to: Aggregates
- defdelegate get_average_difficulty(blocks), to: Aggregates
- defdelegate unhex(str), to: HexUtils
- defdelegate to_hex(str), to: HexUtils
- defdelegate is_valid_address?(address), to: HexUtils
- defdelegate hex_to_decimal(hex_string), to: HexUtils
- defdelegate load_abi(file), to: ABI
- defdelegate reformat_abi(abi), to: ABI
- defdelegate abi_method_signature(abi, name), to: ABI, as: :method_signature
- defdelegate encode_abi_event(signature), to: ABI, as: :encode_event
- defdelegate encode_abi_data(signature), to: ABI, as: :encode_data
- defdelegate encode_abi_options(options, keys), to: ABI, as: :encode_options
- defdelegate encode_abi_option(value), to: ABI, as: :encode_option
- defdelegate encode_abi_method_call(abi, name, input), to: ABI, as: :encode_method_call
- defdelegate decode_abi_data(types_signature, data), to: ABI, as: :decode_data
- defdelegate decode_abi_output(abi, name, output), to: ABI, as: :decode_output
- defdelegate decode_abi_event(data, signature), to: ABI, as: :decode_event
- defdelegate abi_keys_to_decimal(map, keys), to: ABI, as: :keys_to_decimal