Module: Web3::EthCalls

Defined in:
lib/eth_calls.rb

Instance Method Summary collapse

Instance Method Details

#eth_accountsObject



39
40
41
42
# File 'lib/eth_calls.rb', line 39

def eth_accounts()
response = do_request("eth_accounts")
response["result"]
end

#eth_blockNumberObject



45
46
47
48
# File 'lib/eth_calls.rb', line 45

def eth_blockNumber()
response = do_request("eth_blockNumber")
to_decimal response["result"]
end

#eth_call(trans_object, block = "latest") ⇒ Object



147
148
149
150
# File 'lib/eth_calls.rb', line 147

def eth_call(trans_object,block="latest")
  response = do_request("eth_call",[trans_object, block])
  response["result"]
end

#eth_coinbaseObject



15
16
17
18
# File 'lib/eth_calls.rb', line 15

def eth_coinbase()
response = do_request("eth_coinbase")
response["result"]
end

#eth_compileLLL(code) ⇒ Object



215
216
217
218
# File 'lib/eth_calls.rb', line 215

def eth_compileLLL(code)
response = do_request("eth_compileLLL",[code])
response["result"]
end

#eth_compileSerpent(code) ⇒ Object



229
230
231
232
# File 'lib/eth_calls.rb', line 229

def eth_compileSerpent(code)
response = do_request("eth_compileSerpent",[code])
response["result"]
end

#eth_compileSolidity(code) ⇒ Object



222
223
224
225
# File 'lib/eth_calls.rb', line 222

def eth_compileSolidity(code)
response = do_request("eth_compileSolidity",[code])
response["result"]
end

#eth_estimateGas(trans_object) ⇒ Object



153
154
155
156
# File 'lib/eth_calls.rb', line 153

def eth_estimateGas(trans_object)
  response = do_request("eth_estimateGas",[trans_object])
  response["result"]
end

#eth_gasPriceObject



33
34
35
36
# File 'lib/eth_calls.rb', line 33

def eth_gasPrice()
response = do_request("eth_gasPrice")
to_decimal response["result"]
end

#eth_getBalance(address, block = "latest") ⇒ Object



51
52
53
54
# File 'lib/eth_calls.rb', line 51

def eth_getBalance(address, block = "latest")
response = do_request("eth_getBalance",[address, block])
to_decimal response["result"]
end

#eth_getBlockByHash(hash, full_transactions = true) ⇒ Object



159
160
161
162
# File 'lib/eth_calls.rb', line 159

def eth_getBlockByHash(hash, full_transactions = true)
response = do_request("eth_getBlockByHash",[hash, full_transactions])
response["result"]
end

#eth_getBlockByNumber(number, full_transactions = true) ⇒ Object



165
166
167
168
# File 'lib/eth_calls.rb', line 165

def eth_getBlockByNumber(number, full_transactions = true)
response = do_request("eth_getBlockByNumber",[number, full_transactions])
response["result"]
end

#eth_getBlockTransactionCountByHash(data) ⇒ Object



69
70
71
72
# File 'lib/eth_calls.rb', line 69

def eth_getBlockTransactionCountByHash(data)
response = do_request("eth_getBlockTransactionCountByHash",[data])
to_decimal response["result"]
end

#eth_getBlockTransactionCountByNumber(block = "latest") ⇒ Object



75
76
77
78
# File 'lib/eth_calls.rb', line 75

def eth_getBlockTransactionCountByNumber(block = "latest")
response = do_request("eth_getBlockTransactionCountByNumber",[block])
to_decimal response["result"]
end

#eth_getCode(address, block = "latest") ⇒ Object



93
94
95
96
# File 'lib/eth_calls.rb', line 93

def eth_getCode(address, block = "latest")
response = do_request("eth_getCode",[address, block])
response["result"]
end

#eth_getCompilersObject



208
209
210
211
# File 'lib/eth_calls.rb', line 208

def eth_getCompilers()
response = do_request("eth_getCompilers")
response["result"]
end

#eth_getFilterChanges(id) ⇒ Object



259
260
261
262
# File 'lib/eth_calls.rb', line 259

def eth_getFilterChanges(id)
response = do_request("eth_getFilterChanges",[id])
response["result"]
end

