Skip to content

Instantly share code, notes, and snippets.

@icostan
Created December 11, 2018 09:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save icostan/4f08312c794e7fa7a785f91903d4181f to your computer and use it in GitHub Desktop.
Save icostan/4f08312c794e7fa7a785f91903d4181f to your computer and use it in GitHub Desktop.

Release: Cryptos-ruby project

I just want to announce the very first release [v0.0.3] of Cryptos-ruby project, a simple and very easy to use Ruby API to manipulate multiple crypto coins.

For more information please check Github project page.

Features

  • Generate private/public keys
  • Generate Bitcoin/Litecoin addresses (more to come)
  • Create Bitcoin/Litecoin transactions
  • Execute atomic swaps between Bitcoin and Litecoin

Installation

gem install cryptos

Usage

# Importing library...
2.5.1 :001 > require 'cryptos'

# Generating private key...
2.5.1 :003 > private_key = Cryptos::PrivateKey.generate
 => #<Cryptos::PrivateKey:0x00007fc9d123e2e8 @value=47930083789607287790662857866073624449854924554643360243140359905082181414216, @order=115792089237316195423570985008687907852837564279074904382605163141518161494337>

# Generating public key...
2.5.1 :004 > public_key = Cryptos::PublicKey.new private_key
 => #<Cryptos::PublicKey:0x00007fc9d122fc48 @private_key=#<Cryptos::PrivateKey:0x00007fc9d123e2e8 @value=47930083789607287790662857866073624449854924554643360243140359905082181414216, @order=115792089237316195423570985008687907852837564279074904382605163141518161494337>, @x=37935518911551901189910488779135983333966395037400135768523765072809885233888, @y=60841756395196742058661917858407687798753194961782162321894682162865330386541>

# Generating Bitcoin address for testnet
2.5.1 :005 > address = Cryptos::Bitcoin::Address.new public_key
 => #<Cryptos::Bitcoin::Address:0x00007fc9d18a29b8 @public_key=#<Cryptos::PublicKey:0x00007fc9d122fc48 @private_key=#<Cryptos::PrivateKey:0x00007fc9d123e2e8 @value=47930083789607287790662857866073624449854924554643360243140359905082181414216, @order=115792089237316195423570985008687907852837564279074904382605163141518161494337>, @x=37935518911551901189910488779135983333966395037400135768523765072809885233888, @y=60841756395196742058661917858407687798753194961782162321894682162865330386541>, @testnet=true>
2.5.1 :006 > address.to_s
 => "n37t517bJymxg3YftzqyVTAnjg4wKb3Tth"

# Generating Litecoin address for mainnet
2.5.1 :007 > address = Cryptos::Litecoin::Address.new public_key, testnet: false
 => #<Cryptos::Litecoin::Address:0x00007fc9d119a1e8 @public_key=#<Cryptos::PublicKey:0x00007fc9d122fc48 @private_key=#<Cryptos::PrivateKey:0x00007fc9d123e2e8 @value=47930083789607287790662857866073624449854924554643360243140359905082181414216, @order=115792089237316195423570985008687907852837564279074904382605163141518161494337>, @x=37935518911551901189910488779135983333966395037400135768523765072809885233888, @y=60841756395196742058661917858407687798753194961782162321894682162865330386541>, @testnet=false>
2.5.1 :008 > address.to_s
 => "Lgpt3ALSacam9jmDMZrtwZ2E5tqWVYzEkH"

Todos

  • Work in progress: Zcash and Ethereum support
  • Add more and more coins, cool crypto tech
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment