xgt-ruby 0.1.0
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 +11 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +56 -0
- data/LICENSE.txt +21 -0
- data/README.md +45 -0
- data/Rakefile +6 -0
- data/bin/.wallet.swp +0 -0
- data/bin/setup +8 -0
- data/bin/wallet +438 -0
- data/examples/api/account_by_key_api/get_key_references.rb +18 -0
- data/examples/api/account_history_api/deprecated/enum_virtual_ops.rb +15 -0
- data/examples/api/account_history_api/deprecated/get_transaction.rb +12 -0
- data/examples/api/account_history_api/get_account_history.rb +16 -0
- data/examples/api/account_history_api/get_ops_in_block.rb +17 -0
- data/examples/api/chain_api/deprecated/dummy_code.rb +65 -0
- data/examples/api/chain_api/deprecated/push_block.rb +20 -0
- data/examples/api/database_api/accounts/find_accounts.rb +16 -0
- data/examples/api/database_api/accounts/list_accounts.rb +18 -0
- data/examples/api/database_api/accounts/not_supported/find_account_recovery_requests.rb +16 -0
- data/examples/api/database_api/accounts/not_supported/find_change_recovery_account_requests.rb +0 -0
- data/examples/api/database_api/accounts/not_supported/find_decline_voting_rights_requests.rb +0 -0
- data/examples/api/database_api/accounts/not_supported/find_escrows.rb +0 -0
- data/examples/api/database_api/accounts/not_supported/find_sbd_conversion_requests.rb +0 -0
- data/examples/api/database_api/accounts/not_supported/find_vesting_delegation_expirations.rb +0 -0
- data/examples/api/database_api/accounts/not_supported/find_vesting_delegations.rb +0 -0
- data/examples/api/database_api/accounts/not_supported/find_withdraw_vesting_routes.rb +18 -0
- data/examples/api/database_api/accounts/not_supported/list_account_recovery_requests.rb +18 -0
- data/examples/api/database_api/accounts/not_supported/list_change_recovery_account_requests.rb +0 -0
- data/examples/api/database_api/accounts/not_supported/list_decline_voting_rights_requests.rb +0 -0
- data/examples/api/database_api/accounts/not_supported/list_escrows.rb +18 -0
- data/examples/api/database_api/accounts/not_supported/list_recovery_histories.rb +17 -0
- data/examples/api/database_api/accounts/not_supported/list_sbd_conversion_requests.rb +0 -0
- data/examples/api/database_api/accounts/not_supported/list_vesting_delegation_expirations.rb +0 -0
- data/examples/api/database_api/accounts/not_supported/list_vesting_delegations.rb +18 -0
- data/examples/api/database_api/accounts/not_supported/list_withdraw_vesting_routes.rb +18 -0
- data/examples/api/database_api/authority/not_supported/find_smt_contributions.rb +0 -0
- data/examples/api/database_api/authority/not_supported/find_smt_token_balances.rb +0 -0
- data/examples/api/database_api/authority/not_supported/find_smt_token_emissions.rb +0 -0
- data/examples/api/database_api/authority/not_supported/find_smt_tokens.rb +0 -0
- data/examples/api/database_api/authority/not_supported/get_nai_pool.rb +0 -0
- data/examples/api/database_api/authority/not_supported/get_potential_signatures.rb +0 -0
- data/examples/api/database_api/authority/not_supported/get_required_signatures.rb +0 -0
- data/examples/api/database_api/authority/not_supported/get_smt_balances.rb +0 -0
- data/examples/api/database_api/authority/not_supported/get_transaction_hex.rb +0 -0
- data/examples/api/database_api/authority/not_supported/list_smt_contributions.rb +0 -0
- data/examples/api/database_api/authority/not_supported/list_smt_token_balances.rb +0 -0
- data/examples/api/database_api/authority/not_supported/list_smt_token_emissions.rb +0 -0
- data/examples/api/database_api/authority/not_supported/list_smt_tokens.rb +0 -0
- data/examples/api/database_api/authority/not_supported/verify_account_authority.rb +0 -0
- data/examples/api/database_api/authority/not_supported/verify_authority.rb +0 -0
- data/examples/api/database_api/authority/not_supported/verify_signatures.rb +0 -0
- data/examples/api/database_api/comments/not_supported/find_comments.rb +0 -0
- data/examples/api/database_api/comments/not_supported/find_votes.rb +0 -0
- data/examples/api/database_api/comments/not_supported/list_comments.rb +0 -0
- data/examples/api/database_api/comments/not_supported/list_votes.rb +0 -0
- data/examples/api/database_api/globals/get_config.rb +14 -0
- data/examples/api/database_api/globals/get_dynamic_global_properties.rb +14 -0
- data/examples/api/database_api/globals/get_hardfork_properties.rb +14 -0
- data/examples/api/database_api/globals/get_reward_funds.rb +14 -0
- data/examples/api/database_api/globals/get_version.rb +15 -0
- data/examples/api/database_api/globals/get_witness_schedule.rb +14 -0
- data/examples/api/database_api/market/not_supported/find_limit_orders.rb +0 -0
- data/examples/api/database_api/market/not_supported/get_order_book.rb +0 -0
- data/examples/api/database_api/market/not_supported/list_limit_orders.rb +0 -0
- data/examples/api/database_api/sps/not_supported/find_proposals.rb +0 -0
- data/examples/api/database_api/sps/not_supported/list_proposal_votes.rb +0 -0
- data/examples/api/database_api/sps/not_supported/list_proposals.rb +0 -0
- data/examples/api/database_api/witnesses/deprecated/get_round.rb +14 -0
- data/examples/api/database_api/witnesses/find_witnesses.rb +16 -0
- data/examples/api/database_api/witnesses/get_active_witnesses.rb +14 -0
- data/examples/api/database_api/witnesses/list_witnesses.rb +17 -0
- data/examples/api/database_api/witnesses/not_supported/list_witness_votes.rb +16 -0
- data/examples/api/extras/get_balance.rb +27 -0
- data/examples/api/network_broadcast_api/broadcast_transaction.rb +16 -0
- data/examples/api/network_broadcast_api/broadcast_transaction_synchronous.rb +15 -0
- data/examples/api/network_broadcast_api/create_wallet.rb +79 -0
- data/examples/api/network_broadcast_api/dummy_code.rb +68 -0
- data/examples/api/network_broadcast_api/get_transaction_hex.rb +17 -0
- data/examples/api/network_broadcast_api/not_supported/broadcast_block.rb +17 -0
- data/examples/api/network_broadcast_api/transfer.rb +45 -0
- data/examples/api/payloads.txt +3580 -0
- data/examples/api/transaction_status_api/find_transaction.rb +16 -0
- data/examples/operations/broadcast_transaction_synchronous.rb +16 -0
- data/examples/operations/completed/account_create.rb +79 -0
- data/examples/operations/completed/account_witness_proxy.rb +29 -0
- data/examples/operations/completed/account_witness_vote.rb +31 -0
- data/examples/operations/completed/claim_account.rb +33 -0
- data/examples/operations/completed/create_claimed_account.rb +62 -0
- data/examples/operations/completed/custom.rb +31 -0
- data/examples/operations/completed/custom_json.rb +32 -0
- data/examples/operations/completed/decline_voting_rights.rb +30 -0
- data/examples/operations/completed/delegate_some_vesting_shares.rb +32 -0
- data/examples/operations/completed/set_withdraw_vesting_route.rb +32 -0
- data/examples/operations/completed/transfer.rb +44 -0
- data/examples/operations/completed/transfer_to_vesting.rb +32 -0
- data/examples/operations/completed/update_proposal_votes.rb +31 -0
- data/examples/operations/completed/withdraw_vesting.rb +30 -0
- data/examples/operations/completed/witness_update.rb +64 -0
- data/examples/operations/deprecated/account_update.rb +44 -0
- data/examples/operations/deprecated/cancel_transfer_from_savings.rb +30 -0
- data/examples/operations/deprecated/challenge_authority.rb +28 -0
- data/examples/operations/deprecated/claim_reward_balance.rb +35 -0
- data/examples/operations/deprecated/convert.rb +38 -0
- data/examples/operations/deprecated/custom_binary.rb +31 -0
- data/examples/operations/deprecated/feed_publish.rb +33 -0
- data/examples/operations/do_later/change_recovery_account.rb +31 -0
- data/examples/operations/do_later/claim_reward_balance2.rb +37 -0
- data/examples/operations/do_later/remove_proposal_votes.rb +0 -0
- data/examples/operations/in_progress/create_proposal.rb +40 -0
- data/examples/operations/in_progress/escrow_approve.rb +36 -0
- data/examples/operations/in_progress/witness_set_properties.rb +62 -0
- data/lib/xgt/.ruby.rb.swp +0 -0
- data/lib/xgt/ruby.rb +200 -0
- data/lib/xgt/ruby/version.rb +5 -0
- data/payloads.txt +461 -0
- data/sample.rb +41 -0
- data/sample2.rb +104 -0
- data/xgt-ruby.gemspec +31 -0
- metadata +262 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
require 'xgt/ruby'
|
|
2
|
+
|
|
3
|
+
def find_transaction(tx_id)
|
|
4
|
+
rpc = Xgt::Ruby::Rpc.new('http://localhost:8751')
|
|
5
|
+
payload = {
|
|
6
|
+
transaction_id: tx_id
|
|
7
|
+
}
|
|
8
|
+
response = rpc.call('transaction_status_api.find_transaction', payload)
|
|
9
|
+
|
|
10
|
+
puts JSON.pretty_generate(payload)
|
|
11
|
+
puts "\n\n"
|
|
12
|
+
puts JSON.pretty_generate(response)
|
|
13
|
+
response
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
transaction = find_transaction('b103d553a2650e06345255a6de1d618924077721')
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
require 'xgt/ruby'
|
|
2
|
+
load 'dummy_code.rb'
|
|
3
|
+
load 'account_witness_vote.rb'
|
|
4
|
+
|
|
5
|
+
def broadcast_transaction_synchronous(signed_transaction)
|
|
6
|
+
rpc = Xgt::Ruby::Rpc.new('http://localhost:8751')
|
|
7
|
+
payload = [signed_transaction]
|
|
8
|
+
response = rpc.call('network_broadcast_api.broadcast_transaction_synchronous', payload)
|
|
9
|
+
|
|
10
|
+
puts JSON.pretty_generate(payload)
|
|
11
|
+
puts "\n\n"
|
|
12
|
+
puts JSON.pretty_generate(response)
|
|
13
|
+
response
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
broadcast_transaction_synchronous([Dummy_code.account_create, Account_witness_vote.account_witness_vote])
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
require 'xgt/ruby'
|
|
2
|
+
|
|
3
|
+
# Requires local node: clone into xgt repo, rake run
|
|
4
|
+
|
|
5
|
+
def account_create()
|
|
6
|
+
current_name = ENV["NAME"] || "XGT0000000000000"
|
|
7
|
+
wif = ENV["WIF"] || '5JNHfZYKGaomSFvd4NUdQ9qMcEAC43kujbfjueTHpVapX1Kzq2n'
|
|
8
|
+
rpc = Xgt::Ruby::Rpc.new('http://localhost:8751')
|
|
9
|
+
config = rpc.call('database_api.get_config', {})
|
|
10
|
+
address_prefix = config['XGT_ADDRESS_PREFIX']
|
|
11
|
+
chain_id = config["XGT_CHAIN_ID"]
|
|
12
|
+
|
|
13
|
+
witness_schedule = rpc.call('database_api.get_witness_schedule', {}) || {}
|
|
14
|
+
chain_properties = witness_schedule['median_props']
|
|
15
|
+
|
|
16
|
+
fee = chain_properties["account_creation_fee"] || {}
|
|
17
|
+
amount = fee['amount'].to_f * 0.001
|
|
18
|
+
creation_fee = "#{'%0.3f' % amount} XGT"
|
|
19
|
+
|
|
20
|
+
# Generate keys
|
|
21
|
+
master = Xgt::Ruby::Auth.random_wif
|
|
22
|
+
recovery_private = Xgt::Ruby::Auth.generate_wif(current_name, master, 'recovery')
|
|
23
|
+
recovery_public = Xgt::Ruby::Auth.wif_to_public_key(recovery_private, address_prefix)
|
|
24
|
+
money_private = Xgt::Ruby::Auth.generate_wif(current_name, master, 'money')
|
|
25
|
+
money_public = Xgt::Ruby::Auth.wif_to_public_key(money_private, address_prefix)
|
|
26
|
+
social_private = Xgt::Ruby::Auth.generate_wif(current_name, master, 'social')
|
|
27
|
+
social_public = Xgt::Ruby::Auth.wif_to_public_key(social_private, address_prefix)
|
|
28
|
+
memo_private = Xgt::Ruby::Auth.generate_wif(current_name, master, 'memo')
|
|
29
|
+
memo_public = Xgt::Ruby::Auth.wif_to_public_key(memo_private, address_prefix)
|
|
30
|
+
|
|
31
|
+
puts JSON.pretty_generate(recovery_private)
|
|
32
|
+
puts "\n\n"
|
|
33
|
+
puts JSON.pretty_generate(money_private)
|
|
34
|
+
puts "\n\n"
|
|
35
|
+
|
|
36
|
+
txn = {
|
|
37
|
+
'extensions': [],
|
|
38
|
+
'operations': [[
|
|
39
|
+
'account_create',
|
|
40
|
+
{
|
|
41
|
+
'fee': creation_fee,
|
|
42
|
+
'creator': current_name,
|
|
43
|
+
'recovery': {
|
|
44
|
+
'weight_threshold': 1,
|
|
45
|
+
'account_auths': [],
|
|
46
|
+
'key_auths': [[recovery_public, 1]]
|
|
47
|
+
},
|
|
48
|
+
'money': {
|
|
49
|
+
'weight_threshold': 1,
|
|
50
|
+
'account_auths': [],
|
|
51
|
+
'key_auths': [[money_public, 1]]
|
|
52
|
+
},
|
|
53
|
+
'social': {
|
|
54
|
+
'weight_threshold': 1,
|
|
55
|
+
'account_auths': [],
|
|
56
|
+
'key_auths': [[social_public, 1]]
|
|
57
|
+
},
|
|
58
|
+
'memo_key': memo_public,
|
|
59
|
+
'json_metadata': "",
|
|
60
|
+
'extensions': []
|
|
61
|
+
}
|
|
62
|
+
]]
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
puts "\e[36mSent:\n\e[0m"
|
|
66
|
+
puts JSON.pretty_generate(txn)
|
|
67
|
+
signed = Xgt::Ruby::Auth.sign_transaction(rpc, txn, [wif], chain_id)
|
|
68
|
+
response = rpc.call('network_broadcast_api.broadcast_transaction_synchronous', [signed])
|
|
69
|
+
puts "\e[36m\nResponse:\n\e[0m"
|
|
70
|
+
puts JSON.pretty_generate(response)
|
|
71
|
+
|
|
72
|
+
account_names = rpc.call('condenser_api.get_account_names_by_block_num', [response['block_num']])
|
|
73
|
+
account_name = account_names.first
|
|
74
|
+
|
|
75
|
+
puts("\nAccount name: #{account_name}")
|
|
76
|
+
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
account_create()
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require 'xgt/ruby'
|
|
2
|
+
|
|
3
|
+
def account_witness_proxy
|
|
4
|
+
rpc = Xgt::Ruby::Rpc.new('http://localhost:8751')
|
|
5
|
+
money_private = '5KVfFwjTr3N7JgwbWFrXZq2yijBppemQZdU9e6m7Qn11khsNxqf'
|
|
6
|
+
config = rpc.call('database_api.get_config', {})
|
|
7
|
+
address_prefix = config['XGT_ADDRESS_PREFIX']
|
|
8
|
+
chain_id = config['XGT_CHAIN_ID']
|
|
9
|
+
|
|
10
|
+
txn = {
|
|
11
|
+
"extensions": [],
|
|
12
|
+
"operations": [
|
|
13
|
+
[
|
|
14
|
+
"account_witness_proxy",
|
|
15
|
+
{
|
|
16
|
+
"account": "XGT29ZJ2QvhkV4wM",
|
|
17
|
+
"proxy": "XGT0000000000000"
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
|
+
]
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
signed = Xgt::Ruby::Auth.sign_transaction(rpc, txn, [money_private], chain_id)
|
|
24
|
+
puts JSON.pretty_generate(signed)
|
|
25
|
+
response = rpc.call('network_broadcast_api.broadcast_transaction_synchronous', [signed])
|
|
26
|
+
puts JSON.pretty_generate(response)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
account_witness_proxy
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require 'xgt/ruby'
|
|
2
|
+
|
|
3
|
+
def account_witness_vote
|
|
4
|
+
rpc = Xgt::Ruby::Rpc.new('http://localhost:8751')
|
|
5
|
+
money_private = '5Kgsi9os8SG8kdg3ZVb4gjWnZhXYb4xLoYFEkQEWLkzodahY2dn'
|
|
6
|
+
config = rpc.call('database_api.get_config', {})
|
|
7
|
+
address_prefix = config['XGT_ADDRESS_PREFIX']
|
|
8
|
+
chain_id = config["XGT_CHAIN_ID"]
|
|
9
|
+
|
|
10
|
+
txn = {
|
|
11
|
+
"extensions": [],
|
|
12
|
+
"operations": [
|
|
13
|
+
[
|
|
14
|
+
"account_witness_vote",
|
|
15
|
+
{
|
|
16
|
+
"account": "XGT28Ab1ezDunt2g",
|
|
17
|
+
"witness": "XGT0000000000000",
|
|
18
|
+
"approve": true
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
signed = Xgt::Ruby::Auth.sign_transaction(rpc, txn, [money_private], chain_id)
|
|
25
|
+
puts JSON.pretty_generate(signed)
|
|
26
|
+
puts "\n\n"
|
|
27
|
+
response = rpc.call('network_broadcast_api.broadcast_transaction_synchronous', [signed])
|
|
28
|
+
puts JSON.pretty_generate(response)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
account_witness_vote
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
require 'xgt/ruby'
|
|
2
|
+
|
|
3
|
+
def claim_account
|
|
4
|
+
rpc = Xgt::Ruby::Rpc.new('http://localhost:8751')
|
|
5
|
+
wif = '5JNHfZYKGaomSFvd4NUdQ9qMcEAC43kujbfjueTHpVapX1Kzq2n'
|
|
6
|
+
config = rpc.call('database_api.get_config', {})
|
|
7
|
+
address_prefix = config['XGT_ADDRESS_PREFIX']
|
|
8
|
+
chain_id = config["XGT_CHAIN_ID"]
|
|
9
|
+
|
|
10
|
+
txn = {
|
|
11
|
+
"extensions": [],
|
|
12
|
+
"operations": [
|
|
13
|
+
[
|
|
14
|
+
"claim_account",
|
|
15
|
+
{
|
|
16
|
+
"amount": "0.000 XGT",
|
|
17
|
+
"precision": 3,
|
|
18
|
+
"nai": "@@000000021",
|
|
19
|
+
"creator": "XGT0000000000000",
|
|
20
|
+
"extensions": []
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
signed = Xgt::Ruby::Auth.sign_transaction(rpc, txn, [wif], chain_id)
|
|
27
|
+
puts JSON.pretty_generate(signed)
|
|
28
|
+
puts "\n\n"
|
|
29
|
+
response = rpc.call('network_broadcast_api.broadcast_transaction_synchronous', [signed])
|
|
30
|
+
puts JSON.pretty_generate(response)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
claim_account
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
require 'xgt/ruby'
|
|
2
|
+
|
|
3
|
+
def create_claimed_account
|
|
4
|
+
rpc = Xgt::Ruby::Rpc.new('http://localhost:8751')
|
|
5
|
+
wif = '5JNHfZYKGaomSFvd4NUdQ9qMcEAC43kujbfjueTHpVapX1Kzq2n'
|
|
6
|
+
config = rpc.call('database_api.get_config', {})
|
|
7
|
+
address_prefix = config['XGT_ADDRESS_PREFIX']
|
|
8
|
+
chain_id = config["XGT_CHAIN_ID"]
|
|
9
|
+
|
|
10
|
+
txn = {
|
|
11
|
+
"extensions": [],
|
|
12
|
+
"operations": [
|
|
13
|
+
[
|
|
14
|
+
"create_claimed_account",
|
|
15
|
+
{
|
|
16
|
+
"creator": "XGT0000000000000",
|
|
17
|
+
"new_account_name": "XGT1234567890123",
|
|
18
|
+
"recovery": {
|
|
19
|
+
"weight_threshold": 1,
|
|
20
|
+
"account_auths": [],
|
|
21
|
+
"key_auths": [
|
|
22
|
+
[
|
|
23
|
+
"XGT5b4i9gBqvh4sbgrooXPu2dbGLewNPZkXeuNeBjyiswnu2szgXx",
|
|
24
|
+
1
|
|
25
|
+
]
|
|
26
|
+
]
|
|
27
|
+
},
|
|
28
|
+
"money": {
|
|
29
|
+
"weight_threshold": 1,
|
|
30
|
+
"account_auths": [],
|
|
31
|
+
"key_auths": [
|
|
32
|
+
[
|
|
33
|
+
"XGT7ko5nzqaYfjbD4tKWGmiy3xtT9eQFZ3Pcmq5JmygTRptWSiVQy",
|
|
34
|
+
1
|
|
35
|
+
]
|
|
36
|
+
]
|
|
37
|
+
},
|
|
38
|
+
"social": {
|
|
39
|
+
"weight_threshold": 1,
|
|
40
|
+
"account_auths": [],
|
|
41
|
+
"key_auths": [
|
|
42
|
+
[
|
|
43
|
+
"XGT5xAKxnMT2y9VoVJdF63K8xRQAohsiQy9bA33aHeyMB5vgkzaay",
|
|
44
|
+
1
|
|
45
|
+
]
|
|
46
|
+
]
|
|
47
|
+
},
|
|
48
|
+
"memo_key": "XGT8ZSyzjPm48GmUuMSRufkVYkwYbZzbxeMysAVp7KFQwbTf98TcG",
|
|
49
|
+
"json_metadata": "{}"
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
signed = Xgt::Ruby::Auth.sign_transaction(rpc, txn, [wif], chain_id)
|
|
56
|
+
puts JSON.pretty_generate(signed)
|
|
57
|
+
puts "\n\n"
|
|
58
|
+
response = rpc.call('network_broadcast_api.broadcast_transaction_synchronous', [signed])
|
|
59
|
+
puts JSON.pretty_generate(response)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
create_claimed_account
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require 'xgt/ruby'
|
|
2
|
+
|
|
3
|
+
def custom
|
|
4
|
+
rpc = Xgt::Ruby::Rpc.new('http://localhost:8751')
|
|
5
|
+
wif = '5JNHfZYKGaomSFvd4NUdQ9qMcEAC43kujbfjueTHpVapX1Kzq2n'
|
|
6
|
+
config = rpc.call('database_api.get_config', {})
|
|
7
|
+
address_prefix = config['XGT_ADDRESS_PREFIX']
|
|
8
|
+
chain_id = config["XGT_CHAIN_ID"]
|
|
9
|
+
|
|
10
|
+
txn = {
|
|
11
|
+
"extensions": [],
|
|
12
|
+
"operations": [
|
|
13
|
+
[
|
|
14
|
+
"custom",
|
|
15
|
+
{
|
|
16
|
+
"required_auths": ["XGT0000000000000"],
|
|
17
|
+
"id": 777,
|
|
18
|
+
"data": "0a627974656d617374657207737465656d697402a3d13897d82114466ad87a74b73a53292d8331d1bd1d3082da6bfbcff19ed097029db013797711c88cccca3692407f9ff9b9ce7221aaa2d797f1692be2215d0a5f6d2a8cab6832050078bc5729201e3ea24ea9f7873e6dbdc65a6bd9899053b9acda876dc69f11a13df9ca8b26b6"
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
signed = Xgt::Ruby::Auth.sign_transaction(rpc, txn, [wif], chain_id)
|
|
25
|
+
puts JSON.pretty_generate(signed)
|
|
26
|
+
puts "\n\n"
|
|
27
|
+
response = rpc.call('network_broadcast_api.broadcast_transaction_synchronous', [signed])
|
|
28
|
+
puts JSON.pretty_generate(response)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
custom
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
require 'xgt/ruby'
|
|
2
|
+
|
|
3
|
+
def custom_json
|
|
4
|
+
rpc = Xgt::Ruby::Rpc.new('http://localhost:8751')
|
|
5
|
+
wif = ENV["WIF"] || '5JNHfZYKGaomSFvd4NUdQ9qMcEAC43kujbfjueTHpVapX1Kzq2n'
|
|
6
|
+
config = rpc.call('database_api.get_config', {})
|
|
7
|
+
address_prefix = config['XGT_ADDRESS_PREFIX']
|
|
8
|
+
chain_id = config["XGT_CHAIN_ID"]
|
|
9
|
+
|
|
10
|
+
txn = {
|
|
11
|
+
"extensions": [],
|
|
12
|
+
"operations": [
|
|
13
|
+
[
|
|
14
|
+
"custom_json",
|
|
15
|
+
{
|
|
16
|
+
"required_auths": [],
|
|
17
|
+
"required_social_auths": ["XGT0000000000000"],
|
|
18
|
+
"id": "follow",
|
|
19
|
+
"json": "[\"follow\",{\"follower\":\"steemit\",\"following\":\"alice\",\"what\":[\"blog\"]}]"
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
signed = Xgt::Ruby::Auth.sign_transaction(rpc, txn, [wif], chain_id)
|
|
26
|
+
puts JSON.pretty_generate(signed)
|
|
27
|
+
puts "\n\n"
|
|
28
|
+
response = rpc.call('network_broadcast_api.broadcast_transaction_synchronous', [signed])
|
|
29
|
+
puts JSON.pretty_generate(response)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
custom_json
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require 'xgt/ruby'
|
|
2
|
+
|
|
3
|
+
def decline_voting_rights
|
|
4
|
+
rpc = Xgt::Ruby::Rpc.new('http://localhost:8751')
|
|
5
|
+
wif = '5JNHfZYKGaomSFvd4NUdQ9qMcEAC43kujbfjueTHpVapX1Kzq2n'
|
|
6
|
+
config = rpc.call('database_api.get_config', {})
|
|
7
|
+
address_prefix = config['XGT_ADDRESS_PREFIX']
|
|
8
|
+
chain_id = config["XGT_CHAIN_ID"]
|
|
9
|
+
|
|
10
|
+
txn = {
|
|
11
|
+
"extensions": [],
|
|
12
|
+
"operations": [
|
|
13
|
+
[
|
|
14
|
+
"decline_voting_rights",
|
|
15
|
+
{
|
|
16
|
+
"account": "XGT0000000000000",
|
|
17
|
+
"decline": true
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
|
+
]
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
signed = Xgt::Ruby::Auth.sign_transaction(rpc, txn, [wif], chain_id)
|
|
24
|
+
puts JSON.pretty_generate(signed)
|
|
25
|
+
puts "\n\n"
|
|
26
|
+
response = rpc.call('network_broadcast_api.broadcast_transaction_synchronous', [signed])
|
|
27
|
+
puts JSON.pretty_generate(response)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
decline_voting_rights
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
require 'xgt/ruby'
|
|
2
|
+
|
|
3
|
+
def delegate_some_vesting_shares
|
|
4
|
+
rpc = Xgt::Ruby::Rpc.new('http://localhost:8751')
|
|
5
|
+
wif = '5JNHfZYKGaomSFvd4NUdQ9qMcEAC43kujbfjueTHpVapX1Kzq2n'
|
|
6
|
+
config = rpc.call('database_api.get_config', {})
|
|
7
|
+
address_prefix = config['XGT_ADDRESS_PREFIX']
|
|
8
|
+
chain_id = config["XGT_CHAIN_ID"]
|
|
9
|
+
|
|
10
|
+
vesting_shares = "#{'%.6f' % 600}"
|
|
11
|
+
|
|
12
|
+
txn = {
|
|
13
|
+
"extensions": [],
|
|
14
|
+
"operations": [
|
|
15
|
+
[
|
|
16
|
+
"delegate_vesting_shares",
|
|
17
|
+
{
|
|
18
|
+
"delegator": "XGT0000000000000",
|
|
19
|
+
"delegatee": "XGT0000000000000",
|
|
20
|
+
"vesting_shares": "#{vesting_shares} VESTS"
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
signed = Xgt::Ruby::Auth.sign_transaction(rpc, txn, [wif], chain_id)
|
|
27
|
+
puts JSON.pretty_generate(signed)
|
|
28
|
+
response = rpc.call('network_broadcast_api.broadcast_transaction_synchronous', [signed])
|
|
29
|
+
puts JSON.pretty_generate(response)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
delegate_some_vesting_shares
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
require 'xgt/ruby'
|
|
2
|
+
|
|
3
|
+
def set_withdraw_vesting_route
|
|
4
|
+
rpc = Xgt::Ruby::Rpc.new('http://localhost:8751')
|
|
5
|
+
wif = ENV["WIF"] || '5JNHfZYKGaomSFvd4NUdQ9qMcEAC43kujbfjueTHpVapX1Kzq2n'
|
|
6
|
+
config = rpc.call('database_api.get_config', {})
|
|
7
|
+
address_prefix = config['XGT_ADDRESS_PREFIX']
|
|
8
|
+
chain_id = config["XGT_CHAIN_ID"]
|
|
9
|
+
|
|
10
|
+
txn = {
|
|
11
|
+
"extensions": [],
|
|
12
|
+
"operations": [
|
|
13
|
+
[
|
|
14
|
+
"set_withdraw_vesting_route",
|
|
15
|
+
{
|
|
16
|
+
"from_account": "XGT0000000000000",
|
|
17
|
+
"to_account": "XGT28Ab1ezDunt2g",
|
|
18
|
+
"percent": 10000,
|
|
19
|
+
"auto_vest": true
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
signed = Xgt::Ruby::Auth.sign_transaction(rpc, txn, [wif], chain_id)
|
|
26
|
+
puts JSON.pretty_generate(signed)
|
|
27
|
+
puts "\n\n"
|
|
28
|
+
response = rpc.call('network_broadcast_api.broadcast_transaction_synchronous', [signed])
|
|
29
|
+
puts JSON.pretty_generate(response)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
set_withdraw_vesting_route
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
require 'xgt/ruby'
|
|
2
|
+
|
|
3
|
+
def transfer
|
|
4
|
+
# Connect to chain
|
|
5
|
+
wif = '5JNHfZYKGaomSFvd4NUdQ9qMcEAC43kujbfjueTHpVapX1Kzq2n'
|
|
6
|
+
rpc = Xgt::Ruby::Rpc.new('http://localhost:8751')
|
|
7
|
+
config = rpc.call('database_api.get_config', {})
|
|
8
|
+
chain_id = config['XGT_CHAIN_ID']
|
|
9
|
+
witness_schedule = rpc.call('database_api.get_witness_schedule', {}) || {}
|
|
10
|
+
chain_properties = witness_schedule['median_props']
|
|
11
|
+
fee = chain_properties['account_creation_fee'] || {}
|
|
12
|
+
amount = fee['amount'].to_f * 0.001
|
|
13
|
+
creation_fee = "#{'%0.3f' % amount} XGT"
|
|
14
|
+
currency_symbol = creation_fee.split(/\s+/).last
|
|
15
|
+
string_amount = '%.3f' % (1000 * 0.001)
|
|
16
|
+
|
|
17
|
+
txn = {
|
|
18
|
+
'extensions': [],
|
|
19
|
+
'operations': [
|
|
20
|
+
[
|
|
21
|
+
'transfer',
|
|
22
|
+
{
|
|
23
|
+
'from': 'XGT0000000000000',
|
|
24
|
+
'to': 'XGT0000000000000',
|
|
25
|
+
'amount': %(#{string_amount} #{currency_symbol}),
|
|
26
|
+
'memo': '',
|
|
27
|
+
'json_metadata': '',
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
puts "\e[36mSent:\n\e[0m"
|
|
34
|
+
puts JSON.pretty_generate(txn)
|
|
35
|
+
signed = Xgt::Ruby::Auth.sign_transaction(rpc, txn, [wif], chain_id)
|
|
36
|
+
puts "\e[36m\nSigned:\n\e[0m"
|
|
37
|
+
puts JSON.pretty_generate(signed)
|
|
38
|
+
response = rpc.call('call', ['network_broadcast_api', 'broadcast_transaction_synchronous', [signed]])
|
|
39
|
+
puts "\e[36m\nResponse:\n\e[0m"
|
|
40
|
+
puts JSON.pretty_generate(response)
|
|
41
|
+
response
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
transfer
|