#eth_getFilterLogs(id) ⇒ Object



265
266
267
268
# File 'lib/eth_calls.rb', line 265

def eth_getFilterLogs(id)
response = do_request("eth_getFilterLogs",[id])
response["result"]
end

#eth_getLogs(filter_obj) ⇒ Object



271
272
273
274
# File 'lib/eth_calls.rb', line 271

def eth_getLogs(filter_obj)
response = do_request("eth_getLogs",[filter_obj])
response["result"]
end

#eth_getStorageAt(storage_address, position, block = "latest") ⇒ Object



57
58
59
60
# File 'lib/eth_calls.rb', line 57

def eth_getStorageAt(storage_address, position, block = "latest")
response = do_request("eth_getStorageAt",[storage_address, to_hex(position), block])
response["result"]
end

#eth_getTransactionByBlockHashAndIndex(hash, index) ⇒ Object



177
178
179
180
# File 'lib/eth_calls.rb', line 177

def eth_getTransactionByBlockHashAndIndex(hash, index)
response = do_request("eth_getTransactionByBlockHashAndIndex",[hash, index])
response["result"]
end

#eth_getTransactionByBlockNumberAndIndex(number, index) ⇒ Object



183
184
185
186
# File 'lib/eth_calls.rb', line 183

def eth_getTransactionByBlockNumberAndIndex(number, index)
response = do_request("eth_getTransactionByBlockNumberAndIndex",[number, index])
response["result"]
end

#eth_getTransactionByHash(hash) ⇒ Object



171
172
173
174
# File 'lib/eth_calls.rb', line 171

def eth_getTransactionByHash(hash)
response = do_request("eth_getTransactionByHash",[hash])
response["result"]
end

#eth_getTransactionCount(address, block = "latest") ⇒ Object



63
64
65
66
# File 'lib/eth_calls.rb', line 63

def eth_getTransactionCount(address, block = "latest")
response = do_request("eth_getTransactionCount",[address, block])
to_decimal response["result"]
end

#eth_getTransactionReceipt(hash) ⇒ Object



189
190
191
192
# File 'lib/eth_calls.rb', line 189

def eth_getTransactionReceipt(hash)
response = do_request("eth_getTransactionReceipt",[hash])
response["result"]
end

#eth_getUncleByBlockHashAndIndex(hash, index) ⇒ Object



195
196
197
198
# File 'lib/eth_calls.rb', line 195

def eth_getUncleByBlockHashAndIndex(hash, index)
response = do_request("eth_getUncleByBlockHashAndIndex",[hash, index])
response["result"]
end

#eth_getUncleByBlockNumberAndIndex(number, index) ⇒ Object



201
202
203
204
# File 'lib/eth_calls.rb', line 201

def eth_getUncleByBlockNumberAndIndex(number, index)
response = do_request("eth_getUncleByBlockNumberAndIndex",[number, index])
response["result"]
end

#eth_getUncleCountByBlockHash(data) ⇒ Object



81
82
83
84
# File 'lib/eth_calls.rb', line 81

def eth_getUncleCountByBlockHash(data)
response = do_request("eth_getUncleCountByBlockHash",[data])
to_decimal response["result"]
end

#eth_getUncleCountByBlockNumber(data) ⇒ Object



87
88
89
90
# File 'lib/eth_calls.rb', line 87

def eth_getUncleCountByBlockNumber(data)
response = do_request("eth_getUncleCountByBlockNumber",[data])
to_decimal response["result"]
end

#eth_getWorkObject



277
278
279
280
# File 'lib/eth_calls.rb', line 277

def eth_getWork()
response = do_request("eth_getWork")
response["result"]
end

#eth_hashrateObject



27
28
29
30
# File 'lib/eth_calls.rb', line 27

def eth_hashrate()
response = do_request("eth_hashrate")
to_decimal response["result"]
end

#eth_miningObject



21
22
23
24
# File 'lib/eth_calls.rb', line 21

def eth_mining()
response = do_request("eth_mining")
response["result"]
end

#eth_newBlockFilterObject



241
242
243
244
# File 'lib/eth_calls.rb', line 241

def eth_newBlockFilter()
response = do_request("eth_newBlockFilter")
to_decimal response["result"]
end

