ethscribe 0.1.0 → 0.2.0

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
  SHA256:
3
- metadata.gz: e4217cdc814f3b713841774ed4eec4abe0f024d598e365a5b7b34e142f555d77
4
- data.tar.gz: a28f4ca71df40a9da404ccc817e2e4ae13b247da8a44ea4878d5fee9e0f54a6b
3
+ metadata.gz: '09ac9a5eb1dbb35dde2105a3865bf6c67edd5469e8f9518e46949752f127991a'
4
+ data.tar.gz: 81e37a9c8a75bf4b1ec7a7ac82feccee8906a4a45636c750f7ba54e8c3797334
5
5
  SHA512:
6
- metadata.gz: e3d408e310e9df8cd9ef4df9376d854f3d243eabd321920071d27d6a94131e03114865427ee36c5dbf97693a1893ba4329d0cd1e56278611519f2f05f4b57185
7
- data.tar.gz: 9cb5cb71409a5e8280ea5be41c1c2c07b1ea0602766caee4168decb8a530a3f99931d950f4d28074905505fc76225530a13517126bd57da2f9039a23e93ac050
6
+ metadata.gz: 5cc33bb70781c8490fb1f5c8c3512f22d614fa6eade666d90ec7c1e7e30a77559e42a77f0bbaa28518111b1b1b0da498c764b9627d31488e0aab3d7788919f3b
7
+ data.tar.gz: 73547597a38a756b3be3dcf8d11ee387e651dffdfea3db936f250a146288bdc74b5a7f2d575e1a9eccce9e21b1b204591e4df8436601656f35780866a29afa06
data/CHANGELOG.md CHANGED
@@ -1,4 +1,4 @@
1
- ### 0.1.0
1
+ ### 0.2.0
2
2
  ### 0.0.1 / 2023-11-20
3
3
 
4
4
  * Everything is new. First release
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
- To be done...
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
- # page - integer (starting at 1)
30
- # per_page - integer (default: 25)
31
- # sort_order - string "asc" or "desc" (default: desc - latest first)
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
@@ -1,7 +1,7 @@
1
1
 
2
2
  module Ethscribe
3
3
  MAJOR = 0 ## todo: namespace inside version or something - why? why not??
4
- MINOR = 1
4
+ MINOR = 2
5
5
  PATCH = 0
6
6
  VERSION = [MAJOR,MINOR,PATCH].join('.')
7
7
 
data/lib/ethscribe.rb CHANGED
@@ -69,6 +69,7 @@ module Ethscribe
69
69
  ### more convenience shortcuts
70
70
 
71
71
  def self.inscribes( **kwargs ) client.ethscriptions( **kwargs ); end
72
+ def self.inscribe( id_or_num ) client.ethscription( id_or_num ); end
72
73
  end # module Ethscribe
73
74
 
74
75
 
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.1.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 & helpers
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 & helpers for
103
- Ethereum & co.
102
+ summary: ethscribe - inscription / inscribe (ethscription calldata) api wrapper &
103
+ helpers for Ethereum & co.
104
104
  test_files: []