was formerly abi2sol?
20 |
21 |
22 |
--------------------------------------------------------------------------------
/attic/bitshilling-blockchain/blk001.txt:
--------------------------------------------------------------------------------
1 | ---
2 | index : 1
3 | timestamp : 2017-09-19 11:01:38
4 | previous_hash : edbd4e11e69bc399a9ccd8faaea44fb27410fe8e3023bb9462450a0a9c4caa1b
5 | hash : eb8ecbf6d5870763ae246e37539d82e37052cb32f88bb8c59971f9978e437743
6 | ---
7 |
8 | from: Grossklockner to: Sepp amount: 3798
9 | from: Grossvenediger to: Franz amount: 3666
10 | from: Dachstein to: Sissi amount: 2995
11 | from: Wildspitze to: Maria amount: 3768
12 |
--------------------------------------------------------------------------------
/blockchain-lite/Manifest.txt:
--------------------------------------------------------------------------------
1 | CHANGELOG.md
2 | Manifest.txt
3 | README.md
4 | Rakefile
5 | lib/blockchain-lite.rb
6 | lib/blockchain-lite/base.rb
7 | lib/blockchain-lite/basic/block.rb
8 | lib/blockchain-lite/bitcoin/block.rb
9 | lib/blockchain-lite/blockchain.rb
10 | lib/blockchain-lite/proof_of_work/block.rb
11 | lib/blockchain-lite/version.rb
12 | test/helper.rb
13 | test/test_block.rb
14 | test/test_block_basic.rb
15 | test/test_block_proof_of_work.rb
16 | test/test_blockchain.rb
17 | test/test_version.rb
18 |
--------------------------------------------------------------------------------
/abi2sol/sandbox/test_parse2.rb:
--------------------------------------------------------------------------------
1 | ###
2 | # to run use
3 | # ruby -I ./lib sandbox/test_parse2.rb
4 |
5 | $LOAD_PATH.unshift( "../abiparser/lib" )
6 | require 'abi2sol'
7 |
8 | names = [
9 | 'AirSwap',
10 | 'BunchaStructs',
11 | ]
12 |
13 | names.each do |name|
14 | abi = ABI.read( "./abis//#{name}.abi.json" )
15 | pp abi
16 |
17 | buf = abi.generate_interface( name: name )
18 | puts buf
19 | write_text( "./tmp/#{name}.sol", buf )
20 | end
21 |
22 |
23 | puts "bye"
24 |
--------------------------------------------------------------------------------
/elliptic-lite/lib/elliptic-lite/version.rb:
--------------------------------------------------------------------------------
1 | module ECCLite
2 |
3 | MAJOR = 0
4 | MINOR = 1
5 | PATCH = 0
6 | VERSION = [MAJOR,MINOR,PATCH].join('.')
7 |
8 | def self.version
9 | VERSION
10 | end
11 |
12 | def self.banner
13 | "elliptic-lite/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}] in (#{root})"
14 | end
15 |
16 | def self.root
17 | File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )
18 | end
19 |
20 | end # module ECCLite
21 |
--------------------------------------------------------------------------------
/p2p/lib/p2p/version.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 |
4 | module PeerToPeer
5 |
6 | MAJOR = 0
7 | MINOR = 0
8 | PATCH = 1
9 | VERSION = [MAJOR,MINOR,PATCH].join('.')
10 |
11 | def self.version
12 | VERSION
13 | end
14 |
15 | def self.banner
16 | "p2p/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
17 | end
18 |
19 | def self.root
20 | "#{File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )}"
21 | end
22 |
23 | end # module PeerToPeer
24 |
--------------------------------------------------------------------------------
/cryptoquotes/lib/cryptoquotes/version.rb:
--------------------------------------------------------------------------------
1 |
2 |
3 | module Quotes
4 |
5 | MAJOR = 1
6 | MINOR = 1
7 | PATCH = 0
8 | VERSION = [MAJOR,MINOR,PATCH].join('.')
9 |
10 | def self.version
11 | VERSION
12 | end
13 |
14 | def self.banner
15 | "cryptoquotes/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}] (in #{root})"
16 | end
17 |
18 | def self.root
19 | File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )
20 | end
21 |
22 | end # module Quotes
23 |
--------------------------------------------------------------------------------
/solidity/lib/solidity/version.rb:
--------------------------------------------------------------------------------
1 |
2 | module Solidity
3 | MAJOR = 0
4 | MINOR = 2
5 | PATCH = 0
6 | VERSION = [MAJOR,MINOR,PATCH].join('.')
7 |
8 | def self.version
9 | VERSION
10 | end
11 |
12 | def self.banner
13 | "solidity/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}] in (#{root})"
14 | end
15 |
16 | def self.root
17 | File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )
18 | end
19 |
20 | end # module Solidity
21 |
--------------------------------------------------------------------------------
/elliptic/lib/elliptic/version.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 |
4 | module EC
5 |
6 | MAJOR = 1
7 | MINOR = 0
8 | PATCH = 2
9 | VERSION = [MAJOR,MINOR,PATCH].join('.')
10 |
11 | def self.version
12 | VERSION
13 | end
14 |
15 | def self.banner
16 | "elliptic/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}] in (#{root})"
17 | end
18 |
19 | def self.root
20 | File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )
21 | end
22 |
23 | end # module EC
24 |
--------------------------------------------------------------------------------
/crypto-lite/lib/crypto-lite/version.rb:
--------------------------------------------------------------------------------
1 |
2 | module CryptoLite
3 |
4 | MAJOR = 0
5 | MINOR = 4
6 | PATCH = 0
7 | VERSION = [MAJOR,MINOR,PATCH].join('.')
8 |
9 | def self.version
10 | VERSION
11 | end
12 |
13 | def self.banner
14 | "crypto-lite/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}] in (#{root})"
15 | end
16 |
17 | def self.root
18 | File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )
19 | end
20 |
21 | end # module CryptoLite
22 |
23 |
24 |
--------------------------------------------------------------------------------
/ethlite/lib/ethlite/version.rb:
--------------------------------------------------------------------------------
1 |
2 |
3 | module Ethlite
4 | MAJOR = 1
5 | MINOR = 0
6 | PATCH = 0
7 | VERSION = [MAJOR,MINOR,PATCH].join('.')
8 |
9 | def self.version
10 | VERSION
11 | end
12 |
13 | def self.banner
14 | "ethlite/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}] in (#{root})"
15 | end
16 |
17 | def self.root
18 | File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )
19 | end
20 |
21 | end # module Ethlite
22 |
23 |
--------------------------------------------------------------------------------
/ethname/lib/ethname/version.rb:
--------------------------------------------------------------------------------
1 |
2 |
3 | module Ethname
4 | MAJOR = 0
5 | MINOR = 1
6 | PATCH = 3
7 | VERSION = [MAJOR,MINOR,PATCH].join('.')
8 |
9 | def self.version
10 | VERSION
11 | end
12 |
13 | def self.banner
14 | "ethname/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}] in (#{root})"
15 | end
16 |
17 | def self.root
18 | File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )
19 | end
20 |
21 | end # module Ethname
22 |
23 |
--------------------------------------------------------------------------------
/natspec/sandbox/test_parse.rb:
--------------------------------------------------------------------------------
1 | ###
2 | # to run use
3 | # ruby -I ./lib sandbox/test_parse.rb
4 |
5 | require 'natspec'
6 |
7 | punks_v1 = '0x6ba6f2207e343923ba692e5cae646fb0f566db8d'
8 |
9 | nat = Natspec.read( "../../awesome-contracts/address/#{punks_v1}/contract.md" )
10 | pp nat
11 |
12 |
13 |
14 | punk_blocks = '0x58e90596c2065befd3060767736c829c18f3474c'
15 |
16 | nat = Natspec.read( "../../awesome-contracts/address/#{punk_blocks}/contract.md" )
17 | pp nat
18 |
19 |
20 | puts "bye"
21 |
--------------------------------------------------------------------------------
/ledger-lite/lib/ledger-lite/version.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 |
4 | module LedgerLite
5 |
6 | MAJOR = 1
7 | MINOR = 1
8 | PATCH = 1
9 | VERSION = [MAJOR,MINOR,PATCH].join('.')
10 |
11 | def self.version
12 | VERSION
13 | end
14 |
15 | def self.banner
16 | "ledger-lite/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
17 | end
18 |
19 | def self.root
20 | "#{File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )}"
21 | end
22 |
23 | end # module LedgerLite
24 |
--------------------------------------------------------------------------------
/base32-alphabets/lib/base32-alphabets/version.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | module Base32
4 | MAJOR = 1
5 | MINOR = 2
6 | PATCH = 0
7 | VERSION = [MAJOR,MINOR,PATCH].join('.')
8 |
9 | def self.version
10 | VERSION
11 | end
12 |
13 | def self.banner
14 | "base32-alphabets/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}] in (#{root})"
15 | end
16 |
17 | def self.root
18 | File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )
19 | end
20 |
21 | end # module Base32
22 |
--------------------------------------------------------------------------------
/base58-alphabets/lib/base58-alphabets/version.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | module Base58
4 | MAJOR = 1
5 | MINOR = 0
6 | PATCH = 0
7 | VERSION = [MAJOR,MINOR,PATCH].join('.')
8 |
9 | def self.version
10 | VERSION
11 | end
12 |
13 | def self.banner
14 | "base58-alphabets/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}] in (#{root})"
15 | end
16 |
17 | def self.root
18 | File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )
19 | end
20 |
21 | end # module Base58
22 |
23 |
--------------------------------------------------------------------------------
/digest-lite/lib/digest-lite/version.rb:
--------------------------------------------------------------------------------
1 |
2 |
3 | module Digestlite
4 | MAJOR = 0
5 | MINOR = 0
6 | PATCH = 1
7 | VERSION = [MAJOR,MINOR,PATCH].join('.')
8 |
9 | def self.version
10 | VERSION
11 | end
12 |
13 | def self.banner
14 | "digest-lite/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}] in (#{root})"
15 | end
16 |
17 | def self.root
18 | File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )
19 | end
20 |
21 | end # module Digestlite
22 |
23 |
--------------------------------------------------------------------------------
/etherscan-lite/lib/etherscan-lite/version.rb:
--------------------------------------------------------------------------------
1 |
2 |
3 | module EtherscanLite
4 | MAJOR = 0
5 | MINOR = 1
6 | PATCH = 1
7 | VERSION = [MAJOR,MINOR,PATCH].join('.')
8 |
9 | def self.version
10 | VERSION
11 | end
12 |
13 | def self.banner
14 | "etherscan-lite/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}] in (#{root})"
15 | end
16 |
17 | def self.root
18 | File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )
19 | end
20 |
21 | end # module EtherscanLite
22 |
23 |
--------------------------------------------------------------------------------
/blockchain-lite/lib/blockchain-lite/version.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 |
4 | module BlockchainLite
5 |
6 | MAJOR = 1
7 | MINOR = 4
8 | PATCH = 1
9 | VERSION = [MAJOR,MINOR,PATCH].join('.')
10 |
11 | def self.version
12 | VERSION
13 | end
14 |
15 | def self.banner
16 | "blockchain-lite/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}] in (#{root})"
17 | end
18 |
19 | def self.root
20 | File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )
21 | end
22 |
23 | end # module BlockchainLite
24 |
--------------------------------------------------------------------------------
/base58-alphabets/test/test_bytes.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | ###
4 | # to run use
5 | # ruby -I ./lib -I ./test test/test_bytes.rb
6 |
7 |
8 | require 'helper'
9 |
10 |
11 | class TestBytes < MiniTest::Test
12 |
13 |
14 | def test_bytes
15 | bytes = Base58::Base._bytes( 123456789 )
16 | ## pp bytes
17 |
18 | assert_equal [10,52,43,23,19], bytes
19 |
20 | assert_equal 123456789, Base58::Base._pack( bytes )
21 |
22 |
23 | assert_equal 123456789, Base58::Base._pack( Base58::Base._bytes( 123456789 ))
24 | end
25 |
26 | end # class TestBytes
27 |
--------------------------------------------------------------------------------
/p2p/README.md:
--------------------------------------------------------------------------------
1 | # Peer-to-Peer (P2P)
2 |
3 | build your own peer-to-peer (p2p) networks; run your own peer-to-peer (p2p) nodes over HTTP
4 |
5 |
6 | ## Usage
7 |
8 | to be done
9 |
10 |
11 |
12 |
13 | ## Install
14 |
15 | Just install the gem:
16 |
17 | $ gem install p2p
18 |
19 |
20 | ## License
21 |
22 | The `p2p` scripts are dedicated to the public domain.
23 | Use it as you please with no restrictions whatsoever.
24 |
25 |
26 | ## Questions? Comments?
27 |
28 | Send them along to the [wwwmake forum](http://groups.google.com/group/wwwmake).
29 | Thanks!
30 |
--------------------------------------------------------------------------------
/abidoc/lib/abidoc/version.rb:
--------------------------------------------------------------------------------
1 |
2 | module ABIDoc
3 |
4 | MAJOR = 0
5 | MINOR = 1
6 | PATCH = 1
7 | VERSION = [MAJOR,MINOR,PATCH].join('.')
8 |
9 | def self.version
10 | VERSION
11 | end
12 |
13 | def self.banner
14 | "abidoc/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}] in (#{root})"
15 | end
16 |
17 | def self.root
18 | File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )
19 | end
20 |
21 | end # module ABIDoc
22 |
23 | ## add convenience alternate spellings - why? why not?
24 | AbiDoc = ABIDoc
25 |
26 |
--------------------------------------------------------------------------------
/merkletree/lib/merkletree/version.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 |
4 | class MerkleTree ## note: use class (!) for now and NOT module
5 | MAJOR = 0
6 | MINOR = 1
7 | PATCH = 1
8 | VERSION = [MAJOR,MINOR,PATCH].join('.')
9 |
10 | def self.version
11 | VERSION
12 | end
13 |
14 | def self.banner
15 | "merkletree/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}] in (#{root})"
16 | end
17 |
18 | def self.root
19 | File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )
20 | end
21 |
22 | end # module MerkleTree
23 |
--------------------------------------------------------------------------------
/solidity/sandbox/test_tokens.rb:
--------------------------------------------------------------------------------
1 | ###
2 | # to run use
3 | # ruby -I ./lib sandbox/test_tokens.rb
4 |
5 | require 'solidity'
6 |
7 |
8 | addr = "0x0cfdb3ba1694c2bb2cfacb0339ad7b1ae5932b63"
9 | ## addr = "0x34625ecaa75c0ea33733a05c584f4cf112c10b6b"
10 | ## addr = "0x031920cc2d9f5c10b444fd44009cd64f829e7be2"
11 |
12 | path = "../../awesome-contracts/address/#{addr}/contract.sol"
13 |
14 | ## path = "./contracts/contract3.sol"
15 |
16 | lexer = Solidity::Lexer.read( path )
17 |
18 | puts "---"
19 | puts "tokens:"
20 | pp lexer.tokenize
21 |
22 |
23 | puts "bye"
--------------------------------------------------------------------------------
/abicoder/lib/abicoder/version.rb:
--------------------------------------------------------------------------------
1 |
2 | module ABICoder
3 | MAJOR = 1
4 | MINOR = 0
5 | PATCH = 1
6 | VERSION = [MAJOR,MINOR,PATCH].join('.')
7 |
8 | def self.version
9 | VERSION
10 | end
11 |
12 | def self.banner
13 | "abicoder/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}] in (#{root})"
14 | end
15 |
16 | def self.root
17 | File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )
18 | end
19 |
20 | end # module ABICoder
21 |
22 | ## add convenience alternate spellings - why? why not?
23 | AbiCoder = ABICoder
24 |
25 |
--------------------------------------------------------------------------------
/abiparser/lib/abiparser/version.rb:
--------------------------------------------------------------------------------
1 |
2 | module ABIParser
3 | MAJOR = 0
4 | MINOR = 1
5 | PATCH = 4
6 | VERSION = [MAJOR,MINOR,PATCH].join('.')
7 |
8 | def self.version
9 | VERSION
10 | end
11 |
12 | def self.banner
13 | "abiparser/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}] in (#{root})"
14 | end
15 |
16 | def self.root
17 | File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) )
18 | end
19 |
20 | end # module ABIParser
21 |
22 | ## add convenience alternate spellings - why? why not?
23 | AbiParser = ABIParser
24 |
25 |
--------------------------------------------------------------------------------
/centralbank/lib/centralbank/views/_wallet.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
Address
5 |
<%= @node.wallet.address %>
6 |
Balance
7 |
$<%= @node.bank.ledger.wallets[@node.wallet.address] || 0 %>
8 |
9 |
16 |
17 |
--------------------------------------------------------------------------------
/attic/bitshilling/lib/shilling/views/_wallet.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
Address
5 |
<%= @node.wallet.address %>
6 |
Balance
7 |
$<%= @node.bank.ledger[@node.wallet.address] || 0 %>
8 |
9 |
16 |
17 |
--------------------------------------------------------------------------------
/merkletree/.gitignore:
--------------------------------------------------------------------------------
1 | *.gem
2 | *.rbc
3 | /.config
4 | /coverage/
5 | /InstalledFiles
6 | /pkg/
7 | /spec/reports/
8 | /test/tmp/
9 | /test/version_tmp/
10 | /tmp/
11 |
12 |
13 | ## Documentation cache and generated files:
14 | /.yardoc/
15 | /_yardoc/
16 | /doc/
17 | /rdoc/
18 |
19 | ## Environment normalisation:
20 | /.bundle/
21 | /vendor/bundle
22 | /lib/bundler/man/
23 |
24 | # for a library or gem, you might want to ignore these files since the code is
25 | # intended to run in multiple environments; otherwise, check them in:
26 | # Gemfile.lock
27 | # .ruby-version
28 | # .ruby-gemset
29 |
30 | # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
31 | .rvmrc
32 |
--------------------------------------------------------------------------------
/attic/bitshilling/lib/shilling/views/_pending_transactions.erb:
--------------------------------------------------------------------------------
1 |
2 |
Pending Transactions
3 | <% if @node.bank.pending.any? %>
4 |
5 |
6 | | From |
7 | To |
8 | $ |
9 | Id |
10 |
11 | <% @node.bank.pending.each do |tx| %>
12 |
13 | | <%= tx.from[0..15] %> |
14 | <%= tx.to[0..15] %> |
15 | <%= tx.amount %> |
16 | <%= tx.id[0..2] %> |
17 |
18 | <% end %>
19 |
20 | <% else %>
21 |
No pending transactions
22 | <% end %>
23 |
24 |
--------------------------------------------------------------------------------
/blockchain-lite/.gitignore:
--------------------------------------------------------------------------------
1 | *.gem
2 | *.rbc
3 | /.config
4 | /coverage/
5 | /InstalledFiles
6 | /pkg/
7 | /spec/reports/
8 | /test/tmp/
9 | /test/version_tmp/
10 | /tmp/
11 |
12 |
13 | ## Documentation cache and generated files:
14 | /.yardoc/
15 | /_yardoc/
16 | /doc/
17 | /rdoc/
18 |
19 | ## Environment normalisation:
20 | /.bundle/
21 | /vendor/bundle
22 | /lib/bundler/man/
23 |
24 | # for a library or gem, you might want to ignore these files since the code is
25 | # intended to run in multiple environments; otherwise, check them in:
26 | # Gemfile.lock
27 | # .ruby-version
28 | # .ruby-gemset
29 |
30 | # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
31 | .rvmrc
32 |
--------------------------------------------------------------------------------
/centralbank/lib/centralbank/views/_pending_transactions.erb:
--------------------------------------------------------------------------------
1 |
2 |
Pending Transactions
3 | <% if @node.bank.pending.any? %>
4 |
5 |
6 | | From |
7 | To |
8 | $ |
9 | Id |
10 |
11 | <% @node.bank.pending.each do |tx| %>
12 |
13 | | <%= tx.from[0..15] %> |
14 | <%= tx.to[0..15] %> |
15 | <%= tx.amount %> |
16 | <%= tx.id[0..2] %> |
17 |
18 | <% end %>
19 |
20 | <% else %>
21 |
No pending transactions
22 | <% end %>
23 |
24 |
--------------------------------------------------------------------------------
/cryptoquotes/script/bundle.rb:
--------------------------------------------------------------------------------
1 | #################
2 | # update (get) the crypto quotes bundled with this gem
3 | # from the source:
4 | # https://github.com/openblockchains/crypto-quotes
5 | #
6 | # to run use:
7 | # ruby script/bundle.rb
8 |
9 |
10 | require 'fileutils'
11 |
12 |
13 | files = Dir.glob( '/sites/openblockchains/crypto-quotes/*.yml' )
14 |
15 | puts "sources:"
16 | pp files
17 | puts
18 |
19 | files.each_with_index do |file,i|
20 | basename = File.basename( file )
21 | dest = "./data/#{basename}"
22 | puts "[#{i+1}/#{files.size}] copying to #{dest}..."
23 | FileUtils.cp( file, dest )
24 | end
25 |
26 | puts
27 | puts " done - copied #{files.size} file(s)"
--------------------------------------------------------------------------------
/centralbank/lib/centralbank/transaction.rb:
--------------------------------------------------------------------------------
1 |
2 |
3 | class Transaction
4 |
5 | attr_reader :from, :to, :amount, :id
6 |
7 | def initialize( from, to, amount, id=SecureRandom.uuid )
8 | @from = from
9 | @to = to
10 | @amount = amount
11 | @id = id
12 | end
13 |
14 | def self.from_h( hash )
15 | self.new *hash.values_at( 'from', 'to', 'amount', 'id' )
16 | end
17 |
18 | def to_h
19 | { from: @from, to: @to, amount: @amount, id: @id }
20 | end
21 |
22 |
23 | def valid?
24 | ## check signature in the future; for now always true
25 | true
26 | end
27 |
28 | end # class Transaction
29 |
30 | Tx = Transaction ## add Tx shortcut / alias
31 |
--------------------------------------------------------------------------------
/attic/bitshilling/Manifest.txt:
--------------------------------------------------------------------------------
1 | HISTORY.md
2 | LICENSE.md
3 | Manifest.txt
4 | README.md
5 | Rakefile
6 | bin/shilling
7 | lib/shilling.rb
8 | lib/shilling/bank.rb
9 | lib/shilling/block.rb
10 | lib/shilling/blockchain.rb
11 | lib/shilling/cache.rb
12 | lib/shilling/node.rb
13 | lib/shilling/pool.rb
14 | lib/shilling/service.rb
15 | lib/shilling/tool.rb
16 | lib/shilling/transaction.rb
17 | lib/shilling/version.rb
18 | lib/shilling/views/_blockchain.erb
19 | lib/shilling/views/_ledger.erb
20 | lib/shilling/views/_peers.erb
21 | lib/shilling/views/_pending_transactions.erb
22 | lib/shilling/views/_wallet.erb
23 | lib/shilling/views/index.erb
24 | lib/shilling/views/style.scss
25 | lib/shilling/wallet.rb
26 |
--------------------------------------------------------------------------------
/attic/bitshilling/lib/shilling/transaction.rb:
--------------------------------------------------------------------------------
1 |
2 |
3 | class Transaction
4 |
5 | attr_reader :from, :to, :amount, :id
6 |
7 | def initialize( from, to, amount, id=SecureRandom.uuid )
8 | @from = from
9 | @to = to
10 | @amount = amount
11 | @id = id
12 | end
13 |
14 | def self.from_h( hash )
15 | self.new *hash.values_at( 'from', 'to', 'amount', 'id' )
16 | end
17 |
18 | def to_h
19 | { from: @from, to: @to, amount: @amount, id: @id }
20 | end
21 |
22 |
23 | def valid?
24 | ## check signature in the future; for now always true
25 | true
26 | end
27 |
28 | end # class Transaction
29 |
30 | Tx = Transaction ## add Tx shortcut / alias
31 |
--------------------------------------------------------------------------------
/rlp-lite/test/test_sedes_binary.rb:
--------------------------------------------------------------------------------
1 | ##
2 | # to run use
3 | # ruby -I ./lib -I ./test test/test_sedes_binary.rb
4 |
5 |
6 |
7 |
8 |
9 | require 'helper'
10 |
11 |
12 | class TestRlp < MiniTest::Test
13 |
14 | def test_fixed_length_binary
15 | b = Rlp::Sedes::Binary.fixed_length( 3 )
16 |
17 | assert_equal "foo", b.serialize( "foo" )
18 | assert_equal "bar", b.deserialize( "bar" )
19 |
20 | assert_raises( Rlp::SerializationError, "Object has invalid length" ) {
21 | b.serialize "foobar"
22 | }
23 | assert_raises( Rlp::DeserializationError, "String has invalid length" ) {
24 | b.deserialize "foobar"
25 | }
26 | end
27 |
28 | end
29 |
30 |
--------------------------------------------------------------------------------
/blockchain-lite/lib/blockchain-lite/base.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | require 'digest' # for hash checksum digest function SHA256
4 | require 'pp' # for pp => pretty printer
5 |
6 | require 'forwardable'
7 | require 'date'
8 | require 'time'
9 | require 'json'
10 | require 'uri'
11 |
12 |
13 | ## 3rd party libs
14 | require 'merkletree'
15 |
16 |
17 | ## our own code
18 | require 'blockchain-lite/version' # note: let version always go first
19 |
20 | require 'blockchain-lite/basic/block'
21 | require 'blockchain-lite/proof_of_work/block'
22 |
23 | require 'blockchain-lite/blockchain'
24 |
25 |
26 |
27 | # say hello
28 | puts BlockchainLite.banner ## if defined?($RUBYLIBS_DEBUG) && $RUBYLIBS_DEBUG
29 |
--------------------------------------------------------------------------------
/abidoc/sandbox/test_gen.rb:
--------------------------------------------------------------------------------
1 | ###
2 | # to run use
3 | # ruby -I ./lib sandbox/test_gen.rb
4 |
5 | $LOAD_PATH.unshift( "../abiparser/lib" )
6 | require 'abidoc'
7 |
8 | punks_v1 = '0x6ba6f2207e343923ba692e5cae646fb0f566db8d'
9 |
10 | abi = ABI.read( "../test/address/#{punks_v1}.json" )
11 | pp abi
12 |
13 | buf = abi.generate_doc( title: 'Contract ABI for Punks V1' )
14 | write_text( "./tmp/punks_v1.md", buf )
15 |
16 |
17 | punk_blocks = '0x58e90596c2065befd3060767736c829c18f3474c'
18 |
19 | abi = ABI.read( "../test/address/#{punk_blocks}.json" )
20 | pp abi
21 |
22 | buf = abi.generate_doc( title: 'Contract ABI for PunkBlocks' )
23 | write_text( "./tmp/punk_blocks.md", buf )
24 |
25 | puts "bye"
26 |
--------------------------------------------------------------------------------
/blockchain-lite/test/helper.rb:
--------------------------------------------------------------------------------
1 | ## $:.unshift(File.dirname(__FILE__))
2 |
3 | ## minitest setup
4 |
5 | require 'minitest/autorun'
6 |
7 |
8 | ## our own code
9 |
10 | require 'blockchain-lite/base' ## note: use "modular" version without "top-level" Block constant
11 |
12 |
13 | module Basic
14 | Block = BlockchainLite::Basic::Block ## convenience shortcut
15 |
16 | class Blockchain < BlockchainLite::Blockchain
17 | def block_class() Block; end
18 | end
19 | end # module Basic
20 |
21 |
22 | module ProofOfWork
23 | Block = BlockchainLite::ProofOfWork::Block ## convenience shortcut
24 |
25 | class Blockchain < BlockchainLite::Blockchain
26 | def block_class() Block; end
27 | end
28 | end # module ProofOfWork
29 |
--------------------------------------------------------------------------------
/solidity/sandbox/test_outline.rb:
--------------------------------------------------------------------------------
1 | ###
2 | # to run use
3 | # ruby -I ./lib sandbox/test_outline.rb
4 |
5 | require 'solidity'
6 |
7 |
8 | ## addr = "0x0cfdb3ba1694c2bb2cfacb0339ad7b1ae5932b63"
9 | ## addr = "0x34625ecaa75c0ea33733a05c584f4cf112c10b6b"
10 | addr = "0x031920cc2d9f5c10b444fd44009cd64f829e7be2"
11 |
12 | ## path = "../../awesome-contracts/address/#{addr}/contract.sol"
13 |
14 | path = "./contracts/contract3.sol"
15 |
16 | parser = Solidity::Parser.read( path )
17 | pp parser._quick_pass_one
18 |
19 |
20 |
21 | puts "---"
22 | puts "outline:"
23 | puts parser.outline
24 | pp parser.outline
25 |
26 | puts
27 | puts "pragmas:"
28 | puts parser.pragmas
29 | pp parser.pragmas
30 |
31 |
32 | puts "bye"
--------------------------------------------------------------------------------
/ethname/lib/ethname.rb:
--------------------------------------------------------------------------------
1 | require 'cocos'
2 |
3 |
4 |
5 | ## our own code
6 | require_relative 'ethname/version'
7 | require_relative 'ethname/directory'
8 |
9 |
10 | module Ethname
11 |
12 | def self.dir
13 | @dir ||= Directory.read( "#{root}/config/contracts.2017.csv",
14 | "#{root}/config/contracts.2021.csv",
15 | "#{root}/config/contracts.2022.csv",
16 | "#{root}/config/contracts.2023.csv",
17 | )
18 | end
19 | class << self
20 | alias_method :directory, :dir
21 | end
22 |
23 | def self.[]( q )
24 | dir[ q ]
25 | end
26 |
27 | end # module Ethname
28 |
29 |
30 |
31 | Ethname.banner ## say hello
--------------------------------------------------------------------------------
/p2p/.gitignore:
--------------------------------------------------------------------------------
1 | *.gem
2 | *.rbc
3 | /.config
4 | /coverage/
5 | /InstalledFiles
6 | /pkg/
7 | /spec/reports/
8 | /test/tmp/
9 | /test/version_tmp/
10 | /tmp/
11 |
12 | ## Specific to RubyMotion:
13 | .dat*
14 | .repl_history
15 | build/
16 |
17 | ## Documentation cache and generated files:
18 | /.yardoc/
19 | /_yardoc/
20 | /doc/
21 | /rdoc/
22 |
23 | ## Environment normalisation:
24 | /.bundle/
25 | /vendor/bundle
26 | /lib/bundler/man/
27 |
28 | # for a library or gem, you might want to ignore these files since the code is
29 | # intended to run in multiple environments; otherwise, check them in:
30 | # Gemfile.lock
31 | # .ruby-version
32 | # .ruby-gemset
33 |
34 | # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35 | .rvmrc
36 |
--------------------------------------------------------------------------------
/elliptic/.gitignore:
--------------------------------------------------------------------------------
1 | *.gem
2 | *.rbc
3 | /.config
4 | /coverage/
5 | /InstalledFiles
6 | /pkg/
7 | /spec/reports/
8 | /test/tmp/
9 | /test/version_tmp/
10 | /tmp/
11 |
12 | ## Specific to RubyMotion:
13 | .dat*
14 | .repl_history
15 | build/
16 |
17 | ## Documentation cache and generated files:
18 | /.yardoc/
19 | /_yardoc/
20 | /doc/
21 | /rdoc/
22 |
23 | ## Environment normalisation:
24 | /.bundle/
25 | /vendor/bundle
26 | /lib/bundler/man/
27 |
28 | # for a library or gem, you might want to ignore these files since the code is
29 | # intended to run in multiple environments; otherwise, check them in:
30 | # Gemfile.lock
31 | # .ruby-version
32 | # .ruby-gemset
33 |
34 | # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35 | .rvmrc
36 |
--------------------------------------------------------------------------------
/solidity/.gitignore:
--------------------------------------------------------------------------------
1 | *.gem
2 | *.rbc
3 | /.config
4 | /coverage/
5 | /InstalledFiles
6 | /pkg/
7 | /spec/reports/
8 | /test/tmp/
9 | /test/version_tmp/
10 | /tmp/
11 |
12 | ## Specific to RubyMotion:
13 | .dat*
14 | .repl_history
15 | build/
16 |
17 | ## Documentation cache and generated files:
18 | /.yardoc/
19 | /_yardoc/
20 | /doc/
21 | /rdoc/
22 |
23 | ## Environment normalisation:
24 | /.bundle/
25 | /vendor/bundle
26 | /lib/bundler/man/
27 |
28 | # for a library or gem, you might want to ignore these files since the code is
29 | # intended to run in multiple environments; otherwise, check them in:
30 | # Gemfile.lock
31 | # .ruby-version
32 | # .ruby-gemset
33 |
34 | # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35 | .rvmrc
36 |
--------------------------------------------------------------------------------
/abi2sol/sandbox/test_parse.rb:
--------------------------------------------------------------------------------
1 | ###
2 | # to run use
3 | # ruby -I ./lib sandbox/test_parse.rb
4 |
5 | $LOAD_PATH.unshift( "../abiparser/lib" )
6 | require 'abi2sol'
7 |
8 |
9 | punks_v1 = '0x6ba6f2207e343923ba692e5cae646fb0f566db8d'
10 | punk_blocks = '0x58e90596c2065befd3060767736c829c18f3474c'
11 |
12 | abi = ABI.read( "../test/address/#{punks_v1}.json" )
13 | pp abi
14 |
15 | buf = abi.generate_interface( name: 'PunksV1' )
16 | puts buf
17 | write_text( "./tmp/punks_v1.sol", buf )
18 |
19 |
20 |
21 | abi = ABI.read( "../test/address/#{punk_blocks}.json" )
22 | pp abi
23 |
24 | buf = abi.generate_interface( name: 'PunkBlocks' )
25 | puts buf
26 | write_text( "./tmp/punk_blocks.sol", buf )
27 |
28 |
29 | puts "bye"
30 |
--------------------------------------------------------------------------------
/crypto-lite/.gitignore:
--------------------------------------------------------------------------------
1 | *.gem
2 | *.rbc
3 | /.config
4 | /coverage/
5 | /InstalledFiles
6 | /pkg/
7 | /spec/reports/
8 | /test/tmp/
9 | /test/version_tmp/
10 | /tmp/
11 |
12 | ## Specific to RubyMotion:
13 | .dat*
14 | .repl_history
15 | build/
16 |
17 | ## Documentation cache and generated files:
18 | /.yardoc/
19 | /_yardoc/
20 | /doc/
21 | /rdoc/
22 |
23 | ## Environment normalisation:
24 | /.bundle/
25 | /vendor/bundle
26 | /lib/bundler/man/
27 |
28 | # for a library or gem, you might want to ignore these files since the code is
29 | # intended to run in multiple environments; otherwise, check them in:
30 | # Gemfile.lock
31 | # .ruby-version
32 | # .ruby-gemset
33 |
34 | # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35 | .rvmrc
36 |
--------------------------------------------------------------------------------
/cryptoquotes/.gitignore:
--------------------------------------------------------------------------------
1 | *.gem
2 | *.rbc
3 | /.config
4 | /coverage/
5 | /InstalledFiles
6 | /pkg/
7 | /spec/reports/
8 | /test/tmp/
9 | /test/version_tmp/
10 | /tmp/
11 |
12 | ## Specific to RubyMotion:
13 | .dat*
14 | .repl_history
15 | build/
16 |
17 | ## Documentation cache and generated files:
18 | /.yardoc/
19 | /_yardoc/
20 | /doc/
21 | /rdoc/
22 |
23 | ## Environment normalisation:
24 | /.bundle/
25 | /vendor/bundle
26 | /lib/bundler/man/
27 |
28 | # for a library or gem, you might want to ignore these files since the code is
29 | # intended to run in multiple environments; otherwise, check them in:
30 | # Gemfile.lock
31 | # .ruby-version
32 | # .ruby-gemset
33 |
34 | # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35 | .rvmrc
36 |
--------------------------------------------------------------------------------
/digest-lite/.gitignore:
--------------------------------------------------------------------------------
1 | *.gem
2 | *.rbc
3 | /.config
4 | /coverage/
5 | /InstalledFiles
6 | /pkg/
7 | /spec/reports/
8 | /test/tmp/
9 | /test/version_tmp/
10 | /tmp/
11 |
12 | ## Specific to RubyMotion:
13 | .dat*
14 | .repl_history
15 | build/
16 |
17 | ## Documentation cache and generated files:
18 | /.yardoc/
19 | /_yardoc/
20 | /doc/
21 | /rdoc/
22 |
23 | ## Environment normalisation:
24 | /.bundle/
25 | /vendor/bundle
26 | /lib/bundler/man/
27 |
28 | # for a library or gem, you might want to ignore these files since the code is
29 | # intended to run in multiple environments; otherwise, check them in:
30 | # Gemfile.lock
31 | # .ruby-version
32 | # .ruby-gemset
33 |
34 | # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35 | .rvmrc
36 |
--------------------------------------------------------------------------------
/elliptic-lite/.gitignore:
--------------------------------------------------------------------------------
1 | *.gem
2 | *.rbc
3 | /.config
4 | /coverage/
5 | /InstalledFiles
6 | /pkg/
7 | /spec/reports/
8 | /test/tmp/
9 | /test/version_tmp/
10 | /tmp/
11 |
12 | ## Specific to RubyMotion:
13 | .dat*
14 | .repl_history
15 | build/
16 |
17 | ## Documentation cache and generated files:
18 | /.yardoc/
19 | /_yardoc/
20 | /doc/
21 | /rdoc/
22 |
23 | ## Environment normalisation:
24 | /.bundle/
25 | /vendor/bundle
26 | /lib/bundler/man/
27 |
28 | # for a library or gem, you might want to ignore these files since the code is
29 | # intended to run in multiple environments; otherwise, check them in:
30 | # Gemfile.lock
31 | # .ruby-version
32 | # .ruby-gemset
33 |
34 | # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35 | .rvmrc
36 |
--------------------------------------------------------------------------------
/tulipmania/Manifest.txt:
--------------------------------------------------------------------------------
1 | HISTORY.md
2 | LICENSE.md
3 | Manifest.txt
4 | README.md
5 | Rakefile
6 | bin/tulipmania
7 | lib/tulipmania.rb
8 | lib/tulipmania/block.rb
9 | lib/tulipmania/blockchain.rb
10 | lib/tulipmania/cache.rb
11 | lib/tulipmania/exchange.rb
12 | lib/tulipmania/ledger.rb
13 | lib/tulipmania/node.rb
14 | lib/tulipmania/pool.rb
15 | lib/tulipmania/service.rb
16 | lib/tulipmania/tool.rb
17 | lib/tulipmania/transaction.rb
18 | lib/tulipmania/version.rb
19 | lib/tulipmania/views/_blockchain.erb
20 | lib/tulipmania/views/_ledger.erb
21 | lib/tulipmania/views/_peers.erb
22 | lib/tulipmania/views/_pending_transactions.erb
23 | lib/tulipmania/views/_wallet.erb
24 | lib/tulipmania/views/index.erb
25 | lib/tulipmania/views/style.scss
26 | lib/tulipmania/wallet.rb
27 |
--------------------------------------------------------------------------------
/centralbank/Manifest.txt:
--------------------------------------------------------------------------------
1 | CHANGELOG.md
2 | Manifest.txt
3 | README.md
4 | Rakefile
5 | bin/centralbank
6 | lib/centralbank.rb
7 | lib/centralbank/bank.rb
8 | lib/centralbank/block.rb
9 | lib/centralbank/blockchain.rb
10 | lib/centralbank/cache.rb
11 | lib/centralbank/ledger.rb
12 | lib/centralbank/node.rb
13 | lib/centralbank/pool.rb
14 | lib/centralbank/service.rb
15 | lib/centralbank/tool.rb
16 | lib/centralbank/transaction.rb
17 | lib/centralbank/version.rb
18 | lib/centralbank/views/_blockchain.erb
19 | lib/centralbank/views/_ledger.erb
20 | lib/centralbank/views/_peers.erb
21 | lib/centralbank/views/_pending_transactions.erb
22 | lib/centralbank/views/_wallet.erb
23 | lib/centralbank/views/index.erb
24 | lib/centralbank/views/style.scss
25 | lib/centralbank/wallet.rb
26 |
--------------------------------------------------------------------------------
/tulipmania/lib/tulipmania/views/_pending_transactions.erb:
--------------------------------------------------------------------------------
1 |
2 |
Pending Transactions
3 | <% if @node.exchange.pending.any? %>
4 |
5 |
6 | | From |
7 | To |
8 | What |
9 | Qty |
10 | Id |
11 |
12 | <% @node.exchange.pending.each do |tx| %>
13 |
14 | | <%= tx.from[0..15] %> |
15 | <%= tx.to[0..15] %> |
16 | <%= tx.what %> |
17 | × <%= tx.qty %> |
18 | <%= tx.id[0..2] %> |
19 |
20 | <% end %>
21 |
22 | <% else %>
23 |
No pending transactions
24 | <% end %>
25 |
26 |
--------------------------------------------------------------------------------
/centralbank/lib/centralbank/views/index.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Central Bank Node
5 |
6 |
7 |
8 |
9 | Central Bank Node
10 |
11 |
12 |
13 | <%= erb :'_wallet' %>
14 | <%= erb :'_pending_transactions' %>
15 | <%= erb :'_peers' %>
16 | <%= erb :'_ledger' %>
17 |
18 |
19 |
20 | <%= erb :'_blockchain' %>
21 |
22 |
23 |
24 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/crypto-lite/lib/crypto-lite/config.rb:
--------------------------------------------------------------------------------
1 | module Crypto
2 |
3 | class Configuration
4 |
5 | def initialize
6 | @debug = false
7 | end
8 |
9 | def debug?() @debug || false; end
10 | def debug=(value) @debug = value; end
11 | end # class Configuration
12 |
13 | ## lets you use
14 | ## Crypto.configure do |config|
15 | ## config.debug = true
16 | ## end
17 |
18 | def self.configuration
19 | @configuration ||= Configuration.new
20 | end
21 |
22 | def self.configure
23 | yield( configuration )
24 | end
25 |
26 | ## add convenience helper for format
27 | def self.debug?() configuration.debug?; end
28 | def self.debug=(value) self.configuration.debug = value; end
29 | end # module Crypto
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/p2p/Rakefile:
--------------------------------------------------------------------------------
1 | require 'hoe'
2 | require './lib/p2p/version.rb'
3 |
4 | Hoe.spec 'p2p' do
5 |
6 | self.version = PeerToPeer::VERSION
7 |
8 | self.summary = "p2p - build your own peer-to-peer (p2p) networks; run your own peer-to-peer (p2p) nodes over HTTP"
9 | self.description = summary
10 |
11 | self.urls = ['https://github.com/openblockchains/peer-to-peer.rb']
12 |
13 | self.author = 'Gerald Bauer'
14 | self.email = 'wwwmake@googlegroups.com'
15 |
16 | # switch extension to .markdown for gihub formatting
17 | self.readme_file = 'README.md'
18 | self.history_file = 'HISTORY.md'
19 |
20 | self.extra_deps = [
21 | ]
22 |
23 | self.licenses = ['Public Domain']
24 |
25 | self.spec_extras = {
26 | required_ruby_version: '>= 2.3'
27 | }
28 |
29 | end
30 |
--------------------------------------------------------------------------------
/tulipmania/lib/tulipmania/transaction.rb:
--------------------------------------------------------------------------------
1 |
2 |
3 | class Transaction
4 |
5 | attr_reader :from, :to, :qty, :what, :id
6 |
7 | def initialize( from, to, qty, what, id=SecureRandom.uuid )
8 | @from = from
9 | @to = to
10 | @qty = qty
11 | @what = what # tulip name - change to name or title - why? why not?
12 | @id = id
13 | end
14 |
15 | def self.from_h( hash )
16 | self.new *hash.values_at( 'from', 'to', 'qty', 'what', 'id' )
17 | end
18 |
19 | def to_h
20 | { from: @from, to: @to, qty: @qty, what: @what, id: @id }
21 | end
22 |
23 |
24 | def valid?
25 | ## check signature in the future; for now always true
26 | true
27 | end
28 |
29 | end # class Transaction
30 |
31 | Tx = Transaction ## add Tx shortcut / alias
32 |
--------------------------------------------------------------------------------
/tulipmania/lib/tulipmania/views/index.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Tulipmania (Anno 1637) Node
5 |
6 |
7 |
8 |
9 | Tulipmania (Anno 1637) Node
10 |
11 |
12 |
13 | <%= erb :'_wallet' %>
14 | <%= erb :'_pending_transactions' %>
15 | <%= erb :'_peers' %>
16 | <%= erb :'_ledger' %>
17 |
18 |
19 |
20 | <%= erb :'_blockchain' %>
21 |
22 |
23 |
24 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/ethlite-contracts/Rakefile:
--------------------------------------------------------------------------------
1 | require 'hoe'
2 |
3 |
4 | Hoe.spec 'ethlite-contracts' do
5 |
6 | self.version = '0.1.4'
7 | self.summary = "ethlite-contracts - ready-to-use (blockchain) contract services / function calls for ethereum & co."
8 | self.description = summary
9 |
10 | self.urls = { home: 'https://github.com/rubycocos/blockchain' }
11 |
12 | self.author = 'Gerald Bauer'
13 | self.email = 'wwwmake@googlegroups.com'
14 |
15 | # switch extension to .markdown for gihub formatting
16 | self.readme_file = 'README.md'
17 | self.history_file = 'CHANGELOG.md'
18 |
19 | self.extra_deps = [
20 | ['ethlite'],
21 | ]
22 |
23 | self.licenses = ['Public Domain']
24 |
25 | self.spec_extras = {
26 | required_ruby_version: '>= 2.3'
27 | }
28 |
29 | end
30 |
31 |
--------------------------------------------------------------------------------
/ethlite-contracts/lib/ethlite/contracts/nouns_seeder.rb:
--------------------------------------------------------------------------------
1 | # NounsSeeder contract / (blockchain) services / function calls
2 | #
3 | # auto-generated via abigen (see https://rubygems.org/gems/abigen) on 2023-01-16 16:17:10 UTC
4 | # - 1 query functions(s)
5 | # - 0 helper functions(s)
6 |
7 |
8 | class NounsSeeder < Ethlite::Contract
9 |
10 | address "0xcc8a0fb5ab3c7132c1b2a0109142fb112c4ce515"
11 |
12 | # function **generateSeed**(uint256 nounId, contract INounsDescriptor descriptor) ⇒ (struct INounsSeeder.Seed _) _readonly_
13 | def generateSeed(nounId, descriptor)
14 | do_call("generateSeed", nounId, descriptor)
15 | end
16 | sig "generateSeed", inputs: ["uint256","address"], outputs: ["(uint48,uint48,uint48,uint48,uint48)"]
17 |
18 | end ## class NounsSeeder
19 |
20 |
--------------------------------------------------------------------------------
/ethname/sandbox/timeline_query.rb:
--------------------------------------------------------------------------------
1 | ###
2 | # use etherscan api to lint / check-up on contract addresses
3 | # (and get creation timestamp etc.)
4 | #
5 | # to run use
6 | # ruby -I ./lib sandbox/timeline_query.rb
7 |
8 |
9 | require_relative 'helper'
10 |
11 | ## step 1:
12 | ## collect more metadata about (contract) address
13 |
14 | ## build cache
15 | cache = ContractDetailsCache.new( './sandbox/contractdetails.csv' )
16 |
17 |
18 | Ethname.directory.records.each_with_index do |rec,i|
19 | puts "==> [#{i+1}] #{rec.names.join('|')} @ #{rec.addr} supports #{rec.interfaces.join('|')}..."
20 |
21 | data = cache[ rec.addr ]
22 | pp data
23 | end
24 |
25 |
26 | ### note: save back contractdetails cache
27 | cache.save
28 |
29 |
30 | puts "bye"
31 |
32 |
--------------------------------------------------------------------------------
/abicoder/test/helper.rb:
--------------------------------------------------------------------------------
1 |
2 | require 'minitest/autorun'
3 |
4 |
5 |
6 |
7 | class String
8 | ## add bin_to_hex helper method
9 | ## note: String#hex already in use (is an alias for String#to_i(16) !!)
10 | def hexdigest() self.unpack('H*').first; end
11 | end
12 |
13 | def hex( hex ) # convert hex(adecimal) string to binary string
14 | ## note: strip all whitespaces
15 | hex = hex.gsub( /[ \t\n\r]/, '' )
16 |
17 | if ['0x', '0X'].include?( hex[0,2] ) ## cut-of leading 0x or 0X if present
18 | [hex[2..-1]].pack('H*')
19 | else
20 | [hex].pack('H*')
21 | end
22 | end
23 |
24 |
25 | require 'yaml'
26 |
27 | def read_yml( path )
28 | txt = File.open( path, 'r:utf-8' ) { |f| f.read }
29 | YAML.load( txt )
30 | end
31 |
32 |
33 |
34 |
35 | ## our own code
36 | require 'abicoder'
37 |
--------------------------------------------------------------------------------
/natspec/Rakefile:
--------------------------------------------------------------------------------
1 | require 'hoe'
2 |
3 |
4 | Hoe.spec 'natspec' do
5 |
6 | self.version = '0.0.1'
7 |
8 | self.summary = "natspec - natural specification (comments) parser / machinery; document application binary interfaces (abis) for Ethereum & Co. (blockchain) contracts"
9 | self.description = summary
10 |
11 | self.urls = { home: 'https://github.com/rubycocos/blockchain' }
12 |
13 | self.author = 'Gerald Bauer'
14 | self.email = 'wwwmake@googlegroups.com'
15 |
16 | # switch extension to .markdown for gihub formatting
17 | self.readme_file = 'README.md'
18 | self.history_file = 'CHANGELOG.md'
19 |
20 | self.extra_deps = [
21 | ]
22 |
23 | self.licenses = ['Public Domain']
24 |
25 | self.spec_extras = {
26 | required_ruby_version: '>= 2.3'
27 | }
28 |
29 | end
30 |
31 |
--------------------------------------------------------------------------------
/elliptic/Rakefile:
--------------------------------------------------------------------------------
1 | require 'hoe'
2 | require './lib/elliptic/version.rb'
3 |
4 | Hoe.spec 'elliptic' do
5 |
6 | self.version = EC::VERSION
7 |
8 | self.summary = "elliptic - elliptic curve digital signature algorithm (ECDSA) cryptography with OpenSSL made easy (incl. secp256k1 curve)"
9 | self.description = summary
10 |
11 | self.urls = { home: 'https://github.com/rubycocos/blockchain' }
12 |
13 | self.author = 'Gerald Bauer'
14 | self.email = 'wwwmake@googlegroups.com'
15 |
16 | # switch extension to .markdown for gihub formatting
17 | self.readme_file = 'README.md'
18 | self.history_file = 'CHANGELOG.md'
19 |
20 | self.extra_deps = [
21 | ]
22 |
23 | self.licenses = ['Public Domain']
24 |
25 | self.spec_extras = {
26 | required_ruby_version: '>= 2.3'
27 | }
28 |
29 | end
30 |
--------------------------------------------------------------------------------
/ethlite-contracts/punksmeta/punk0.json:
--------------------------------------------------------------------------------
1 | {
2 | "description": "CryptoPunks launched as a fixed set of 10,000 items in mid-2017 and became one of the inspirations for the ERC-721 standard. They have been featured in places like The New York Times, Christie's of London, Art|Basel Miami, and The PBS NewsHour.",
3 | "external_url": "https://cryptopunks.app/cryptopunks/details/0",
4 | "name": "CryptoPunk #0",
5 | "attributes": [
6 | {
7 | "trait_type": "Type",
8 | "value": "Female 2"
9 | },
10 | {
11 | "trait_type": "Accessory",
12 | "value": "Earring"
13 | },
14 | {
15 | "trait_type": "Accessory",
16 | "value": "Blonde Bob"
17 | },
18 | {
19 | "trait_type": "Accessory",
20 | "value": "Green Eye Shadow"
21 | }
22 | ]
23 | }
--------------------------------------------------------------------------------
/blockchain-lite/test/test_block_basic.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | ###
4 | # to run use
5 | # ruby -I ./lib -I ./test test/test_block_basic.rb
6 |
7 |
8 | require 'helper'
9 |
10 |
11 | class TestBlockBasic < MiniTest::Test
12 |
13 | include Basic ## adds Block = BlockchainLite::Basic::Block etc.
14 |
15 |
16 | def test_example
17 |
18 | b0 = Block.first( 'Genesis' )
19 | b1 = Block.next( b0, 'Transaction Data...' )
20 | b2 = Block.next( b1, 'Transaction Data...', 'Transaction Data...' )
21 | b3 = Block.next( b2 ) ## no transaction data
22 | b4 = Block.next( b3, ['Transaction Data...', 'Transaction Data...'] )
23 |
24 | blockchain = [b0, b1, b2, b3, b4]
25 |
26 | pp blockchain
27 |
28 | assert true ## (for now) everything ok if we get here
29 | end
30 |
31 | end # class TestBlockBasic
32 |
--------------------------------------------------------------------------------
/attic/bitshilling/lib/shilling/views/index.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Shilling Central Bank Node - Rock-Solid Alpine Dollar From Austria
5 |
6 |
7 |
8 |
9 | Shilling Central Bank Node
10 |
11 |
12 |
13 | <%= erb :'_wallet' %>
14 | <%= erb :'_pending_transactions' %>
15 | <%= erb :'_peers' %>
16 | <%= erb :'_ledger' %>
17 |
18 |
19 |
20 | <%= erb :'_blockchain' %>
21 |
22 |
23 |
24 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/solidity/contracts/contract3.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: GPL-3.0
2 | pragma solidity >=0.7.0 <0.9.0;
3 |
4 | contract owned {
5 | constructor() { owner = payable(msg.sender); }
6 | address payable owner;
7 | }
8 |
9 | contract Destructible is owned {
10 | function destroy() public virtual {
11 | if (msg.sender == owner) selfdestruct(owner);
12 | }
13 | }
14 |
15 | contract Base1 is Destructible {
16 | function destroy() public virtual override { /* do cleanup 1 */ Destructible.destroy(); }
17 | }
18 |
19 | contract Base2 is Destructible {
20 | function destroy() public virtual override { /* do cleanup 2 */ Destructible.destroy(); }
21 | }
22 |
23 | contract Final is Base1, Base2 {
24 | function destroy() public override(Base1, Base2) { Base2.destroy(); }
25 | }
26 |
27 |
--------------------------------------------------------------------------------
/abidoc/Rakefile:
--------------------------------------------------------------------------------
1 | require 'hoe'
2 | require './lib/abidoc/version.rb'
3 |
4 |
5 | Hoe.spec 'abidoc' do
6 |
7 | self.version = ABIDoc::VERSION
8 |
9 | self.summary = "abidoc - application binary interface (abi) documentation generator for Ethereum & Co. (blockchain) contracts"
10 | self.description = summary
11 |
12 | self.urls = { home: 'https://github.com/rubycocos/blockchain' }
13 |
14 | self.author = 'Gerald Bauer'
15 | self.email = 'wwwmake@googlegroups.com'
16 |
17 | # switch extension to .markdown for gihub formatting
18 | self.readme_file = 'README.md'
19 | self.history_file = 'CHANGELOG.md'
20 |
21 | self.extra_deps = [
22 | ['abiparser'],
23 | ]
24 |
25 | self.licenses = ['Public Domain']
26 |
27 | self.spec_extras = {
28 | required_ruby_version: '>= 2.3'
29 | }
30 |
31 | end
32 |
33 |
--------------------------------------------------------------------------------
/base32-alphabets/Rakefile:
--------------------------------------------------------------------------------
1 | require 'hoe'
2 | require './lib/base32-alphabets/version.rb'
3 |
4 | Hoe.spec 'base32-alphabets' do
5 |
6 | self.version = Base32::VERSION
7 |
8 | self.summary = "base32-alphabets - base32 (2^5) encoding / decoding in 5-bit groups with kai, crockford or electrologica notation / alphabet"
9 | self.description = summary
10 |
11 | self.urls = { home: 'https://github.com/rubycocos/blockchain' }
12 |
13 | self.author = 'Gerald Bauer'
14 | self.email = 'wwwmake@googlegroups.com'
15 |
16 | # switch extension to .markdown for gihub formatting
17 | self.readme_file = 'README.md'
18 | self.history_file = 'CHANGELOG.md'
19 |
20 | self.extra_deps = [
21 | ]
22 |
23 | self.licenses = ['Public Domain']
24 |
25 | self.spec_extras = {
26 | required_ruby_version: '>= 2.3'
27 | }
28 |
29 | end
30 |
--------------------------------------------------------------------------------
/ethlite-contracts/Manifest.txt:
--------------------------------------------------------------------------------
1 | CHANGELOG.md
2 | Manifest.txt
3 | README.md
4 | Rakefile
5 | lib/ethlite-contracts.rb
6 | lib/ethlite/contract.rb
7 | lib/ethlite/contracts.rb
8 | lib/ethlite/contracts/mad_camels.rb
9 | lib/ethlite/contracts/marcs.rb
10 | lib/ethlite/contracts/moonbirds.rb
11 | lib/ethlite/contracts/mooncats.rb
12 | lib/ethlite/contracts/nouns.rb
13 | lib/ethlite/contracts/nouns_auction_house.rb
14 | lib/ethlite/contracts/nouns_descriptor.rb
15 | lib/ethlite/contracts/nouns_descriptor_v2.rb
16 | lib/ethlite/contracts/nouns_seeder.rb
17 | lib/ethlite/contracts/phunks_v2.rb
18 | lib/ethlite/contracts/punk_blocks.rb
19 | lib/ethlite/contracts/punks_data.rb
20 | lib/ethlite/contracts/punks_meta.rb
21 | lib/ethlite/contracts/punks_v1.rb
22 | lib/ethlite/contracts/synth_nouns.rb
23 | lib/ethlite/contracts/synth_punks.rb
24 |
--------------------------------------------------------------------------------
/merkletree/Rakefile:
--------------------------------------------------------------------------------
1 | require 'hoe'
2 | require './lib/merkletree/version.rb'
3 |
4 | Hoe.spec 'merkletree' do
5 |
6 | self.version = MerkleTree::VERSION
7 |
8 | self.summary = "merkletree - build your own crypto hash trees; named after Ralph Merkle who patented hash trees in 1979; grow your own money on trees"
9 | self.description = summary
10 |
11 | self.urls = { home: 'https://github.com/rubycocos/blockchain' }
12 |
13 | self.author = 'Gerald Bauer'
14 | self.email = 'wwwmake@googlegroups.com'
15 |
16 | # switch extension to .markdown for gihub formatting
17 | self.readme_file = 'README.md'
18 | self.history_file = 'CHANGELOG.md'
19 |
20 | ## self.extra_deps = [
21 | ## ]
22 |
23 | self.licenses = ['Public Domain']
24 |
25 | self.spec_extras = {
26 | required_ruby_version: '>= 2.3'
27 | }
28 |
29 | end
30 |
--------------------------------------------------------------------------------
/base32-alphabets/.gitignore:
--------------------------------------------------------------------------------
1 | *.gem
2 | *.rbc
3 | /.config
4 | /coverage/
5 | /InstalledFiles
6 | /pkg/
7 | /spec/reports/
8 | /test/tmp/
9 | /test/version_tmp/
10 | /tmp/
11 |
12 | ## Specific to RubyMotion:
13 | .dat*
14 | .repl_history
15 | build/
16 |
17 | ## Documentation cache and generated files:
18 | /.yardoc/
19 | /_yardoc/
20 | /doc/
21 | /rdoc/
22 |
23 | ## Environment normalisation:
24 | /.bundle/
25 | /vendor/bundle
26 | /lib/bundler/man/
27 |
28 | # for a library or gem, you might want to ignore these files since the code is
29 | # intended to run in multiple environments; otherwise, check them in:
30 | # Gemfile.lock
31 | # .ruby-version
32 | # .ruby-gemset
33 |
34 | # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35 | .rvmrc
36 |
37 |
38 | ########
39 | ## ruby test sandbox script - do NOT check in
40 | test.rb
41 |
--------------------------------------------------------------------------------
/base58-alphabets/.gitignore:
--------------------------------------------------------------------------------
1 | *.gem
2 | *.rbc
3 | /.config
4 | /coverage/
5 | /InstalledFiles
6 | /pkg/
7 | /spec/reports/
8 | /test/tmp/
9 | /test/version_tmp/
10 | /tmp/
11 |
12 | ## Specific to RubyMotion:
13 | .dat*
14 | .repl_history
15 | build/
16 |
17 | ## Documentation cache and generated files:
18 | /.yardoc/
19 | /_yardoc/
20 | /doc/
21 | /rdoc/
22 |
23 | ## Environment normalisation:
24 | /.bundle/
25 | /vendor/bundle
26 | /lib/bundler/man/
27 |
28 | # for a library or gem, you might want to ignore these files since the code is
29 | # intended to run in multiple environments; otherwise, check them in:
30 | # Gemfile.lock
31 | # .ruby-version
32 | # .ruby-gemset
33 |
34 | # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35 | .rvmrc
36 |
37 |
38 | ########
39 | ## ruby test sandbox script - do NOT check in
40 | test.rb
41 |
--------------------------------------------------------------------------------
/cryptoquotes/Manifest.txt:
--------------------------------------------------------------------------------
1 | CHANGELOG.md
2 | Manifest.txt
3 | README.md
4 | Rakefile
5 | bin/oracle
6 | data/Alex_de_Vries.yml
7 | data/Amy_Castor.yml
8 | data/Anthony_Pompliano,_Bitcoin_Cheerleader.yml
9 | data/Bitcoiner.yml
10 | data/Bitcoiner_(BCH),_Cash_Is_King.yml
11 | data/Bitcoiner_(BTC).yml
12 | data/Cameron_Winklevoss,_Bitcoin_Billionaire.yml
13 | data/Crypto_US$_Stablecoin_Printer.yml
14 | data/David_Gerard.yml
15 | data/Frances_Coppola.yml
16 | data/Jemima_Kelly,_Financial_Times_Alphaville.yml
17 | data/Jorge_Stolfi.yml
18 | data/Michael_Saylor,_Business_Intelligence_Billionaire.yml
19 | data/Nouriel_Roubini.yml
20 | data/Patrick_McKenzie.yml
21 | data/Preston_Byrne.yml
22 | data/SEC_Investor_Education.yml
23 | data/Trolly_McTrollface.yml
24 | data/Tyler_Winklevoss,_Bitcoin_Billionaire.yml
25 | lib/cryptoquotes.rb
26 | lib/cryptoquotes/version.rb
27 |
--------------------------------------------------------------------------------
/ethname/config/contracts.2023.csv:
--------------------------------------------------------------------------------
1 | address, names, interfaces, created
2 | 0x22a81c80bb6bf4b797acf08351934b46193bddde, novo | novo punks, , 2023-01-08 04:10:59
3 | 0x897792d16a46f9e70446638bfc6a0d884b741f9b, pepe burb punks, , 2023-01-10 13:36:47
4 | 0x0e10e5e978ba4d1af92eb554cd730c9b97f4e571, pepe blocks, , 2023-01-14 05:37:35
5 | 0x5a8e04a84fb2f6ad4002c824045c7c1bde10cb81, frog central, , 2023-01-17 03:42:35
6 | 0xe302f509c4a3729791215f74299f1fa626396e5a, gm kevin, , 2023-01-19 00:24:35
7 | 0xcce158dd5384b599fc29fe34d83b11ea8fb7a816, death of kevin, , 2023-01-22 12:09:47
8 | 0xb0dc51536e2b4950d7d6667748a6be6fc53c3318, cute kevin, , 2023-01-22 16:29:35
9 | 0x94cb646dd34b3b0ff7c116208f7f7ff7ac216079, ecc0s, , 2023-01-25 12:38:11
10 | 0xe6313d1776e4043d906d5b7221be70cf470f5e87, shiba, , 2023-01-26 02:20:47
11 |
--------------------------------------------------------------------------------
/base58-alphabets/Rakefile:
--------------------------------------------------------------------------------
1 | require 'hoe'
2 | require './lib/base58-alphabets/version.rb'
3 |
4 | Hoe.spec 'base58-alphabets' do
5 |
6 | self.version = Base58::VERSION
7 |
8 | self.summary = "base58-alphabets - base58 encoding / decoding numbers, hex or binary strings (incl. leading zeros) with bitcoin or flickr notation / alphabet"
9 | self.description = summary
10 |
11 | self.urls = { home: 'https://github.com/rubycocos/blockchain' }
12 |
13 | self.author = 'Gerald Bauer'
14 | self.email = 'wwwmake@googlegroups.com'
15 |
16 | # switch extension to .markdown for gihub formatting
17 | self.readme_file = 'README.md'
18 | self.history_file = 'CHANGELOG.md'
19 |
20 | self.extra_deps = [
21 | ]
22 |
23 | self.licenses = ['Public Domain']
24 |
25 | self.spec_extras = {
26 | required_ruby_version: '>= 2.3'
27 | }
28 |
29 | end
30 |
--------------------------------------------------------------------------------
/blockchain-lite/test/test_block_proof_of_work.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | ###
4 | # to run use
5 | # ruby -I ./lib -I ./test test/test_block_proof_of_work.rb
6 |
7 |
8 | require 'helper'
9 |
10 |
11 | class TestBlockProofOfWork < MiniTest::Test
12 |
13 | include ProofOfWork ## adds Block = BlockchainLite::ProofOfWork::Block etc.
14 |
15 |
16 | def test_example
17 |
18 | b0 = Block.first( 'Genesis' )
19 | b1 = Block.next( b0, 'Transaction Data...' )
20 | b2 = Block.next( b1, 'Transaction Data...', 'Transaction Data...' )
21 | b3 = Block.next( b2 ) ## no transaction data
22 | b4 = Block.next( b3, ['Transaction Data...', 'Transaction Data...'] )
23 |
24 | blockchain = [b0, b1, b2, b3, b4]
25 |
26 | pp blockchain
27 |
28 | assert true ## (for now) everything ok if we get here
29 | end
30 |
31 | end # class TestBlockProofOfWork
32 |
--------------------------------------------------------------------------------
/centralbank/lib/centralbank/views/_peers.erb:
--------------------------------------------------------------------------------
1 |
2 |
Peers
3 | <% if @node.peers.any? %>
4 |
5 | <% @node.peers.each_with_index do |(host, port), i| %>
6 | -
7 | http://<%= host %>:<%= port %>
8 |
11 |
12 | <% end %>
13 |
14 | <% else %>
15 |
No peers
16 | <% end %>
17 |
24 |
25 |
--------------------------------------------------------------------------------
/solidity/test/test_lexer.rb:
--------------------------------------------------------------------------------
1 | ##
2 | # to run use
3 | # ruby -I ./lib -I ./test test/test_lexer.rb
4 |
5 |
6 | require 'helper'
7 |
8 |
9 |
10 | class TestLexer < MiniTest::Test
11 |
12 | def _untokenize( tokens )
13 | buf = String.new('')
14 | tokens.each do |t|
15 | buf << (t.is_a?( String ) ? t : t[1])
16 |
17 | ## dump some token types
18 | pp t if [:comment, :string].include?( t[0] )
19 | end
20 | buf
21 | end
22 |
23 |
24 | def test_contracts
25 | ['contract1',
26 | 'contract2',
27 | 'contract3'].each do |name, exp|
28 | path = "./contracts/#{name}.sol"
29 | lexer = Solidity::Lexer.read( path )
30 |
31 | tokens = lexer.tokenize
32 |
33 | txt = read_text( path )
34 | assert_equal txt, _untokenize( tokens )
35 | end
36 | end
37 | end ## class TestLexer
38 |
--------------------------------------------------------------------------------
/tulipmania/lib/tulipmania/views/_peers.erb:
--------------------------------------------------------------------------------
1 |
2 |
Peers
3 | <% if @node.peers.any? %>
4 |
5 | <% @node.peers.each_with_index do |(host, port), i| %>
6 | -
7 | http://<%= host %>:<%= port %>
8 |
11 |
12 | <% end %>
13 |
14 | <% else %>
15 |
No peers
16 | <% end %>
17 |
24 |
25 |
--------------------------------------------------------------------------------
/attic/bitshilling/lib/shilling/views/_peers.erb:
--------------------------------------------------------------------------------
1 |
2 |
Peers
3 | <% if @node.peers.any? %>
4 |
5 | <% @node.peers.each_with_index do |(host, port), i| %>
6 | -
7 | http://<%= host %>:<%= port %>
8 |
11 |
12 | <% end %>
13 |
14 | <% else %>
15 |
No peers
16 | <% end %>
17 |
24 |
25 |
--------------------------------------------------------------------------------
/abigen/Rakefile:
--------------------------------------------------------------------------------
1 | require 'hoe'
2 |
3 |
4 | Hoe.spec 'abigen' do
5 |
6 | self.version = '0.1.1'
7 | self.summary = '"high-level" all-in-one umbrella quick starter gem for easy installation & usage application binary interface (abi) code or doc(umentation) gen(eration) for ethereum & co.'
8 | self.description = summary
9 |
10 | self.urls = { home: 'https://github.com/rubycocos/blockchain' }
11 |
12 | self.author = 'Gerald Bauer'
13 | self.email = 'wwwmake@googlegroups.com'
14 |
15 | # switch extension to .markdown for gihub formatting
16 | self.readme_file = 'README.md'
17 | self.history_file = 'CHANGELOG.md'
18 |
19 | self.extra_deps = [
20 | ['abi2ruby'],
21 | ['abi2sol'],
22 | ['abidoc'],
23 | ]
24 |
25 | self.licenses = ['Public Domain']
26 |
27 | self.spec_extras = {
28 | required_ruby_version: '>= 2.3'
29 | }
30 |
31 | end
32 |
33 |
--------------------------------------------------------------------------------
/ledger-lite/Rakefile:
--------------------------------------------------------------------------------
1 | require 'hoe'
2 | require './lib/ledger-lite/version.rb'
3 |
4 | Hoe.spec 'ledger-lite' do
5 |
6 | self.version = LedgerLite::VERSION
7 |
8 | self.summary = "ledger-lite - hyper ledger book for the distributed blockchain internet era; add your transactions one block at a time; transfer crypto(currencie)s and balance the accounts"
9 | self.description = summary
10 |
11 | self.urls = ['https://github.com/openblockchains/ledger.lite.rb']
12 |
13 | self.author = 'Gerald Bauer'
14 | self.email = 'wwwmake@googlegroups.com'
15 |
16 | # switch extension to .markdown for gihub formatting
17 | self.readme_file = 'README.md'
18 | self.history_file = 'HISTORY.md'
19 |
20 | self.extra_deps = [
21 | ]
22 |
23 | self.licenses = ['Public Domain']
24 |
25 | self.spec_extras = {
26 | required_ruby_version: '>= 2.3'
27 | }
28 |
29 | end
30 |
--------------------------------------------------------------------------------
/abiparser/Rakefile:
--------------------------------------------------------------------------------
1 | require 'hoe'
2 | require './lib/abiparser/version.rb'
3 |
4 |
5 | Hoe.spec 'abiparser' do
6 |
7 | self.version = ABIParser::VERSION
8 |
9 | self.summary = "abiparser - application binary interface (abi) parser machinery / helper for Ethereum & Co. (blockchain) contracts"
10 | self.description = summary
11 |
12 | self.urls = { home: 'https://github.com/rubycocos/blockchain' }
13 |
14 | self.author = 'Gerald Bauer'
15 | self.email = 'wwwmake@googlegroups.com'
16 |
17 | # switch extension to .markdown for gihub formatting
18 | self.readme_file = 'README.md'
19 | self.history_file = 'CHANGELOG.md'
20 |
21 | self.extra_deps = [
22 | ['cocos'],
23 | ['bytes'],
24 | ['digest-lite'],
25 | ]
26 |
27 | self.licenses = ['Public Domain']
28 |
29 | self.spec_extras = {
30 | required_ruby_version: '>= 2.3'
31 | }
32 |
33 | end
34 |
35 |
--------------------------------------------------------------------------------
/etherscan-lite/Rakefile:
--------------------------------------------------------------------------------
1 | require 'hoe'
2 | require './lib/etherscan-lite/version.rb'
3 |
4 |
5 | Hoe.spec 'etherscan-lite' do
6 |
7 | self.version = EtherscanLite::VERSION
8 |
9 | self.summary = "etherscan-lite - light-weight machinery / helper for the Etherscan (blockchain) JSON HTTP API / web services (note: API key sign-up required)"
10 | self.description = summary
11 |
12 | self.urls = { home: 'https://github.com/rubycocos/blockchain' }
13 |
14 | self.author = 'Gerald Bauer'
15 | self.email = 'wwwmake@googlegroups.com'
16 |
17 | # switch extension to .markdown for gihub formatting
18 | self.readme_file = 'README.md'
19 | self.history_file = 'CHANGELOG.md'
20 |
21 | self.extra_deps = [
22 | ['cocos'],
23 | ]
24 |
25 | self.licenses = ['Public Domain']
26 |
27 | self.spec_extras = {
28 | required_ruby_version: '>= 2.3'
29 | }
30 |
31 | end
32 |
33 |
--------------------------------------------------------------------------------
/ethlite/sandbox/eth_call.rb:
--------------------------------------------------------------------------------
1 | $LOAD_PATH.unshift( "../abicoder/lib" )
2 | $LOAD_PATH.unshift( "./lib" )
3 | require 'ethlite'
4 |
5 |
6 |
7 | ETH_NODE = JsonRpc.new( ENV['INFURA_URI'] )
8 |
9 |
10 |
11 | ## contract address - let's try moonbirds
12 | contract_address = '0x23581767a106ae21c074b2276d25e5c3e136a68b'
13 |
14 |
15 |
16 |
17 | ETH_tokenURI = Ethlite::ContractMethod.new( 'tokenURI',
18 | inputs: ['uint256'],
19 | outputs: ['string'] )
20 |
21 | # token_ids = (0..9)
22 | token_ids = [0,1,2,3,4,5,7,8]
23 |
24 | ## check token no. 6 & 9 for moonbirds - is now on-chain????
25 | token_ids.each do |token_id|
26 | puts "==> tokenURI(#{token_id}) returns:"
27 | pp ETH_tokenURI.do_call( ETH_NODE, contract_address, [token_id] )
28 | end
29 |
30 |
31 | puts "bye"
32 |
--------------------------------------------------------------------------------
/ethlite/Rakefile:
--------------------------------------------------------------------------------
1 | require 'hoe'
2 | require './lib/ethlite/version.rb'
3 |
4 |
5 | Hoe.spec 'ethlite' do
6 |
7 | self.version = Ethlite::VERSION
8 |
9 | self.summary = "ethlite - light-weight machinery to query / call ethereum (blockchain contract) services via json-rpc (incl. tuple support)"
10 | self.description = summary
11 |
12 | self.urls = { home: 'https://github.com/rubycocos/blockchain' }
13 |
14 | self.author = 'Gerald Bauer'
15 | self.email = 'wwwmake@googlegroups.com'
16 |
17 | # switch extension to .markdown for gihub formatting
18 | self.readme_file = 'README.md'
19 | self.history_file = 'CHANGELOG.md'
20 |
21 | self.extra_deps = [
22 | ['cocos'],
23 | ['digest-lite'],
24 | ['abicoder'],
25 | ]
26 |
27 | self.licenses = ['Public Domain']
28 |
29 | self.spec_extras = {
30 | required_ruby_version: '>= 2.3'
31 | }
32 |
33 | end
34 |
35 |
--------------------------------------------------------------------------------
/blockchain-lite/Rakefile:
--------------------------------------------------------------------------------
1 | require 'hoe'
2 | require './lib/blockchain-lite/version.rb'
3 |
4 | Hoe.spec 'blockchain-lite' do
5 |
6 | self.version = BlockchainLite::VERSION
7 |
8 | self.summary = "blockchain-lite - build your own blockchain with crypto hashes - revolutionize the world with blockchains, blockchains, blockchains one block at a time"
9 | self.description = summary
10 |
11 | self.urls = { home: 'https://github.com/rubycocos/blockchain' }
12 |
13 | self.author = 'Gerald Bauer'
14 | self.email = 'wwwmake@googlegroups.com'
15 |
16 | # switch extension to .markdown for gihub formatting
17 | self.readme_file = 'README.md'
18 | self.history_file = 'CHANGELOG.md'
19 |
20 | self.extra_deps = [
21 | ['merkletree'],
22 | ]
23 |
24 | self.licenses = ['Public Domain']
25 |
26 | self.spec_extras = {
27 | required_ruby_version: '>= 2.3'
28 | }
29 |
30 | end
31 |
--------------------------------------------------------------------------------
/base58-alphabets/test/test_base58_flickr.rb:
--------------------------------------------------------------------------------
1 | ###
2 | # to run use
3 | # ruby -I ./lib -I ./test test/test_base58_flickr.rb
4 |
5 |
6 | require 'helper'
7 |
8 |
9 | class TestBase58Flickr < MiniTest::Test
10 |
11 | NUM_TESTS = [
12 | [3471391110, "6hKMCS"],
13 | [3470152229, "6hDrmR"],
14 | [3470988633, "6hHHZB"],
15 | [3470993664, "6hHKum"],
16 | [3471485480, "6hLgFW"],
17 | [3469844075, "6hBRKR"],
18 | [3470820062, "6hGRTd"],
19 | [3469966999, "6hCuie"],
20 | ]
21 |
22 |
23 | def test_num
24 | NUM_TESTS.each do |item|
25 | assert_equal item[1], Base58::Flickr.encode_num( item[0] )
26 | assert_equal item[0], Base58::Flickr.decode_num( item[1] )
27 |
28 | Base58.format = :flickr
29 | assert_equal item[1], Base58.encode_num( item[0] )
30 | assert_equal item[0], Base58.decode_num( item[1] )
31 | end
32 | end
33 |
34 |
35 | end # class TestBase58Flickr
36 |
--------------------------------------------------------------------------------
/centralbank/lib/centralbank/ledger.rb:
--------------------------------------------------------------------------------
1 |
2 | class Ledger
3 | attr_reader :wallets ## use addresses - why? why not? for now single address wallet (wallet==address)
4 |
5 | def initialize( chain=[] )
6 | @wallets = {}
7 | chain.each do |block|
8 | apply_transactions( block.transactions )
9 | end
10 | end
11 |
12 | def sufficient_funds?( wallet, amount )
13 | return true if Centralbank.config.coinbase?( wallet )
14 | @wallets.has_key?( wallet ) && @wallets[wallet] - amount >= 0
15 | end
16 |
17 |
18 | private
19 |
20 | def apply_transactions( transactions )
21 | transactions.each do |tx|
22 | if sufficient_funds?(tx.from, tx.amount)
23 | @wallets[tx.from] -= tx.amount unless Centralbank.config.coinbase?( tx.from )
24 | @wallets[tx.to] ||= 0
25 | @wallets[tx.to] += tx.amount
26 | end
27 | end
28 | end
29 |
30 | end ## class Ledger
31 |
--------------------------------------------------------------------------------
/rlp-lite/NOTES.md:
--------------------------------------------------------------------------------
1 | # Notes
2 |
3 |
4 | Try to put together a "stand-alone" no-dependency gem for rlp (recursive length prefix).
5 |
6 |
7 | Try to use the "best" of
8 |
9 | - (is standalone but now archived - and may support too much) and
10 | - (- see /rlp - is simpler but "inline" and not standalone)
11 |
12 |
13 |
14 |
15 | Check the issue with the source encoding - ASCII-8BIT required (for BINARY string encodings for constants) - why? why not?
16 |
17 |
18 | ## More rlp gems in ruby
19 |
20 |
21 | -
22 | -
23 |
24 |
25 | ## Mor rlp packages in other langs
26 |
27 |
28 |
29 | ## About RLP
30 |
31 |
32 | -
33 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/abibase/README.md:
--------------------------------------------------------------------------------
1 | # Application Binary Inteface (ABI) Command Line Tool For Ethereum & Co.
2 |
3 | abibase - command line tool / helper to manage application binary interfaces (abis)
4 |
5 |
6 | * home :: [github.com/rubycocos/blockchain](https://github.com/rubycocos/blockchain)
7 | * bugs :: [github.com/rubycocos/blockchain/issues](https://github.com/rubycocos/blockchain/issues)
8 | * gem :: [rubygems.org/gems/abibase](https://rubygems.org/gems/abibase)
9 | * rdoc :: [rubydoc.info/gems/abibase](http://rubydoc.info/gems/abibase)
10 |
11 |
12 |
13 | ## Usage
14 |
15 | to be done
16 |
17 |
18 |
19 |
20 | ## License
21 |
22 | The scripts are dedicated to the public domain.
23 | Use it as you please with no restrictions whatsoever.
24 |
25 |
26 | ## Questions? Comments?
27 |
28 |
29 | Post them on the [D.I.Y. Punk (Pixel) Art reddit](https://old.reddit.com/r/DIYPunkArt). Thanks.
30 |
31 |
32 |
--------------------------------------------------------------------------------
/soldoc/Rakefile:
--------------------------------------------------------------------------------
1 | require 'hoe'
2 |
3 |
4 | ###
5 | # hack/ quick fix for broken intuit_values - overwrite with dummy
6 | class Hoe
7 | def intuit_values( input ); end
8 | end
9 |
10 |
11 | Hoe.spec 'soldoc' do
12 |
13 | self.version = '0.0.1'
14 |
15 | self.summary = "soldoc gem - command-line tool for solidity (contract) source code documentationn for Ethereum & Co."
16 | self.description = summary
17 |
18 | self.urls = { home: 'https://github.com/rubycocos/blockchain' }
19 |
20 | self.author = 'Gerald Bauer'
21 | self.email = 'wwwmake@googlegroups.com'
22 |
23 | # switch extension to .markdown for gihub formatting
24 | self.readme_file = 'README.md'
25 | self.history_file = 'CHANGELOG.md'
26 |
27 | self.extra_deps = [
28 | ['solidity'],
29 | ]
30 |
31 | self.licenses = ['Public Domain']
32 |
33 | self.spec_extras = {
34 | required_ruby_version: '>= 2.3'
35 | }
36 |
37 | end
38 |
39 |
--------------------------------------------------------------------------------
/digest-lite/Rakefile:
--------------------------------------------------------------------------------
1 | require 'hoe'
2 | require './lib/digest-lite/version.rb'
3 |
4 | Hoe.spec 'digest-lite' do
5 |
6 | self.version = Digestlite::VERSION
7 |
8 | self.summary = 'digest-lite - crypto(graphic) hash functions / classes - Digest::KeccakLite (512bit, 256bit, etc), Digest::SHA3Lite (512bit, 256bit, etc) in "100% pure" ruby "lite" scripts, that is, without any c-extensions and with zero-dependency'
9 | self.description = summary
10 |
11 | self.urls = { home: 'https://github.com/rubycocos/blockchain' }
12 |
13 | self.author = 'Gerald Bauer'
14 | self.email = 'wwwmake@googlegroups.com'
15 |
16 | # switch extension to .markdown for gihub formatting
17 | self.readme_file = 'README.md'
18 | self.history_file = 'CHANGELOG.md'
19 |
20 | self.extra_deps = [
21 | ]
22 |
23 | self.licenses = ['Public Domain']
24 |
25 | self.spec_extras = {
26 | required_ruby_version: '>= 2.3'
27 | }
28 |
29 | end
30 |
--------------------------------------------------------------------------------
/elliptic/lib/elliptic/signature.rb:
--------------------------------------------------------------------------------
1 | module EC
2 |
3 | class Signature
4 |
5 | def self.decode_der( der )
6 | asn1 = OpenSSL::ASN1.decode( der )
7 | r = asn1.value[0].value.to_i
8 | s = asn1.value[1].value.to_i
9 | new(r, s)
10 | end
11 |
12 | def self.decode_base64( str )
13 | decode_der( Base64.decode64( str ) )
14 | end
15 |
16 | class << self
17 | alias_method :from_der, :decode_der
18 | alias_method :from_base64, :decode_base64
19 | end
20 |
21 |
22 |
23 | attr_reader :r, :s
24 | def initialize(r, s)
25 | @r, @s = r, s
26 | end
27 |
28 | def to_der
29 | asn1 = OpenSSL::ASN1::Sequence.new [
30 | OpenSSL::ASN1::Integer.new( @r ),
31 | OpenSSL::ASN1::Integer.new( @s ),
32 | ]
33 | asn1.to_der
34 | end
35 |
36 | def to_base64
37 | Base64.encode64( to_der ).gsub("\n", '' )
38 | end
39 | end ## class Signature
40 |
41 | end ## module EC
42 |
--------------------------------------------------------------------------------
/crypto-lite/Rakefile:
--------------------------------------------------------------------------------
1 | require 'hoe'
2 | require './lib/crypto-lite/version.rb'
3 |
4 |
5 | Hoe.spec 'crypto-lite' do
6 |
7 | self.version = CryptoLite::VERSION
8 |
9 | self.summary = "crypto-lite - cryptographic secure hash functions and public key signature algorithms made easy"
10 | self.description = summary
11 |
12 | self.urls = { home: 'https://github.com/rubycocos/blockchain' }
13 |
14 | self.author = 'Gerald Bauer'
15 | self.email = 'wwwmake@googlegroups.com'
16 |
17 | # switch extension to .markdown for gihub formatting
18 | self.readme_file = 'README.md'
19 | self.history_file = 'CHANGELOG.md'
20 |
21 | self.extra_deps = [
22 | ['bytes'],
23 | ['digest-lite'],
24 | ['base32-alphabets'],
25 | ['base58-alphabets'],
26 | ['elliptic'],
27 | ]
28 |
29 | self.licenses = ['Public Domain']
30 |
31 | self.spec_extras = {
32 | required_ruby_version: '>= 2.3'
33 | }
34 |
35 | end
36 |
--------------------------------------------------------------------------------
/abibase/pkg/abibase-0.0.1/README.md:
--------------------------------------------------------------------------------
1 | # Application Binary Inteface (ABI) Command Line Tool For Ethereum & Co.
2 |
3 | abibase - command line tool / helper to manage application binary interfaces (abis)
4 |
5 |
6 | * home :: [github.com/rubycocos/blockchain](https://github.com/rubycocos/blockchain)
7 | * bugs :: [github.com/rubycocos/blockchain/issues](https://github.com/rubycocos/blockchain/issues)
8 | * gem :: [rubygems.org/gems/abibase](https://rubygems.org/gems/abibase)
9 | * rdoc :: [rubydoc.info/gems/abibase](http://rubydoc.info/gems/abibase)
10 |
11 |
12 |
13 | ## Usage
14 |
15 | to be done
16 |
17 |
18 |
19 |
20 | ## License
21 |
22 | The scripts are dedicated to the public domain.
23 | Use it as you please with no restrictions whatsoever.
24 |
25 |
26 | ## Questions? Comments?
27 |
28 |
29 | Post them on the [D.I.Y. Punk (Pixel) Art reddit](https://old.reddit.com/r/DIYPunkArt). Thanks.
30 |
31 |
32 |
--------------------------------------------------------------------------------
/abidump/Rakefile:
--------------------------------------------------------------------------------
1 | require 'hoe'
2 |
3 |
4 | ###
5 | # hack/ quick fix for broken intuit_values - overwrite with dummy
6 | class Hoe
7 | def intuit_values( input ); end
8 | end
9 |
10 |
11 | Hoe.spec 'abidump' do
12 |
13 | self.version = '0.1.1'
14 |
15 | self.summary = "abidump gem - command-line tool to dump / pretty print or (re)format application binary interfaces (abi) for Ethereum & Co."
16 | self.description = summary
17 |
18 | self.urls = { home: 'https://github.com/rubycocos/blockchain' }
19 |
20 | self.author = 'Gerald Bauer'
21 | self.email = 'wwwmake@googlegroups.com'
22 |
23 | # switch extension to .markdown for gihub formatting
24 | self.readme_file = 'README.md'
25 | self.history_file = 'CHANGELOG.md'
26 |
27 | self.extra_deps = [
28 | ['cocos'],
29 | ]
30 |
31 | self.licenses = ['Public Domain']
32 |
33 | self.spec_extras = {
34 | required_ruby_version: '>= 2.3'
35 | }
36 |
37 | end
38 |
39 |
--------------------------------------------------------------------------------
/cryptoquotes/data/Patrick_McKenzie.yml:
--------------------------------------------------------------------------------
1 | #######################
2 | # Patrick McKenzie
3 | #
4 | # see https://twitter.com/patio11
5 |
6 | - quote: |
7 | A friend of mine, who works in finance, asked me to explain what Tether was.
8 |
9 | Short version: Tether is the internal accounting system for
10 | the largest fraud since Madoff's ponzi scheme.
11 | date: 2019-10-28
12 | source: https://www.kalzumeus.com/2019/10/28/tether-and-bitfinex/
13 |
14 |
15 | - quote: |
16 | Many Bitcoin exchanges use "I am a James Bond villain" as a compliance strategy;
17 | they are present everywhere and nowhere geographically,
18 | always where they need to be to move the plot along
19 | but never where they are meaningfully constrained.
20 |
21 | Much like Bond villains, though,
22 | most Bitcoin exchanges will not survive the third act.
23 | date: 2020-12-11
24 | source: https://twitter.com/patio11/status/1337474851938811905
25 |
--------------------------------------------------------------------------------
/rlp-lite/Rakefile:
--------------------------------------------------------------------------------
1 | require 'hoe'
2 | require './lib/rlp-lite/version.rb'
3 |
4 |
5 | ###
6 | # hack/ quick fix for broken intuit_values - overwrite with dummy
7 | class Hoe
8 | def intuit_values( input ); end
9 | end
10 |
11 |
12 |
13 | Hoe.spec 'rlp-lite' do
14 |
15 | self.version = Rlp::VERSION
16 |
17 | self.summary = "rlp-lite - light-weight machinery to serialize / deserialze via rlp (recursive length prefix)"
18 | self.description = summary
19 |
20 | self.urls = { home: 'https://github.com/rubycocos/blockchain' }
21 |
22 | self.author = 'Gerald Bauer'
23 | self.email = 'wwwmake@googlegroups.com'
24 |
25 | # switch extension to .markdown for gihub formatting
26 | self.readme_file = 'README.md'
27 | self.history_file = 'CHANGELOG.md'
28 |
29 | self.extra_deps = [
30 | ]
31 |
32 | self.licenses = ['Public Domain']
33 |
34 | self.spec_extras = {
35 | required_ruby_version: '>= 2.3'
36 | }
37 |
38 | end
39 |
40 |
--------------------------------------------------------------------------------
/cryptoquotes/Rakefile:
--------------------------------------------------------------------------------
1 | require 'hoe'
2 | require './lib/cryptoquotes/version.rb'
3 |
4 | Hoe.spec 'cryptoquotes' do
5 |
6 | self.version = Quotes::VERSION
7 |
8 | self.summary = "cryptoquotes - incl. oracle tool to get a random crypto quote of the day on the command line - on the new new 'in math we trust' ponzi economics - on get-rich-quick blockchain secrets - on bitcon maximalists, scammers, morons, clowns, shills & bagHODLers and more"
9 | self.description = summary
10 |
11 | self.urls = { home: 'https://github.com/rubycocos/blockchain' }
12 |
13 | self.author = 'Gerald Bauer'
14 | self.email = 'wwwmake@googlegroups.com'
15 |
16 | # switch extension to .markdown for gihub formatting
17 | self.readme_file = 'README.md'
18 | self.history_file = 'CHANGELOG.md'
19 |
20 | self.extra_deps = []
21 |
22 | self.licenses = ['Public Domain']
23 |
24 | self.spec_extras = {
25 | required_ruby_version: '>= 2.3'
26 | }
27 |
28 | end
29 |
--------------------------------------------------------------------------------
/abi2sol/Rakefile:
--------------------------------------------------------------------------------
1 | require 'hoe'
2 |
3 |
4 | ###
5 | # hack/ quick fix for broken intuit_values - overwrite with dummy
6 | class Hoe
7 | def intuit_values( input ); end
8 | end
9 |
10 |
11 | Hoe.spec 'abi2sol' do
12 |
13 | self.version = '0.1.0'
14 |
15 | self.summary = "abi2sol gem - command-line tool for application binary interface (abi) to solidity (contract) source code generation for Ethereum & Co."
16 | self.description = summary
17 |
18 | self.urls = { home: 'https://github.com/rubycocos/blockchain' }
19 |
20 | self.author = 'Gerald Bauer'
21 | self.email = 'wwwmake@googlegroups.com'
22 |
23 | # switch extension to .markdown for gihub formatting
24 | self.readme_file = 'README.md'
25 | self.history_file = 'CHANGELOG.md'
26 |
27 | self.extra_deps = [
28 | ['abiparser'],
29 | ]
30 |
31 | self.licenses = ['Public Domain']
32 |
33 | self.spec_extras = {
34 | required_ruby_version: '>= 2.3'
35 | }
36 |
37 | end
38 |
39 |
--------------------------------------------------------------------------------
/crypto-lite/lib/crypto-lite.rb:
--------------------------------------------------------------------------------
1 | require 'pp'
2 | require 'digest'
3 | require 'base64'
4 | require 'openssl'
5 |
6 |
7 | ## our own 3rd party (2nd party?)
8 | require 'bytes'
9 |
10 | ## extend String
11 | class String
12 | alias_method :hexdigest, :bin_to_hex ## note: bin_to_hex added via Bytes!!!
13 | end
14 |
15 |
16 | require 'digest-lite' # e.g. keccak (original submission/proposal NOT official sha3)
17 | require 'base32-alphabets'
18 | require 'base58-alphabets'
19 | require 'elliptic'
20 |
21 |
22 | ## our own code
23 | require_relative 'crypto-lite/version' # note: let version always go first
24 | require_relative 'crypto-lite/config'
25 | require_relative 'crypto-lite/metal'
26 | require_relative 'crypto-lite/helper'
27 |
28 |
29 | require_relative 'crypto-lite/sign_rsa'
30 | RSA = Crypto::RSA
31 |
32 |
33 | ## auto-add top-level helpers - why? why not?
34 | include CryptoHelper
35 |
36 |
37 |
38 |
39 | puts CryptoLite.banner ## say hello
40 |
--------------------------------------------------------------------------------
/ethers/Rakefile:
--------------------------------------------------------------------------------
1 | require 'hoe'
2 |
3 |
4 | Hoe.spec 'ethers' do
5 |
6 | self.version = '0.1.0'
7 | self.summary = 'ethers - "high-level" all-in-one umbrella quick starter gem for easy installation & usage for ethereum & co. (blockchain) contract services in ruby'
8 | self.description = summary
9 |
10 | self.urls = { home: 'https://github.com/rubycocos/blockchain' }
11 |
12 | self.author = 'Gerald Bauer'
13 | self.email = 'wwwmake@googlegroups.com'
14 |
15 | # switch extension to .markdown for gihub formatting
16 | self.readme_file = 'README.md'
17 | self.history_file = 'CHANGELOG.md'
18 |
19 | self.extra_deps = [
20 | ['crypto-lite'],
21 | ['ethlite'],
22 | ['ethlite-contracts'],
23 | ['ethname'],
24 | ['etherscan-lite'],
25 | ['abidoc'],
26 | ['abigen'],
27 | ]
28 |
29 | self.licenses = ['Public Domain']
30 |
31 | self.spec_extras = {
32 | required_ruby_version: '>= 2.3'
33 | }
34 |
35 | end
36 |
37 |
--------------------------------------------------------------------------------
/elliptic/test/test_openssl.rb:
--------------------------------------------------------------------------------
1 | ###
2 | # to run use
3 | # ruby -I ./lib -I ./test test/test_openssl.rb
4 |
5 |
6 | require 'helper'
7 |
8 |
9 | ## test some "basic" openssl (binding) machinery
10 | ## for source, see https://github.com/ruby/openssl
11 |
12 | class TestOpenssl < MiniTest::Test
13 |
14 | def test_version
15 | puts "OPENSSL_VERSION: #{OpenSSL::OPENSSL_VERSION}"
16 | puts "OPENSSL_LIBRARY_VERSION: #{OpenSSL::OPENSSL_LIBRARY_VERSION}"
17 | end
18 |
19 |
20 | def test_bn
21 | [999,
22 | -999,
23 | 2**107-1,
24 | -(2**107-1)].each do |num|
25 | assert_equal OpenSSL::BN.new( num ), num.to_bn
26 | end
27 | end
28 |
29 | def test_bn_to_hex
30 | [
31 | [999, "03E7"],
32 | [-999, "-03E7"],
33 | [2**107-1, "07FFFFFFFFFFFFFFFFFFFFFFFFFF"],
34 | [-(2**107-1), "-07FFFFFFFFFFFFFFFFFFFFFFFFFF"]
35 | ].each do |item|
36 | assert_equal item[1], item[0].to_bn.to_s(16)
37 | end
38 | end
39 |
40 | end # class TestOpenssl
41 |
--------------------------------------------------------------------------------
/abi2ruby/Rakefile:
--------------------------------------------------------------------------------
1 | require 'hoe'
2 |
3 |
4 | ###
5 | # hack/ quick fix for broken intuit_values - overwrite with dummy
6 | class Hoe
7 | def intuit_values( input ); end
8 | end
9 |
10 |
11 | Hoe.spec 'abi2ruby' do
12 |
13 | self.version = '0.1.0'
14 | self.summary = "abi2ruby - generate ready-to-use (blockchain) contract services / function calls for ethereum & co. via application binary inferfaces (abis)"
15 | self.description = summary
16 |
17 | self.urls = { home: 'https://github.com/rubycocos/blockchain' }
18 |
19 | self.author = 'Gerald Bauer'
20 | self.email = 'wwwmake@googlegroups.com'
21 |
22 | # switch extension to .markdown for gihub formatting
23 | self.readme_file = 'README.md'
24 | self.history_file = 'CHANGELOG.md'
25 |
26 | self.extra_deps = [
27 | ['abiparser'],
28 | ['natspec'],
29 | ]
30 |
31 | self.licenses = ['Public Domain']
32 |
33 | self.spec_extras = {
34 | required_ruby_version: '>= 2.3'
35 | }
36 |
37 | end
38 |
39 |
--------------------------------------------------------------------------------
/attic/bitshilling/attic/ledger.rb:
--------------------------------------------------------------------------------
1 | ###
2 | ## old "custom" ledger
3 | ## delete - use ledger-lite library
4 |
5 |
6 | class Ledger
7 | attr_reader :wallets ## use addresses - why? why not? for now single address wallet (wallet==address)
8 |
9 | def initialize( chain=[] )
10 | @wallets = {}
11 | chain.each do |block|
12 | apply_transactions( block.transactions )
13 | end
14 | end
15 |
16 | def sufficient_funds?( wallet, amount )
17 | return true if Shilling.config.coinbase?( wallet )
18 | @wallets.has_key?( wallet ) && @wallets[wallet] - amount >= 0
19 | end
20 |
21 |
22 | private
23 |
24 | def apply_transactions( transactions )
25 | transactions.each do |tx|
26 | if sufficient_funds?(tx.from, tx.amount)
27 | @wallets[tx.from] -= tx.amount unless Shilling.config.coinbase?( tx.from )
28 | @wallets[tx.to] ||= 0
29 | @wallets[tx.to] += tx.amount
30 | end
31 | end
32 | end
33 |
34 | end ## class Ledger
35 |
--------------------------------------------------------------------------------
/ethname/Rakefile:
--------------------------------------------------------------------------------
1 | require 'hoe'
2 | require './lib/ethname/version.rb'
3 |
4 |
5 | Hoe.spec 'ethname' do
6 |
7 | self.version = Ethname::VERSION
8 |
9 | self.summary = 'ethname - light-weight crowd-sourced "off-chain" ethereum name to (contract) address service / helper (incl. punks v1,v2,v3,v4; phunks v1,v2, synth punks, punk blocks, nouns, nouns descriptor, synth nouns, etc.) - yes, you can! - add more names / contracts via git ;-)'
10 | self.description = summary
11 |
12 | self.urls = { home: 'https://github.com/rubycocos/blockchain' }
13 |
14 | self.author = 'Gerald Bauer'
15 | self.email = 'wwwmake@googlegroups.com'
16 |
17 | # switch extension to .markdown for gihub formatting
18 | self.readme_file = 'README.md'
19 | self.history_file = 'CHANGELOG.md'
20 |
21 | self.extra_deps = [
22 | ['cocos'],
23 | ]
24 |
25 | self.licenses = ['Public Domain']
26 |
27 | self.spec_extras = {
28 | required_ruby_version: '>= 2.3'
29 | }
30 |
31 | end
32 |
33 |
--------------------------------------------------------------------------------
/natspec/README.md:
--------------------------------------------------------------------------------
1 | # Natspec - Natural Spec(ification) Documentation Parser
2 |
3 | natspec - natural specification (comments) parser / machinery; document application binary interfaces (abis) for Ethereum & Co. (blockchain) contracts
4 |
5 |
6 |
7 | * home :: [github.com/rubycocos/blockchain](https://github.com/rubycocos/blockchain)
8 | * bugs :: [github.com/rubycocos/blockchain/issues](https://github.com/rubycocos/blockchain/issues)
9 | * gem :: [rubygems.org/gems/natspec](https://rubygems.org/gems/natspec)
10 | * rdoc :: [rubydoc.info/gems/natspec](http://rubydoc.info/gems/natspec)
11 |
12 |
13 |
14 | ## Usage
15 |
16 | To be done
17 |
18 |
19 |
20 |
21 | ## License
22 |
23 | The scripts are dedicated to the public domain.
24 | Use it as you please with no restrictions whatsoever.
25 |
26 |
27 | ## Questions? Comments?
28 |
29 |
30 | Post them on the [D.I.Y. Punk (Pixel) Art reddit](https://old.reddit.com/r/DIYPunkArt). Thanks.
31 |
32 |
33 |
--------------------------------------------------------------------------------
/solidity/Rakefile:
--------------------------------------------------------------------------------
1 | require 'hoe'
2 | require './lib/solidity/version.rb'
3 |
4 |
5 | ###
6 | # hack/ quick fix for broken intuit_values - overwrite with dummy
7 | class Hoe
8 | def intuit_values( input ); end
9 | end
10 |
11 |
12 |
13 | Hoe.spec 'solidity' do
14 |
15 | self.version = Solidity::VERSION
16 |
17 | self.summary = "solidity - (fuzzy) lexer & parser for (crypto) contracts for ethereum & co."
18 | self.description = summary
19 |
20 | self.urls = { home: 'https://github.com/rubycocos/blockchain' }
21 |
22 | self.author = 'Gerald Bauer'
23 | self.email = 'wwwmake@googlegroups.com'
24 |
25 | # switch extension to .markdown for gihub formatting
26 | self.readme_file = 'README.md'
27 | self.history_file = 'CHANGELOG.md'
28 |
29 | self.extra_deps = [
30 | ['cocos'],
31 | ]
32 |
33 | self.licenses = ['Public Domain']
34 |
35 | self.spec_extras = {
36 | required_ruby_version: '>= 2.2.2'
37 | }
38 |
39 | end
40 |
--------------------------------------------------------------------------------
/abicoder/attic/codec.rb:
--------------------------------------------------------------------------------
1 |
2 | def encode_primitive_type(type, arg)
3 |
4 |
5 | when 'ufixed'
6 | high, low = type.sub.split('x').map(&:to_i)
7 |
8 | raise ValueOutOfBounds, arg unless arg >= 0 && arg < 2**high
9 | Utils.zpad_int((arg * 2**low).to_i)
10 | when 'fixed'
11 | high, low = type.sub.split('x').map(&:to_i)
12 |
13 | raise ValueOutOfBounds, arg unless arg >= -2**(high - 1) && arg < 2**(high - 1)
14 |
15 | i = (arg * 2**low).to_i
16 | Utils.zpad_int(i % 2**(high+low))
17 |
18 | #...
19 | when 'hash'
20 | size = type.sub.to_i
21 | raise EncodingError, "too long: #{arg}" unless size > 0 && size <= 32
22 |
23 | if arg.is_a?(Integer)
24 | Utils.zpad_int(arg)
25 | elsif arg.size == size
26 | Utils.zpad arg, 32
27 | elsif arg.size == size * 2
28 | Utils.zpad_hex arg
29 | else
30 | raise EncodingError, "Could not parse hash: #{arg}"
31 | end
32 | # ...
33 | end
--------------------------------------------------------------------------------
/base32-alphabets/lib/base32-alphabets.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 |
3 | require 'pp'
4 |
5 |
6 | ## our own code
7 | require 'base32-alphabets/version' # note: let version always go first
8 |
9 | require 'base32-alphabets/base'
10 | require 'base32-alphabets/kai'
11 | require 'base32-alphabets/crockford'
12 | require 'base32-alphabets/electrologica'
13 | require 'base32-alphabets/base32'
14 |
15 |
16 |
17 |
18 |
19 | ## add a shortcut (convenience) alias
20 | Kai = Base32::Kai
21 | Crockford = Base32::Crockford
22 | Electrologica = Base32::Electrologica
23 |
24 |
25 | def encode32( num_or_bytes )
26 | Base32.encode( num_or_bytes )
27 | end
28 |
29 | def decode32( str_or_bytes )
30 | Base32.decode( str_or_bytes )
31 | end
32 |
33 |
34 | ## -- add bytes32 - why? why not?
35 | ##
36 | ## def bytes32( num_or_str )
37 | ## Base32.bytes( num_or_str )
38 | ## end
39 |
40 |
41 |
42 | # say hello
43 | puts Base32.banner if $DEBUG || (defined?($RUBYCOCO_DEBUG) && $RUBYCOCO_DEBUG)
44 |
--------------------------------------------------------------------------------
/elliptic-lite/Rakefile:
--------------------------------------------------------------------------------
1 | require 'hoe'
2 | require './lib/elliptic-lite/version.rb'
3 |
4 | Hoe.spec 'elliptic-lite' do
5 |
6 | self.version = ECCLite::VERSION
7 |
8 | self.summary = "elliptic-lite - elliptic curve cryptography from scratch / zero - start with finite fields, add elliptic curve points and point addition and scalar multiplications, add the elliptic curve digital signature algorithm (ECDSA) using the secp256k1 curve / group to sign and verify messages and more"
9 | self.description = summary
10 |
11 | self.urls = { home: 'https://github.com/rubycocos/blockchain' }
12 |
13 | self.author = 'Gerald Bauer'
14 | self.email = 'wwwmake@googlegroups.com'
15 |
16 | # switch extension to .markdown for gihub formatting
17 | self.readme_file = 'README.md'
18 | self.history_file = 'CHANGELOG.md'
19 |
20 | self.extra_deps = [
21 | ]
22 |
23 | self.licenses = ['Public Domain']
24 |
25 | self.spec_extras = {
26 | required_ruby_version: '>= 2.3'
27 | }
28 |
29 | end
30 |
--------------------------------------------------------------------------------
/abi2ruby/sandbox/test_gen.rb:
--------------------------------------------------------------------------------
1 | ###
2 | # to run use
3 | # ruby -I ./lib sandbox/test_gen.rb
4 |
5 | $LOAD_PATH.unshift( "../natspec/lib" )
6 | require 'abi2ruby'
7 |
8 | punks_v1 = '0x6ba6f2207e343923ba692e5cae646fb0f566db8d'
9 |
10 | abi = ABI.read( "../../awesome-contracts/address/#{punks_v1}/abi.json" )
11 | pp abi
12 |
13 | natspec = Natspec.read( "../../awesome-contracts/address/#{punks_v1}/contract.md" )
14 | pp natspec
15 |
16 | buf = abi.generate_code( name: 'PunksV1', natspec: natspec )
17 | write_text( "./tmp/punks_v1.rb", buf )
18 |
19 |
20 |
21 | punk_blocks = '0x58e90596c2065befd3060767736c829c18f3474c'
22 |
23 | abi = ABI.read( "../../awesome-contracts/address/#{punk_blocks}/abi.json" )
24 | pp abi
25 |
26 | natspec = Natspec.read( "../../awesome-contracts/address/#{punk_blocks}/contract.md" )
27 | pp natspec
28 |
29 |
30 | buf = abi.generate_code( name: 'PunkBlocks', natspec: natspec )
31 | write_text( "./tmp/punk_blocks.rb", buf )
32 |
33 | puts "bye"
34 |
--------------------------------------------------------------------------------
/tulipmania/lib/tulipmania/block.rb:
--------------------------------------------------------------------------------
1 |
2 |
3 | Block = BlockchainLite::ProofOfWork::Block
4 |
5 | ## see https://github.com/openblockchains/blockchain.lite.rb/blob/master/lib/blockchain-lite/proof_of_work/block.rb
6 |
7 |
8 | ######
9 | # add more methods
10 |
11 | class Block
12 |
13 | def to_h
14 | { index: @index,
15 | timestamp: @timestamp,
16 | nonce: @nonce,
17 | transactions: @transactions.map { |tx| tx.to_h },
18 | previous_hash: @previous_hash }
19 | end
20 |
21 | def self.from_h( h )
22 | transactions = h['transactions'].map { |h_tx| Tx.from_h( h_tx ) }
23 |
24 | ## parse iso8601 format e.g 2017-10-05T22:26:12-04:00
25 | timestamp = Time.parse( h['timestamp'] )
26 |
27 | self.new( h['index'],
28 | transactions,
29 | h['previous_hash'],
30 | timestamp: timestamp,
31 | nonce: h['nonce'].to_i )
32 | end
33 |
34 |
35 | def valid?
36 | true ## for now always valid
37 | end
38 |
39 |
40 | end # class Block
41 |
--------------------------------------------------------------------------------
/centralbank/Rakefile:
--------------------------------------------------------------------------------
1 | require 'hoe'
2 | require './lib/centralbank/version.rb'
3 |
4 | Hoe.spec 'centralbank' do
5 |
6 | self.version = Centralbank::VERSION
7 |
8 | self.summary = 'centralbank - print your own money / cryptocurrency; run your own federated central bank nodes on the blockchain peer-to-peer over HTTP; revolutionize the world one block at a time'
9 | self.description = summary
10 |
11 | self.urls = { home: 'https://github.com/rubycocos/blockchain' }
12 |
13 | self.author = 'Gerald Bauer'
14 | self.email = 'ruby-talk@ruby-lang.org'
15 |
16 | # switch extension to .markdown for gihub formatting
17 | self.readme_file = 'README.md'
18 | self.history_file = 'CHANGELOG.md'
19 |
20 | self.extra_deps = [
21 | ['sinatra', '>=2.0'],
22 | ['sass'], ## used for css style preprocessing (scss)
23 | ['blockchain-lite', '>=1.3.1'],
24 | ]
25 |
26 | self.licenses = ['Public Domain']
27 |
28 | self.spec_extras = {
29 | required_ruby_version: '>= 2.3'
30 | }
31 |
32 | end
33 |
--------------------------------------------------------------------------------
/attic/bitshilling/lib/shilling/block.rb:
--------------------------------------------------------------------------------
1 |
2 | ######
3 | ## add more methods
4 |
5 |
6 | class Block
7 |
8 | def to_h
9 | { index: @index,
10 | timestamp: @timestamp,
11 | nonce: @nonce,
12 | transactions: @transactions.map { |tx| tx.to_h },
13 | transactions_hash: @transactions_hash,
14 | previous_hash: @previous_hash,
15 | hash: @hash }
16 | end
17 |
18 | def self.from_h( h )
19 | transactions = h['transactions'].map { |h_tx| Tx.from_h( h_tx ) }
20 |
21 | ## todo: use hash and transactions_hash to check integrity of block - why? why not?
22 |
23 | ## parse iso8601 format e.g 2017-10-05T22:26:12-04:00
24 | timestamp = Time.parse( h['timestamp'] )
25 |
26 | self.new( h['index'],
27 | transactions,
28 | h['previous_hash'],
29 | timestamp: timestamp,
30 | nonce: h['nonce'].to_i )
31 | end
32 |
33 |
34 | def valid?
35 | true ## for now always valid
36 | end
37 |
38 |
39 | end # class Block
40 |
--------------------------------------------------------------------------------
/abibase/Rakefile:
--------------------------------------------------------------------------------
1 | require 'hoe'
2 |
3 |
4 | ###
5 | # hack/ quick fix for broken intuit_values - overwrite with dummy
6 | class Hoe
7 | def intuit_values( input ); end
8 | end
9 |
10 |
11 | Hoe.spec 'abibase' do
12 |
13 | self.version = '0.0.1'
14 |
15 | self.summary = "abibase - command line tool / helper to manage application binary interfaces (abis)"
16 | self.description = summary
17 |
18 | self.urls = { home: 'https://github.com/rubycocos/blockchain' }
19 |
20 | self.author = 'Gerald Bauer'
21 | self.email = 'wwwmake@googlegroups.com'
22 |
23 | # switch extension to .markdown for gihub formatting
24 | self.readme_file = 'README.md'
25 | self.history_file = 'CHANGELOG.md'
26 |
27 | self.extra_deps = [
28 | ## ['ethlite'],
29 | ['etherscan-lite'],
30 | ['abiparser'],
31 | ['natspec'],
32 | ['abidoc'],
33 | ['abigen'],
34 | ]
35 |
36 | self.licenses = ['Public Domain']
37 |
38 | self.spec_extras = {
39 | required_ruby_version: '>= 2.3'
40 | }
41 |
42 | end
43 |
44 |
--------------------------------------------------------------------------------
/abibase/pkg/abibase-0.0.1/Rakefile:
--------------------------------------------------------------------------------
1 | require 'hoe'
2 |
3 |
4 | ###
5 | # hack/ quick fix for broken intuit_values - overwrite with dummy
6 | class Hoe
7 | def intuit_values( input ); end
8 | end
9 |
10 |
11 | Hoe.spec 'abibase' do
12 |
13 | self.version = '0.0.1'
14 |
15 | self.summary = "abibase - command line tool / helper to manage application binary interfaces (abis)"
16 | self.description = summary
17 |
18 | self.urls = { home: 'https://github.com/rubycocos/blockchain' }
19 |
20 | self.author = 'Gerald Bauer'
21 | self.email = 'wwwmake@googlegroups.com'
22 |
23 | # switch extension to .markdown for gihub formatting
24 | self.readme_file = 'README.md'
25 | self.history_file = 'CHANGELOG.md'
26 |
27 | self.extra_deps = [
28 | ## ['ethlite'],
29 | ['etherscan-lite'],
30 | ['abiparser'],
31 | ['natspec'],
32 | ['abidoc'],
33 | ['abigen'],
34 | ]
35 |
36 | self.licenses = ['Public Domain']
37 |
38 | self.spec_extras = {
39 | required_ruby_version: '>= 2.3'
40 | }
41 |
42 | end
43 |
44 |
--------------------------------------------------------------------------------
/abicoder/attic/type.rb:
--------------------------------------------------------------------------------
1 |
2 | class Type
3 |
4 | BASE_TYPE_RX = /([a-z]*)
5 | ([0-9]*x?[0-9]*)
6 | (
7 | (\[[0-9]*\])*
8 | )/x
9 |
10 |
11 |
12 | def self.parse( type )
13 | # ...
14 |
15 | case base
16 | when ''
17 | return parse 'address'
18 | # ...
19 | when 'fixed', 'ufixed'
20 | raise ParseError, "Fixed type must have suffix of form x, e.g. 128x128" unless sub =~ /\A[0-9]+x[0-9]+\z/
21 |
22 | high, low = sub.split('x').map(&:to_i)
23 | total = high + low
24 |
25 | raise ParseError, "Fixed size out of bounds (max 32 bytes)" unless total >= 8 && total <= 256
26 | raise ParseError, "Fixed high size must be multiple of 8" unless high % 8 == 0
27 | raise ParseError, "Low sizes must be 0 to 80" unless low>0 && low<=80
28 | when 'hash'
29 | raise ParseError, "Hash type must have numerical suffix" unless sub =~ /\A[0-9]+\z/
30 |
31 | # ...
32 | end
33 | end # class Type
--------------------------------------------------------------------------------
/elliptic-lite/lib/elliptic-lite/secp256k1.rb:
--------------------------------------------------------------------------------
1 |
2 | module ECC
3 |
4 | class S256Field < FiniteField::Element
5 | P = 2**256 - 2**32 - 977
6 | def self.prime() P; end
7 | end
8 |
9 | class S256Point < Point
10 | def self.curve() @curve ||= Curve.new( a: 0, b: 7, f: S256Field ); end
11 |
12 | def inspect ## change to fixed 64 char hexstring for x/y
13 | if infinity?
14 | "#{self.class.name}(:infinity)"
15 | else
16 | "#{self.class.name}(#{'0x%064x' % @x},#{'0x%064x' % @y})"
17 | end
18 | end
19 | end # class S256Point
20 |
21 |
22 | # use Secp256k1 - why? why not?
23 | # or use GROUP_SECP256K1 or SECP256K1_GROUP (different from "plain" CURVE_SECP256K1) - why? why not?
24 | SECP256K1 = Group.new(
25 | g: S256Point.new( 0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798,
26 | 0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 ),
27 | n: 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141
28 | )
29 | end # module ECC
30 |
31 |
32 |
--------------------------------------------------------------------------------
/ethlite/attic/contract.rb:
--------------------------------------------------------------------------------
1 |
2 | class ContractMethod
3 |
4 | def self.parse_abi( abi )
5 | ## convenience helper - auto-convert to json if string passed in
6 | abi = JSON.parse( abi ) if abi.is_a?( String )
7 |
8 | name = abi['name']
9 | constant = !!abi['constant'] || abi['stateMutability']=='view'
10 | input_types = abi['inputs'] ? abi['inputs'].map{|a| _parse_component_type( a ) } : []
11 | output_types = abi['outputs'] ? abi['outputs'].map{|a| _parse_component_type( a ) } : []
12 |
13 | new( name, inputs: input_types,
14 | outputs: output_types,
15 | constant: constant )
16 | end
17 |
18 | def self._parse_component_type( argument )
19 | if argument['type'] =~ /^tuple((\[[0-9]*\])*)/
20 | argument['components'] ? "(#{argument['components'].collect{ |c| _parse_component_type( c ) }.join(',')})#{$1}"
21 | : "()#{$1}"
22 | else
23 | argument['type']
24 | end
25 | end
26 |
27 | end # class ContractMethod
28 |
--------------------------------------------------------------------------------
/abicoder/Rakefile:
--------------------------------------------------------------------------------
1 | require 'hoe'
2 | require './lib/abicoder/version.rb'
3 |
4 |
5 | ###
6 | # hack/ quick fix for broken intuit_values - overwrite with dummy
7 | class Hoe
8 | def intuit_values( input ); end
9 | end
10 |
11 |
12 | Hoe.spec 'abicoder' do
13 |
14 | self.version = ABICoder::VERSION
15 |
16 | self.summary = "abicoder - 'lite' application binary interface (abi) encoding / decoding machinery / helper (incl. nested arrays and/or tuples) for Ethereum & Co. (blockchain) contracts with zero-dependencies for easy (re)use"
17 | self.description = summary
18 |
19 | self.urls = { home: 'https://github.com/rubycocos/blockchain' }
20 |
21 | self.author = 'Gerald Bauer'
22 | self.email = 'wwwmake@googlegroups.com'
23 |
24 | # switch extension to .markdown for gihub formatting
25 | self.readme_file = 'README.md'
26 | self.history_file = 'CHANGELOG.md'
27 |
28 | self.extra_deps = [
29 | ]
30 |
31 | self.licenses = ['Public Domain']
32 |
33 | self.spec_extras = {
34 | required_ruby_version: '>= 2.3'
35 | }
36 |
37 | end
38 |
39 |
--------------------------------------------------------------------------------
/crypto-lite/lib/crypto-lite/sign_rsa.rb:
--------------------------------------------------------------------------------
1 | module Crypto
2 |
3 |
4 | module RSA
5 | def self.generate_keys ## todo/check: add a generate alias - why? why not?
6 | key_pair = OpenSSL::PKey::RSA.new( 2048 )
7 | private_key = key_pair.export
8 | public_key = key_pair.public_key.export
9 |
10 | [private_key, public_key]
11 | end
12 |
13 |
14 | def self.sign( plaintext, private_key )
15 | private_key = OpenSSL::PKey::RSA.new( private_key ) ## note: convert/wrap into to obj from exported text format
16 | Base64.encode64( private_key.private_encrypt( plaintext ))
17 | end
18 |
19 | def self.decrypt( ciphertext, public_key )
20 | public_key = OpenSSL::PKey::RSA.new( public_key ) ## note: convert/wrap into to obj from exported text format
21 | public_key.public_decrypt( Base64.decode64( ciphertext ))
22 | end
23 |
24 |
25 | def self.valid_signature?( plaintext, ciphertext, public_key )
26 | plaintext == decrypt( ciphertext, public_key )
27 | end
28 | end # module RSA
29 | end # module Crypto
30 |
--------------------------------------------------------------------------------
/crypto-lite/test/test_base58.rb:
--------------------------------------------------------------------------------
1 | ###
2 | # to run use
3 | # ruby -I ./lib -I ./test test/test_base58.rb
4 |
5 |
6 | require 'helper'
7 |
8 |
9 | class TestBase58 < MiniTest::Test
10 |
11 | HEX_TESTS = [
12 | ["00000000000000000000", "1111111111"],
13 | ["00000000000000000000123456789abcdef0", "111111111143c9JGph3DZ"],
14 | ]
15 |
16 |
17 | def test_hex
18 | HEX_TESTS.each do |item|
19 | assert_equal item[1], Crypto.base58( hex: item[0] )
20 | bin = Bytes.hex_to_bin( item[0] )
21 | assert_equal item[1], Crypto.base58( bin )
22 | end
23 | end
24 |
25 |
26 | def test_bitcoin_addr
27 | addr_exp = '1PMycacnJaSqwwJqjawXBErnLsZ7RkXUAs'
28 |
29 | pkh = 'f54a5851e9372b87810a8e60cdd2e7cfd80b6e31'
30 |
31 | ## all-in-one
32 | assert_equal addr_exp, Crypto.base58check( hex: '00' + pkh )
33 | bin = Bytes.hex_to_bin('00' + pkh)
34 | assert_equal addr_exp, Crypto.base58check( bin )
35 |
36 | assert_equal addr_exp, Crypto::Metal.base58check( "\x00" + [pkh].pack('H*') )
37 | end
38 |
39 | end # class TestBase58
40 |
--------------------------------------------------------------------------------
/abi2ruby/.gitignore:
--------------------------------------------------------------------------------
1 | *.gem
2 | *.rbc
3 | /.config
4 | /coverage/
5 | /InstalledFiles
6 | /pkg/
7 | /spec/reports/
8 | /test/tmp/
9 | /test/version_tmp/
10 | /tmp/
11 |
12 | ## Specific to RubyMotion:
13 | .dat*
14 | .repl_history
15 | build/
16 |
17 | ## Documentation cache and generated files:
18 | /.yardoc/
19 | /_yardoc/
20 | /doc/
21 | /rdoc/
22 |
23 | ## Environment normalisation:
24 | /.bundle/
25 | /vendor/bundle
26 | /lib/bundler/man/
27 |
28 | # for a library or gem, you might want to ignore these files since the code is
29 | # intended to run in multiple environments; otherwise, check them in:
30 | # Gemfile.lock
31 | .ruby-version
32 | .ruby-gemset
33 |
34 | # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35 | .rvmrc
36 |
37 | # Gladiator (Glimmer Editor)
38 | .gladiator
39 | .DS_Store
40 |
41 |
42 |
43 | ####
44 | # exclude all tmp & tmp2 and o directory (in all levels)
45 | tmp/
46 | tmp2/
47 | o/
48 |
49 | ########
50 | # exclude all dbs e.g. artbase.db etc.
51 | *.db
52 |
53 | ######
54 | # exclude all zips (in /dl)
55 | *.zip
56 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/abi2sol/.gitignore:
--------------------------------------------------------------------------------
1 | *.gem
2 | *.rbc
3 | /.config
4 | /coverage/
5 | /InstalledFiles
6 | /pkg/
7 | /spec/reports/
8 | /test/tmp/
9 | /test/version_tmp/
10 | /tmp/
11 |
12 | ## Specific to RubyMotion:
13 | .dat*
14 | .repl_history
15 | build/
16 |
17 | ## Documentation cache and generated files:
18 | /.yardoc/
19 | /_yardoc/
20 | /doc/
21 | /rdoc/
22 |
23 | ## Environment normalisation:
24 | /.bundle/
25 | /vendor/bundle
26 | /lib/bundler/man/
27 |
28 | # for a library or gem, you might want to ignore these files since the code is
29 | # intended to run in multiple environments; otherwise, check them in:
30 | # Gemfile.lock
31 | .ruby-version
32 | .ruby-gemset
33 |
34 | # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35 | .rvmrc
36 |
37 | # Gladiator (Glimmer Editor)
38 | .gladiator
39 | .DS_Store
40 |
41 |
42 |
43 | ####
44 | # exclude all tmp & tmp2 and o directory (in all levels)
45 | tmp/
46 | tmp2/
47 | o/
48 |
49 | ########
50 | # exclude all dbs e.g. artbase.db etc.
51 | *.db
52 |
53 | ######
54 | # exclude all zips (in /dl)
55 | *.zip
56 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/abicoder/.gitignore:
--------------------------------------------------------------------------------
1 | *.gem
2 | *.rbc
3 | /.config
4 | /coverage/
5 | /InstalledFiles
6 | /pkg/
7 | /spec/reports/
8 | /test/tmp/
9 | /test/version_tmp/
10 | /tmp/
11 |
12 | ## Specific to RubyMotion:
13 | .dat*
14 | .repl_history
15 | build/
16 |
17 | ## Documentation cache and generated files:
18 | /.yardoc/
19 | /_yardoc/
20 | /doc/
21 | /rdoc/
22 |
23 | ## Environment normalisation:
24 | /.bundle/
25 | /vendor/bundle
26 | /lib/bundler/man/
27 |
28 | # for a library or gem, you might want to ignore these files since the code is
29 | # intended to run in multiple environments; otherwise, check them in:
30 | # Gemfile.lock
31 | .ruby-version
32 | .ruby-gemset
33 |
34 | # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35 | .rvmrc
36 |
37 | # Gladiator (Glimmer Editor)
38 | .gladiator
39 | .DS_Store
40 |
41 |
42 |
43 | ####
44 | # exclude all tmp & tmp2 and o directory (in all levels)
45 | tmp/
46 | tmp2/
47 | o/
48 |
49 | ########
50 | # exclude all dbs e.g. artbase.db etc.
51 | *.db
52 |
53 | ######
54 | # exclude all zips (in /dl)
55 | *.zip
56 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/abidoc/.gitignore:
--------------------------------------------------------------------------------
1 | *.gem
2 | *.rbc
3 | /.config
4 | /coverage/
5 | /InstalledFiles
6 | /pkg/
7 | /spec/reports/
8 | /test/tmp/
9 | /test/version_tmp/
10 | /tmp/
11 |
12 | ## Specific to RubyMotion:
13 | .dat*
14 | .repl_history
15 | build/
16 |
17 | ## Documentation cache and generated files:
18 | /.yardoc/
19 | /_yardoc/
20 | /doc/
21 | /rdoc/
22 |
23 | ## Environment normalisation:
24 | /.bundle/
25 | /vendor/bundle
26 | /lib/bundler/man/
27 |
28 | # for a library or gem, you might want to ignore these files since the code is
29 | # intended to run in multiple environments; otherwise, check them in:
30 | # Gemfile.lock
31 | .ruby-version
32 | .ruby-gemset
33 |
34 | # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35 | .rvmrc
36 |
37 | # Gladiator (Glimmer Editor)
38 | .gladiator
39 | .DS_Store
40 |
41 |
42 |
43 | ####
44 | # exclude all tmp & tmp2 and o directory (in all levels)
45 | tmp/
46 | tmp2/
47 | o/
48 |
49 | ########
50 | # exclude all dbs e.g. artbase.db etc.
51 | *.db
52 |
53 | ######
54 | # exclude all zips (in /dl)
55 | *.zip
56 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/abidump/.gitignore:
--------------------------------------------------------------------------------
1 | *.gem
2 | *.rbc
3 | /.config
4 | /coverage/
5 | /InstalledFiles
6 | /pkg/
7 | /spec/reports/
8 | /test/tmp/
9 | /test/version_tmp/
10 | /tmp/
11 |
12 | ## Specific to RubyMotion:
13 | .dat*
14 | .repl_history
15 | build/
16 |
17 | ## Documentation cache and generated files:
18 | /.yardoc/
19 | /_yardoc/
20 | /doc/
21 | /rdoc/
22 |
23 | ## Environment normalisation:
24 | /.bundle/
25 | /vendor/bundle
26 | /lib/bundler/man/
27 |
28 | # for a library or gem, you might want to ignore these files since the code is
29 | # intended to run in multiple environments; otherwise, check them in:
30 | # Gemfile.lock
31 | .ruby-version
32 | .ruby-gemset
33 |
34 | # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35 | .rvmrc
36 |
37 | # Gladiator (Glimmer Editor)
38 | .gladiator
39 | .DS_Store
40 |
41 |
42 |
43 | ####
44 | # exclude all tmp & tmp2 and o directory (in all levels)
45 | tmp/
46 | tmp2/
47 | o/
48 |
49 | ########
50 | # exclude all dbs e.g. artbase.db etc.
51 | *.db
52 |
53 | ######
54 | # exclude all zips (in /dl)
55 | *.zip
56 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/abigen/.gitignore:
--------------------------------------------------------------------------------
1 | *.gem
2 | *.rbc
3 | /.config
4 | /coverage/
5 | /InstalledFiles
6 | /pkg/
7 | /spec/reports/
8 | /test/tmp/
9 | /test/version_tmp/
10 | /tmp/
11 |
12 | ## Specific to RubyMotion:
13 | .dat*
14 | .repl_history
15 | build/
16 |
17 | ## Documentation cache and generated files:
18 | /.yardoc/
19 | /_yardoc/
20 | /doc/
21 | /rdoc/
22 |
23 | ## Environment normalisation:
24 | /.bundle/
25 | /vendor/bundle
26 | /lib/bundler/man/
27 |
28 | # for a library or gem, you might want to ignore these files since the code is
29 | # intended to run in multiple environments; otherwise, check them in:
30 | # Gemfile.lock
31 | .ruby-version
32 | .ruby-gemset
33 |
34 | # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35 | .rvmrc
36 |
37 | # Gladiator (Glimmer Editor)
38 | .gladiator
39 | .DS_Store
40 |
41 |
42 |
43 | ####
44 | # exclude all tmp & tmp2 and o directory (in all levels)
45 | tmp/
46 | tmp2/
47 | o/
48 |
49 | ########
50 | # exclude all dbs e.g. artbase.db etc.
51 | *.db
52 |
53 | ######
54 | # exclude all zips (in /dl)
55 | *.zip
56 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/abiparser/.gitignore:
--------------------------------------------------------------------------------
1 | *.gem
2 | *.rbc
3 | /.config
4 | /coverage/
5 | /InstalledFiles
6 | /pkg/
7 | /spec/reports/
8 | /test/tmp/
9 | /test/version_tmp/
10 | /tmp/
11 |
12 | ## Specific to RubyMotion:
13 | .dat*
14 | .repl_history
15 | build/
16 |
17 | ## Documentation cache and generated files:
18 | /.yardoc/
19 | /_yardoc/
20 | /doc/
21 | /rdoc/
22 |
23 | ## Environment normalisation:
24 | /.bundle/
25 | /vendor/bundle
26 | /lib/bundler/man/
27 |
28 | # for a library or gem, you might want to ignore these files since the code is
29 | # intended to run in multiple environments; otherwise, check them in:
30 | # Gemfile.lock
31 | .ruby-version
32 | .ruby-gemset
33 |
34 | # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35 | .rvmrc
36 |
37 | # Gladiator (Glimmer Editor)
38 | .gladiator
39 | .DS_Store
40 |
41 |
42 |
43 | ####
44 | # exclude all tmp & tmp2 and o directory (in all levels)
45 | tmp/
46 | tmp2/
47 | o/
48 |
49 | ########
50 | # exclude all dbs e.g. artbase.db etc.
51 | *.db
52 |
53 | ######
54 | # exclude all zips (in /dl)
55 | *.zip
56 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/ethname/.gitignore:
--------------------------------------------------------------------------------
1 | *.gem
2 | *.rbc
3 | /.config
4 | /coverage/
5 | /InstalledFiles
6 | /pkg/
7 | /spec/reports/
8 | /test/tmp/
9 | /test/version_tmp/
10 | /tmp/
11 |
12 | ## Specific to RubyMotion:
13 | .dat*
14 | .repl_history
15 | build/
16 |
17 | ## Documentation cache and generated files:
18 | /.yardoc/
19 | /_yardoc/
20 | /doc/
21 | /rdoc/
22 |
23 | ## Environment normalisation:
24 | /.bundle/
25 | /vendor/bundle
26 | /lib/bundler/man/
27 |
28 | # for a library or gem, you might want to ignore these files since the code is
29 | # intended to run in multiple environments; otherwise, check them in:
30 | # Gemfile.lock
31 | .ruby-version
32 | .ruby-gemset
33 |
34 | # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35 | .rvmrc
36 |
37 | # Gladiator (Glimmer Editor)
38 | .gladiator
39 | .DS_Store
40 |
41 |
42 |
43 | ####
44 | # exclude all tmp & tmp2 and o directory (in all levels)
45 | tmp/
46 | tmp2/
47 | o/
48 |
49 | ########
50 | # exclude all dbs e.g. artbase.db etc.
51 | *.db
52 |
53 | ######
54 | # exclude all zips (in /dl)
55 | *.zip
56 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/natspec/.gitignore:
--------------------------------------------------------------------------------
1 | *.gem
2 | *.rbc
3 | /.config
4 | /coverage/
5 | /InstalledFiles
6 | /pkg/
7 | /spec/reports/
8 | /test/tmp/
9 | /test/version_tmp/
10 | /tmp/
11 |
12 | ## Specific to RubyMotion:
13 | .dat*
14 | .repl_history
15 | build/
16 |
17 | ## Documentation cache and generated files:
18 | /.yardoc/
19 | /_yardoc/
20 | /doc/
21 | /rdoc/
22 |
23 | ## Environment normalisation:
24 | /.bundle/
25 | /vendor/bundle
26 | /lib/bundler/man/
27 |
28 | # for a library or gem, you might want to ignore these files since the code is
29 | # intended to run in multiple environments; otherwise, check them in:
30 | # Gemfile.lock
31 | .ruby-version
32 | .ruby-gemset
33 |
34 | # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35 | .rvmrc
36 |
37 | # Gladiator (Glimmer Editor)
38 | .gladiator
39 | .DS_Store
40 |
41 |
42 |
43 | ####
44 | # exclude all tmp & tmp2 and o directory (in all levels)
45 | tmp/
46 | tmp2/
47 | o/
48 |
49 | ########
50 | # exclude all dbs e.g. artbase.db etc.
51 | *.db
52 |
53 | ######
54 | # exclude all zips (in /dl)
55 | *.zip
56 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/rlp-lite/.gitignore:
--------------------------------------------------------------------------------
1 | *.gem
2 | *.rbc
3 | /.config
4 | /coverage/
5 | /InstalledFiles
6 | /pkg/
7 | /spec/reports/
8 | /test/tmp/
9 | /test/version_tmp/
10 | /tmp/
11 |
12 | ## Specific to RubyMotion:
13 | .dat*
14 | .repl_history
15 | build/
16 |
17 | ## Documentation cache and generated files:
18 | /.yardoc/
19 | /_yardoc/
20 | /doc/
21 | /rdoc/
22 |
23 | ## Environment normalisation:
24 | /.bundle/
25 | /vendor/bundle
26 | /lib/bundler/man/
27 |
28 | # for a library or gem, you might want to ignore these files since the code is
29 | # intended to run in multiple environments; otherwise, check them in:
30 | # Gemfile.lock
31 | .ruby-version
32 | .ruby-gemset
33 |
34 | # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35 | .rvmrc
36 |
37 | # Gladiator (Glimmer Editor)
38 | .gladiator
39 | .DS_Store
40 |
41 |
42 |
43 | ####
44 | # exclude all tmp & tmp2 and o directory (in all levels)
45 | tmp/
46 | tmp2/
47 | o/
48 |
49 | ########
50 | # exclude all dbs e.g. artbase.db etc.
51 | *.db
52 |
53 | ######
54 | # exclude all zips (in /dl)
55 | *.zip
56 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/soldoc/.gitignore:
--------------------------------------------------------------------------------
1 | *.gem
2 | *.rbc
3 | /.config
4 | /coverage/
5 | /InstalledFiles
6 | /pkg/
7 | /spec/reports/
8 | /test/tmp/
9 | /test/version_tmp/
10 | /tmp/
11 |
12 | ## Specific to RubyMotion:
13 | .dat*
14 | .repl_history
15 | build/
16 |
17 | ## Documentation cache and generated files:
18 | /.yardoc/
19 | /_yardoc/
20 | /doc/
21 | /rdoc/
22 |
23 | ## Environment normalisation:
24 | /.bundle/
25 | /vendor/bundle
26 | /lib/bundler/man/
27 |
28 | # for a library or gem, you might want to ignore these files since the code is
29 | # intended to run in multiple environments; otherwise, check them in:
30 | # Gemfile.lock
31 | .ruby-version
32 | .ruby-gemset
33 |
34 | # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35 | .rvmrc
36 |
37 | # Gladiator (Glimmer Editor)
38 | .gladiator
39 | .DS_Store
40 |
41 |
42 |
43 | ####
44 | # exclude all tmp & tmp2 and o directory (in all levels)
45 | tmp/
46 | tmp2/
47 | o/
48 |
49 | ########
50 | # exclude all dbs e.g. artbase.db etc.
51 | *.db
52 |
53 | ######
54 | # exclude all zips (in /dl)
55 | *.zip
56 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/etherscan-lite/.gitignore:
--------------------------------------------------------------------------------
1 | *.gem
2 | *.rbc
3 | /.config
4 | /coverage/
5 | /InstalledFiles
6 | /pkg/
7 | /spec/reports/
8 | /test/tmp/
9 | /test/version_tmp/
10 | /tmp/
11 |
12 | ## Specific to RubyMotion:
13 | .dat*
14 | .repl_history
15 | build/
16 |
17 | ## Documentation cache and generated files:
18 | /.yardoc/
19 | /_yardoc/
20 | /doc/
21 | /rdoc/
22 |
23 | ## Environment normalisation:
24 | /.bundle/
25 | /vendor/bundle
26 | /lib/bundler/man/
27 |
28 | # for a library or gem, you might want to ignore these files since the code is
29 | # intended to run in multiple environments; otherwise, check them in:
30 | # Gemfile.lock
31 | .ruby-version
32 | .ruby-gemset
33 |
34 | # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35 | .rvmrc
36 |
37 | # Gladiator (Glimmer Editor)
38 | .gladiator
39 | .DS_Store
40 |
41 |
42 |
43 | ####
44 | # exclude all tmp & tmp2 and o directory (in all levels)
45 | tmp/
46 | tmp2/
47 | o/
48 |
49 | ########
50 | # exclude all dbs e.g. artbase.db etc.
51 | *.db
52 |
53 | ######
54 | # exclude all zips (in /dl)
55 | *.zip
56 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/elliptic-lite/NOTES.md:
--------------------------------------------------------------------------------
1 | # Notes
2 |
3 |
4 |
5 | https://johannes-bauer.com/compsci/ecc/
6 | https://johannes-bauer.com/compsci/ecc/
7 |
8 | https://github.com/johndoe31415/joeecc
9 |
10 |
11 | https://pypi.org/project/tinyec/
12 | https://pypi.org/project/ecdsa/
13 |
14 | https://github.com/starkbank/ecdsa-python
15 |
16 | http://cslashm.github.io/ECPy/
17 |
18 |
19 | https://www.rubydoc.info/gems/ecc/0.1.3/Ecc/Point
20 |
21 |
22 | !!! great book on ecc crytpo !!!
23 |
24 | https://onyb.gitbook.io/secp256k1-python/introduction
25 | https://onyb.gitbook.io/secp256k1-python/galois-fields
26 | https://onyb.gitbook.io/secp256k1-python/group-theory
27 | https://onyb.gitbook.io/secp256k1-python/point-addition-in-python
28 | https://onyb.gitbook.io/secp256k1-python/scalar-multiplication-in-python
29 | https://onyb.gitbook.io/secp256k1-python/ecdsa
30 | source: https://gist.github.com/onyb/cf795c819fdf8aa6015de2772fde24de
31 |
32 |
33 |
34 | https://cryptobook.nakov.com/digital-signatures/ecdsa-sign-verify-messages
35 | https://cryptobook.nakov.com/digital-signatures/ecdsa-sign-verify-examples
36 |
37 |
--------------------------------------------------------------------------------
/etherscan-lite/sandbox/query.rb:
--------------------------------------------------------------------------------
1 | ###
2 | # to run use
3 | # ruby -I ./lib sandbox/query.rb
4 |
5 | require 'etherscan-lite'
6 |
7 |
8 | PUNKS_ADDRESS = '0xb47e3cd837ddf8e4c57f05d70ab865de6e193bbb'
9 | MOONBIRDS_ADDRESS = '0x23581767a106ae21c074b2276D25e5C3e136a68b'
10 |
11 | address = '0x7174039818a41E1ae40FDcFA3E293b0f41592AF2'
12 |
13 |
14 | pp Etherscan.config.key
15 |
16 | pp Etherscan.txlist_url( address: address )
17 | # data = Etherscan.txlist( address: address )
18 | # pp data
19 |
20 |
21 | pp Etherscan.tokentx_url( address: address,
22 | contractaddress: PUNKS_ADDRESS )
23 |
24 | # data = Etherscan.tokentx( address: address, contractaddress: PUNKS_ADDRESS )
25 | # pp data
26 |
27 | data = Etherscan.tokentx( contractaddress: PUNKS_ADDRESS )
28 | pp data
29 |
30 | # data = Etherscan.tokentx( address: address )
31 | # pp data
32 |
33 |
34 | pp Etherscan.tokennfttx_url( contractaddress: MOONBIRDS_ADDRESS )
35 | ## data = Etherscan.tokennfttx( contractaddress: MOONBIRDS_ADDRESS )
36 | ## pp data
37 |
38 |
39 |
40 | puts "bye"
--------------------------------------------------------------------------------
/ethlite-contracts/lib/ethlite/contracts/punks_data.rb:
--------------------------------------------------------------------------------
1 | # PunksData contract / (blockchain) services / function calls
2 | #
3 | # auto-generated via abigen (see https://rubygems.org/gems/abigen) on 2023-01-15 16:36:46 UTC
4 | # - 3 query functions(s)
5 | # - 0 helper functions(s)
6 |
7 |
8 | class PunksData < Ethlite::Contract
9 |
10 | address "0x16f5a35647d6f03d5d3da7b35409d65ba03af3b2"
11 |
12 | # function **punkAttributes**(uint16 index) ⇒ (string text) _readonly_
13 | def punkAttributes(index)
14 | do_call("punkAttributes", index)
15 | end
16 | sig "punkAttributes", inputs: ["uint16"], outputs: ["string"]
17 |
18 | # function **punkImage**(uint16 index) ⇒ (bytes _) _readonly_
19 | def punkImage(index)
20 | do_call("punkImage", index)
21 | end
22 | sig "punkImage", inputs: ["uint16"], outputs: ["bytes"]
23 |
24 | # function **punkImageSvg**(uint16 index) ⇒ (string svg) _readonly_
25 | def punkImageSvg(index)
26 | do_call("punkImageSvg", index)
27 | end
28 | sig "punkImageSvg", inputs: ["uint16"], outputs: ["string"]
29 |
30 | end ## class PunksData
31 |
32 |
--------------------------------------------------------------------------------
/tulipmania/lib/tulipmania/ledger.rb:
--------------------------------------------------------------------------------
1 |
2 | class Ledger
3 | attr_reader :wallets ## use addresses - why? why not? for now single address wallet (wallet==address)
4 |
5 | def initialize( chain=[] )
6 | @wallets = {}
7 | chain.each do |block|
8 | apply_transactions( block.transactions )
9 | end
10 | end
11 |
12 | def sufficient_tulips?( wallet, qty, what )
13 | return true if Tulipmania.config.coinbase?( wallet )
14 |
15 | @wallets.has_key?( wallet ) &&
16 | @wallets[wallet].has_key?( what ) &&
17 | @wallets[wallet][what] - qty >= 0
18 | end
19 |
20 |
21 | private
22 |
23 | def apply_transactions( transactions )
24 | transactions.each do |tx|
25 | if sufficient_tulips?(tx.from, tx.qty, tx.what)
26 | @wallets[tx.from][tx.what] -= tx.qty unless Tulipmania.config.coinbase?( tx.from )
27 | @wallets[tx.to] ||= {} ## make sure wallet exists (e.g. init with empty hash {})
28 | @wallets[tx.to][tx.what] ||= 0
29 | @wallets[tx.to][tx.what] += tx.qty
30 | end
31 | end
32 | end
33 |
34 | end ## class Ledger
35 |
--------------------------------------------------------------------------------
/centralbank/lib/centralbank/views/_blockchain.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 | Blockchain
4 | <%= @node.bank.chain.size %> blocks
5 |
6 |
9 |
10 |
11 | <% @node.bank.chain.last(10).reverse.each do |block| %>
12 |
13 |
16 |
17 | <% block.transactions.each do |tx| %>
18 |
19 | |
20 | <%= tx.id[0..2] %>
21 | |
22 |
23 | $<%= tx.amount %>
24 | |
25 |
26 | <%= tx.from[0..15] %> → <%= tx.to[0..15] %>
27 | |
28 |
29 | <% end %>
30 |
31 |
32 | <% end %>
33 |
34 |
35 | †: Miner Transaction - New $$ on the Market!
36 |
37 |
38 |
--------------------------------------------------------------------------------
/attic/bitshilling/lib/shilling/views/_blockchain.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 | Blockchain
4 | <%= @node.bank.chain.size %> blocks
5 |
6 |
9 |
10 |
11 | <% @node.bank.chain.last(10).reverse.each do |block| %>
12 |
13 |
16 |
17 | <% block.transactions.each do |tx| %>
18 |
19 | |
20 | <%= tx.id[0..2] %>
21 | |
22 |
23 | $<%= tx.amount %>
24 | |
25 |
26 | <%= tx.from[0..15] %> → <%= tx.to[0..15] %>
27 | |
28 |
29 | <% end %>
30 |
31 |
32 | <% end %>
33 |
34 |
35 | †: Miner Transaction - New Shillings on the Market!
36 |
37 |
38 |
--------------------------------------------------------------------------------
/tulipmania/Rakefile:
--------------------------------------------------------------------------------
1 | require 'hoe'
2 | require './lib/tulipmania/version.rb'
3 |
4 | Hoe.spec 'tulipmania' do
5 |
6 | self.version = Tulipmania::VERSION
7 |
8 | self.summary = 'tulipmania - tulips on the blockchain; learn by example from the real world (anno 1637) - buy! sell! hodl! enjoy the beauty of admiral of admirals, semper augustus, and more; run your own hyper ledger tulip exchange nodes on the blockchain peer-to-peer over HTTP; revolutionize the world one block at a time'
9 | self.description = summary
10 |
11 | self.urls = ['https://github.com/openblockchains/tulipmania']
12 |
13 | self.author = 'Gerald Bauer'
14 | self.email = 'ruby-talk@ruby-lang.org'
15 |
16 | # switch extension to .markdown for gihub formatting
17 | self.readme_file = 'README.md'
18 | self.history_file = 'History.md'
19 |
20 | self.extra_deps = [
21 | ['sinatra', '>=2.0'],
22 | ['sass'], ## used for css style preprocessing (scss)
23 | ['blockchain-lite', '>=1.3.1'],
24 | ]
25 |
26 | self.licenses = ['Public Domain']
27 |
28 | self.spec_extras = {
29 | required_ruby_version: '>= 2.3'
30 | }
31 |
32 | end
33 |
--------------------------------------------------------------------------------
/tulipmania/lib/tulipmania/views/_blockchain.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 | Blockchain
4 | <%= @node.exchange.chain.size %> blocks
5 |
6 |
9 |
10 |
11 | <% @node.exchange.chain.last(10).reverse.each do |block| %>
12 |
13 |
16 |
17 | <% block.transactions.each do |tx| %>
18 |
19 | |
20 | <%= tx.id[0..2] %>
21 | |
22 |
23 | <%= tx.from[0..15] %> → <%= tx.to[0..15] %>
24 | |
25 |
26 | <%= tx.what %> × <%= tx.qty %>
27 | |
28 |
29 | <% end %>
30 |
31 |
32 | <% end %>
33 |
34 |
35 | †: Grower Transaction - New Tulips on the Market!
36 |
37 |
38 |
--------------------------------------------------------------------------------
/abi2sol/abis/BunchaStructs.abi.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - anonymous: false
3 | inputs:
4 | - components:
5 | - internalType: uint256
6 | name: a
7 | type: uint256
8 | indexed: false
9 | internalType: struct BunchaStructs.A[]
10 | name: a
11 | type: tuple[]
12 | - components:
13 | - components:
14 | - components:
15 | - components:
16 | - internalType: address
17 | name: e
18 | type: address
19 | internalType: struct Other.E
20 | name: e
21 | type: tuple
22 | - internalType: string
23 | name: d
24 | type: string
25 | internalType: struct C[]
26 | name: c
27 | type: tuple[]
28 | internalType: struct B
29 | name: b
30 | type: tuple
31 | - components:
32 | - internalType: address
33 | name: e
34 | type: address
35 | internalType: struct Other.E
36 | name: e
37 | type: tuple
38 | indexed: false
39 | internalType: struct Other.D
40 | name: d
41 | type: tuple
42 | name: Event
43 | type: event
44 |
--------------------------------------------------------------------------------
/ethlite/.gitignore:
--------------------------------------------------------------------------------
1 | *.gem
2 | *.rbc
3 | /.config
4 | /coverage/
5 | /InstalledFiles
6 | /pkg/
7 | /spec/reports/
8 | /test/tmp/
9 | /test/version_tmp/
10 | /tmp/
11 |
12 | ## Specific to RubyMotion:
13 | .dat*
14 | .repl_history
15 | build/
16 |
17 | ## Documentation cache and generated files:
18 | /.yardoc/
19 | /_yardoc/
20 | /doc/
21 | /rdoc/
22 |
23 | ## Environment normalisation:
24 | /.bundle/
25 | /vendor/bundle
26 | /lib/bundler/man/
27 |
28 | # for a library or gem, you might want to ignore these files since the code is
29 | # intended to run in multiple environments; otherwise, check them in:
30 | # Gemfile.lock
31 | .ruby-version
32 | .ruby-gemset
33 |
34 | # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35 | .rvmrc
36 |
37 | # Gladiator (Glimmer Editor)
38 | .gladiator
39 | .DS_Store
40 |
41 |
42 |
43 | ####
44 | # exclude all tmp & tmp2 and o directory (in all levels)
45 | tmp/
46 | tmp2/
47 | o/
48 |
49 | ########
50 | # exclude all dbs e.g. artbase.db etc.
51 | *.db
52 |
53 | ######
54 | # exclude all zips (in /dl)
55 | *.zip
56 |
57 |
58 | # do NOT check in dev/test enviroment variables in .env (dot env files)
59 | .env
60 |
61 |
--------------------------------------------------------------------------------
/ethlite/lib/ethlite/utils.rb:
--------------------------------------------------------------------------------
1 | module Ethlite
2 |
3 |
4 | module Helpers
5 | def keccak256( bin )
6 | # Digest::SHA3.new(256).digest(x)
7 | ## Digest::Keccak.digest(x, 256)
8 | Digest::KeccakLite.new(256).digest( bin )
9 | end
10 |
11 | def encode_hex( bin ) ## bin_to_hex
12 | raise TypeError, "Value must be a string" unless bin.is_a?( String )
13 | ## note: always return a hex string with default encoding e.g. utf-8 - why? why not?
14 | bin.unpack("H*").first.force_encoding( Encoding::UTF_8 )
15 | end
16 | alias_method :bin_to_hex, :encode_hex
17 |
18 | def decode_hex( hex ) ## hex_to_bin
19 | raise TypeError, "Value must be a string" unless hex.is_a?( String )
20 | raise TypeError, 'Non-hexadecimal char found' unless hex.empty? || hex =~ /\A(0x)?[0-9a-fA-F]{2,}\z/
21 |
22 | ## allow optional starting 0x - why? why not?
23 | hex = hex[2..-1] if hex[0,2] == '0x'
24 |
25 | [hex].pack("H*")
26 | end
27 | alias_method :hex_to_bin, :decode_hex
28 | end # module Helpers
29 |
30 |
31 |
32 | module Utils
33 | extend Helpers
34 | end
35 |
36 | end # module Ethlite
37 |
38 |
--------------------------------------------------------------------------------
/ethers/.gitignore:
--------------------------------------------------------------------------------
1 | *.gem
2 | *.rbc
3 | /.config
4 | /coverage/
5 | /InstalledFiles
6 | /pkg/
7 | /spec/reports/
8 | /test/tmp/
9 | /test/version_tmp/
10 | /tmp/
11 |
12 | ## Specific to RubyMotion:
13 | .dat*
14 | .repl_history
15 | build/
16 |
17 | ## Documentation cache and generated files:
18 | /.yardoc/
19 | /_yardoc/
20 | /doc/
21 | /rdoc/
22 |
23 | ## Environment normalisation:
24 | /.bundle/
25 | /vendor/bundle
26 | /lib/bundler/man/
27 |
28 | # for a library or gem, you might want to ignore these files since the code is
29 | # intended to run in multiple environments; otherwise, check them in:
30 | # Gemfile.lock
31 | .ruby-version
32 | .ruby-gemset
33 |
34 | # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35 | .rvmrc
36 |
37 | # Gladiator (Glimmer Editor)
38 | .gladiator
39 | .DS_Store
40 |
41 |
42 |
43 | ####
44 | # exclude all tmp & tmp2 and o directory (in all levels)
45 | tmp/
46 | tmp2/
47 | o/
48 |
49 | ########
50 | # exclude all dbs e.g. artbase.db etc.
51 | *.db
52 |
53 | ######
54 | # exclude all zips (in /dl)
55 | *.zip
56 |
57 |
58 | # do NOT check in dev/test enviroment variables in .env (dot env files)
59 | .env
60 |
61 |
62 |
--------------------------------------------------------------------------------
/attic/bitshilling/Rakefile:
--------------------------------------------------------------------------------
1 | require 'hoe'
2 | require './lib/shilling/version.rb'
3 |
4 | Hoe.spec 'shilling' do
5 |
6 | self.version = Shilling::VERSION
7 |
8 | self.summary = 'shilling (or schilling) on the blockchain! rock-solid alpine dollar from austria; print (mine) your own shillings; run your own federated shilling central bank nodes w/ public distributed (hyper) ledger book on the blockchain peer-to-peer over HTTP; revolutionize the world one block at a time with cryptos'
9 | self.description = summary
10 |
11 | self.urls = ['https://github.com/bitshilling/bitshilling.tools']
12 |
13 | self.author = 'Gerald Bauer'
14 | self.email = 'ruby-talk@ruby-lang.org'
15 |
16 | # switch extension to .markdown for gihub formatting
17 | self.readme_file = 'README.md'
18 | self.history_file = 'History.md'
19 |
20 | self.extra_deps = [
21 | ['sinatra', '>=2.0'],
22 | ['sass'], ## used for css style preprocessing (scss)
23 | ['blockchain-lite', '>=1.4.0'],
24 | ['ledger-lite', '>=1.1.1' ]
25 | ]
26 |
27 |
28 | self.licenses = ['Public Domain']
29 |
30 | self.spec_extras = {
31 | required_ruby_version: '>= 2.3'
32 | }
33 |
34 | end
35 |
--------------------------------------------------------------------------------
/centralbank/lib/centralbank/pool.rb:
--------------------------------------------------------------------------------
1 | ####################################
2 | # pending (unconfirmed) transactions (mem) pool
3 |
4 | class Pool
5 | extend Forwardable
6 | def_delegators :@transactions, :[], :size, :each, :empty?, :any?
7 |
8 |
9 | def initialize( transactions=[] )
10 | @transactions = transactions
11 | end
12 |
13 | def transactions() @transactions; end
14 |
15 | def <<( tx )
16 | @transactions << tx
17 | end
18 |
19 |
20 | def update!( txns_confirmed )
21 | ## find a better name?
22 | ## remove confirmed transactions from pool
23 |
24 | ## document - keep only pending transaction not yet (confirmed) in blockchain ????
25 | @transactions = @transactions.select do |tx_unconfirmed|
26 | txns_confirmed.none? { |tx_confirmed| tx_confirmed.id == tx_unconfirmed.id }
27 | end
28 | end
29 |
30 |
31 |
32 | def as_json
33 | @transactions.map { |tx| tx.to_h }
34 | end
35 |
36 | def self.from_json( data )
37 | ## note: assumes data is an array of block records/objects in json
38 | transactions = data.map { |h| Tx.from_h( h ) }
39 | self.new( transactions )
40 | end
41 |
42 | end # class Pool
43 |
--------------------------------------------------------------------------------
/tulipmania/lib/tulipmania/pool.rb:
--------------------------------------------------------------------------------
1 | ####################################
2 | # pending (unconfirmed) transactions (mem) pool
3 |
4 | class Pool
5 | extend Forwardable
6 | def_delegators :@transactions, :[], :size, :each, :empty?, :any?
7 |
8 |
9 | def initialize( transactions=[] )
10 | @transactions = transactions
11 | end
12 |
13 | def transactions() @transactions; end
14 |
15 | def <<( tx )
16 | @transactions << tx
17 | end
18 |
19 |
20 | def update!( txns_confirmed )
21 | ## find a better name?
22 | ## remove confirmed transactions from pool
23 |
24 | ## document - keep only pending transaction not yet (confirmed) in blockchain ????
25 | @transactions = @transactions.select do |tx_unconfirmed|
26 | txns_confirmed.none? { |tx_confirmed| tx_confirmed.id == tx_unconfirmed.id }
27 | end
28 | end
29 |
30 |
31 |
32 | def as_json
33 | @transactions.map { |tx| tx.to_h }
34 | end
35 |
36 | def self.from_json( data )
37 | ## note: assumes data is an array of block records/objects in json
38 | transactions = data.map { |h| Tx.from_h( h ) }
39 | self.new( transactions )
40 | end
41 |
42 | end # class Pool
43 |
--------------------------------------------------------------------------------
/attic/bitshilling/lib/shilling/pool.rb:
--------------------------------------------------------------------------------
1 | ####################################
2 | # pending (unconfirmed) transactions (mem) pool
3 |
4 | class Pool
5 | extend Forwardable
6 | def_delegators :@transactions, :[], :size, :each, :empty?, :any?
7 |
8 |
9 | def initialize( transactions=[] )
10 | @transactions = transactions
11 | end
12 |
13 | def transactions() @transactions; end
14 |
15 | def <<( tx )
16 | @transactions << tx
17 | end
18 |
19 |
20 | def update!( txns_confirmed )
21 | ## find a better name?
22 | ## remove confirmed transactions from pool
23 |
24 | ## document - keep only pending transaction not yet (confirmed) in blockchain ????
25 | @transactions = @transactions.select do |tx_unconfirmed|
26 | txns_confirmed.none? { |tx_confirmed| tx_confirmed.id == tx_unconfirmed.id }
27 | end
28 | end
29 |
30 |
31 |
32 | def as_json
33 | @transactions.map { |tx| tx.to_h }
34 | end
35 |
36 | def self.from_json( data )
37 | ## note: assumes data is an array of block records/objects in json
38 | transactions = data.map { |h| Tx.from_h( h ) }
39 | self.new( transactions )
40 | end
41 |
42 | end # class Pool
43 |
--------------------------------------------------------------------------------
/ethlite-contracts/.gitignore:
--------------------------------------------------------------------------------
1 | *.gem
2 | *.rbc
3 | /.config
4 | /coverage/
5 | /InstalledFiles
6 | /pkg/
7 | /spec/reports/
8 | /test/tmp/
9 | /test/version_tmp/
10 | /tmp/
11 |
12 | ## Specific to RubyMotion:
13 | .dat*
14 | .repl_history
15 | build/
16 |
17 | ## Documentation cache and generated files:
18 | /.yardoc/
19 | /_yardoc/
20 | /doc/
21 | /rdoc/
22 |
23 | ## Environment normalisation:
24 | /.bundle/
25 | /vendor/bundle
26 | /lib/bundler/man/
27 |
28 | # for a library or gem, you might want to ignore these files since the code is
29 | # intended to run in multiple environments; otherwise, check them in:
30 | # Gemfile.lock
31 | .ruby-version
32 | .ruby-gemset
33 |
34 | # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35 | .rvmrc
36 |
37 | # Gladiator (Glimmer Editor)
38 | .gladiator
39 | .DS_Store
40 |
41 |
42 |
43 | ####
44 | # exclude all tmp & tmp2 and o directory (in all levels)
45 | tmp/
46 | tmp2/
47 | o/
48 |
49 | ########
50 | # exclude all dbs e.g. artbase.db etc.
51 | *.db
52 |
53 | ######
54 | # exclude all zips (in /dl)
55 | *.zip
56 |
57 |
58 | # do NOT check in dev/test enviroment variables in .env (dot env files)
59 | .env
60 |
61 |
62 |
--------------------------------------------------------------------------------
/ethlite-contracts/lib/ethlite-contracts.rb:
--------------------------------------------------------------------------------
1 | ## 3rd party gems
2 | require 'ethlite'
3 |
4 |
5 |
6 |
7 | ## our own code
8 |
9 | # shared base contract machinery - keep here
10 | ## or rename to Base or such - why? why not?
11 | require_relative 'ethlite/contract'
12 |
13 | ### generated contracts via abigen
14 | require_relative 'ethlite/contracts/punks_v1'
15 | require_relative 'ethlite/contracts/punk_blocks'
16 | require_relative 'ethlite/contracts/punks_meta'
17 |
18 | require_relative 'ethlite/contracts/mooncats'
19 | require_relative 'ethlite/contracts/phunks_v2'
20 | require_relative 'ethlite/contracts/punks_data'
21 | require_relative 'ethlite/contracts/synth_punks'
22 | require_relative 'ethlite/contracts/moonbirds'
23 | require_relative 'ethlite/contracts/marcs'
24 | require_relative 'ethlite/contracts/mad_camels'
25 |
26 | require_relative 'ethlite/contracts/nouns'
27 | require_relative 'ethlite/contracts/nouns_auction_house'
28 | require_relative 'ethlite/contracts/nouns_seeder'
29 | require_relative 'ethlite/contracts/nouns_descriptor'
30 | require_relative 'ethlite/contracts/nouns_descriptor_v2'
31 | require_relative 'ethlite/contracts/synth_nouns'
32 |
--------------------------------------------------------------------------------
/abiparser/lib/abiparser/utils.rb:
--------------------------------------------------------------------------------
1 | module ABI
2 | module Helpers
3 |
4 |
5 | SIGHASH_RX = /\A
6 | (0x)?
7 | (?[0-9a-f]{8})
8 | \z/ix
9 |
10 | def support?( selectors, sig )
11 | if sig.is_a?( Interface )
12 | iface = sig
13 | iface.selectors.each do |sighash|
14 | unless selectors.include?( sighash )
15 | puts " sighash >#{sighash}< not found in interface"
16 | return false
17 | end
18 | end
19 | true
20 | else
21 | sighash = if m=SIGHASH_RX.match( sig )
22 | m[:sighash].downcase ## assume it's sighash (hexstring)
23 | else
24 | ## for convenience allow (white)spaces; auto-strip - why? why not?
25 | sig = sig.gsub( /[ \r\t\n]/, '' )
26 | keccak256( sig )[0,4].hexdigest
27 | end
28 |
29 | selectors.include?( sighash ) ? true : false
30 | end
31 | end
32 | end # module Helpers
33 |
34 |
35 | module Utils
36 | extend Helpers
37 | ## e.g. Utils.supports?( selectors, sig ) etc.
38 | end
39 |
40 | end # module ABI
--------------------------------------------------------------------------------
/attic/bitshilling/lib/shilling/blockchain.rb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | class Blockchain
5 | extend Forwardable
6 | def_delegators :@chain, :[], :size, :each, :empty?, :any?, :last
7 |
8 |
9 | def initialize( chain=[] )
10 | @chain = chain
11 | end
12 |
13 | def <<( txs )
14 | ## todo: check if is block or array
15 | ## if array (of transactions) - auto-add (build) block
16 | ## allow block - why? why not?
17 | ## for now just use transactions (keep it simple :-)
18 |
19 | if @chain.size == 0
20 | block = Block.first( txs )
21 | else
22 | block = Block.next( @chain.last, txs )
23 | end
24 | @chain << block
25 | end
26 |
27 |
28 |
29 | def as_json
30 | @chain.map { |block| block.to_h }
31 | end
32 |
33 | def transactions
34 | ## "accumulate" get all transactions from all blocks "reduced" into a single array
35 | @chain.reduce( [] ) { |acc, block| acc + block.transactions }
36 | end
37 |
38 |
39 |
40 | def self.from_json( data )
41 | ## note: assumes data is an array of block records/objects in json
42 | chain = data.map { |h| Block.from_h( h ) }
43 | self.new( chain )
44 | end
45 |
46 |
47 | end # class Blockchain
48 |
--------------------------------------------------------------------------------
/centralbank/lib/centralbank/blockchain.rb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | class Blockchain
5 | extend Forwardable
6 | def_delegators :@chain, :[], :size, :each, :empty?, :any?, :last
7 |
8 |
9 | def initialize( chain=[] )
10 | @chain = chain
11 | end
12 |
13 | def <<( txs )
14 | ## todo: check if is block or array
15 | ## if array (of transactions) - auto-add (build) block
16 | ## allow block - why? why not?
17 | ## for now just use transactions (keep it simple :-)
18 |
19 | if @chain.size == 0
20 | block = Block.first( txs )
21 | else
22 | block = Block.next( @chain.last, txs )
23 | end
24 | @chain << block
25 | end
26 |
27 |
28 |
29 | def as_json
30 | @chain.map { |block| block.to_h }
31 | end
32 |
33 | def transactions
34 | ## "accumulate" get all transactions from all blocks "reduced" into a single array
35 | @chain.reduce( [] ) { |acc, block| acc + block.transactions }
36 | end
37 |
38 |
39 |
40 | def self.from_json( data )
41 | ## note: assumes data is an array of block records/objects in json
42 | chain = data.map { |h| Block.from_h( h ) }
43 | self.new( chain )
44 | end
45 |
46 |
47 | end # class Blockchain
48 |
--------------------------------------------------------------------------------
/centralbank/lib/centralbank/block.rb:
--------------------------------------------------------------------------------
1 |
2 |
3 | Block = BlockchainLite::ProofOfWork::Block
4 |
5 | ## see https://github.com/openblockchains/blockchain.lite.rb/blob/master/lib/blockchain-lite/proof_of_work/block.rb
6 |
7 | ######
8 | ## add more methods
9 |
10 | class Block
11 |
12 |
13 | def to_h
14 | { index: @index,
15 | timestamp: @timestamp,
16 | nonce: @nonce,
17 | transactions: @transactions.map { |tx| tx.to_h },
18 | transactions_hash: @transactions_hash,
19 | previous_hash: @previous_hash,
20 | hash: @hash }
21 | end
22 |
23 | def self.from_h( h )
24 | transactions = h['transactions'].map { |h_tx| Tx.from_h( h_tx ) }
25 |
26 | ## todo: use hash and transactions_hash to check integrity of block - why? why not?
27 |
28 | ## parse iso8601 format e.g 2017-10-05T22:26:12-04:00
29 | timestamp = Time.parse( h['timestamp'] )
30 |
31 | self.new( h['index'],
32 | transactions,
33 | h['previous_hash'],
34 | timestamp: timestamp,
35 | nonce: h['nonce'].to_i )
36 | end
37 |
38 |
39 | def valid?
40 | true ## for now always valid
41 | end
42 |
43 |
44 | end # class Block
45 |
--------------------------------------------------------------------------------
/rlp-lite/test/test_sedes.rb:
--------------------------------------------------------------------------------
1 | ##
2 | # to run use
3 | # ruby -I ./lib -I ./test test/test_sedes.rb
4 |
5 |
6 | require 'helper'
7 |
8 |
9 |
10 | class TestRlp < MiniTest::Test
11 |
12 | PAIRS =
13 | [
14 | [5, Rlp::Sedes.big_endian_int],
15 | [0, Rlp::Sedes.big_endian_int],
16 | [-1, nil],
17 | ["", Rlp::Sedes.binary],
18 | ["asdf", Rlp::Sedes.binary],
19 | ['\xe4\xf6\xfc\xea\xe2\xfb', Rlp::Sedes.binary],
20 | [[], Rlp::Sedes::List.new],
21 | [[1, 2, 3], Rlp::Sedes::List.new(elements: [Rlp::Sedes.big_endian_int,
22 | Rlp::Sedes.big_endian_int,
23 | Rlp::Sedes.big_endian_int])],
24 | [[[], "asdf"], Rlp::Sedes::List.new(elements: [[], Rlp::Sedes.binary])],
25 | ]
26 |
27 |
28 | def test_infer
29 | PAIRS.each do |obj, sedes|
30 | if sedes.nil?
31 | assert_raises( TypeError ) {
32 | Rlp::Sedes.infer( obj )
33 | }
34 | else
35 | inferred = Rlp::Sedes.infer( obj )
36 | assert_equal sedes, inferred
37 | end
38 | end
39 | end
40 |
41 | end
42 |
43 |
--------------------------------------------------------------------------------
/ethlite-contracts/lib/ethlite/contract.rb:
--------------------------------------------------------------------------------
1 |
2 |
3 | module Ethlite
4 |
5 | class Contract
6 |
7 |
8 | def self.at( address )
9 | puts " creating new contract #{self.name} @ #{address}"
10 | new( address )
11 | end
12 |
13 |
14 | def self.sig( name, inputs: [], outputs: [] )
15 | @methods ||= {}
16 | @methods[ name ] = ContractMethod.new( name,
17 | inputs: inputs,
18 | outputs: outputs )
19 | @methods
20 | end
21 | def self.methods()
22 | @methods ||= {}
23 | @methods
24 | end
25 |
26 |
27 |
28 | def self.address( address )
29 | @address = address
30 | @address
31 | end
32 |
33 | def self.default_address()
34 | defined?( @address ) ? @address : nil
35 | end
36 |
37 | def initialize( address = self.class.default_address )
38 | @address = address
39 | end
40 |
41 |
42 | def do_call( name, *args )
43 | puts "==> calling #{self.class.name}##{name} with args:"
44 | pp args
45 | method = self.class.methods[ name ]
46 | ## pp m
47 | method.do_call( Ethlite.config.rpc, @address, args )
48 | end
49 |
50 | end ## class Contract
51 |
52 |
53 | end ## module Ethlite
--------------------------------------------------------------------------------
/cryptoquotes/data/Crypto_US$_Stablecoin_Printer.yml:
--------------------------------------------------------------------------------
1 | ################
2 | # Crypto US$ Stablecoin Printer - TrueUSD, TrustToken, USDCoin or Tether
3 | #
4 | # see https://twitter.com/usdcoinprinter
5 |
6 |
7 | - quote: |
8 | Just printed $200,000,000 USDT!
9 |
10 | Total circulating USDT (Tether) supply: $20,533,323,926
11 | source: https://twitter.com/usdcoinprinter/status/1339001081662214145
12 |
13 | - quote: |
14 | Just printed $149,786,927 USDT!
15 |
16 | Total circulating USDT (Tether) supply: $20,333,323,926
17 | source: https://twitter.com/usdcoinprinter/status/1337551507319873539
18 |
19 | - quote: |
20 | Just printed $320,000,000 USDT!
21 |
22 | Total circulation USDT (Tether) supply: $18,783,536,999
23 | source: https://twitter.com/usdcoinprinter/status/1329941363132145672
24 |
25 | - quote: |
26 | Just printed $37,806,778 USDC!
27 |
28 | Total circulating USDC (USD Coin) supply: $3,308,104,351
29 | source: https://twitter.com/usdcoinprinter/status/1339272856807608321
30 |
31 | - quote: |
32 | Just printed $29,807,927 TUSD!
33 |
34 | Total circulating TUSD (True USD) supply: $514,347,179
35 | source: https://twitter.com/usdcoinprinter/status/1306181045839069184
36 |
37 |
--------------------------------------------------------------------------------
/ledger-lite/.gitignore:
--------------------------------------------------------------------------------
1 | *.gem
2 | *.rbc
3 | /.config
4 | /coverage/
5 | /InstalledFiles
6 | /pkg/
7 | /spec/reports/
8 | /spec/examples.txt
9 | /test/tmp/
10 | /test/version_tmp/
11 | /tmp/
12 |
13 | # Used by dotenv library to load environment variables.
14 | # .env
15 |
16 | ## Specific to RubyMotion:
17 | .dat*
18 | .repl_history
19 | build/
20 | *.bridgesupport
21 | build-iPhoneOS/
22 | build-iPhoneSimulator/
23 |
24 | ## Specific to RubyMotion (use of CocoaPods):
25 | #
26 | # We recommend against adding the Pods directory to your .gitignore. However
27 | # you should judge for yourself, the pros and cons are mentioned at:
28 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
29 | #
30 | # vendor/Pods/
31 |
32 | ## Documentation cache and generated files:
33 | /.yardoc/
34 | /_yardoc/
35 | /doc/
36 | /rdoc/
37 |
38 | ## Environment normalization:
39 | /.bundle/
40 | /vendor/bundle
41 | /lib/bundler/man/
42 |
43 | # for a library or gem, you might want to ignore these files since the code is
44 | # intended to run in multiple environments; otherwise, check them in:
45 | # Gemfile.lock
46 | # .ruby-version
47 | # .ruby-gemset
48 |
49 | # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
50 | .rvmrc
51 |
--------------------------------------------------------------------------------
/merkletree/NOTES.md:
--------------------------------------------------------------------------------
1 | # Notes
2 |
3 | ## Todos
4 |
5 | - add from array in ctor ??
6 | - add parent to node - why? why not? needed for??
7 |
8 |
9 | ## Ruby Libraries / Code
10 |
11 | - https://github.com/piotrmurach/merkle_tree
12 |
13 | - https://github.com/mpalmer/merkle-hash-tree
14 | - read up on -> http://www.rubydoc.info/gems/merkle-hash-tree/0.1.1
15 |
16 | - https://github.com/phad/merkle
17 |
18 |
19 | - https://github.com/lian/bitcoin-ruby/blob/master/lib/bitcoin/protocol/partial_merkle_tree.rb
20 |
21 |
22 | ## Go Libraries / Code
23 |
24 | - https://github.com/cbergoon/merkletree
25 |
26 |
27 | ## Java Script Libraries / Code
28 |
29 | - https://www.npmjs.com/package/merkle
30 | - https://www.npmjs.com/package/merkle-tools
31 | - https://www.npmjs.com/package/merkletree
32 | - https://www.npmjs.com/package/mtree
33 |
34 | ## Articles
35 |
36 | Understanding Merkle Trees - Why use them, who uses them, and how to use them by Marc Clifton, Mar 2017
37 | - https://www.codeproject.com/Articles/1176140/Understanding-Merkle-Trees-Why-use-them-who-uses-t
38 |
39 |
40 | More
41 |
42 | - https://bitcoin.org/en/glossary/merkle-tree
43 | - https://bitcoin.org/en/developer-guide#term-merkle-tree
44 | - https://github.com/bitcoinbook/bitcoinbook/blob/second_edition/ch09.asciidoc
45 |
--------------------------------------------------------------------------------
/abi2sol/abis/DepositContract.abi.json:
--------------------------------------------------------------------------------
1 | [{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes","name":"pubkey","type":"bytes"},{"indexed":false,"internalType":"bytes","name":"withdrawal_credentials","type":"bytes"},{"indexed":false,"internalType":"bytes","name":"amount","type":"bytes"},{"indexed":false,"internalType":"bytes","name":"signature","type":"bytes"},{"indexed":false,"internalType":"bytes","name":"index","type":"bytes"}],"name":"DepositEvent","type":"event"},{"inputs":[{"internalType":"bytes","name":"pubkey","type":"bytes"},{"internalType":"bytes","name":"withdrawal_credentials","type":"bytes"},{"internalType":"bytes","name":"signature","type":"bytes"},{"internalType":"bytes32","name":"deposit_data_root","type":"bytes32"}],"name":"deposit","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"get_deposit_count","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"get_deposit_root","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"}]
2 |
--------------------------------------------------------------------------------
/digest-lite/test/test_standard.rb:
--------------------------------------------------------------------------------
1 | ##
2 | # to run use
3 | # ruby -I ./lib -I ./test test/test_standard.rb
4 |
5 |
6 | require 'helper'
7 |
8 |
9 |
10 | class TestStandard < MiniTest::Test
11 |
12 |
13 | def test_algos
14 | pp Digest::MD5.hexdigest( 'abc' )
15 |
16 | pp Digest::RMD160.hexdigest( 'abc' )
17 |
18 | pp Digest::SHA1.hexdigest( 'abc' )
19 |
20 | pp Digest::SHA2.new(256).hexdigest( 'abc' ) # or
21 | pp Digest::SHA256.hexdigest( 'abc' )
22 |
23 | pp Digest::SHA2.new(384).hexdigest 'abc' # or
24 | pp Digest::SHA384.hexdigest 'abc'
25 |
26 | pp Digest::SHA2.new(512).hexdigest 'abc' # or
27 | pp Digest::SHA512.hexdigest 'abc'
28 | end
29 |
30 |
31 | def test_more_algos
32 | pp Digest::KeccakLite.new( 256 ).hexdigest( 'abc' ) # or
33 | pp Digest::KeccakLite.hexdigest( 'abc', 256 )
34 |
35 | pp Digest::SHA3Lite.new( 224 ).hexdigest( 'abc' ) # or
36 | pp Digest::SHA3Lite.hexdigest( 'abc', 224 )
37 |
38 | pp Digest::SHA3Lite.new( 256 ).hexdigest( 'abc' ) # or
39 | pp Digest::SHA3Lite.hexdigest( 'abc', 256 )
40 |
41 | pp Digest::SHA3Lite.new( 384 ).hexdigest( 'abc' ) # or
42 | pp Digest::SHA3Lite.hexdigest( 'abc', 384 )
43 |
44 | pp Digest::SHA3Lite.new( 512 ).hexdigest( 'abc' ) # or
45 | pp Digest::SHA3Lite.hexdigest( 'abc', 512 )
46 | end
47 |
48 | end # class TestStandard
--------------------------------------------------------------------------------
/ethname/config/contracts.2021.csv:
--------------------------------------------------------------------------------
1 | address, names, interfaces, created
2 | 0x16f5a35647d6f03d5d3da7b35409d65ba03af3b2, punks data | crypto punks data,, 2021-08-18 00:10:24
3 | 0xf4a4644e818c2843ba0aabea93af6c80b5984114, punks v1 wrapped i | classic punks, erc721, 2021-03-25 04:26:43
4 |
5 | 0xa82f3a61f002f83eba7d184c50bb2a8b359ca1ce, phunks v1 | philips, erc721, 2021-06-14 04:18:53
6 | 0xf07468ead8cf26c752c676e43c814fee9c8cf402, phunks v2 | phunks, erc721, 2021-06-21 00:07:08
7 |
8 | 0x031920cc2d9f5c10b444fd44009cd64f829e7be2, zunks, erc721, 2021-08-07 04:01:17
9 |
10 | 0x0d0167a823c6619d430b1a96ad85b888bcf97c37, xpunks | expansion punks, erc721, 2021-08-15 00:13:20
11 | 0x71eb5c179ceb640160853144cbb8df5bd24ab5cc, xphunks | expansion phunks, erc721, 2021-12-30 10:14:39
12 |
13 |
14 | 0x7c40c393dc0f283f318791d746d894ddd3693572, mooncats wrapped, erc721, 2021-03-12 20:20:10
15 | 0xc3f733ca98e0dad0386979eb96fb1722a1a05e69, acclimated mooncats | mooncats acclimated, erc721, 2021-04-22 01:52:09
16 |
17 |
18 |
19 | 0x0cfdb3ba1694c2bb2cfacb0339ad7b1ae5932b63, nouns descriptor,, 2021-08-08 16:00:38
20 | 0xcc8a0fb5ab3c7132c1b2a0109142fb112c4ce515, nouns seeder,, 2021-08-08 16:01:13
21 | 0x9c8ff314c9bc7f6e59a9d9225fb22946427edc03, nouns token | nouns,, 2021-08-08 16:02:23
22 | 0xf15a943787014461d94da08ad4040f79cd7c124e, nouns auction house,, 2021-08-08-2021 16:03:33
23 |
--------------------------------------------------------------------------------
/abiparser/lib/abiparser/event.rb:
--------------------------------------------------------------------------------
1 | module ABI
2 | class Event
3 |
4 | def self.parse( o )
5 | ## todo/fix: assert type function (or contructor) ??
6 | name = o['name']
7 | inputs = o['inputs'].map {|param| Param.parse( param ) }
8 |
9 | new( name, inputs: inputs )
10 | end
11 |
12 |
13 | attr_reader :name,
14 | :inputs
15 | ## :input_types
16 |
17 | def initialize( name,
18 | inputs: [] )
19 | @name = name
20 | @inputs = inputs
21 | end
22 |
23 |
24 | def sig
25 | ## note: signature
26 | ## only includes name and inputs
27 |
28 | ##
29 | ## todo/fix: check if event sig includes indexed or/and
30 | ## special prefix or such!!!!
31 |
32 | buf = "#{@name}"
33 | if @inputs.empty?
34 | buf << "()"
35 | else
36 | params = @inputs.map {|param| param.sig }
37 | buf << "(#{params.join(',')})"
38 | end
39 | buf
40 | end
41 |
42 | def sighash
43 | keccak256( sig )[0,4].hexdigest
44 | end
45 |
46 |
47 |
48 |
49 | def types
50 | ## for debugging / analytics return all used types (input+output)
51 | @inputs.map {|param| param.type }
52 | end
53 |
54 | end ## class Event
55 | end ## module ABI
56 |
57 |
--------------------------------------------------------------------------------
/centralbank/NOTES.md:
--------------------------------------------------------------------------------
1 | # Notes
2 |
3 |
4 | ## Todos
5 |
6 | - [ ] add favicon.png - why? why not? (see webservice gem)
7 | - [ ] add a Pool class (for pending transaction pool) !!!!!
8 | - [ ] add secure versions with signature e.g. SecureWallet, SecureTransaction, etc.
9 |
10 | ```
11 | Source: https://www.reddit.com/r/ruby/comments/7ly337/day_24_ruby_advent_calendar_2017_centralbank/
12 |
13 | I'm playing with your Ruby blockchain stuff. It's very good. It's giving me a way to learn it without having to learn Go or C++ at the same time. But...
14 |
15 | When I try running central bank from the command line as described in blockchains section 6. using
16 |
17 | centralbank
18 | it doesn't work because centralbank is in the bin/ directory, so I tried (after setting chmod +x etc)
19 |
20 | bin/centralbank
21 | and then got an error I've never seen before
22 |
23 | env: ruby\r: No such file or directory
24 | So I wrote added one space at the end of the shebang header line That removed the extra \r and I then progressed to
25 |
26 | bin/centralbank
27 | Traceback (most recent call last):
28 | (LoadError)h file or directory --
29 | Because it doesn't know where the library path is. If I run with
30 |
31 | ruby -Ilib bin/centralbank
32 | Then it's fine.
33 |
34 | So you need to do something to remove that \r at the end of the shebang line, and add the library path before the require.
35 | ```
36 |
--------------------------------------------------------------------------------
/ethlite-contracts/sandbox/test_punks.rb:
--------------------------------------------------------------------------------
1 | ###
2 | # to run use
3 | # ruby -I ./lib sandbox/test_punks.rb
4 |
5 |
6 |
7 | require 'ethlite/contracts'
8 |
9 |
10 | ###############################
11 | # try Punks V1 contract
12 | punksv1 = PunksV1.new ## note: will use default (eth main network) contract address
13 |
14 | pp punksv1
15 |
16 |
17 | pp punksv1.name
18 | pp punksv1.symbol
19 | pp punksv1.numberOfPunksReserved
20 | pp punksv1.totalSupply
21 | pp punksv1.imageHash
22 | pp punksv1.balanceOf( '0x0000000000000000000000000000000000000000' )
23 |
24 |
25 | ##################################
26 | # try Punk Blocks contract
27 | punkblocks = PunkBlocks.new ## note: will use default (eth main network) contract address
28 |
29 |
30 | pp punkblocks.getBlocks( 0, 1 ) ## _fromID, _count
31 |
32 |
33 |
34 | ############################
35 | # try Punks Meta contract
36 |
37 | punksmeta = PunksMeta.new
38 |
39 | tokenId = 0
40 | pp punksmeta.parseAttributes( tokenId )
41 | pp punksmeta.getAttributes( tokenId )
42 | pp punksmeta.tokenURI( tokenId )
43 |
44 |
45 | ############################
46 | # try Punks Data contract
47 | punksdata = PunksData.new
48 |
49 | tokenId = 0
50 | pp punksdata.punkAttributes( tokenId )
51 | pp punksdata.punkImage( tokenId )
52 | pp punksdata.punkImageSvg( tokenId )
53 |
54 |
55 | puts "bye"
56 |
--------------------------------------------------------------------------------