Class: XRPL::Faucet
- Inherits:
-
Object
- Object
- XRPL::Faucet
- Defined in:
- lib/xrpl/faucet.rb
Overview
Funds (and thereby activates) a wallet on an XRP Ledger test network via the public faucet, then waits until the account shows up on the ledger.
This is the Ruby equivalent of the fundWallet() helper used in the other
XRPL SDKs. It is intended for Testnet/Devnet only.
Constant Summary collapse
- TESTNET_FAUCET =
'https://faucet.altnet.rippletest.net/accounts'- DEVNET_FAUCET =
'https://faucet.devnet.rippletest.net/accounts'- DEFAULT_TIMEOUT =
40- DEFAULT_POLL_INTERVAL =
2
Instance Attribute Summary collapse
-
#faucet_url ⇒ Object
readonly
Returns the value of attribute faucet_url.
Class Method Summary collapse
-
.fund_wallet(client, wallet = nil, faucet_url: TESTNET_FAUCET, **opts) ⇒ Hash
Convenience wrapper matching the tutorial call style.
Instance Method Summary collapse
-
#fund_wallet(client, wallet = nil, amount: nil, timeout: DEFAULT_TIMEOUT, poll_interval: DEFAULT_POLL_INTERVAL) ⇒ Hash
Funds (and activates) a wallet on a test network.
-
#initialize(faucet_url: TESTNET_FAUCET) ⇒ Faucet
constructor
A new instance of Faucet.
Constructor Details
#initialize(faucet_url: TESTNET_FAUCET) ⇒ Faucet
Returns a new instance of Faucet.
35 36 37 |
# File 'lib/xrpl/faucet.rb', line 35 def initialize(faucet_url: TESTNET_FAUCET) @faucet_url = faucet_url end |
Instance Attribute Details
#faucet_url ⇒ Object (readonly)
Returns the value of attribute faucet_url.
32 33 34 |
# File 'lib/xrpl/faucet.rb', line 32 def faucet_url @faucet_url end |
Class Method Details
.fund_wallet(client, wallet = nil, faucet_url: TESTNET_FAUCET, **opts) ⇒ Hash
Convenience wrapper matching the tutorial call style.
44 45 46 |
# File 'lib/xrpl/faucet.rb', line 44 def self.fund_wallet(client, wallet = nil, faucet_url: TESTNET_FAUCET, **opts) new(faucet_url: faucet_url).fund_wallet(client, wallet, **opts) end |
Instance Method Details
#fund_wallet(client, wallet = nil, amount: nil, timeout: DEFAULT_TIMEOUT, poll_interval: DEFAULT_POLL_INTERVAL) ⇒ Hash
Funds (and activates) a wallet on a test network.
57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/xrpl/faucet.rb', line 57 def fund_wallet(client, wallet = nil, amount: nil, timeout: DEFAULT_TIMEOUT, poll_interval: DEFAULT_POLL_INTERVAL) wallet ||= Wallet::Wallet.generate request_funds(wallet.classic_address, amount) balance = await_funding( client, wallet.classic_address, timeout: timeout, poll_interval: poll_interval ) { wallet: wallet, balance: balance } end |