Account

Overview

Service class used to interact with account on Stellar network.

Account Object

AttributeTypeDescription
keypairStellar::KeypairAccount keypair

Initializing

# Account seed
seed = "SBBT7NRAKW43LN6ZGSZI37HEJDYWOC62LIZUL35KHO6NI2SKJLEPVAY4"

# Get a keypair from seed
keypair = Mobius::Client::Blockchain::KeyPairFactory.produce(seed)
# =>
<Stellar::KeyPair:0x00007f01b86a8040
  @public_key=<RbNaCl::Signatures::Ed25519::VerifyKey:243df0b0>,
  @secret_seed=<RbNaCl::Signatures::Ed25519::SigningKey:433fb620>
>

# Initialize account from keypair
account = Mobius::Client::Blockchain::Account.new(keypair)
# =>
<Mobius::Client::Blockchain::Account:0x00007f01b8694e00
  @keypair=<Stellar::KeyPair:0x00007f01b86a8040
  @public_key=<RbNaCl::Signatures::Ed25519::VerifyKey:243df0b0>,
  @secret_seed=<RbNaCl::Signatures::Ed25519::SigningKey:433fb620>
>>

Methods

#account ⇒ Stellar::Account

Returns Stellar::Account instance for given keypair.

account.account
<Stellar::Account:0x00007f01b86627c0 @keypair=#		 
	<Stellar::KeyPair:0x00007f01b86627e8 
		@public_key=#
			<RbNaCl::Signatures::Ed25519::VerifyKey:243df0b0>,
    @secret_seed=#
			<RbNaCl::Signatures::Ed25519::SigningKey:433fb620>>

#authorized?(to_keypair) ⇒ Boolean

Returns true if given keypair is added as cosigner to current account.

account.authorized?(keypair)
# =>
true

#balance(asset = Mobius::Client.stellar_asset) ⇒ Float

Returns balance for given asset.

account.balance
# =>
52.0

#info ⇒ Stellar::Account

Requests and caches Stellar::Account information from network.

account.info
# =>
<Hyperclient::Link(account) {
  "href"=>"https://horizon-testnet.stellar.org/accounts/{account_id}", 
  "templated"=>true
}>

#next_sequence_value ⇒ Integer

Invalidates cache and returns next sequence value for given account.

account.next_sequence_value
# =>
41376336245161986

#reload! ⇒ Object

Invalidates account information cache.

account.reload!

#trustline_exists?(asset = Mobius::Client.stellar_asset) ⇒ Boolean

Returns true if trustline exists for given asset and limit is positive.

account.trustline_exists?
# =>
true