cryptopunks 0.0.1 → 1.0.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: 92192671eaee8d69d5a4e56b28a6d38d0fd2140739fab1a11053d4f4b2fe82ab
4
- data.tar.gz: 9d803e337667a543a6438f8b22e937153965d31fbb4be8ac2420f9427d2f0710
3
+ metadata.gz: 3babd0420946592ca224951eacf1b9b14e6fea52917796bb550d86e4c05d13b1
4
+ data.tar.gz: e301d2ff4f5b84648d9cf7ba61fafbddc9383eca269563ff85a840c21a032159
5
5
  SHA512:
6
- metadata.gz: 374886a9f63aca0c2ff6149b3c8e9ad906555c43fa3a917eb8a6dd6f997bd67a6c419dabd179f0c15b2874e65bd69bf640fbd33dd0654864865a53161265f9bd
7
- data.tar.gz: 9e2942c55b95b628bf1b205405cf203b28f83ae90d0a79cf61feacfa1ec96baa0e95ec4e55deec38a2260209998d6b92bec0255461f469e7318767909170145c
6
+ metadata.gz: c152187a308be9c17a8cd165f2a059abbbc34f39f81ac4e88a4e1d1d0aee597a583675895ee9b8e5f577b3e2752fd0d2dfabf705eebc1d247efbc9c8e2b1de85
7
+ data.tar.gz: 238114795788bdf2685ffc093fd3c25960fd268738722810ac1bd524a3be2708c3388606da3ddce2bf6c6c2762f0f9401e3d768c7f19bcdaa8bdefe45b73ba1d
data/Manifest.txt CHANGED
@@ -2,5 +2,7 @@ CHANGELOG.md
2
2
  Manifest.txt
3
3
  README.md
4
4
  Rakefile
5
+ bin/cryptopunk
6
+ bin/punk
5
7
  lib/cryptopunks.rb
6
8
  lib/cryptopunks/version.rb
data/README.md CHANGED
@@ -1,15 +1,184 @@
1
- # cryptopunks
1
+ # Crypto Punks
2
2
 
3
- mint your own 24×24 pixel punk images off chain from the True Official Genuine CryptoPunks™ sha256-verified original; incl. 2x/4x/8x zoom for bigger sizes
3
+ cryptopunks - mint your own 24×24 pixel punk images off chain from the True Official Genuine CryptoPunks™ sha256-verified original 10 000 unique character collection; incl. 2x/4x/8x zoom for bigger sizes
4
4
 
