Git Product home page Git Product logo

monero's Introduction

Monero Ruby Client

Ruby client to connect and use Monero Wallet RPC.


Disclaimer - before you start - important notice!

To try out please make sure that you run your monerod and your monero-wallet-rpc with the --testnet option. Always use the Testchain to play around. Be careful with your wallet, you might lose coins if you try out on the real chain.


Installation

For easy installation add gem 'monero' to your Gemfile or run gem install monero

Preparation

Start your daemon ./monerod --testnet

Start your RPC Client ./monero-wallet-rpc --testnet --rpc-bind-port 18081 --rpc-bind-ip 127.0.0.1 --rpc-login username:password --log-level 4 --wallet-dir ./

  • To open a wallet at start use --wallet-file filename and --password pass
  • In case you need to access the client from another machine, you need to set --confirm-external-bind.
  • To be able to create/open other wallets you need to specify --wallet-file /path/to/wallets/on/your/machine
  • if you don't specify --rpc-login a file will be created that stores the login data (cat monero-wallet-rpc.18081.login)

Getting started

Configuration

Monero.config.host = "127.0.0.1"
Monero.config.port = "18081"
Monero.config.username = "username"
Monero.config.password = "password"

Usage

Monero Ruby Client is very easy to use. Full documentation of RPC Client: https://getmonero.org/resources/developer-guides/wallet-rpc.html#transfer


Get the current address

Monero::Wallet.address
=> "9wm6oNA5nP3LnugTKRSwGJhW4vnYv8RAVdRvYyvbistbHUnojyTHyHcYpbZvbTZHDsi4rF1EK5TiYgnCN6FWM9HjTDpKXAE"

Create a new address for a payment (integrated address)

Monero::Wallet.make_integrated_address
=> {"integrated_address"=>"A7TmpAyaPeZLnugTKRSwGJhW4vnYv8RAVdRvYyvbistbHUnojyTHyHcYpbZvbTZHDsi4rF1EK5TiYgnCN6FWM9HjfufSYUchQ8hH2R272H",
"payment_id"=>"9d985c985ce58a8e"}

To get the balance of the current wallet (we use the gem 'money')

Monero::Wallet.balance
# returns an ::XMR object which is just a shortcut for ::Money(amount, :xmr)
=> #<Money fractional:9980629640000 currency:XMR>

Monero::Wallet.balance.format
=> "9.980629640000 XMR"

To get the unlocked balance, which is currently available

Monero::Wallet.unlocked_balance
=> #<Money fractional:10000 currency:XMR>

To get both combined

Monero::Wallet.getbalance
=> {"balance"=>9961213880000, "unlocked_balance"=>10000}

To get the current block height

Monero::Wallet.getheight
=> 1008032

Send XMR to an address via Monero::Transfer.create. If successfull you will get the transaction details. If not succesfull you'll get returned nil.

amount= 20075 #in atomic units. 1000000000000 == 1.0 XMR    
Monero::Transfer.create("A7TmpAyaPeZLnugTKRSwGJhW4vnYv8RAVdRvYyvbistbHUnojyTHyHcYpbZvbTZHDsi4rF1EK5TiYgnCN6FWM9HjfwGRvbCHYCZAaKSzDx", amount)
=> {"fee"=>19415760000,
	"tx_blob"=>"020001020005bbcf0896e3.......

To send payments you can also specify the following options:

options = { fee: fee, mixin: 5, unlock_time: unlock_time, payment_id: "c7e7146b3335aa54", get_tx_key: true, priority: 0, do_not_relay: false, get_tx_hex: true}

Please note that fee is currently ignored by the chain.

To send payments to multiple recipients simply use an array of [:recipient, :amount]. For example:

recipients = [
	{address:A7TmpAyaPeZLnugTKRSwGJhW4vnYv8RAVdRvYyvbistbHUnojyTHyHcYpbZvbTZHDsi4rF1EK5TiYgnCN6FWM9HjfwGRvbCHYCZAaKSzDx amount: 1599999},
	{address:A7TmpAyaPeZLnugTKRSwGJhW4vnYv8RAVdRvYyvbistbHUnojyTHyHcYpbZvbTZHDsi4rF1EK5TiYgnCN6FWM9Hjftr1RgJ6RM4BMMPLUc amount: 130000},
	{address:A7TmpAyaPeZLnugTKRSwGJhW4vnYv8RAVdRvYyvbistbHUnojyTHyHcYpbZvbTZHDsi4rF1EK5TiYgnCN6FWM9HjfrgPgAEasYGSVhUdwe amount: 442130000}
]

Monero::Transfer.send_bulk(recipients, options)

Donations

If this was useful you might consider a small donation:

  • XMR: 4H19KAdSw1pL2v1iaEx31ngQCQcEGobUpevqtzSzKPTAEAt1Ay7NZrQgU6mnN2mVyWi7yk2ig68KsU8bfXQ45ainLTZFWU7m94yT3D9qUX
  • BTC:
  • LTC:

LICENSE

MIT

monero's People

Contributors

krtschmr avatar

Watchers

James Cloos avatar Marian avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.