Class: Ethereum

Inherits:
Base
  • Object
show all
Defined in:
lib/blocksdk_ruby/ethereum.rb

Instance Attribute Summary

Attributes inherited from Base

#api_token

Instance Method Summary collapse

Methods inherited from Base

#initialize, #request

Constructor Details

This class inherits a constructor from Base

Instance Method Details

#createAddress(request = {}) ⇒ Object



42
43
44
45
# File 'lib/blocksdk_ruby/ethereum.rb', line 42

def createAddress(request = {})
	request["name"].to_s.empty? ? request['name'] = 0 : request["name"]
	return request("POST","/eth/addresses",{"name" => request['name']})
end

#getAddress(request = {}) ⇒ Object



24
25
26
27
28
29
30
31
32
# File 'lib/blocksdk_ruby/ethereum.rb', line 24

def getAddress(request = {})
	request["offset"].to_s.empty? ? request['offset'] = 0 : request["offset"]
	request["limit"].to_s.empty? ? request['limit'] = 10 : request["limit"]
	
	return request("GET","/eth/addresses",{
		"offset" => request['offset'],
		"limit" => request['limit']
	})
end

#getAddressBalance(request = {}) ⇒ Object



57
58
59
# File 'lib/blocksdk_ruby/ethereum.rb', line 57

def getAddressBalance(request = {})
	return request("GET","/eth/addresses/" + (request['address']).to_s + "/balance")
end

#getAddressInfo(request = {}) ⇒ Object



47
48
49
50
51
52
53
54
55
# File 'lib/blocksdk_ruby/ethereum.rb', line 47

def getAddressInfo(request = {})

	request["reverse"].to_s.empty? ? request['reverse'] = true : request['reverse']
	request["rawtx"].to_s.empty? ? request['rawtx'] = false : request['rawtx']
	request["offset"].to_s.empty? ? request['offset'] = 0 : request["offset"]
	request["limit"].to_s.empty? ? request['limit'] = 10 : request["limit"]
	
	return request("GET","/eth/addresses/" + (request['address']).to_s ,{"reverse" => request['reverse'],"rawtx" => request['rawtx'],"offset" => request['offset'],"limit" => request['limit']})
end

#getAuctionNfts(request = {}) ⇒ Object



131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/blocksdk_ruby/ethereum.rb', line 131

def getAuctionNfts(request = {})
	request["order_by"].to_s.empty? ? request['order_by'] = 'end_time' : request["order_by"]
	request["order_direction"].to_s.empty? ? request['order_direction'] = 'desc' : request["order_direction"]
	request["offset"].to_s.empty? ? request['offset'] = 0 : request["offset"]
	request["limit"].to_s.empty? ? request['limit'] = 10 : request["limit"]
	
	return request("GET","/eth/erc721-tokens/" + (request['contract_address']).to_s + "/auction",{
		"order_by" => request['order_by'],
		"order_direction" => request['order_direction'],
		"offset" => request['offset'],
		"limit" => request['limit']
	})
end

#getBlock(request = {}) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/blocksdk_ruby/ethereum.rb', line 8

def getBlock(request = {})
	request["rawtx"].to_s.empty? ? request['rawtx'] = false : request['rawtx']
	request["offset"].to_s.empty? ? request['offset'] = 0 : request["offset"]
	request["limit"].to_s.empty? ? request['limit'] = 10 : request["limit"]

	return request("GET","/eth/blocks/" + (request['block']).to_s,{"rawtx" => request['rawtx'],"offset" => request['offset'],"limit" => request['limit']})
end

#getBlockChain(request = {}) ⇒ Object



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

def getBlockChain(request = {})
	return request("GET","/eth/info")		
end

#getContractRead(request = {}) ⇒ Object



279
280
281
282
283
284
285
286
287
288
289
# File 'lib/blocksdk_ruby/ethereum.rb', line 279

