ethereum.rb 2.1.0 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 26d401a1321c2035fc258764f3806ccc20fe6eba
4
- data.tar.gz: 99b9fe1ffbe16b5f4a93640979f1ecbf823c2dc5
3
+ metadata.gz: a3f3a3f9140665a3b64447587dcf3bcf8a919a5a
4
+ data.tar.gz: 1d8a748b87ee23dfee41d145020186de114d2e44
5
5
  SHA512:
6
- metadata.gz: ee49b13d4f24d61a4448e9b94ce3e2607781d554b345ad02c6b9a094e8f98a9d16f81079a1f73fc3488878c20389f5f7ef4b8e3bba10e29d7445db9e708790e4
7
- data.tar.gz: 59eb35fc5add5ea192dcf0d632c6b7494fdad783364e117e5815ccefb9d2fd48a1843b461135173d798e7d391ce90acb92f27779768de37a5387cf9461eaad33
6
+ metadata.gz: fe2a8618f99cc13711d2a23db8bc7b80dd82f6a30a5be2bac4cf2c436bf2405e5b17b3aed628c47262afbed010f52c2d2936cca6562702e0554cac4d06add726
7
+ data.tar.gz: e44306b317587642f3c719d51566cc80a316f883d9da41435d768541b9147fa55e38aad212c1cb4228c20bd6f646ac3f840e0d8ce8056456d5ad7f5c6b49d6cf
@@ -12,12 +12,13 @@ before_install:
12
12
  - sudo bin/install_parity
13
13
  - gem install bundler -v 1.11.2
14
14
  before_script:
15
- - parity --warp --chain ropsten -d ~/.parity --password ~/.parity/pass --unlock 3089630d06fD90Ef48a0c43f000971587c1F3247 --author 3089630d06fD90Ef48a0c43f000971587c1F3247 daemon ~/.parity.pid --log-file ~/.parity.log
15
+ - parity --warp --chain ropsten --password ~/.pass --unlock 3089630d06fD90Ef48a0c43f000971587c1F3247 --author 3089630d06fD90Ef48a0c43f000971587c1F3247 daemon ~/.parity.pid --log-file ~/.parity.log
16
16
  - cat ~/.parity.log
17
17
  - sleep 5
18
- - parity --chain testnet account list
18
+ - parity --chain ropsten account list
19
19
  - cat ~/.parity.log
20
20
  - bundle exec rake ethereum:node:waitforsync
21
+ - cat ~/.parity.log
21
22
  script:
22
23
  - bundle exec rspec --tag ~blockchain && bundle exec rspec --tag blockchain
23
24
  before_cache:
data/README.md CHANGED
@@ -8,7 +8,8 @@ The goal of ethereum.rb is to make interacting with ethereum blockchain from rub
8
8
 
9
9
  * Simple syntax, programmer friendly
10
10
  * Deploy and interact with contracts on the blockchain
