ethscribe 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1 -1
- data/README.md +86 -4
- data/Rakefile +1 -1
- data/lib/ethscribe/api.rb +122 -4
- data/lib/ethscribe/version.rb +1 -1
- data/lib/ethscribe.rb +1 -0
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '09ac9a5eb1dbb35dde2105a3865bf6c67edd5469e8f9518e46949752f127991a'
|
4
|
+
data.tar.gz: 81e37a9c8a75bf4b1ec7a7ac82feccee8906a4a45636c750f7ba54e8c3797334
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5cc33bb70781c8490fb1f5c8c3512f22d614fa6eade666d90ec7c1e7e30a77559e42a77f0bbaa28518111b1b1b0da498c764b9627d31488e0aab3d7788919f3b
|
7
|
+
data.tar.gz: 73547597a38a756b3be3dcf8d11ee387e651dffdfea3db936f250a146288bdc74b5a7f2d575e1a9eccce9e21b1b204591e4df8436601656f35780866a29afa06
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
# Ethscribe - Inscription (Ethscription Calldata) API Wrapper & Helpers for Ethereum & Co.
|
1
|
+
# Ethscribe - Inscription / Inscribe (Ethscription Calldata) API Wrapper & Helpers for Ethereum & Co.
|
2
2
|
|
3
|
-
ethscribe - inscription (ethscription calldata) api wrapper & helpers for Ethereum & co.
|
3
|
+
ethscribe - inscription / inscribe (ethscription calldata) api wrapper & helpers for Ethereum & co.
|
4
4
|
|
5
5
|
|
6
6
|
|
@@ -10,13 +10,95 @@ ethscribe - inscription (ethscription calldata) api wrapper & helpers for Ethe
|
|
10
10
|
* rdoc :: [rubydoc.info/gems/ethscribe](http://rubydoc.info/gems/ethscribe)
|
11
11
|
|
12
12
|
|
13
|
-
## What's Ethscription Calldata / Ethereum Inscription?!
|
14
13
|
|
15
|
-
|
14
|
+
## What's Ethscription Calldata - Ethereum Inscription / Inscribe?!
|
16
15
|
|
16
|
+
See [Introducing Ethscriptions - A new way of creating and sharing digital artifacts on the Ethereum blockchain using transaction calldata »](https://medium.com/@dumbnamenumbers/introducing-ethscriptions-698b295d6f2a)
|
17
17
|
|
18
18
|
|
19
19
|
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
This is a little "lite" wrapper around the ethscriptions.com api(s).
|
23
|
+
|
24
|
+
|
25
|
+
> The Ethscriptions.com API (v1)
|
26
|
+
> does not require a key, however it is rate limited.
|
27
|
+
> If you need more throughput, contact Middlemarch on Twitter.
|
28
|
+
>
|
29
|
+
> If you build something cool, also contact Middlemarch on Twitter!
|
30
|
+
>
|
31
|
+
> There is a goerli API and a mainnet API. The base URIs are:
|
32
|
+
>
|
33
|
+
> - https://goerli-api.ethscriptions.com/api
|
34
|
+
> - https://mainnet-api.ethscriptions.com/api
|
35
|
+
>
|
36
|
+
> Append the below paths, plus a query string if you want, to access the API!
|
37
|
+
>
|
38
|
+
> -- [Introducing the Ethscriptions.com API (v1)](https://medium.com/@dumbnamenumbers/introducing-the-ethscriptions-com-api-v1-6d2c507d82cd)
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
The (ethereum) goerli testnet api is wrapped in `Ethscribe::Api.goerli` and
|
43
|
+
the (ethereum) mainnet api is wrapped in `Ethscribe::Api.mainnet`.
|
44
|
+
|
45
|
+
Let's try the mainnet:
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
require 'ethscribe'
|
49
|
+
|
50
|
+
web = Ethscribe::Api.mainnet # or Ethscribe::Api.goerli
|
51
|
+
|
52
|
+
|
53
|
+
## get latest 25 inscriptions (defaults: page_size=25, sort_order=desc)
|
54
|
+
pp web.ethscriptions
|
55
|
+
|
56
|
+
## get inscriptions page 1 (same as above)
|
57
|
+
pp web.ethscriptions( page: 1 )
|
58
|
+
|
59
|
+
# get inscriptions page 2
|
60
|
+
pp web.ethscriptions( page: 2 )
|
61
|
+
|
62
|
+
# get oldest first - sort_order=asc
|
63
|
+
pp web.ethscriptions( page: 1, sort_order: 'asc' )
|
64
|
+
pp web.ethscriptions( page: 2, sort_order: 'asc' )
|
65
|
+
|
66
|
+
|
67
|
+
# get inscription by id or num
|
68
|
+
pp web.ethscription( 0 )
|
69
|
+
pp web.ethscription( 1 )
|
70
|
+
pp web.ethscription( 1000 )
|
71
|
+
pp web.ethscription( 1_000_000 )
|
72
|
+
|
73
|
+
|
74
|
+
# get inscriptions owend by <addresss>
|
75
|
+
address = '0x2a878245b52a2d46cb4327541cbc96e403a84791'
|
76
|
+
pp web.ethscriptions_owned_by( address )
|
77
|
+
|
78
|
+
|
79
|
+
# get inscription (decoded) content_data and content_type by id or num
|
80
|
+
pp web.ethscription_data( 0 )
|
81
|
+
pp web.ethscription_data( 1 )
|
82
|
+
pp web.ethscription_data( 2 )
|
83
|
+
|
84
|
+
|
85
|
+
# check if content exists (using sha256 hash)
|
86
|
+
# inscribe no. 0
|
87
|
+
sha = '2817fd9cf901e4435253881550731a5edc5e519c19de46b08e2b19a18e95143e'
|
88
|
+
pp web.ethscription_exists( sha )
|
89
|
+
|
90
|
+
# inscribe no. ??
|
91
|
+
sha = '2817fd9cf901e4435253833550731a5edc5e519c19de46b08e2b19a18e95143e'
|
92
|
+
pp web.ethscription_exists( sha )
|
93
|
+
|
94
|
+
# check the indexer (block) status
|
95
|
+
pp web.block_status
|
96
|
+
```
|
97
|
+
|
98
|
+
|
99
|
+
That's it for now.
|
100
|
+
|
101
|
+
|
20
102
|
|
21
103
|
## Bonus - More Blockchain (Crypto) Tools, Libraries & Scripts In Ruby
|
22
104
|
|
data/Rakefile
CHANGED
@@ -5,7 +5,7 @@ require './lib/ethscribe/version.rb'
|
|
5
5
|
Hoe.spec 'ethscribe' do
|
6
6
|
self.version = Ethscribe::VERSION
|
7
7
|
|
8
|
-
self.summary = 'ethscribe - inscription (ethscription calldata) api wrapper & helpers for Ethereum & co.'
|
8
|
+
self.summary = 'ethscribe - inscription / inscribe (ethscription calldata) api wrapper & helpers for Ethereum & co.'
|
9
9
|
self.description = summary
|
10
10
|
|
11
11
|
self.urls = { home: 'https://github.com/s6ruby/rubidity' }
|
data/lib/ethscribe/api.rb
CHANGED
@@ -25,10 +25,16 @@ class Api ## change/rename Api to Client - why? why not?
|
|
25
25
|
@requests = 0 ## count requests (for delay_in_s sleeping/throttling)
|
26
26
|
end
|
27
27
|
|
28
|
-
|
29
|
-
#
|
30
|
-
#
|
31
|
-
#
|
28
|
+
|
29
|
+
#
|
30
|
+
# Get all ethscriptions
|
31
|
+
#
|
32
|
+
# /ethscriptions
|
33
|
+
#
|
34
|
+
# Query parameters:
|
35
|
+
# page - integer (starting at 1)
|
36
|
+
# per_page - integer (default: 25 - max: 50)
|
37
|
+
# sort_order - string "asc" or "desc" (default: desc - latest first)
|
32
38
|
|
33
39
|
|
34
40
|
def ethscriptions( page: nil, per_page: nil, sort_order: nil )
|
@@ -46,6 +52,118 @@ class Api ## change/rename Api to Client - why? why not?
|
|
46
52
|
res.json ## return parsed json data - why? why not?
|
47
53
|
end
|
48
54
|
|
55
|
+
#
|
56
|
+
# Get ethscriptions owned by address
|
57
|
+
#
|
58
|
+
# /ethscriptions/owned_by/:address
|
59
|
+
#
|
60
|
+
# Query parameters: page, per_page( max 1000), sort_order (asc / desc)
|
61
|
+
|
62
|
+
def ethscriptions_owned_by( address )
|
63
|
+
src = "#{@base}/ethscriptions/owned_by/#{address}"
|
64
|
+
|
65
|
+
res = get( src )
|
66
|
+
res.json ## return parsed json data - why? why not?
|
67
|
+
end
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
#
|
72
|
+
# Get specific ethscription
|
73
|
+
#
|
74
|
+
# /ethscriptions/:ethscription_id
|
75
|
+
#
|
76
|
+
# Or
|
77
|
+
#
|
78
|
+
# /ethscriptions/:ethscription_number
|
79
|
+
#
|
80
|
+
# (ethscription_id is the transaction hash of the transaction that created the ethscription)
|
81
|
+
|
82
|
+
# note: use singular (overload method by args not possible in ruby)
|
83
|
+
def ethscription( id_or_num )
|
84
|
+
src = "#{@base}/ethscriptions/#{id_or_num}"
|
85
|
+
res = get( src )
|
86
|
+
res.json ## return parsed json data - why? why not?
|
87
|
+
end
|
88
|
+
|
89
|
+
#
|
90
|
+
# Get data of an ethscription
|
91
|
+
#
|
92
|
+
# /ethscriptions/:ethscription_id/data
|
93
|
+
#
|
94
|
+
# Or
|
95
|
+
#
|
96
|
+
# /ethscriptions/:ethscription_number/data
|
97
|
+
#
|
98
|
+
# This will return the ethscription's raw decoded data in the correct mimetype
|
99
|
+
|
100
|
+
|
101
|
+
###
|
102
|
+
# use a struct-like content class - why? why not?
|
103
|
+
class Content
|
104
|
+
attr_reader :data,
|
105
|
+
:type,
|
106
|
+
:length
|
107
|
+
def initialize( data, type, length )
|
108
|
+
@data = data
|
109
|
+
@type = type
|
110
|
+
@length = length
|
111
|
+
end
|
112
|
+
|
113
|
+
alias_method :blob, :data
|
114
|
+
end ## (nested) class Content
|
115
|
+
|
116
|
+
|
117
|
+
def ethscription_data( id_or_num )
|
118
|
+
src = "#{@base}/ethscriptions/#{id_or_num}/data"
|
119
|
+
res = get( src )
|
120
|
+
|
121
|
+
content_type = res.content_type
|
122
|
+
content_length = res.content_length
|
123
|
+
|
124
|
+
## note - content_length -- returns an integer (number)
|
125
|
+
## puts "content_length:"
|
126
|
+
## print content_length.inspect
|
127
|
+
## print " - #{content_length.class.name}\n"
|
128
|
+
|
129
|
+
## fix-fix-fix
|
130
|
+
## if text/json/svg type etc.
|
131
|
+
## convert to utf8 (from binary blob why? why not?) - why? why not?
|
132
|
+
## or add text accessor to content?
|
133
|
+
|
134
|
+
content = Content.new(
|
135
|
+
res.blob,
|
136
|
+
content_type,
|
137
|
+
content_length )
|
138
|
+
content
|
139
|
+
end
|
140
|
+
|
141
|
+
|
142
|
+
###
|
143
|
+
# Check whether content is already ethscribed
|
144
|
+
#
|
145
|
+
# /ethscriptions/exists/:sha
|
146
|
+
#
|
147
|
+
# Where sha is the sha256 of the UTF-8 data URI
|
148
|
+
|
149
|
+
# {"result":false,"ethscription":null}
|
150
|
+
|
151
|
+
def ethscription_exists( sha )
|
152
|
+
src = "#{@base}/ethscriptions/exists/#{sha}"
|
153
|
+
res = get( src )
|
154
|
+
res.json ## return parsed json data - why? why not?
|
155
|
+
end
|
156
|
+
|
157
|
+
# Determine if the indexer is behind
|
158
|
+
#
|
159
|
+
# {"current_block_number":18619883,"last_imported_block":18619883,"blocks_behind":0}
|
160
|
+
|
161
|
+
def block_status
|
162
|
+
src = "#{@base}/block_status"
|
163
|
+
res = get( src )
|
164
|
+
res.json ## return parsed json data - why? why not?
|
165
|
+
end
|
166
|
+
|
49
167
|
|
50
168
|
def get( src )
|
51
169
|
@requests += 1
|
data/lib/ethscribe/version.rb
CHANGED
data/lib/ethscribe.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ethscribe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerald Bauer
|
@@ -58,8 +58,8 @@ dependencies:
|
|
58
58
|
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: '4.0'
|
61
|
-
description: ethscribe - inscription (ethscription calldata) api wrapper
|
62
|
-
for Ethereum & co.
|
61
|
+
description: ethscribe - inscription / inscribe (ethscription calldata) api wrapper
|
62
|
+
& helpers for Ethereum & co.
|
63
63
|
email: gerald.bauer@gmail.com
|
64
64
|
executables: []
|
65
65
|
extensions: []
|
@@ -99,6 +99,6 @@ requirements: []
|
|
99
99
|
rubygems_version: 3.4.10
|
100
100
|
signing_key:
|
101
101
|
specification_version: 4
|
102
|
-
summary: ethscribe - inscription (ethscription calldata) api wrapper &
|
103
|
-
Ethereum & co.
|
102
|
+
summary: ethscribe - inscription / inscribe (ethscription calldata) api wrapper &
|
103
|
+
helpers for Ethereum & co.
|
104
104
|
test_files: []
|