Last active
February 15, 2018 08:18
-
-
Save lengshuiyulangcn/12f6cb8f69f564b0e63d365d1264a669 to your computer and use it in GitHub Desktop.
put your poem on nem testnet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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