11
- * Contract - ruby object mapping
11
+ * Contract - ruby object mapping to solidity contract
12
+ * Signing transactions with [ruby-eth](https://github.com/se3000/ruby-eth) gem.
12
13
  * Compile Solidity contracts with solc compiler from ruby
13
14
  * Receive events from contract
14
15
  * Make direct json rpc calls to node from ruby application
@@ -55,7 +56,7 @@ contract.call.greet # => "Hello from ethereum.rb!"
55
56
 
56
57
  You can see example contract [greeter here](https://github.com/marekkirejczyk/ruby_ethereum_example/blob/master/contracts/greeter.sol).
57
58
 
58
- ## Creating contract
59
+ ## Smart contracts
59
60
 
60
61
  ### Compile multiple contracts at once
61
62
 
@@ -198,7 +199,63 @@ Note: methods are transated to underscore notation.
198
199
 
199
200
  Full list of json rpc methods is available [here](https://github.com/ethereum/wiki/wiki/JSON-RPC#user-content-json-rpc-methods)
200
201
 
201
- ## Utils rake tasks
202
+ ### Signed transactions
203
+
204
+ Ethereum.rb supports signing transactions with key using [ruby-eth gem](https://github.com/se3000/ruby-eth).
205
+
206
+ To create a new key simply do the following:
207
+
208
+ ```ruby
209
+ key = Eth::Key.new
210
+ ```
211
+
212
+ Then you can use the key to deploy contracts and send transactions, i.e.:
213
+
214
+ ```ruby
215
+ contract = Ethereum::Contract.create(file: "...")
216
+ contract.key = key
217
+ contract.deploy_and_wait("Allo Allo!")
218
+ contract.transact_and_wait.set("greeting", "Aloha!")
219
+ ```
220
+
221
+ You can also transfer ether transfer using custom keys:
222
+
223
+ ```ruby
224
+ client.transfer(key, "0x342bcf27DCB234FAb8190e53E2d949d7b2C37411", amount)
225
+ client.transfer_and_wait(key, "0x949d7b2C37411eFB763fcDCB234FAb8190e53E2d", amount)
226
+ ```
227
+
228
+ ### Custom gas price and gas limit
229
+
230
+ You can change gas price or gas limit in the client:
231
+
232
+ ```ruby
233
+ client.gas_limit = 2_000_000_
234
+ client.gas_price = 24_000_000_000
235
+ ```
236
+
237
+ or per contract:
238
+ ```ruby
239
+ contract.gas_limit = 2_000_000_
240
+ contract.gas_price = 24_000_000_000
241
+ ```
242
+
243
+ ## Utils
244
+
245
+ ### Url helpers for rails applciations
246
+
247
+ Often in the application you want to link to blockchain explorer. This can be problematic if you want links to work with different networks (ropsten, mainnet, kovan) depending on environment you're working on.
248
+ Following helpers will generate link according to network connected:
249
+
250
+ ```ruby
251
+ link_to_tx("See the transaction", "0x3a4e53b01274b0ca9087750d96d8ba7f5b6b27bf93ac65f3174f48174469846d")
252
+ link_to_address("See the wallet", "0xE08cdFD4a1b2Ef5c0FC193877EC6A2Bb8f8Eb373")
253
+ ```
254
+ They use [etherscan.io](http://etherscan.io/) as a blockexplorer.
255
+
256
+ Note: Helpers work in rails environment only.
257
+
258
+ ### Utils rake tasks
202
259
 
203
260
  There are couple of rake tasks to help in wallet maintenance, i.e.:
204
261
 
@@ -218,7 +275,6 @@ Logs from communication between ruby app and node are available under following
218
275
  ## Roadmap
219
276
 
220
277
  * Rubydoc documentation
221
- * Signing transactions
222
278
 
223
279
  ## Development
224
280
 
@@ -11,11 +11,7 @@ wget http://d1h4xl4cr1h0mo.cloudfront.net/v$PARITY\/x86_64-unknown-linux-gnu/par
11
11
  sudo dpkg -i parity_$PARITY\_amd64.deb
12
12
 
13
13
  echo "Setuping parity..."
14
- mkdir -p ~/.parity
15
- wget https://raw.githubusercontent.com/ethcore/parity/master/ethcore/res/ethereum/ropsten.json --output-document ~/.parity/ropsten.json
16
- echo $pass > ~/.parity/pass
17
- mkdir -p ~/.parity/keys
18
- echo $wallet > ~/.parity/keys/UTC--2017-01-08T21-02-29.039669388Z--3089630d06fd90ef48a0c43f000971587c1f3247
19
- chown -R travis:travis ~/.parity
20
-
21
- ls -la ~/.parity
14
+ echo $pass > ~/.pass
15
+ mkdir -p ~/.local/share/io.parity.ethereum/keys/test
16
+ chown -R travis:travis ~/.local/share/io.parity.ethereum
17
+ echo $wallet > ~/.local/share/io.parity.ethereum/keys/test/UTC--2017-01-08T21-02-29.039669388Z--3089630d06fd90ef48a0c43f000971587c1f3247
@@ -48,8 +48,8 @@ module Ethereum
48
48
  end
49
49
 
50
50
  def decode_address(value, _ = nil, _)
51
- raise ArgumentError if value.size != 40
52
- value
51
+ raise ArgumentError if value.size != 64
52
+ value[24..64]
53
53
  end
54
54
 
55
55
  def decode_bytes(value, subtype, start)
@@ -76,8 +76,8 @@ module Ethereum
76
76
  end
77
77
 
78
78
  def encode_address(value, _)
79
- value = value.gsub(/^0x/,'')
80
- raise ArgumentError if value.size != 40
79
+ value = "0" * 24 + value.gsub(/^0x/,'')
80
+ raise ArgumentError if value.size != 64
81
81
  value
82
82
  end
83
83
 
@@ -1,3 +1,3 @@
1
1
  module Ethereum
2
- VERSION = "2.1.0"
2
+ VERSION = "2.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ethereum.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marek Kirejczyk
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-04-07 00:00:00.000000000 Z
11
+ date: 2017-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -210,7 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
210
210
  version: '0'
211
211
  requirements: []
212
212
  rubyforge_project:
213
- rubygems_version: 2.5.1
213
+ rubygems_version: 2.6.8
214
214
  signing_key:
215
215
  specification_version: 4
216
216
  summary: Ruby Ethereum client using the JSON-RPC interface