def getContractRead(request = {})
	request["parameter_type"].to_s.empty? ? request['parameter_type'] = nil : request["parameter_type"]
	request["parameter_data"].to_s.empty? ? request['parameter_data'] = nil : request["parameter_data"]
	
	return request("POST","/eth/contracts/" + (request['contract_address']).to_s + "/read",{
		"method" => request['method'],
		"return_type" => request['return_type'],
		"parameter_type" => request['parameter_type'],
		"parameter_data" => request['parameter_data']
	})
end

#getContractWrite(request = {}) ⇒ Object



291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
# File 'lib/blocksdk_ruby/ethereum.rb', line 291

def getContractWrite(request = {})
	request["private_key"].to_s.empty? ? request['private_key'] = nil : request["private_key"]
	request["password"].to_s.empty? ? request['password'] = nil : request["password"]
	request["gas_limit"].to_s.empty? ? request['gas_limit'] = nil : request["gas_limit"]
	
	request["parameter_type"].to_s.empty? ? request['parameter_type'] = nil : request["parameter_type"]
	request["parameter_data"].to_s.empty? ? request['parameter_data'] = nil : request["parameter_data"]
	
	return request("POST","/eth/contracts/" + (request['contract_address']).to_s + "/write",{
		"method" => request['method'],
		"return_type" => request['return_type'],
		"parameter_type" => request['parameter_type'],
		"parameter_data" => request['parameter_data'],
		"from" => request['from'],
		"private_key" => request['private_key'],
		"password" => request['password'],
		"amount" => request['amount'],
		"gas_limit" => request['gas_limit']
	})
end

#getContractWriteFees(request = {}) ⇒ Object



312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
# File 'lib/blocksdk_ruby/ethereum.rb', line 312

def getContractWriteFees(request = {})
	request["gas_limit"].to_s.empty? ? request['gas_limit'] = nil : request["gas_limit"]
	
	request["parameter_type"].to_s.empty? ? request['parameter_type'] = nil : request["parameter_type"]
	request["parameter_data"].to_s.empty? ? request['parameter_data'] = nil : request["parameter_data"]
	
	return request("POST","/eth/contracts/" + (request['contract_address']).to_s + "/write/fees",{
		"method" => request['method'],
		"return_type" => request['return_type'],
		"parameter_type" => request['parameter_type'],
		"parameter_data" => request['parameter_data'],
		"from" => request['from'],
		"amount" => request['amount'],
		"gas_limit" => request['gas_limit']
	})
end

#getCreatorNfts(request = {}) ⇒ Object



121
122
123
124
125
126
127
128
129
# File 'lib/blocksdk_ruby/ethereum.rb', line 121

def getCreatorNfts(request = {})
	request["offset"].to_s.empty? ? request['offset'] = 0 : request["offset"]
	request["limit"].to_s.empty? ? request['limit'] = 10 : request["limit"]
	
	return request("GET","/eth/erc721-tokens/" + (request['contract_address']).to_s + "/" + (request['creator_address']).to_s + "/creator",{
		"offset" => request['offset'],
		"limit" => request['limit']
	})
end

#getErc20(request = {}) ⇒ Object



81
82
83
# File 'lib/blocksdk_ruby/ethereum.rb', line 81

def getErc20(request = {})
	return request("GET","/eth/erc20-tokens/" + (request['contract_address']).to_s)
end

#getErc20Balance(request = {}) ⇒ Object



85
86
87
# File 'lib/blocksdk_ruby/ethereum.rb', line 85

def getErc20Balance(request = {})
	return request("GET","/eth/erc20-tokens/" + (request['contract_address']).to_s + "/" + (request['from']).to_s + "/balance")
end

#getErc20Transfer(request = {}) ⇒ Object



89
90
91
92
93
94
95
96
97
98
99
# File 'lib/blocksdk_ruby/ethereum.rb', line 89

def getErc20Transfer(request = {})
	if request["gwei"].to_s.empty?
		blockChain = getBlockChain()
		request['gwei'] = blockChain['high_gwei']
	end
	request["private_key"].to_s.empty? ? request['private_key'] = nil : request["private_key"]
	request["password"].to_s.empty? ? request['password'] = nil : request["password"]
	request["gas_limit"].to_s.empty? ? request['gas_limit'] = nil : request["gas_limit"]
	
	return request("POST","/eth/erc20-tokens/" + (request['contract_address']).to_s + "/" + (request['from']).to_s + "/transfer",{"to" => request['to'],"amount" => request['amount'],"private_key" => request['private_key'],"password" => request['password'],"gwei" => request['gwei'],"gas_limit" => request['gas_limit']})
