erc20 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rultor.yml +2 -2
- data/Gemfile.lock +3 -3
- data/README.md +2 -2
- data/erc20.gemspec +1 -1
- data/lib/erc20/erc20.rb +46 -0
- data/lib/erc20/wallet.rb +38 -1
- data/lib/erc20.rb +2 -9
- data/test/erc20/test_wallet.rb +0 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c553c2335f6272040af4bd2d361a30a11f0094e6871190799b90688482ad0eda
|
4
|
+
data.tar.gz: a5adb387763f6303dfccdcddeefa9a190e51c327f42a299fd25588018f9a9f6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 332235aa28a28b38e0d56caf6f223560679b3b2622491cf6351016b6b8e11221f414bd5790d3b393af644b1d6a9c50be807a80126866108afc6c399729c73231
|
7
|
+
data.tar.gz: d74969a43d49696bfa5dfa04e26f6f0206772fffed76d94843e28189f2586d7552853361387ae102010ae976f90edcca497b1eee45addfdb101d3734641e091a
|
data/.rultor.yml
CHANGED
@@ -31,8 +31,8 @@ release:
|
|
31
31
|
[[ "${tag}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || exit -1
|
32
32
|
DONCE_SUDO=true bundle exec rake
|
33
33
|
rm -rf *.gem
|
34
|
-
sed -i "s/0\.0\.0/${tag}/g" lib/erc20.rb
|
35
|
-
git add lib/erc20.rb
|
34
|
+
sed -i "s/0\.0\.0/${tag}/g" lib/erc20/erc20.rb
|
35
|
+
git add lib/erc20/erc20.rb
|
36
36
|
git commit -m "version set to ${tag}"
|
37
37
|
gem build erc20.gemspec
|
38
38
|
chmod 0600 ../rubygems.yml
|
data/Gemfile.lock
CHANGED
@@ -51,7 +51,7 @@ GEM
|
|
51
51
|
connection_pool (2.5.0)
|
52
52
|
crass (1.0.6)
|
53
53
|
date (3.4.1)
|
54
|
-
diff-lcs (1.
|
54
|
+
diff-lcs (1.6.0)
|
55
55
|
docile (1.4.1)
|
56
56
|
donce (0.1.0)
|
57
57
|
backtrace (> 0)
|
@@ -103,7 +103,7 @@ GEM
|
|
103
103
|
keccak (1.3.2)
|
104
104
|
konstructor (1.0.2)
|
105
105
|
language_server-protocol (3.17.0.4)
|
106
|
-
logger (1.6.
|
106
|
+
logger (1.6.6)
|
107
107
|
loofah (2.24.0)
|
108
108
|
crass (~> 1.0.2)
|
109
109
|
nokogiri (>= 1.12.0)
|
@@ -147,7 +147,7 @@ GEM
|
|
147
147
|
loog (> 0)
|
148
148
|
tago (> 0)
|
149
149
|
racc (1.8.1)
|
150
|
-
rack (3.1.
|
150
|
+
rack (3.1.10)
|
151
151
|
rack-session (2.1.0)
|
152
152
|
base64 (>= 0.1.0)
|
153
153
|
rack (>= 3.0.0)
|
data/README.md
CHANGED
@@ -14,7 +14,7 @@
|
|
14
14
|
This small Ruby [gem](https://rubygems.org/gems/erc20)
|
15
15
|
makes manipulations with [Etherium] [ERC20] tokens
|
16
16
|
as simple as they can be, if you have a provider of
|
17
|
-
[JSON-RPC] and [
|
17
|
+
[JSON-RPC] and [WebSockets] Etherium APIs, for example
|
18
18
|
[Infura], [GetBlock], or [Alchemy]:
|
19
19
|
|
20
20
|
```ruby
|
@@ -92,7 +92,7 @@ If it's clean and you don't see any error messages, submit your pull request.
|
|
92
92
|
[Etherium]: https://en.wikipedia.org/wiki/Ethereum
|
93
93
|
[ERC20]: https://ethereum.org/en/developers/docs/standards/tokens/erc-20/
|
94
94
|
[JSON-RPC]: https://ethereum.org/en/developers/docs/apis/json-rpc/
|
95
|
-
[
|
95
|
+
[Websockets]: https://ethereum.org/en/developers/tutorials/using-websockets/
|
96
96
|
[Infura]: https://infura.io/
|
97
97
|
[Alchemy]: https://alchemy.com/
|
98
98
|
[GetBlock]: https://getblock.io/
|
data/erc20.gemspec
CHANGED
data/lib/erc20/erc20.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright (c) 2025 Yegor Bugayenko
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the 'Software'), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
13
|
+
# copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
# SOFTWARE.
|
22
|
+
|
23
|
+
# This module makes manipulations with Etherium ERC20 tokens
|
24
|
+
# as simple as they can be, if you have a provider of
|
25
|
+
# JSON-RPC and WebSockets Etherium APIs, for example
|
26
|
+
# Infura, GetBlock, or Alchemy.
|
27
|
+
#
|
28
|
+
# Start like this:
|
29
|
+
#
|
30
|
+
# require 'erc20'
|
31
|
+
# w = ERC20::Wallet.new(
|
32
|
+
# host: 'mainnet.infura.io',
|
33
|
+
# http_path: '/v3/<your-infura-key>',
|
34
|
+
# ws_path: '/ws/v3/<your-infura-key>'
|
35
|
+
# )
|
36
|
+
# puts w.balance(address)
|
37
|
+
#
|
38
|
+
# This should print the balance of the ERC20 address.
|
39
|
+
#
|
40
|
+
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
41
|
+
# Copyright:: Copyright (c) 2025 Yegor Bugayenko
|
42
|
+
# License:: MIT
|
43
|
+
module ERC20
|
44
|
+
# Current version of the gem (changed by the +.rultor.yml+ on every release)
|
45
|
+
VERSION = '0.0.9'
|
46
|
+
end
|
data/lib/erc20/wallet.rb
CHANGED
@@ -27,12 +27,49 @@ require 'json'
|
|
27
27
|
require 'jsonrpc/client'
|
28
28
|
require 'loog'
|
29
29
|
require 'uri'
|
30
|
-
require_relative '
|
30
|
+
require_relative 'erc20'
|
31
31
|
|
32
32
|
# A wallet with ERC20 tokens on Etherium.
|
33
33
|
#
|
34
34
|
# Objects of this class are thread-safe.
|
35
35
|
#
|
36
|
+
# In order to check the balance of ERC20 address:
|
37
|
+
#
|
38
|
+
# require 'erc20'
|
39
|
+
# w = ERC20::Wallet.new(
|
40
|
+
# contract: ERC20::Wallet.USDT, # hex of it
|
41
|
+
# host: 'mainnet.infura.io',
|
42
|
+
# http_path: '/v3/<your-infura-key>',
|
43
|
+
# ws_path: '/ws/v3/<your-infura-key>',
|
44
|
+
# log: $stdout
|
45
|
+
# )
|
46
|
+
# usdt = w.balance(address)
|
47
|
+
#
|
48
|
+
# In order to send a payment:
|
49
|
+
#
|
50
|
+
# hex = w.pay(private_key, to_address, amount)
|
51
|
+
#
|
52
|
+
# In order to catch incoming payments to a set of addresses:
|
53
|
+
#
|
54
|
+
# addresses = ['0x...', '0x...']
|
55
|
+
# w.accept(addresses) do |event|
|
56
|
+
# puts event[:txt] # hash of transaction
|
57
|
+
# puts event[:amount] # how much, in tokens (1000000 = $1 USDT)
|
58
|
+
# puts event[:from] # who sent the payment
|
59
|
+
# puts event[:to] # who was the receiver
|
60
|
+
# end
|
61
|
+
#
|
62
|
+
# To connect to the server via HTTP proxy with basic authentication:
|
63
|
+
#
|
64
|
+
# w = ERC20::Wallet.new(
|
65
|
+
# host: 'go.getblock.io',
|
66
|
+
# http_path: '/<your-rpc-getblock-key>',
|
67
|
+
# ws_path: '/<your-ws-getblock-key>',
|
68
|
+
# proxy: 'http://jeffrey:swordfish@example.com:3128' # here!
|
69
|
+
# )
|
70
|
+
#
|
71
|
+
# More information in our README.
|
72
|
+
#
|
36
73
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
37
74
|
# Copyright:: Copyright (c) 2025 Yegor Bugayenko
|
38
75
|
# License:: MIT
|
data/lib/erc20.rb
CHANGED
@@ -20,12 +20,5 @@
|
|
20
20
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
21
|
# SOFTWARE.
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
26
|
-
# Copyright:: Copyright (c) 2025 Yegor Bugayenko
|
27
|
-
# License:: MIT
|
28
|
-
module ERC20
|
29
|
-
# Current version of the gem (changed by .rultor.yml on every release)
|
30
|
-
VERSION = '0.0.8'
|
31
|
-
end
|
23
|
+
require_relative 'erc20/erc20'
|
24
|
+
require_relative 'erc20/wallet'
|
data/test/erc20/test_wallet.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: erc20
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yegor Bugayenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-02-
|
11
|
+
date: 2025-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: eth
|
@@ -122,6 +122,7 @@ files:
|
|
122
122
|
- hardhat/ignition/modules/Foo.ts
|
123
123
|
- hardhat/package.json
|
124
124
|
- lib/erc20.rb
|
125
|
+
- lib/erc20/erc20.rb
|
125
126
|
- lib/erc20/wallet.rb
|
126
127
|
- renovate.json
|
127
128
|
- test/erc20/test_wallet.rb
|