Sha256: d5d6c415f03457462705ac1c004a9452b8260a8f7b78e143af04d9dce54b0b01
Contents?: true
Size: 993 Bytes
Versions: 2
Compression:
Stored size: 993 Bytes
Contents
#!/usr/bin/env ruby require 'bundler/setup' require 'scale_rb' require 'json' require 'optparse' # ./exe/metadata https://polkadot-rpc.dwellir.com -b 0xfc2d86c5a2cc92b7770dcc14e74116912c9f848000b5f4ceca6fe1475588692c # ./exe/metadata https://polkadot-rpc.dwellir.com -b 22931689 # ./exe/metadata https://polkadot-rpc.dwellir.com @options = {} parser = OptionParser.new do |opts| opts.banner = 'Usage: metadata [url] [options]' opts.on('-bNUMBERORHASH', '--block=NUMBERORHASH', 'Block number or hash') do |value| @options[:block] = value end end if ARGV.empty? puts parser else parser.parse! url = ARGV[0] client = ScaleRb::HttpClient.new(url) block_hash = nil if @options[:block] if @options[:block].length == 66 block_hash = @options[:block] else block_number = @options[:block].to_i block_hash = client.chain_getBlockHash(block_number) end end metadata = client.get_metadata(block_hash) puts JSON.pretty_generate(metadata) end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
scale_rb-0.5.1 | exe/metadata |
scale_rb-0.5.0 | exe/metadata |