#eth_newFilter(fromBlock, toBlock, address, topics) ⇒ Object



235
236
237
238
# File 'lib/eth_calls.rb', line 235

def eth_newFilter(fromBlock, toBlock, address, topics)
response = do_request("$CODE",[fromBlock, toBlock, address, topics])
to_decimal response["result"]
end

#eth_newPendingTransactionFilterObject



247
248
249
250
# File 'lib/eth_calls.rb', line 247

def eth_newPendingTransactionFilter()
response = do_request("eth_newPendingTransactionFilter")
to_decimal response["result"]
end

#eth_pendingTransactionsObject

Returns pending transactions that belong to any of the users accounts See github.com/ethereum/go-ethereum/wiki/JavaScript-Console#ethpendingtransactions



121
122
123
124
# File 'lib/eth_calls.rb', line 121

def eth_pendingTransactions()
  response = do_request("eth_pendingTransactions")
  response["result"]
end

#eth_protocolVersionObject



4
5
6
# File 'lib/eth_calls.rb', line 4

def eth_protocolVersion()
raise NotImplementedError.new "JSON-RPC call to eth_protocolVersion is not currently supported"
end

#eth_resend(pending_transaction, gasPrice = nil, gasLimit = nil) ⇒ Object

Resends a transaction. These can ge retrieved from eth_pendingTransactions(). gasPrice and gasLimit can be included together if the gas settings are being changed from their original settings in the pending_transaction object See github.com/ethereum/go-ethereum/wiki/JavaScript-Console#ethresend



130
131
132
133
134
135
136
137
# File 'lib/eth_calls.rb', line 130

def eth_resend(pending_transaction, gasPrice=nil, gasLimit=nil)
  package = [pending_transaction]
  if gasPrice != nil
    package += [gasPrice, gasLimit]
  end
  response = do_request("eth_resend", package)
  response["result"]
end

#eth_sendRawTransaction(data) ⇒ Object

This sends a transaction that looks something like this: See github.com/ethereum/wiki/wiki/JSON-RPC#eth_sendrawtransaction



141
142
143
144
# File 'lib/eth_calls.rb', line 141

def eth_sendRawTransaction(data)
  response = do_request("eth_sendRawTransaction",[data])
  response["result"]
end

#eth_sendTransaction(transaction_object) ⇒ Object

Sends a transaction for posting to the ethereum network. The transaction_object that is sent should look something like this:

{"from"=> accounts[0],  "to" => accounts[1],  "value" => w3.ether_to_0xwei(0.001)}

Other 0x-fomatted attributes that can be included in the transaction_object are:

"data"                                  : formatted as hex
"gas", "gasPrice", "value", and "nonce" : formatted as "0x" + hex

See github.com/ethereum/wiki/wiki/JSON-RPC#eth_sendtransaction



114
115
116
117
# File 'lib/eth_calls.rb', line 114

def eth_sendTransaction(transaction_object)
  response = do_request("eth_sendTransaction",[transaction_object])
  response["result"]
end

#eth_sign(address, data) ⇒ Object



99
100
101
102
# File 'lib/eth_calls.rb', line 99

def eth_sign(address, data)
response = do_request("eth_sign",[address, data])
response["result"]
end

#eth_submitHashrate(hashrate, id) ⇒ Object



289
290
291
292
# File 'lib/eth_calls.rb', line 289

def eth_submitHashrate(hashrate, id)
response = do_request("eth_submitHashrate",[hashrate, id])
response["result"]
end

#eth_submitWork(nonce, powHash, mixDigest) ⇒ Object



283
284
285
286
# File 'lib/eth_calls.rb', line 283

def eth_submitWork(nonce, powHash, mixDigest)
response = do_request("eth_submitWork",[nonce, powHash, mixDigest])
response["result"]
end

#eth_syncingObject



9
10
11
12
# File 'lib/eth_calls.rb', line 9

def eth_syncing()
response = do_request("eth_syncing")
response["result"]
end

#eth_uninstallFilter(id) ⇒ Object



253
254
255
256
# File 'lib/eth_calls.rb', line 253

def eth_uninstallFilter(id)
response = do_request("eth_uninstallFilter",[id])
response["result"]
end