end

#getMemPool(request = {}) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/blocksdk_ruby/ethereum.rb', line 16

def getMemPool(request = {})
	request["rawtx"].to_s.empty? ? request['rawtx'] = false : request['rawtx']
	request["offset"].to_s.empty? ? request['offset'] = 0 : request["offset"]
	request["limit"].to_s.empty? ? request['limit'] = 10 : request["limit"]
	
	return request("GET","/eth/mempool",{"rawtx" => request['rawtx'],"offset" => request['offset'],"limit" => request['limit']})
end

#getMultiNft(request = {}) ⇒ Object



188
189
190
191
192
193
194
195
196
# File 'lib/blocksdk_ruby/ethereum.rb', line 188

def getMultiNft(request = {})
	request["offset"].to_s.empty? ? request['offset'] = 0 : request["offset"]
	request["limit"].to_s.empty? ? request['limit'] = 10 : request["limit"]
	
	return request("GET","/eth/erc1155-tokens/" + (request['contract_address']).to_s + "/tokens",{
		"offset" => request['offset'],
		"limit" => request['limit']
	})
end

#getMultiNftContractCreator(request = {}) ⇒ Object



228
229
230
231
232
233
234
235
236
# File 'lib/blocksdk_ruby/ethereum.rb', line 228

def getMultiNftContractCreator(request = {})
	request["offset"].to_s.empty? ? request['offset'] = 0 : request["offset"]
	request["limit"].to_s.empty? ? request['limit'] = 10 : request["limit"]
	
	return request("GET","/eth/erc1155-tokens/" + (request['contract_address']).to_s + "/" + (request['creator_address']).to_s + "/creators",{
		"offset" => request['offset'],
		"limit" => request['limit']
	})
end

#getMultiNftContractOwner(request = {}) ⇒ Object



208
209
210
211
212
213
214
215
216
# File 'lib/blocksdk_ruby/ethereum.rb', line 208

def getMultiNftContractOwner(request = {})
	request["offset"].to_s.empty? ? request['offset'] = 0 : request["offset"]
	request["limit"].to_s.empty? ? request['limit'] = 10 : request["limit"]
	
	return request("GET","/eth/erc1155-tokens/" + (request['contract_address']).to_s + "/" + (request['owner_address']).to_s + "/owners",{
		"offset" => request['offset'],
		"limit" => request['limit']
	})
end

#getMultiNftCreator(request = {}) ⇒ Object



238
239
240
241
242
243
244
245
246
# File 'lib/blocksdk_ruby/ethereum.rb', line 238

def getMultiNftCreator(request = {})
	request["offset"].to_s.empty? ? request['offset'] = 0 : request["offset"]
	request["limit"].to_s.empty? ? request['limit'] = 10 : request["limit"]
	
	return request("GET","/eth/erc1155-tokens/" + (request['creator_address']).to_s + "/creator",{
		"offset" => request['offset'],
		"limit" => request['limit']
	})
end

#getMultiNftInfo(request = {}) ⇒ Object



248
249
250
251
# File 'lib/blocksdk_ruby/ethereum.rb', line 248

def getMultiNftInfo(request = {})
	return request("GET","/eth/erc1155-tokens/" + (request['contract_address']).to_s + "/" + (request['token_id']).to_s + "/info",{
	})
end

#getMultiNftOwner(request = {}) ⇒ Object



218
219
220
221
222
223
224
225
226
# File 'lib/blocksdk_ruby/ethereum.rb', line 218

def getMultiNftOwner(request = {})
	request["offset"].to_s.empty? ? request['offset'] = 0 : request["offset"]
	request["limit"].to_s.empty? ? request['limit'] = 10 : request["limit"]
	
	return request("GET","/eth/erc1155-tokens/" + (request['owner_address']).to_s + "/owner",{
		"offset" => request['offset'],
		"limit" => request['limit']
	})
