DogecoinClient is a gem that makes it easy to work with dogecoin in ruby.
The only requirement is a running dogecoin daemon (dogecoind). Make sure to check out the doc section and follow the instructions for your os. NOTICE: by default dogecoind will only allow local connections.
Add this line to your application's Gemfile:
gem 'dogecoin_client'
Or install it yourself as:
$ gem install dogecoin_client
If you're using rails you can create an initializer. Here are the default settings:
# config/initializers/dogecoin_client.rb
DogecoinClient.configure do |config|
config.host = 'localhost'
config.port = 22555
config.protocol = :http
config.user = ''
config.password = ''
end
You can also pass config variables as an options hash when creating a new client:
client = DogecoinClient.new(user: 'my_dogecoind_username', password: 'my_super_secure_password')
# create a new instance of the client
client = DogecoinClient.new
# check that dogecoind is running and that our credentials are correct
if client.valid?
# get a new wallet address
new_wallet_addr = client.get_new_address
# get the balance of our new wallet
my_balance = client.get_balance(new_wallet_addr)
puts "I have #{my_balance} doge!"
else
puts 'Something is wrong...'
end
Method | Params | Description | unlckd wallet req? |
---|---|---|---|
add_multi_sig_address | [nrequired] ["key","key"] [account] | Currently only available on testnet Add a nrequired-to-sign multisignature address to the wallet. Each key is a dogecoin address or hex-encoded public key. If [account] is specified, assign address to [account]. | No |
backup_wallet | [destination] | Safely copies wallet.dat to destination, which can be a directory or a path with filename. | No |
dump_priv_key | [dogecoinaddress] | Reveals the private key corresponding to | Yes |
encrypt_wallet | [passphrase] | Encrypts the wallet with | No |
get_account | [dogecoinaddress] | Returns the account associated with the given address. | No |
get_account_address | [account] | Returns the current dogecoin address for receiving payments to this account. | No |
get_addresses_by_account | [account] | Returns the list of addresses for the given account. | No |
get_balance | [account] [minconf=1] | If [account] is not specified, returns the server's total available balance. If [account] is specified, returns the balance in the account. |
No |
get_block | [hash] | Returns information about the given block hash. | No |
get_block_count | Returns the number of blocks in the longest block chain. | No | |
get_block_hash | [index] | Returns hash of block in best-block-chain at | No |
get_block_number | Deprecated. Use getblockcount. | No | |
get_connection_count | Returns the number of connections to other nodes. | No | |
get_difficulty | Returns the proof-of-work difficulty as a multiple of the minimum difficulty. | No | |
get_generate | Returns true or false whether dogecoind is currently generating hashes | No | |
get_hashes_per_sec | Returns a recent hashes per second performance measurement while generating. | No | |
get_info | Returns an object containing various state info. | No | |
get_memory_pool | [data] | If [data] is not specified, returns data needed to construct a block to work on:
If [data] is specified, tries to solve the block and returns true if it was successful. |
No |
get_mining_info | Returns an object containing mining-related information:
|
No | |
get_new_address | [account] | Returns a new dogecoin address for receiving payments. If [account] is specified (recommended), it is added to the address book so payments received with the address will be credited to [account]. | No |
get_received_by_account | [account] [minconf=1] | Returns the total amount received by addresses with [account] in transactions with at least [minconf] confirmations. If [account] not provided return will include all transactions to all accounts. (version 0.3.24-beta) | No |
get_received_by_address | [dogecoinaddress] [minconf=1] | Returns the total amount received by | No |
get_transaction | [txid] | Returns an object about the given transaction containing:
|
No |
get_work | [data] | If [data] is not specified, returns formatted hash data to work on:
If [data] is specified, tries to solve the block and returns true if it was successful. |
No |
help | [command] | List commands, or get help for a command. | No |
import_priv_key | [dogecoinprivkey] [label] | Adds a private key (as returned by dumpprivkey) to your wallet. | Yes |
key_pool_refill | Fills the keypool, requires wallet passphrase to be set. | Yes | |
list_accounts | [minconf=1] | Returns Object that has account names as keys, account balances as values. | No |
list_received_by_account | [minconf=1] [includeempty=false] | Returns an array of objects containing:
|
No |
list_received_by_address | [minconf=1] [includeempty=false] | Returns an array of objects containing:
To get a list of accounts on the system, execute dogecoind listreceivedbyaddress 0 true |
No |
list_since_block | [blockhash] [target-confirmations] | Get all transactions in blocks since block [blockhash], or all transactions if omitted. | No |
list_transactions | [account] [count=10] [from=0] | Returns up to [count] most recent transactions skipping the first [from] transactions for account [account]. If [account] not provided will return recent transaction from all accounts. | No |
move | [fromaccount] [toaccount] [amount] [minconf=1] [comment] | Move from one account in your wallet to another | No |
send_from | [fromaccount] [todogecoinaddress] [amount] [minconf=1] [comment] [comment-to] | Yes | |
send_many | [fromaccount] [address:amount,...] [minconf=1] [comment] | amounts are double-precision floating point numbers | Yes |
send_to_address | [dogecoinaddress] [amount] [comment] [comment-to] | Yes | |
set_account | [dogecoinaddress] [account] | Sets the account associated with the given address. Assigning address that is already assigned to the same account will create a new address associated with that account. | No |
set_generate | [generate] [genproclimit] | [generate] is true or false to turn generation on or off.
Generation is limited to [genproclimit] processors, -1 is unlimited. |
No |
sign_message | [dogecoinaddress] [message] | Sign a message with the private key of an address. | Yes |
set_tx_fee | [amount] | [amount] is a real and is rounded to the nearest 0.00000001 | No |
stop | Stop dogecoin server. | No | |
validate_address | [dogecoinaddress] | Return information about [dogecoinaddress]. | No |
verify_message | [dogecoinaddress] [signature] [message] | Verify a signed message. | No |
wallet_lock | Removes the wallet encryption key from memory, locking the wallet. After calling this method, you will need to call walletpassphrase again before being able to call any methods which require the wallet to be unlocked. | No | |
wallet_passphrase | [passphrase] [timeout] | Stores the wallet decryption key in memory for | No |
wallet_passphrase_change | [oldpassphrase] [newpassphrase] | Changes the wallet passphrase from | No |
*Table stolen from node-dogecoin
For local testing, make sure to replace the user/password in spec/client_spec.rb
and spec/dogecoin_client_spec.rb
with the credentials for your local dogecoind.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
Perhaps, but this way you don't need to worry about any current or future api inconsistencies. Plus, why use a tool built for an inferior alt coin?