cardano-wallet-rb
Ruby wrapper over cardano-wallet's REST API. Requires running cardano-wallet
.
Cardano-wallet-rb is used for e2e testing of cardano-wallet and also as a backend of Ikar.
Installation
In Gemfile:
gem 'cardano_wallet'
Or:
$ gem install cardano_wallet
Documentation
Link | Description |
---|---|
Ruby API (edge) | cardano-wallet-rb API |
REST API (edge) | cardano-wallet's REST API |
:warning: Links point to
edge
APIs corresponding tomaster
branches for both cardano-wallet and cardano-wallet-rb. Refer to release page for API doc suitable for the latest release.
Examples
CW = CardanoWallet.new
BYRON = CW.byron
SHELLEY = CW.shelley
MISC = CW.misc
#Byron
BYRON.wallets.create({name: "Byron",
style: "random",
mnemonic_sentence: CW.utils.mnemonic_sentence,
passphrase: "Secure Passphrase"})
BYRON.wallets.list.each_with_index do |wal, i|
BYRON.wallets.(wal['id'], {name: "Wallet number #{i}"})
end
BYRON.wallets.list.each do |wal|
puts wal['name']
end
#Shelley
w = SHELLEY.wallets.create({name: "Shelley",
mnemonic_sentence: CW.utils.mnemonic_sentence,
passphrase: "Secure Passphrase"})
SHELLEY.wallets.get(w['id'])
SHELLEY.wallets.delete(w['id'])
# Transaction
wid = '1f82e...ccd95'
= { "1" => "test"}
tx_c = SHELLEY.transactions.construct(wid, payments = nil, withdrawal = nil, )
tx_s = SHELLEY.transactions.sign(wid, 'Secure Passphrase', tx_c['transaction'])
tx_sub = SHELLEY.transactions.submit(wid, tx_s['transaction'])
puts SHELLEY.transactions.get(wid, tx_sub['id'])
# Delegation
wid = '1f82e...ccd95'
random_stake_pool_id = SHELLEY.stake_pools.list({stake: 10000}).sample['id']
delegation = [{
"join" => {
"pool" => random_stake_pool_id,
"stake_key_index" => "0H"
}
}]
tx_c = SHELLEY.transactions.construct(wid, payments = nil, withdrawal = nil, = nil, delegation)
tx_s = SHELLEY.transactions.sign(wid, 'Secure Passphrase', tx_c['transaction'])
tx_sub = SHELLEY.transactions.submit(wid, tx_s['transaction'])
puts SHELLEY.transactions.get(wid, tx_sub['id'])
#Misc
MISC.network.information
MISC.network.clock
MISC.proxy.submit_external_transaction(File.new("/tmp/blob.bin").read)
MISC.utils.addresses("addr_test1vqrlltfahghjxl5sy5h5mvfrrlt6me5fqphhwjqvj5jd88cccqcek")
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/piotr-iohk/cardano-wallet-rb. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.
License
The gem is available as open source under the terms of the MIT License.
Code of Conduct
Everyone interacting in the cardano-wallet-rb
project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.