end

#getMultiNftOwnerList(request = {}) ⇒ Object



198
199
200
201
202
203
204
205
206
# File 'lib/blocksdk_ruby/ethereum.rb', line 198

def getMultiNftOwnerList(request = {})
	request["offset"].to_s.empty? ? request['offset'] = 0 : request["offset"]
	request["limit"].to_s.empty? ? request['limit'] = 10 : request["limit"]
	
	return request("GET","/eth/erc1155-tokens/" + (request['contract_address']).to_s + "/" + (request['token_id']).to_s + "/list",{
		"offset" => request['offset'],
		"limit" => request['limit']
	})
end

#getMultiNftTransfers(request = {}) ⇒ Object



253
254
255
256
257
258
259
260
261
262
263
264
# File 'lib/blocksdk_ruby/ethereum.rb', line 253

def getMultiNftTransfers(request = {})
	request["rawtx"].to_s.empty? ? request['rawtx'] = 0 : request["rawtx"]

	request["offset"].to_s.empty? ? request['offset'] = 0 : request["offset"]
	request["limit"].to_s.empty? ? request['limit'] = 10 : request["limit"]
	
	return request("GET","/eth/erc1155-tokens/" + (request['contract_address']).to_s + "/" + (request['token_id']).to_s + "/transfers",{
		"rawtx" => request['rawtx'],
		"offset" => request['offset'],
		"limit" => request['limit']
	})
end

#getMultiSaleNfts(request = {}) ⇒ Object



266
267
268
269
270
271
272
273
274
275
276
277
# File 'lib/blocksdk_ruby/ethereum.rb', line 266

def getMultiSaleNfts(request = {})
	request["order_direction"].to_s.empty? ? request['order_direction'] = 'desc' : request["order_direction"]

	request["offset"].to_s.empty? ? request['offset'] = 0 : request["offset"]
	request["limit"].to_s.empty? ? request['limit'] = 10 : request["limit"]
	
	return request("GET","/eth/erc1155-tokens/" + (request['contract_address']).to_s + "/" + (request['seller_address']).to_s + "/sale",{
		"order_direction" => request['order_direction'],
		"offset" => request['offset'],
		"limit" => request['limit']
	})
end

#getNftBids(request = {}) ⇒ Object



157
158
159
160
161
162
163
164
165
166
167
168
169
# File 'lib/blocksdk_ruby/ethereum.rb', line 157

def getNftBids(request = {})
	request["rawtx"].to_s.empty? ? request['rawtx'] = 0 : request["rawtx"]
	request["order_direction"].to_s.empty? ? request['order_direction'] = 'desc' : request["order_direction"]
	request["offset"].to_s.empty? ? request['offset'] = 0 : request["offset"]
	request["limit"].to_s.empty? ? request['limit'] = 10 : request["limit"]
	
	return request("GET","/eth/erc721-tokens/" + (request['contract_address']).to_s + "/" + (request['token_id']).to_s + "/bid",{
		"rawtx" => request['rawtx'],
		"order_direction" => request['order_direction'],
		"offset" => request['offset'],
		"limit" => request['limit']
	})
end

#getNftInfo(request = {}) ⇒ Object



171
172
173
# File 'lib/blocksdk_ruby/ethereum.rb', line 171

def getNftInfo(request = {})		
	return request("GET","/eth/erc721-tokens/" + (request['contract_address']).to_s + "/" + (request['token_id']).to_s + "/info")
end

#getNfts(request = {}) ⇒ Object



101
102
103
104
105
106
107
108
109
# File 'lib/blocksdk_ruby/ethereum.rb', line 101

def getNfts(request = {})
	request["offset"].to_s.empty? ? request['offset'] = 0 : request["offset"]
	request["limit"].to_s.empty? ? request['limit'] = 10 : request["limit"]
	
	return request("GET","/eth/erc721-tokens/" + (request['contract_address']).to_s + "/tokens",{
		"offset" => request['offset'],
		"limit" => request['limit']
	})
end

