Method: NanoAccount#send
- Defined in:
- lib/account.rb
#send(amount, recipient) ⇒ Object
Send an amount of Nano to another address. Params:
amount-
The amount of raw Nano to send.
recipient-
The recipient account of the Nano, as a string or
NanoAccount.
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/account.rb', line 139 def send(amount, recipient) raise ImmutableAccountError unless mutable? if recipient.is_a?(String) recipient = NanoAccount.new(recipient) end # Get the frontier of this chain frontier = NanoConfiguration.client.account_info({ account: @address, count: 1 })["frontier"] # Work against the frontier work = NanoConfiguration.client.work_generate({ hash: frontier })["work"] # Create a 'send' block block = NanoConfiguration.client.block_create({ type: "send", key: @private_key, account: @address, destination: recipient.address, previous: frontier, work: work, amount: amount.to_i.to_s, balance: balance })["block"] # Publish the block NanoConfiguration.client.process(block: block) end |