5
+ * home :: [github.com/rubycoco/cryptopunks](https://github.com/rubycoco/cryptopunks)
6
+ * bugs :: [github.com/rubycoco/cryptopunks/issues](https://github.com/rubycoco/cryptopunks/issues)
7
+ * gem :: [rubygems.org/gems/cryptopunks](https://rubygems.org/gems/cryptopunks)
8
+ * rdoc :: [rubydoc.info/gems/cryptopunks](http://rubydoc.info/gems/cryptopunks)
5
9
 
6
10
 
7
- ## Usage
8
11
 
9
- to be done
12
+ > Someday, owning a CryptoPunk might signify just how early of an
13
+ > adopter you were into the world of blockchain and its thriving digital
14
+ > art scene. Or, they could just be a bunch of [24×24 pixel] images.
15
+ >
16
+ > -- [June 2017](https://mashable.com/2017/06/16/cryptopunks-ethereum-art-collectibles/)
17
+ >
18
+ >
19
+ > There will be a desire and need to buy expensive [status symbols]
20
+ > in the digital realm [to "flex" how rich I am].
21
+ > What could be more desirable than a small [24×24]
22
+ > pixelated [knitted cap-wearing ape] face?
23
+ > CryptoPunk artwork [![](i/punk-8219.png) [#8219](https://www.larvalabs.com/cryptopunks/details/8219)] just sold for $176,000.
24
+ >
25
+ > -- [January 2021](https://decrypt.co/53519/an-ethereum-based-cryptopunk-artwork-just-sold-for-176000)
26
+ >
27
+ >
28
+ > Ultra-rare alien [24×24 pixel] CryptoPunk
29
+ > sells for 605 ETH, or $750,000.
30
+ > The investment thesis. "Aliens are the rarest form of CryptoPunk and
31
+ > we believe that the acquired Alien [![](i/punk-2890.png) [#2890](https://www.larvalabs.com/cryptopunks/details/2890), one of nine]
32
+ > will be prized by collectors over
33
+ > time and mature into an iconic digital art piece."
34
+ >
35
+ > -- [January 2021](https://cointelegraph.com/news/ultra-rare-alien-cryptopunk-nft-sells-for-605-eth-or-750-000)
36
+ >
37
+ >
38
+ > The [CryptoPunksMarket] contract now holds 4,095 ETH (~$5.4M USD) in open bids and pending withdrawals.
39
+ >
40
+ > -- [January 2021](https://twitter.com/larvalabs/status/1353915659453870080)
10
41
 
11
42
 
12
43
 
44
+ New to Crypto Punks?
45
+ See the [**Awesome CryptoPunks Bubble (Anno 2021) - Modern 24×24 Pixel Crypto Art on the Blockchain** »](https://github.com/openblockchains/awesome-cryptopunks-bubble)
46
+
47
+
48
+
49
+ ## Command Line
50
+
51
+ Use the `punk` (or `cryptopunk`) command line tool. Try:
52
+
53
+ ```
54
+ $ punk -h
55
+ ```
56
+
57
+ resulting in:
58
+
59
+ ```
60
+ Usage: cryptopunks [options] IDs
61
+ Mint punk characters from composite (./punks.png) - for IDs use 0 to 9999
62
+
63
+ Options:
64
+ -z, --zoom=ZOOM Zoom factor x2, x4, x8, etc. (default: 1)
65
+ -d, --dir=DIR Output directory (default: .)
66
+ -f, --file=FILE True Official Genuine CryptoPunks™ composite image (default: ./punks.png)
67
+ -h, --help Prints this help
68
+ ```
69
+
70
+
71
+ Step 0 - Download the True Official Genuine CryptoPunks™ composite image
72
+
73
+ One time / first time only - Download the True Official Genuine CryptoPunks™ composite
74
+ housing all 10 000 CryptoPunks
75
+ in a single 2400×2400 image (~830 kb) for free.
76
+ See [`punks.png` »](https://github.com/larvalabs/cryptopunks/blob/master/punks.png)
77
+
78
+
79
+ ![](i/punks-zoom.png)
80
+
81
+
82
+
83
+ Now let's give it a try. Let's mint punk #0, #2890, and #8219:
84
+
85
+ ```
86
+ $ punk 0 2890 8219
87
+ ```
88
+
89
+ printing:
90
+
91
+ ```
92
+ ==> reading >./punks.png<...
93
+ >ac39af4793119ee46bbff351d8cb6b5f23da60222126add4268e261199a2921b< SHA256 hash matching
94
+ ✓ True Official Genuine CryptoPunks™ verified
95
+ ==> (1/3) minting punk #0; writing to >./punk-0000.png<...
96
+ ==> (2/3) minting punk #2890; writing to >./punk-2890.png<...
97
+ ==> (3/3) minting punk #8219; writing to >./punk-8219.png<...
98
+ ```
99
+
100
+ And voila!
101
+
102
+ ![](i/punk-0000.png)
103
+ ![](i/punk-2890.png)
104
+ ![](i/punk-8219.png)
105
+
106
+
107
+ Bonus: Try the -z/--zoom factor x2, x4, x8, etc.
108
+
109
+ Now let's give it a try. Let's mint punk #0, #2890, and #8219 in 2x format:
110
+
111
+ ```
112
+ $ punk --zoom 2 0 2890 8219
113
+ # -or-
114
+ $ punk -z2 0 2890 8219
115
+ ```
116
+
117
+ printing:
118
+
119
+ ```
120
+ ==> reading >./punks.png<...
121
+ >ac39af4793119ee46bbff351d8cb6b5f23da60222126add4268e261199a2921b< SHA256 hash matching
122
+ ✓ True Official Genuine CryptoPunks™ verified
123
+ setting zoom to 2x
124
+ ==> (1/3) minting punk #0; writing to >punk-0000x2.png<...
125
+ ==> (2/3) minting punk #2890; writing to >punk-2890x2.png<...
126
+ ==> (3/3) minting punk #8219; writing to >punk-8219x2.png<...
127
+ ```
128
+
129
+ And voila!
130
+
131
+ ![](i/punk-0000x2.png)
132
+ ![](i/punk-2890x2.png)
133
+ ![](i/punk-8219x2.png)
134
+
135
+ And x4:
136
+
137
+ ![](i/punk-0000x4.png)
138
+ ![](i/punk-2890x4.png)
139
+ ![](i/punk-8219x4.png)
140
+
141
+
142
+ And x8:
143
+
144
+ ![](i/punk-0000x8.png)
145
+ ![](i/punk-2890x8.png)
146
+ ![](i/punk-8219x8.png)
147
+
148
+
149
+ And so on.
150
+
151
+
152
+ ## Usage in Your Scripts
153
+
154
+
155
+ Yes, you can mint punks in your own scripts.
156
+ Example:
157
+
158
+ ``` ruby
159
+ require 'cryptopunks'
160
+
161
+ # step 1: read True Official Genuine CryptoPunks™ composite image
162
+ punks = Punks::Image.read( './punks.png' )
163
+
164
+ # step 2: start minting
165
+
166
+ punks[0].save( './punk-0000.png' )
167
+ punks[2890].save( './punk-2890.png' )
168
+ punks[8219].save( './punk-8219.png')
169
+
170
+ # or change the zoom factor
171
+ punks.zoom = 4 # use x4
172
+
173
+ punks[0].save( './punk-0000x4.png' )
174
+ punks[2890].save( './punk-2890x4.png' )
175
+ punks[8219].save( './punk-8219x4.png')
176
+ ```
177
+
178
+ and so on. Happy miniting.
179
+ That's all for now.
180
+
181
+
13
182
 
14
183
  ## Install
15
184
 
data/Rakefile CHANGED
@@ -5,7 +5,7 @@ Hoe.spec 'cryptopunks' do
5
5
 
6
6
  self.version = Cryptopunks::VERSION
7
7
 
8
- self.summary = "cryptopunks - mint your own 24×24 pixel punk images off chain from the True Official Genuine CryptoPunks™ sha256-verified original; incl. 2x/4x/8x zoom for bigger sizes"
8
+ self.summary = "cryptopunks - mint your own 24×24 pixel punk images off chain from the True Official Genuine CryptoPunks™ sha256-verified original 10 000 unique character collection; incl. 2x/4x/8x zoom for bigger sizes"
9
9
  self.description = summary
10
10
 
11
11
  self.urls = { home: 'https://github.com/rubycoco/blockchain' }
data/bin/cryptopunk ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ ###################
4
+ # == DEV TIPS:
5
+ #
6
+ # For local testing run like:
7
+ #
8
+ # ruby -Ilib bin/cryptopunk
9
+ #
10
+ # Set the executable bit in Linux. Example:
11
+ #
12
+ # % chmod a+x bin/cryptopunk
13
+ #
14
+
15
+ require 'cryptopunks'
16
+
17
+ Cryptopunks.main
data/bin/punk ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ ###################
4
+ # == DEV TIPS:
5
+ #
6
+ # For local testing run like:
7
+ #
8
+ # ruby -Ilib bin/punk
9
+ #
10
+ # Set the executable bit in Linux. Example:
11
+ #
12
+ # % chmod a+x bin/punk
13
+ #
14
+
15
+ require 'cryptopunks'
16
+
17
+ Cryptopunks.main
data/lib/cryptopunks.rb CHANGED
@@ -1,9 +1,181 @@
1
- require 'pp'
1
+ ## 3rd party
2
+ require 'crypto-lite'
3
+ require 'chunky_png'
4
+
5
+ ## extra stdlibs
6
+ require 'fileutils'
7
+ require 'optparse'
8
+
2
9
 
3
10
 
4
11
  ## our own code
5
12
  require 'cryptopunks/version' # note: let version always go first
6
13
 
7
14
 
8
- pp Cryptopunks.banner
9
- pp Cryptopunks.root
15
+ module Cryptopunks
16
+ class Image
17
+ def self.read( path='./punks.png' )
18
+ data = File.open( path, 'rb' ) { |f| f.read }
19
+ new( data )
20
+ end
21
+
22
+
23
+ attr_accessor :zoom
24
+
25
+ PUNK_ROWS = 100
26
+ PUNK_COLS = 100
27
+ PUNK_COUNT = PUNK_ROWS * PUNK_COLS ## 10_000 = 100x100 (24000x24000 pixel)
28
+
29
+ PUNK_HEIGHT = 24
30
+ PUNK_WIDTH = 24
31
+
32
+ PUNK_HASH = 'ac39af4793119ee46bbff351d8cb6b5f23da60222126add4268e261199a2921b'
33
+
34
+
35
+ def initialize( data )
36
+ @punks = ChunkyPNG::Image.from_blob( data )
37
+ puts " #{@punks.height}x#{@punks.width} (height x width)"
38
+
39
+ ## check sha256 checksum
40
+ @hexdigest = sha256( data )
41
+ if original?
42
+ puts " >#{@hexdigest}< SHA256 hash matching"
43
+ puts " ✓ True Official Genuine CryptoPunks™ verified"
44
+ else
45
+ puts " !! ERROR: >#{hexdigest}< SHA256 hash NOT matching"
46
+ puts " >#{PUNK_HASH}< expected for True Official Genuine CryptoPunks™."
47
+ puts ""
48
+ puts " Sorry, please download the original."
49
+ exit 1
50
+ end
51
+
52
+ @zoom = 1
53
+ end
54
+
55
+
56
+ def hexdigest() @hexdigest end
57
+
58
+ def verify?() @hexdigest == PUNK_HASH; end
59
+ alias_method :genuine?, :verify?
60
+ alias_method :original?, :verify?
61
+
62
+
63
+
64
+ def size() PUNK_COUNT; end
65
+
66
+ def []( index )
67
+ @zoom == 1 ? crop( index ) : scale( index, @zoom )
68
+ end
69
+
70
+
71
+ def crop( index )
72
+ y, x = index.divmod( PUNK_ROWS )
73
+ @punks.crop( x*PUNK_WIDTH, y*PUNK_HEIGHT, PUNK_WIDTH, PUNK_HEIGHT )
74
+ end
75
+
76
+
77
+ def scale( index, zoom )
78
+ punk = ChunkyPNG::Image.new( PUNK_WIDTH*zoom, PUNK_HEIGHT*zoom,
79
+ ChunkyPNG::Color::WHITE )
80
+
81
+ ## (x,y) offset in big all-in-one punks image
82
+ y, x = index.divmod( PUNK_ROWS )
83
+
84
+ ## copy all 24x24 pixels
85
+ PUNK_WIDTH.times do |i|
86
+ PUNK_HEIGHT.times do |j|
87
+ pixel = @punks[i+x*PUNK_WIDTH, j+y*PUNK_HEIGHT]
88
+ zoom.times do |n|
89
+ zoom.times do |m|
90
+ punk[n+zoom*i,m+zoom*j] = pixel
91
+ end
92
+ end
93
+ end
94
+ end
95
+ punk
96
+ end
97
+ end ## class Image
98
+
99
+
100
+
101
+ class Tool
102
+ def run( args )
103
+ opts = { zoom: 1,
104
+ outdir: '.',
105
+ file: './punks.png',
106
+ }
107
+
108
+ parser = OptionParser.new do |cmd|
109
+ cmd.banner = "Usage: cryptopunks [options] IDs"
110
+
111
+ cmd.separator " Mint punk characters from composite (#{opts[:file]}) - for IDs use 0 to 9999"
112
+ cmd.separator ""
113
+ cmd.separator " Options:"
114
+
115
+ cmd.on("-z", "--zoom=ZOOM", "Zoom factor x2, x4, x8, etc. (default: #{opts[:zoom]})", Integer ) do |zoom|
116
+ opts[:zoom] = zoom
117
+ end
118
+
119
+ cmd.on("-d", "--dir=DIR", "Output directory (default: #{opts[:outdir]})", String ) do |outdir|
120
+ opts[:outdir] = outdir
121
+ end
122
+
123
+ cmd.on("-f", "--file=FILE", "True Official Genuine CryptoPunks™ composite image (default: #{opts[:file]})", String ) do |file|
124
+ opts[:file] = file
125
+ end
126
+
127
+
128
+ cmd.on("-h", "--help", "Prints this help") do
129
+ puts cmd
130
+ exit
131
+ end
132
+ end
133
+
134
+ parser.parse!( args )
135
+
136
+ puts "opts:"
137
+ pp opts
138
+
139
+ puts "==> reading >#{opts[:file]}<..."
140
+ punks = Image.read( opts[:file] )
141
+
142
+
143
+ puts " setting zoom to #{opts[:zoom]}x" if opts[:zoom] != 1
144
+ punks.zoom = opts[:zoom] ## note: always reset zoom even if 1
145
+
146
+ ## make sure outdir exits (default is current working dir e.g. .)
147
+ FileUtils.mkdir_p( opts[:outdir] ) unless Dir.exist?( opts[:outdir] )
148
+
149
+ args.each_with_index do |arg,index|
150
+ punk_index = arg.to_i
151
+ punk_name = "punk-" + "%04d" % punk_index
152
+
153
+ ## if zoom - add x2,x4 or such
154
+ punk_name << "x#{opts[:zoom]}" if opts[:zoom] != 1
155
+
156
+ path = "#{opts[:outdir]}/#{punk_name}.png"
157
+ puts "==> (#{index+1}/#{args.size}) minting punk ##{punk_index}; writing to >#{path}<..."
158
+
159
+ punks[ punk_index ].save( path )
160
+ end
161
+
162
+ puts "done"
163
+ end ## method run
164
+ end # class Tool
165
+
166
+
167
+ def self.main( args=ARGV )
168
+ Tool.new.run( args )
169
+ end
170
+ end ## module Cryptopunks
171
+
172
+
173
+
174
+ ### add some convenience shortcuts
175
+ CryptoPunks = Cryptopunks
176
+ Punks = Cryptopunks
177
+
178
+
179
+
180
+
181
+ puts Cryptopunks.banner # say hello
@@ -2,9 +2,9 @@
2
2
 
3
3
  module Cryptopunks
4
4
 
5
- MAJOR = 0
5
+ MAJOR = 1
6
6
  MINOR = 0
7
- PATCH = 1
7
+ PATCH = 0
8
8
  VERSION = [MAJOR,MINOR,PATCH].join('.')
9
9
 
10
10
  def self.version
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cryptopunks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerald Bauer
@@ -73,10 +73,12 @@ dependencies:
73
73
  - !ruby/object:Gem::Version
74
74
  version: '3.22'
75
75
  description: cryptopunks - mint your own 24×24 pixel punk images off chain from the
76
- True Official Genuine CryptoPunks™ sha256-verified original; incl. 2x/4x/8x zoom
77
- for bigger sizes
76
+ True Official Genuine CryptoPunks™ sha256-verified original 10 000 unique character
77
+ collection; incl. 2x/4x/8x zoom for bigger sizes
78
78
  email: wwwmake@googlegroups.com
79
- executables: []
79
+ executables:
80
+ - cryptopunk
81
+ - punk
80
82
  extensions: []
81
83
  extra_rdoc_files:
82
84
  - CHANGELOG.md
@@ -87,6 +89,8 @@ files:
87
89
  - Manifest.txt
88
90
  - README.md
89
91
  - Rakefile
92
+ - bin/cryptopunk
93
+ - bin/punk
90
94
  - lib/cryptopunks.rb
91
95
  - lib/cryptopunks/version.rb
92
96
  homepage: https://github.com/rubycoco/blockchain
@@ -114,6 +118,6 @@ rubygems_version: 3.1.4
114
118
  signing_key:
115
119
  specification_version: 4
116
120
  summary: cryptopunks - mint your own 24×24 pixel punk images off chain from the True
117
- Official Genuine CryptoPunks™ sha256-verified original; incl. 2x/4x/8x zoom for
118
- bigger sizes
121
+ Official Genuine CryptoPunks™ sha256-verified original 10 000 unique character collection;
122
+ incl. 2x/4x/8x zoom for bigger sizes
119
123
  test_files: []