Module: Rubybear::Mixins::ActsAsWallet

Included in:
Chain
Defined in:
lib/rubybear/mixins/acts_as_wallet.rb

Instance Method Summary collapse

Instance Method Details

#claim_reward_balance(options) ⇒ Object

Create a claim_reward_balance operation.

Examples:

bears = Rubybear::Chain.new(chain: :bears, account_name: 'your account name', wif: 'your wif')
bears.claim_reward_balance(reward_bsd: '100.000 BSD')
bears.broadcast!

Parameters:

  • options (::Hash)

    options

Options Hash (options):

  • :reward_bears (String)

    The amount of BEARS to claim, like: ‘100.000 BEARS`

  • :reward_bsd (String)

    The amount of BSD to claim, like: ‘100.000 BSD`

  • :reward_coins (String)

    The amount of COINS to claim, like: ‘100.000000 COINS`



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rubybear/mixins/acts_as_wallet.rb', line 16

def claim_reward_balance(options)
  reward_bears = options[:reward_bears] || '0.000 BEARS'
  reward_bsd = options[:reward_bsd] || '0.000 BSD'
  reward_coins = options[:reward_coins] || '0.000000 COINS'
  
  @operations << {
    type: :claim_reward_balance,
    account: ,
    reward_bears: reward_bears,
    reward_bsd: reward_bsd,
    reward_coins: reward_coins
  }
  
  self
end

#claim_reward_balance!(permlink) ⇒ Object

Create a claim_reward_balance operation and broadcasts it right away.

Examples:

bears = Rubybear::Chain.new(chain: :bears, account_name: 'your account name', wif: 'your wif')
bears.claim_reward_balance!(reward_bsd: '100.000 BSD')


40
# File 'lib/rubybear/mixins/acts_as_wallet.rb', line 40

def claim_reward_balance!(permlink); claim_reward_balance(permlink).broadcast!(true); end

#transfer(options = {}) ⇒ Object

Create a transfer operation.

bears = Rubybear::Chain.new(chain: :bears, account_name: 'your account name', wif: 'your active wif')
bears.transfer(amount: '1.000 BSD', to: 'account name', memo: 'this is a memo')
bears.broadcast!

Parameters:

  • options (::Hash) (defaults to: {})

    options

Options Hash (options):

  • :amount (String)

    The amount to transfer, like: ‘100.000 BEARS`

  • :to (String)

    The account receiving the transfer.

  • :memo (String) — default: ''

    The memo for the transfer.



52
53
54
55
56
# File 'lib/rubybear/mixins/acts_as_wallet.rb', line 52

def transfer(options = {})
  @operations << options.merge(type: :transfer, from: )
  
  self
end

#transfer!(options = {}) ⇒ Object

Create a transfer operation and broadcasts it right away.

bears = Rubybear::Chain.new(chain: :bears, account_name: 'your account name', wif: 'your wif')
bears.transfer!(amount: '1.000 BSD', to: 'account name', memo: 'this is a memo')

See Also:



64
# File 'lib/rubybear/mixins/acts_as_wallet.rb', line 64

def transfer!(options = {}); transfer(options).broadcast!(true); end