Skip to content

Instantly share code, notes, and snippets.

@lengshuiyulangcn
Last active February 15, 2018 08:18
Show Gist options
  • Save lengshuiyulangcn/12f6cb8f69f564b0e63d365d1264a669 to your computer and use it in GitHub Desktop.
Save lengshuiyulangcn/12f6cb8f69f564b0e63d365d1264a669 to your computer and use it in GitHub Desktop.
put your poem on nem testnet
# gem install nem-ruby
# ruby transter.rb your_poem.md
require 'pp'
require 'nem'
Nem.logger.level = Logger::DEBUG
# sender
A_PRIVATE_KEY = 'your_private_key'
# recipient
B_ADDRESS = 'TAYFYAEQEV7URQSZZ3J3TRT3N6EYW2PEXTMWLL67'
kp = Nem::Keypair.new(A_PRIVATE_KEY)
node = Nem::Node.new(host: 'bigalice2.nem.ninja')
tx_endpoint = Nem::Endpoint::Transaction.new(node)
# with plain message
#
text = File.open(ARGV[0]).read
tx = Nem::Transaction::Transfer.new(B_ADDRESS, 0, text)
pp "Fee: #{tx.fee.to_i}"
req = Nem::Request::Announce.new(tx, kp)
res = tx_endpoint.announce(req)
pp "Message: #{res.message}"
pp "TransactionHash: #{res.transaction_hash}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment