Skip to content
Creates BCH tokens and send money between them for the Keoken protocol.
Ruby
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.yardoc
doc
lib
spec
.gitignore
.rspec
.rubocop.yml
.travis.yml
Gemfile
Gemfile.lock
README.md
Rakefile
keoken.gemspec

README.md

Keoken Build Status Documentation

Creates BCH tokens and send money between them for the Keoken protocol.

https://www.keoken.io/

Installation

Add this line to your application's Gemfile:

gem 'keoken'

And then execute:

$ bundle

Or install it yourself as:

$ gem install keoken

Usage

It uses bitcoin-ruby, but you can use Trezor or Electrum, the most important command is the script, which you can obtain with token.hex, then you can send it as an output with a scriptPubKey and a value of 0. In order to crate a token you need two outputs, the change address with an amount less than original (for fees) and the other one for the script. To send money you need three outputs, the change address, the address who owns the recipient token and the script.

Create token and send it to the blockchain

Bitcoin.network = :testnet3
token = Keoken::Token.new(name: "test-keoken-bitex")
token.create(1_000_000)
key = Bitcoin::Key.from_base58("cShKfHoHVf6iYKZym18ip1MJFQFxJwbcLxW53MQikxdDsGd2ofBU")
script = token.hex
@transaction_token = Keoken::Backend::BitcoinRuby::Transaction.build_for_creation(key.addr, key, script)
transaction = Keoken::Bitprim::Transaction.new
transaction.send_tx(@transaction_token.raw)

Send token money and send transaction to the blockchain

Bitcoin.network = :testnet3
bitprim_transaction = Keoken::Bitprim::Transaction.new
assets = bitprim_transaction.assets_by_address('mro9aqn4xCzXVS7jRFFuzT2ERKonvPdSDA')
token = Keoken::Token.new(id: assets.first['asset_id'])
token.send_amount(500_000)
key = Bitcoin::Key.from_base58('cShKfHoHVf6iYKZym18ip1MJFQFxJwbcLxW53MQikxdDsGd2ofBU')
script = token.hex
@transaction_token = Keoken::Backend::BitcoinRuby::Transaction.build_for_send_amount(key.addr, 'mnTd41YZ1e1YqsaPNJh3wkeSUrFvp1guzi', key, script)
transaction = Keoken::Bitprim::Transaction.new
transaction.send_tx(@transaction_token.raw)

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/bitex-la/keoken-ruby.

License

The gem is available as open source under the terms of the MIT License.

You can’t perform that action at this time.