#getNftTransfers(request = {}) ⇒ Object



175
176
177
178
179
180
181
182
183
184
185
186
# File 'lib/blocksdk_ruby/ethereum.rb', line 175

def getNftTransfers(request = {})
	request["rawtx"].to_s.empty? ? request['rawtx'] = 0 : request["rawtx"]
	request["offset"].to_s.empty? ? request['offset'] = 0 : request["offset"]
	request["limit"].to_s.empty? ? request['limit'] = 10 : request["limit"]
	
	return request("GET","/eth/erc721-tokens/" + (request['contract_address']).to_s + "/" + (request['token_id']).to_s + "/bid",{
		"rawtx" => request['rawtx'],
		"order_direction" => request['order_direction'],
		"offset" => request['offset'],
		"limit" => request['limit']
	})
end

#getOwnerNfts(request = {}) ⇒ Object



111
112
113
114
115
116
117
118
119
# File 'lib/blocksdk_ruby/ethereum.rb', line 111

def getOwnerNfts(request = {})
	request["offset"].to_s.empty? ? request['offset'] = 0 : request["offset"]
	request["limit"].to_s.empty? ? request['limit'] = 10 : request["limit"]
	
	return request("GET","/eth/erc721-tokens/" + (request['contract_address']).to_s + "/" + (request['owner_address']).to_s + "/owner",{
		"offset" => request['offset'],
		"limit" => request['limit']
	})
end

#getSaleNfts(request = {}) ⇒ Object



145
146
147
148
149
150
151
152
153
154
155
# File 'lib/blocksdk_ruby/ethereum.rb', line 145

def getSaleNfts(request = {})
	request["order_direction"].to_s.empty? ? request['order_direction'] = 'desc' : request["order_direction"]
	request["offset"].to_s.empty? ? request['offset'] = 0 : request["offset"]
	request["limit"].to_s.empty? ? request['limit'] = 10 : request["limit"]
	
	return request("GET","/eth/erc721-tokens/" + (request['contract_address']).to_s + "/" + (request['seller_address']).to_s + "/sale",{
		"order_direction" => request['order_direction'],
		"offset" => request['offset'],
		"limit" => request['limit']
	})
end

#getTransactions(request = {}) ⇒ Object



77
78
79
# File 'lib/blocksdk_ruby/ethereum.rb', line 77

def getTransactions(request = {})
	return request("GET","/eth/transactions/" + (request['hash']).to_s)
end

#loadAddress(request = {}) ⇒ Object



34
35
36
# File 'lib/blocksdk_ruby/ethereum.rb', line 34

def loadAddress(request = {})
	return request("POST","/eth/addresses/" + (request['address']).to_s + "/load",{"private_key" => request['private_key'],"password" => request['password']})
end

#sendToAddress(request = {}) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
# File 'lib/blocksdk_ruby/ethereum.rb', line 61

def sendToAddress(request = {})
	if request["gwei"].to_s.empty?
		blockChain = getBlockChain()
		request['gwei'] = blockChain['medium_gwei']
	end
	request["private_key"].to_s.empty? ? request['private_key'] = nil : request["private_key"]
	request["password"].to_s.empty? ? request['password'] = nil : request["password"]
	request["gas_limit"].to_s.empty? ? request['gas_limit'] = nil : request["gas_limit"]
	
	return request("POST","/eth/addresses/" + (request['from']).to_s + "/sendtoaddress",{"to" => request['to'],"amount" => request['amount'],"private_key" => request['private_key'],"password" => request['password'],"gwei" => request['gwei'],"gas_limit" => request['gas_limit']})
end

#sendTransaction(request = {}) ⇒ Object



73
74
75
# File 'lib/blocksdk_ruby/ethereum.rb', line 73

def sendTransaction(request = {})
	return request("POST","/eth/transactions/send",{"hex" => request['hex']})
end

#unloadAddress(request = {}) ⇒ Object



38
39
40
# File 'lib/blocksdk_ruby/ethereum.rb', line 38

def unloadAddress(request = {})
	return request("POST","/eth/addresses/" + (request['address']).to_s + "/unload")
end