This page will document the API classes and ways to properly use the API. Subsequent new releases also maintain backward compatibility with this class approach. For more information, please see Bytom API reference documentation at Bytom wiki
The SDK supports Ruby versions 2.3.0 or later.
Add this line to your application's Gemfile:
gem 'bytom', '>= 1.0.1'
And then execute:
$ bundle
Or install it yourself as:
$ gem install bytom
require "bytom"
# for local node
bytom_client = Bytom::Client.new(base_url: 'http://127.0.0.1:9888')
# for remoate node
bytom_client = Bytom::Client.new(base_url: 'xxx', token: 'xxx')
key_data = bytom_client.keys.create_key(
alias_name: 'bitdayone001',
password: '123456',
language: 'en'
)
account_data = bytom_client.accounts.create_account(
root_xpubs: [key_data['data']['xpub']],
alias_name: 'bitdayone001_account_01',
quorum: 1
)
account_receiver_data = bytom_client.accounts.create_account_receiver(
account_id: account_data['data']['id'],
account_alias: account_data['data']['alias']
)
asset_data = bytom_client.asset.create_asset(
alias_name: 'PropertyAsset',
root_xpubs: [key_data['data']['xpub']],
quorum: 1
)
actions = [
{
account_id: account_data['data']['id'],
amount: 20000000, # fee, unit: neu. 1 BTM = 1000 mBTM = 100000000 neu
asset_id: "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
type: "spend_account"
},
{
amount: 100000,
asset_id: asset_data['data']['id'],
type: "issue"
}, # input action
{
amount: 100000,
asset_id: asset_data['data']['id'],
address: account_receiver_data['data']['address'],
type: "control_address"
} # output action
]
build_transaction_data = bytom_client.transactions.build_transaction(
base_transaction: nil,
ttl: 0,
time_range: 129829,
actions: actions
)
transaction = {
allow_additional_actions: false,
local: true,
raw_transaction: build_transaction_data['data']['raw_transaction'],
signing_instructions: build_transaction_data['data']['signing_instructions']
}
sign_transaction_data = bytom_client.transactions.sign_transaction(
password: '123456',
transaction: transaction
)
bytom_client.transactions.submit_transaction(
raw_transaction: sign_transaction_data['data']['transaction']['raw_transaction']
)
# reponse data if success
{"status"=>"success", "data"=>{"tx_id"=>"77045241ea94ceee617f12b698a4bdef84cd6e16a58f3191b08fe092f247834d"}}
All api usage examples you can see doc.
If you find a bug, please submit the issue in Github directly by using Issues
Bytom Ruby SDK is based on the Apache License, Version 2.0 protocol.