nem-ruby 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.rspec +2 -0
- data/.rubocop.yml +119 -0
- data/.travis.yml +23 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/README.md +81 -0
- data/Rakefile +6 -0
- data/examples/apostille_audit.rb +22 -0
- data/examples/apostille_create.rb +31 -0
- data/examples/endpoint/account.rb +73 -0
- data/examples/endpoint/account_local.rb +21 -0
- data/examples/endpoint/block.rb +14 -0
- data/examples/endpoint/chain.rb +15 -0
- data/examples/endpoint/debug.rb +17 -0
- data/examples/endpoint/local.rb +17 -0
- data/examples/endpoint/mosaic.rb +9 -0
- data/examples/endpoint/namespace.rb +13 -0
- data/examples/endpoint/node.rb +24 -0
- data/examples/endpoint/timesync.rb +9 -0
- data/examples/endpoint/transaction.rb +42 -0
- data/examples/localnode.rb +0 -0
- data/examples/nis.rb +34 -0
- data/examples/node_pool.rb +23 -0
- data/examples/transaction/importance_transfer.rb +23 -0
- data/examples/transaction/mosaic_definition_creation.rb +52 -0
- data/examples/transaction/mosaic_supply_change.rb +25 -0
- data/examples/transaction/multisig_add_cosignatory.rb +31 -0
- data/examples/transaction/multisig_aggregate_modification.rb +29 -0
- data/examples/transaction/multisig_signature.rb +41 -0
- data/examples/transaction/multisig_transfer.rb +35 -0
- data/examples/transaction/provision_namespace.rb +20 -0
- data/examples/transaction/transfer.rb +32 -0
- data/examples/transaction/transfer_mosaic.rb +72 -0
- data/examples/transaction/transfer_with_encrypted_message.rb +40 -0
- data/examples/transaction/transfer_with_local.rb +34 -0
- data/lib/nem.rb +21 -0
- data/lib/nem/apostille.rb +104 -0
- data/lib/nem/apostille_audit.rb +47 -0
- data/lib/nem/client.rb +170 -0
- data/lib/nem/configuration.rb +29 -0
- data/lib/nem/endpoint.rb +4 -0
- data/lib/nem/endpoint/account.rb +264 -0
- data/lib/nem/endpoint/base.rb +45 -0
- data/lib/nem/endpoint/block.rb +15 -0
- data/lib/nem/endpoint/chain.rb +17 -0
- data/lib/nem/endpoint/debug.rb +54 -0
- data/lib/nem/endpoint/local/account.rb +54 -0
- data/lib/nem/endpoint/local/chain.rb +15 -0
- data/lib/nem/endpoint/mosaic.rb +13 -0
- data/lib/nem/endpoint/namespace.rb +37 -0
- data/lib/nem/endpoint/node.rb +83 -0
- data/lib/nem/endpoint/timesync.rb +9 -0
- data/lib/nem/endpoint/transaction.rb +34 -0
- data/lib/nem/error.rb +6 -0
- data/lib/nem/fee.rb +2 -0
- data/lib/nem/fee/importance_transfer.rb +24 -0
- data/lib/nem/fee/mosaic_definition_creation.rb +24 -0
- data/lib/nem/fee/mosaic_supply_change_transfer.rb +24 -0
- data/lib/nem/fee/multisig.rb +24 -0
- data/lib/nem/fee/multisig_aggregation_modification.rb +28 -0
- data/lib/nem/fee/provision_namespace.rb +34 -0
- data/lib/nem/fee/transfer.rb +66 -0
- data/lib/nem/keypair.rb +44 -0
- data/lib/nem/mixin.rb +2 -0
- data/lib/nem/mixin/assignable.rb +12 -0
- data/lib/nem/model.rb +3 -0
- data/lib/nem/model/account.rb +67 -0
- data/lib/nem/model/account_historical.rb +19 -0
- data/lib/nem/model/block.rb +33 -0
- data/lib/nem/model/chain.rb +14 -0
- data/lib/nem/model/connection.rb +23 -0
- data/lib/nem/model/experience.rb +20 -0
- data/lib/nem/model/explorer_block.rb +21 -0
- data/lib/nem/model/harvest.rb +23 -0
- data/lib/nem/model/heartbeat.rb +21 -0
- data/lib/nem/model/importance.rb +29 -0
- data/lib/nem/model/importance_transfer_transaction.rb +16 -0
- data/lib/nem/model/keypair.rb +19 -0
- data/lib/nem/model/message.rb +91 -0
- data/lib/nem/model/mosaic.rb +21 -0
- data/lib/nem/model/mosaic_attachment.rb +22 -0
- data/lib/nem/model/mosaic_definition.rb +65 -0
- data/lib/nem/model/mosaic_definition_creation_transaction.rb +18 -0
- data/lib/nem/model/mosaic_id.rb +27 -0
- data/lib/nem/model/mosaic_levy.rb +32 -0
- data/lib/nem/model/mosaic_owned.rb +22 -0
- data/lib/nem/model/mosaic_properties.rb +44 -0
- data/lib/nem/model/mosaic_supply.rb +21 -0
- data/lib/nem/model/mosaic_supply_change_transaction.rb +18 -0
- data/lib/nem/model/multisig_aggregate_modification_transaction.rb +21 -0
- data/lib/nem/model/multisig_info.rb +16 -0
- data/lib/nem/model/multisig_signature_transaction.rb +17 -0
- data/lib/nem/model/multisig_transaction.rb +21 -0
- data/lib/nem/model/namespace.rb +24 -0
- data/lib/nem/model/nem_announce_result.rb +19 -0
- data/lib/nem/model/network_time.rb +16 -0
- data/lib/nem/model/nis_node_info.rb +26 -0
- data/lib/nem/model/node.rb +41 -0
- data/lib/nem/model/provision_namespace_transaction.rb +18 -0
- data/lib/nem/model/status.rb +21 -0
- data/lib/nem/model/timer.rb +31 -0
- data/lib/nem/model/timesync.rb +19 -0
- data/lib/nem/model/transaction.rb +71 -0
- data/lib/nem/model/transfer_transaction.rb +24 -0
- data/lib/nem/model/unlocked_info.rb +24 -0
- data/lib/nem/mosaic.rb +2 -0
- data/lib/nem/mosaic/dim_coin.rb +21 -0
- data/lib/nem/mosaic/dim_token.rb +21 -0
- data/lib/nem/mosaic/ecobit_eco.rb +21 -0
- data/lib/nem/mosaic/xem.rb +21 -0
- data/lib/nem/node.rb +29 -0
- data/lib/nem/node_pool.rb +31 -0
- data/lib/nem/request.rb +2 -0
- data/lib/nem/request/announce.rb +76 -0
- data/lib/nem/transaction.rb +3 -0
- data/lib/nem/transaction/base.rb +45 -0
- data/lib/nem/transaction/importance_transfer.rb +42 -0
- data/lib/nem/transaction/mosaic_definition_creation.rb +45 -0
- data/lib/nem/transaction/mosaic_supply_change.rb +45 -0
- data/lib/nem/transaction/multisig.rb +29 -0
- data/lib/nem/transaction/multisig_aggregate_modification.rb +30 -0
- data/lib/nem/transaction/multisig_cosignatory_modification.rb +33 -0
- data/lib/nem/transaction/multisig_signature.rb +31 -0
- data/lib/nem/transaction/provision_namespace.rb +65 -0
- data/lib/nem/transaction/transfer.rb +63 -0
- data/lib/nem/util.rb +44 -0
- data/lib/nem/util/assignable.rb +51 -0
- data/lib/nem/util/convert.rb +112 -0
- data/lib/nem/util/deserializer.rb +158 -0
- data/lib/nem/util/ed25519.rb +316 -0
- data/lib/nem/util/serializer.rb +260 -0
- data/lib/nem/version.rb +3 -0
- data/nem-ruby.gemspec +46 -0
- metadata +350 -0
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'pp'
|
2
|
+
require 'nem'
|
3
|
+
|
4
|
+
Nem.logger.level = Logger::DEBUG
|
5
|
+
|
6
|
+
# single node
|
7
|
+
# node = Nem::Node.new(host: '104.128.226.60')
|
8
|
+
|
9
|
+
# --- allow only local node
|
10
|
+
account_endpoint = Nem::Endpoint::Account.new(Nem::Node.new)
|
11
|
+
|
12
|
+
## lock account
|
13
|
+
# privateKey for TARUBYIMKHJF2HMPVVHSJNMKKS7DCBSOH45QKBW2
|
14
|
+
pp account_endpoint.lock('6733898f911bb96f69eab04adf9def4d146add9a5cb16ac0fbe66fba064f126a')
|
15
|
+
|
16
|
+
## unlock account
|
17
|
+
# privateKey for TARUBYIMKHJF2HMPVVHSJNMKKS7DCBSOH45QKBW2
|
18
|
+
pp account_endpoint.unlock('6733898f911bb96f69eab04adf9def4d146add9a5cb16ac0fbe66fba064f126a')
|
19
|
+
|
20
|
+
## generate account
|
21
|
+
pp account_endpoint.generate
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'pp'
|
2
|
+
require 'nem'
|
3
|
+
|
4
|
+
Nem.logger.level = Logger::DEBUG
|
5
|
+
|
6
|
+
node = Nem::Node.new(host: '104.128.226.60')
|
7
|
+
|
8
|
+
# new Block Endpoint Object
|
9
|
+
block_endpoint = Nem::Endpoint::Block.new(node)
|
10
|
+
|
11
|
+
# somehow /block/get can't use.
|
12
|
+
# pp block_endpoint.find('fb5e76bf137eb27451926d29fd2b308e672e5d9ec405d9cbcd47cc0f83492cd0')
|
13
|
+
|
14
|
+
pp block_endpoint.at_public(1_223_559)
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'pp'
|
2
|
+
require 'nem'
|
3
|
+
|
4
|
+
Nem.logger.level = Logger::DEBUG
|
5
|
+
|
6
|
+
node = Nem::Node.new(host: '104.128.226.60')
|
7
|
+
|
8
|
+
# new Block Endpoint Object
|
9
|
+
chain_endpoint = Nem::Endpoint::Chain.new(node)
|
10
|
+
|
11
|
+
pp chain_endpoint.height
|
12
|
+
|
13
|
+
pp chain_endpoint.score
|
14
|
+
|
15
|
+
pp chain_endpoint.last_block
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'pp'
|
2
|
+
require 'nem'
|
3
|
+
|
4
|
+
node = Nem::Node.new(host: '104.128.226.60')
|
5
|
+
|
6
|
+
# new Debug Endpoint Object
|
7
|
+
debug_endpoint = Nem::Endpoint::Debug.new(node)
|
8
|
+
|
9
|
+
pp debug_endpoint.time_syncronization
|
10
|
+
|
11
|
+
pp debug_endpoint.timers
|
12
|
+
|
13
|
+
pp debug_endpoint.connections_incoming
|
14
|
+
pp debug_endpoint.connections_outgoing
|
15
|
+
|
16
|
+
# pp debug_endpoint.connections(:incoming)
|
17
|
+
# pp debug_endpoint.connections(:outgoing)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'pp'
|
2
|
+
require 'nem'
|
3
|
+
|
4
|
+
node = Nem::Node.new
|
5
|
+
|
6
|
+
# new Local Endpoint Object
|
7
|
+
laccount_endpoint = Nem::Endpoint::Local::Account.new(node)
|
8
|
+
|
9
|
+
pp laccount_endpoint.transfers('00b4a68d16dc505302e9631b860664ba43a8183f0903bc5782a2403b2f9eb3c8a1', dir: :in)
|
10
|
+
|
11
|
+
pp laccount_endpoint.transfers('00b4a68d16dc505302e9631b860664ba43a8183f0903bc5782a2403b2f9eb3c8a1', dir: :out)
|
12
|
+
|
13
|
+
pp laccount_endpoint.transfers('00b4a68d16dc505302e9631b860664ba43a8183f0903bc5782a2403b2f9eb3c8a1', dir: :all)
|
14
|
+
|
15
|
+
lchain_endpoint = Nem::Endpoint::Local::Chain.new(node)
|
16
|
+
|
17
|
+
pp lchain_endpoint.blocks_after(1_223_559)
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'pp'
|
2
|
+
require 'nem'
|
3
|
+
|
4
|
+
node = Nem::Node.new(host: '104.128.226.60')
|
5
|
+
|
6
|
+
# new Namespace Endpoint Object
|
7
|
+
ns_endpoint = Nem::Endpoint::Namespace.new(node)
|
8
|
+
|
9
|
+
pp ns_endpoint.find('alice')
|
10
|
+
|
11
|
+
pp ns_endpoint.root(882, page_size: 1)
|
12
|
+
|
13
|
+
pp ns_endpoint.mosaic_definition('tpico')
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'pp'
|
2
|
+
require 'nem'
|
3
|
+
|
4
|
+
node = Nem::Node.new(host: '104.128.226.60')
|
5
|
+
|
6
|
+
# new Node Endpoint Object
|
7
|
+
node_endpoint = Nem::Endpoint::Node.new(node)
|
8
|
+
|
9
|
+
pp node_endpoint.info
|
10
|
+
|
11
|
+
pp node_endpoint.extended_info
|
12
|
+
|
13
|
+
pp node_endpoint.max_chain_height
|
14
|
+
|
15
|
+
pp node_endpoint.experiences
|
16
|
+
|
17
|
+
pp node_endpoint.peerlist_all
|
18
|
+
pp node_endpoint.peerlist_reachable
|
19
|
+
pp node_endpoint.peerlist_active
|
20
|
+
|
21
|
+
# you can also call this way
|
22
|
+
# pp node_endpoint.peerlist(:all)
|
23
|
+
# pp node_endpoint.peerlist(:reachable)
|
24
|
+
# pp node_endpoint.peerlist(:active)
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'pp'
|
2
|
+
require 'nem'
|
3
|
+
|
4
|
+
node = Nem::Node.new(host: '104.128.226.60')
|
5
|
+
|
6
|
+
# new Account Endpoint Object
|
7
|
+
tx_endpoint = Nem::Endpoint::Transaction.new(node)
|
8
|
+
|
9
|
+
# find transfer by hash
|
10
|
+
pp tx_endpoint.find('a7131c0836da45e72f61ac6e76259d7200a85f0d2cf38f79f223b2c366673b08')
|
11
|
+
|
12
|
+
# important transfer
|
13
|
+
hash = '0765dbe0e79c2a57f2f71ae77f915d67b66290b2f72db5b3537bb32a1b09e2bf'
|
14
|
+
pp tx_endpoint.find(hash)
|
15
|
+
|
16
|
+
# multisig aggregate modification
|
17
|
+
hash = '9593e7846c01a3a8c00363af9ae7a333cc11e266eb88636957578ae0d9f495a3'
|
18
|
+
pp tx_endpoint.find(hash)
|
19
|
+
|
20
|
+
# multisig signature
|
21
|
+
# hash = ''
|
22
|
+
# tx_endpoint.find(hash)
|
23
|
+
|
24
|
+
# transfer (multisig)
|
25
|
+
hash = '4185cad053f0bc7a2b3b9e5adc493e81a5af2f0a431f3d34ba2a25c937731629'
|
26
|
+
pp tx_endpoint.find(hash)
|
27
|
+
|
28
|
+
# aggregate (multisig)
|
29
|
+
hash = 'f7d385a4c8b78d8a6a91c7b778df4ae793394c9c8bfeeca1393bf43770328a06'
|
30
|
+
pp tx_endpoint.find(hash)
|
31
|
+
|
32
|
+
# provision namespace
|
33
|
+
hash = '63a3982228b68de56c73896d394cfa3698d7d81e7aec89ea1a77a6d68d103d22'
|
34
|
+
pp tx_endpoint.find(hash)
|
35
|
+
|
36
|
+
# mosaic definition creation
|
37
|
+
hash = '0a16d30f57d65c5241cb0894a50fee51efbf6ff25a7a605de10423819234ab5d'
|
38
|
+
pp tx_endpoint.find(hash)
|
39
|
+
|
40
|
+
# mosaic supply change
|
41
|
+
hash = '7d2c7f4c2895075a4c1bf2fdceba3781c3a80313e6979c29f1cd83277fe64ded'
|
42
|
+
pp tx_endpoint.find(hash)
|
File without changes
|
data/examples/nis.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'pp'
|
2
|
+
require 'nem'
|
3
|
+
|
4
|
+
# Nem.logger.level = Logger::DEBUG
|
5
|
+
|
6
|
+
# output debug log example
|
7
|
+
# Nem.configure do |conf|
|
8
|
+
# conf.logger = Logger.new('./nem-ruby.log')
|
9
|
+
# conf.logger.level = Logger::DEBUG
|
10
|
+
# end
|
11
|
+
|
12
|
+
# Create Node instance
|
13
|
+
node = Nem::Node.new(host: '104.128.226.60')
|
14
|
+
|
15
|
+
# # It returns Nem::NemRequestResult object.
|
16
|
+
pp node.heartbeat
|
17
|
+
|
18
|
+
pp node.status
|
19
|
+
|
20
|
+
# Also call Nem::Node#request method.
|
21
|
+
# The method receive [HTTP Method], [API Path], [Parameters]
|
22
|
+
# It returns hash which converted API JSON response.
|
23
|
+
# by API path /heartbeat, /status
|
24
|
+
pp node.request :get, 'heartbeat'
|
25
|
+
|
26
|
+
pp node.request :get, 'status'
|
27
|
+
|
28
|
+
pp node.request :get, 'account/get', address: 'TBULEAUG2CZQISUR442HWA6UAKGWIXHDABJVIPS4'
|
29
|
+
|
30
|
+
# ---- only accept local node
|
31
|
+
# node = Nem::Node.new
|
32
|
+
|
33
|
+
# Create local Node instance
|
34
|
+
# pp node.shutdown
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'pp'
|
2
|
+
require 'nem'
|
3
|
+
|
4
|
+
Nem.logger.level = Logger::DEBUG
|
5
|
+
|
6
|
+
# Create node pool
|
7
|
+
nodes = Nem::NodePool.new([
|
8
|
+
Nem::Node.new(host: 'dummy1.example.com'),
|
9
|
+
Nem::Node.new(host: 'dummy2.example.com'),
|
10
|
+
Nem::Node.new(host: '104.128.226.60')
|
11
|
+
])
|
12
|
+
|
13
|
+
# Create from hash definitions
|
14
|
+
# nodes = Nem::NodePool.from_hash([
|
15
|
+
# {host: 'dummy1.example.com'},
|
16
|
+
# {host: 'dummy2.example.com'},
|
17
|
+
# {host: '104.128.226.60'}
|
18
|
+
# ])
|
19
|
+
|
20
|
+
account_endpoint = Nem::Endpoint::Account.new(nodes)
|
21
|
+
|
22
|
+
# switch to 104.128.226.60
|
23
|
+
pp account_endpoint.find('TBULEAUG2CZQISUR442HWA6UAKGWIXHDABJVIPS4')
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'pp'
|
2
|
+
require 'nem'
|
3
|
+
|
4
|
+
Nem.logger.level = Logger::DEBUG
|
5
|
+
|
6
|
+
# sender
|
7
|
+
A_PRIVATE_KEY = '260206d683962350532408e8774fd14870a173b7fba17f6b504da3dbc5f1cc9f'
|
8
|
+
|
9
|
+
# remote
|
10
|
+
B_PUBLIC_KEY = 'cc6c9485d15b992501e57fe3799487e99de272f79c5442de94eeb998b45e0144'
|
11
|
+
|
12
|
+
kp = Nem::Keypair.new(A_PRIVATE_KEY)
|
13
|
+
node = Nem::Node.new(host: '104.128.226.60')
|
14
|
+
tx_endpoint = Nem::Endpoint::Transaction.new(node)
|
15
|
+
|
16
|
+
tx = Nem::Transaction::ImportanceTransfer.new(B_PUBLIC_KEY, :activate)
|
17
|
+
pp "Fee: #{tx.fee.to_i}"
|
18
|
+
|
19
|
+
req = Nem::Request::Announce.new(tx, kp)
|
20
|
+
res = tx_endpoint.announce(req)
|
21
|
+
|
22
|
+
pp "Message: #{res.message}"
|
23
|
+
pp "TransactionHash: #{res.transaction_hash}"
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'pp'
|
2
|
+
require 'nem'
|
3
|
+
|
4
|
+
Nem.logger.level = Logger::DEBUG
|
5
|
+
|
6
|
+
# mosaic creator
|
7
|
+
A_PRIVATE_KEY = '4ce5c8f9fce571db0d9ac1adf00b8d3ba0f078ed40835fd3d730a2f24b834214'
|
8
|
+
A_PUBLIC_KEY = 'be2ba9cb15a547110d511a4d43c0482fbb584d78781abac01fb053d18f4a0033'
|
9
|
+
A_ADDRESS = 'TDPP2C4XQLMESBMCYGWN4NRAJAKZEYRV75KGYSOB'
|
10
|
+
|
11
|
+
mosaic_id = Nem::Model::MosaicId.new(
|
12
|
+
namespace_id: 'sushi',
|
13
|
+
name: 'maguro'
|
14
|
+
)
|
15
|
+
|
16
|
+
properties = Nem::Model::MosaicProperties.new(
|
17
|
+
divisibility: 0,
|
18
|
+
initial_supply: 10_000,
|
19
|
+
supply_mutable: true,
|
20
|
+
transferable: true
|
21
|
+
)
|
22
|
+
|
23
|
+
levy = Nem::Model::MosaicLevy.new(
|
24
|
+
type: 1,
|
25
|
+
recipient: A_ADDRESS,
|
26
|
+
mosaic_id: Nem::Model::MosaicId.new(
|
27
|
+
namespace_id: 'nem',
|
28
|
+
name: 'xem'
|
29
|
+
),
|
30
|
+
fee: 1_000
|
31
|
+
)
|
32
|
+
|
33
|
+
definition = Nem::Model::MosaicDefinition.new(
|
34
|
+
creator: A_PUBLIC_KEY,
|
35
|
+
id: mosaic_id,
|
36
|
+
description: 'Japanese Soul food SHUSHI.',
|
37
|
+
properties: properties,
|
38
|
+
levy: levy
|
39
|
+
)
|
40
|
+
|
41
|
+
kp = Nem::Keypair.new(A_PRIVATE_KEY)
|
42
|
+
node = Nem::Node.new(host: '104.128.226.60')
|
43
|
+
tx_endpoint = Nem::Endpoint::Transaction.new(node)
|
44
|
+
|
45
|
+
tx = Nem::Transaction::MosaicDefinitionCreation.new(definition)
|
46
|
+
pp "Fee: #{tx.fee.to_i}"
|
47
|
+
|
48
|
+
req = Nem::Request::Announce.new(tx, kp)
|
49
|
+
res = tx_endpoint.announce(req)
|
50
|
+
|
51
|
+
pp "Message: #{res.message}"
|
52
|
+
pp "TransactionHash: #{res.transaction_hash}"
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'pp'
|
2
|
+
require 'nem'
|
3
|
+
|
4
|
+
Nem.logger.level = Logger::DEBUG
|
5
|
+
|
6
|
+
# mosaic owner
|
7
|
+
A_PRIVATE_KEY = '4ce5c8f9fce571db0d9ac1adf00b8d3ba0f078ed40835fd3d730a2f24b834214'
|
8
|
+
|
9
|
+
mosaic_id = Nem::Model::MosaicId.new(
|
10
|
+
namespace_id: 'sushi',
|
11
|
+
name: 'maguro'
|
12
|
+
)
|
13
|
+
|
14
|
+
kp = Nem::Keypair.new(A_PRIVATE_KEY)
|
15
|
+
node = Nem::Node.new(host: '104.128.226.60')
|
16
|
+
|
17
|
+
tx = Nem::Transaction::MosaicSupplyChange.new(mosaic_id, :increase, 1_000)
|
18
|
+
tx_endpoint = Nem::Endpoint::Transaction.new(node)
|
19
|
+
pp "Fee: #{tx.fee.to_i}"
|
20
|
+
|
21
|
+
req = Nem::Request::Announce.new(tx, kp)
|
22
|
+
res = tx_endpoint.announce(req)
|
23
|
+
|
24
|
+
pp "Message: #{res.message}"
|
25
|
+
pp "TransactionHash: #{res.transaction_hash}"
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'pp'
|
2
|
+
require 'nem'
|
3
|
+
|
4
|
+
Nem.logger.level = Logger::DEBUG
|
5
|
+
|
6
|
+
# multisig
|
7
|
+
M_PUBLIC_KEY = '6d72b57d2bc199d328e7ea3e24775f7f614760bc18f3f8501cd3daa9870cc40c'
|
8
|
+
|
9
|
+
# cosignatory(A)
|
10
|
+
A_PRIVATE_KEY = '4ce5c8f9fce571db0d9ac1adf00b8d3ba0f078ed40835fd3d730a2f24b834214'
|
11
|
+
|
12
|
+
# cosignatory(B)
|
13
|
+
B_PUBLIC_KEY = '9e7ab2924cd1a3482df784db190614cfc8a33671f5d80a5b15a9c9e8b4d13933'
|
14
|
+
|
15
|
+
kp = Nem::Keypair.new(A_PRIVATE_KEY)
|
16
|
+
node = Nem::Node.new(host: '104.128.226.60')
|
17
|
+
tx_endpoint = Nem::Endpoint::Transaction.new(node)
|
18
|
+
|
19
|
+
msig_cosigratories = [
|
20
|
+
Nem::Transaction::MultisigCosignatoryModification.new(:add, B_PUBLIC_KEY)
|
21
|
+
]
|
22
|
+
relative_change = 1
|
23
|
+
mtx = Nem::Transaction::MultisigAggregateModification.new(msig_cosigratories, relative_change)
|
24
|
+
tx = Nem::Transaction::Multisig.new(mtx, M_PUBLIC_KEY)
|
25
|
+
tx_endpoint = Nem::Endpoint::Transaction.new(node)
|
26
|
+
|
27
|
+
req = Nem::Request::Announce.new(tx, kp)
|
28
|
+
res = tx_endpoint.announce(req)
|
29
|
+
|
30
|
+
pp "Message: #{res.message}"
|
31
|
+
pp "TransactionHash: #{res.transaction_hash}"
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'pp'
|
2
|
+
require 'nem'
|
3
|
+
|
4
|
+
Nem.logger.level = Logger::DEBUG
|
5
|
+
|
6
|
+
# multisig
|
7
|
+
M_PRIVATE_KEY = '00f077782658ae91b77f238ba5fcd7ef110564b5c189072e4d4590d9b17f9d76f3'
|
8
|
+
|
9
|
+
# cosignatory(A)
|
10
|
+
# A_PRIVATE_KEY = '4ce5c8f9fce571db0d9ac1adf00b8d3ba0f078ed40835fd3d730a2f24b834214'
|
11
|
+
A_PUBLIC_KEY = 'be2ba9cb15a547110d511a4d43c0482fbb584d78781abac01fb053d18f4a0033'
|
12
|
+
|
13
|
+
kp = Nem::Keypair.new(M_PRIVATE_KEY)
|
14
|
+
node = Nem::Node.new(host: '104.128.226.60')
|
15
|
+
node = Nem::Node.new
|
16
|
+
tx_endpoint = Nem::Endpoint::Transaction.new(node)
|
17
|
+
|
18
|
+
msig_cosignatories = [
|
19
|
+
Nem::Transaction::MultisigCosignatoryModification.new(:add, A_PUBLIC_KEY)
|
20
|
+
]
|
21
|
+
relative_change = 1
|
22
|
+
tx = Nem::Transaction::MultisigAggregateModification.new(msig_cosignatories, relative_change)
|
23
|
+
pp "Fee: #{tx.fee.to_i}"
|
24
|
+
|
25
|
+
req = Nem::Request::Announce.new(tx, kp)
|
26
|
+
res = tx_endpoint.prepare_announce(req)
|
27
|
+
|
28
|
+
pp "Message: #{res.message}"
|
29
|
+
pp "TransactionHash: #{res.transaction_hash}"
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'pp'
|
2
|
+
require 'nem'
|
3
|
+
|
4
|
+
Nem.logger.level = Logger::DEBUG
|
5
|
+
|
6
|
+
# multisig
|
7
|
+
M_PUBLIC_KEY = '6d72b57d2bc199d328e7ea3e24775f7f614760bc18f3f8501cd3daa9870cc40c'
|
8
|
+
M_ADDRESS = 'TDJNDAQ7F7AQRXKP2YVTH67QYCWWKE6QLSJFWN64'
|
9
|
+
|
10
|
+
# cosignatory1
|
11
|
+
# A_PRIVATE_KEY = '4ce5c8f9fce571db0d9ac1adf00b8d3ba0f078ed40835fd3d730a2f24b834214'
|
12
|
+
# A_PUBLIC_KEY = 'be2ba9cb15a547110d511a4d43c0482fbb584d78781abac01fb053d18f4a0033'
|
13
|
+
# A_ADDRESS = 'TDPP2C4XQLMESBMCYGWN4NRAJAKZEYRV75KGYSOB'
|
14
|
+
|
15
|
+
# cosignatory2
|
16
|
+
B_PRIVATE_KEY = '1d13af2c31ee6fb0c3c7aaaea818d9b305dcadba130ba663fc42d9f25b24ded1'
|
17
|
+
B_PUBLIC_KEY = '9e7ab2924cd1a3482df784db190614cfc8a33671f5d80a5b15a9c9e8b4d13933'
|
18
|
+
B_ADDRESS = 'TA4TX6U5HG2MROAESH2JE5524T4ZOY2EQKQ6ELHF'
|
19
|
+
|
20
|
+
kp = Nem::Keypair.new(B_PRIVATE_KEY)
|
21
|
+
node = Nem::Node.new(host: '104.128.226.60')
|
22
|
+
tx_endpoint = Nem::Endpoint::Transaction.new(node)
|
23
|
+
account_endpoint = Nem::Endpoint::Account.new(node)
|
24
|
+
|
25
|
+
txes = account_endpoint.transfers_unconfirmed(B_ADDRESS)
|
26
|
+
|
27
|
+
unless txes.size > 0
|
28
|
+
puts 'There are no transactions to sign.'
|
29
|
+
exit
|
30
|
+
end
|
31
|
+
|
32
|
+
need_sig_tx = txes.first
|
33
|
+
pp "Unconfirmed Transaction Hash: #{need_sig_tx.hash}"
|
34
|
+
|
35
|
+
tx = Nem::Transaction::MultisigSignature.new(need_sig_tx.hash, M_ADDRESS, B_PUBLIC_KEY)
|
36
|
+
|
37
|
+
req = Nem::Request::Announce.new(tx, kp)
|
38
|
+
res = tx_endpoint.announce(req)
|
39
|
+
|
40
|
+
pp "Message: #{res.message}"
|
41
|
+
pp "TransactionHash: #{res.transaction_hash}"
|