-
-
Save ksteigerwald/4ad23336fd79181effcb8e0f6ec8548a to your computer and use it in GitHub Desktop.
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
require 'nis' | |
Nis.logger.level = Logger::DEBUG | |
A_ADDRESS = 'TBHTFLNDRULX4BSFMJ732FT7NCG2DXYPXAAV7O5L' | |
A_PUBLIC_KEY = '-' | |
A_PRIVATE_KEY = '-' | |
nis = Nis.new(host: '104.128.226.60') | |
p nis.account_get(address: A_ADDRESS) | |
p nis.account_get_from_public_key(public_key: A_PUBLIC_KEY) | |
p nis.account_get_forwarded(address: A_ADDRESS) | |
p nis.account_get_forwarded_from_public_key(public_key: A_PUBLIC_KEY) | |
# /account/get?address={address} | |
# -> account_get address: {address} | |
# Passing parameters by keyword arguments. | |
p "-"*50 | |
account_meta_pair = nis.account_get(address: A_ADDRESS) | |
account = account_meta_pair[:account] | |
p account.balance | |
add = Digest::SHA256.hexdigest('151 FORT PITT BLVD APT 604, PITTSBURGH, PA 15222' + A_ADDRESS)[0,31] | |
p add | |
p "-"*50 | |
nis = Nis.new(host: '127.0.0.1') | |
kp = Nis::Keypair.new(A_PRIVATE_KEY) | |
mosaic_id = Nis::Struct::MosaicId.new( | |
namespaceId: 'mowie', | |
name: '27ffaa5e2a7f55246861eb61cc57e2a' | |
) | |
properties = Nis::Struct::MosaicProperties.new( | |
divisibility: 0, | |
initialSupply: 10_000, | |
supplyMutable: true, | |
transferable: true, | |
country: "", | |
state: "", | |
address1: "", | |
address2: "", | |
zip: "" | |
) | |
levy = Nis::Struct::MosaicLevy.new( | |
type: 1, | |
recipient: A_ADDRESS, | |
mosaicId: { | |
namespaceId: 'nem', | |
name: 'xem' | |
}, | |
fee: 1_000 | |
) | |
p "7"*50 | |
p kp.public | |
definition = Nis::Struct::MosaicDefinition.new( | |
creator: kp.public, | |
id: mosaic_id, | |
a: 'Real estate properties', | |
properties: properties, | |
levy: levy | |
) | |
tx = Nis::Transaction::MosaicDefinitionCreation.new(definition) | |
p "Fee: #{tx.fee.to_i}" | |
req = Nis::Request::PrepareAnnounce.new(tx, kp) | |
p req.inspect | |
p "_" * 100 | |
res = nis.transaction_prepare_announce(req) | |
p "Message: #{res.message}" | |
puts "/"*50 | |
p "TransactionHash: #{res.transaction_hash}" | |
# /account/get/from-public-key?public-key={key} | |
# -> account_get_public_key public_key: {key} | |
#account_meta_pair = nis.account_get_from_public_key(public_key: keypair.public_key) | |
#account = account_meta_pair.account |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment