class Web3::Eth::EthModule
Constants
- PREFIX
Public Class Methods
new(web3_rpc)
click to toggle source
# File lib/web3/eth/eth_module.rb, line 10 def initialize web3_rpc @web3_rpc = web3_rpc end
Public Instance Methods
blockNumber()
click to toggle source
# File lib/web3/eth/eth_module.rb, line 24 def blockNumber from_hex @web3_rpc.request("#{PREFIX}#{__method__}") end
contract(abi)
click to toggle source
# File lib/web3/eth/eth_module.rb, line 36 def contract abi Web3::Eth::Contract.new abi, @web3_rpc end
getBalance(address, block = 'latest', convert_to_eth = true)
click to toggle source
# File lib/web3/eth/eth_module.rb, line 14 def getBalance address, block = 'latest', convert_to_eth = true wei = @web3_rpc.request("#{PREFIX}#{__method__}", [address, block]).to_i 16 convert_to_eth ? wei_to_ether(wei) : wei end
getBlockByNumber(block, full = true, convert_to_object = true)
click to toggle source
# File lib/web3/eth/eth_module.rb, line 19 def getBlockByNumber block, full = true, convert_to_object = true resp = @web3_rpc.request("#{PREFIX}#{__method__}", [hex(block), full]) convert_to_object ? Block.new(resp) : resp end
getTransactionByHash(tx_hash)
click to toggle source
# File lib/web3/eth/eth_module.rb, line 28 def getTransactionByHash tx_hash Transaction.new @web3_rpc.request("#{PREFIX}#{__method__}", [tx_hash]) end
getTransactionReceipt(tx_hash)
click to toggle source
# File lib/web3/eth/eth_module.rb, line 32 def getTransactionReceipt tx_hash TransactionReceipt.new @web3_rpc.request("#{PREFIX}#{__method__}", [tx_hash]) end
load_contract(etherscan_api, contract_address)
click to toggle source
# File lib/web3/eth/eth_module.rb, line 40 def load_contract etherscan_api, contract_address contract(etherscan_api.contract_getabi address: contract_address).at contract_address end
method_missing(m, *args)
click to toggle source
# File lib/web3/eth/eth_module.rb, line 45 def method_missing m, *args @web3_rpc.request "#{PREFIX}#{m}", args[0] end