Class: Bytom::Transactions
- Inherits:
-
Object
- Object
- Bytom::Transactions
- Defined in:
- lib/bytom/api/transactions.rb
Instance Method Summary collapse
- #build_chain_transactions(base_transaction: nil, ttl:, time_range:, actions: []) ⇒ Object
-
#build_transaction(base_transaction: nil, ttl: 0, time_range:, actions: []) ⇒ Object
Build transaction.
-
#create_transaction_feed(alias_name:, filter:) ⇒ Object
Create transaction feed.
-
#decode_raw_transaction(raw_transaction:) ⇒ Object
Decode a serialized transaction hex string into a JSON object describing the transaction.
-
#delete_transaction_feed(alias_name:) ⇒ Object
Delete transaction feed by name.
-
#estimate_transaction_gas(transaction_template: {}) ⇒ Object
Estimate consumed neu(1BTM = 10^8NEU) for the transaction.
-
#get_transaction(tx_id:) ⇒ Object
Query the account related transaction by transaction ID.
-
#get_transaction_feed(alias_name:) ⇒ Object
Query detail transaction feed by name.
-
#get_unconfirmed_transaction(tx_id:) ⇒ Object
Query mempool transaction by transaction ID.
-
#initialize(client) ⇒ Transactions
constructor
A new instance of Transactions.
-
#list_transaction_feeds ⇒ Object
Returns the list of all available transaction feeds.
-
#list_transactions(id: nil, account_id: nil, detail: nil, unconfirmed: nil, from: nil, count: nil) ⇒ Object
Returns the sub list of all the account related transactions.
-
#list_unconfirmed_transactions ⇒ Object
Returns the total number of mempool transactions and the list of transaction IDs.
-
#sign_transaction(password:, transaction: {}) ⇒ Object
Sign transaction.
- #sign_transactions(password: nil, transactions: []) ⇒ Object
-
#submit_transaction(raw_transaction: {}) ⇒ Object
Submit transaction.
-
#submit_transactions(raw_transactions: []) ⇒ Object
Submit transactions used for batch submit transactions.
-
#update_transaction_feed(alias_name:, filter:) ⇒ Object
Update transaction feed.
Constructor Details
#initialize(client) ⇒ Transactions
Returns a new instance of Transactions.
6 7 8 |
# File 'lib/bytom/api/transactions.rb', line 6 def initialize(client) @client = client end |
Instance Method Details
#build_chain_transactions(base_transaction: nil, ttl:, time_range:, actions: []) ⇒ Object
59 60 61 62 63 64 65 66 67 |
# File 'lib/bytom/api/transactions.rb', line 59 def build_chain_transactions(base_transaction: nil, ttl:, time_range:, actions: []) params = { base_transaction: base_transaction, ttl: ttl, time_range: time_range, actions: actions } client.make_request('/build-chain-transactions', 'post', params: params) end |
#build_transaction(base_transaction: nil, ttl: 0, time_range:, actions: []) ⇒ Object
Build transaction.
49 50 51 52 53 54 55 56 57 |
# File 'lib/bytom/api/transactions.rb', line 49 def build_transaction(base_transaction: nil, ttl: 0, time_range:, actions: []) params = { base_transaction: base_transaction, ttl: ttl, time_range: time_range, actions: actions } client.make_request('/build-transaction', 'post', params: params) end |
#create_transaction_feed(alias_name:, filter:) ⇒ Object
Create transaction feed.
130 131 132 133 134 135 136 |
# File 'lib/bytom/api/transactions.rb', line 130 def create_transaction_feed(alias_name:, filter:) params = { alias: alias_name, filter: filter } client.make_request('/create-transaction-feed', 'post', params: params) end |
#decode_raw_transaction(raw_transaction:) ⇒ Object
Decode a serialized transaction hex string into a JSON object describing the transaction.
201 202 203 204 205 206 |
# File 'lib/bytom/api/transactions.rb', line 201 def decode_raw_transaction(raw_transaction:) params = { raw_transaction: raw_transaction, } client.make_request('/decode-raw-transaction', 'post', params: params) end |
#delete_transaction_feed(alias_name:) ⇒ Object
Delete transaction feed by name.
160 161 162 163 164 165 |
# File 'lib/bytom/api/transactions.rb', line 160 def delete_transaction_feed(alias_name:) params = { alias: alias_name, } client.make_request('/delete-transaction-feed', 'post', params: params) end |
#estimate_transaction_gas(transaction_template: {}) ⇒ Object
Estimate consumed neu(1BTM = 10^8NEU) for the transaction.
118 119 120 121 122 123 |
# File 'lib/bytom/api/transactions.rb', line 118 def estimate_transaction_gas(transaction_template: {}) params = { transaction_template: transaction_template, } client.make_request('/estimate-transaction-gas', 'post', params: params) end |
#get_transaction(tx_id:) ⇒ Object
Query the account related transaction by transaction ID.
15 16 17 |
# File 'lib/bytom/api/transactions.rb', line 15 def get_transaction(tx_id:) client.make_request('/get-transaction', 'post', params: {tx_id: tx_id}) end |
#get_transaction_feed(alias_name:) ⇒ Object
Query detail transaction feed by name.
141 142 143 144 145 146 |
# File 'lib/bytom/api/transactions.rb', line 141 def get_transaction_feed(alias_name:) params = { alias: alias_name } client.make_request('/get-transaction-feed', 'post', params: params) end |
#get_unconfirmed_transaction(tx_id:) ⇒ Object
Query mempool transaction by transaction ID.
184 185 186 187 188 189 |
# File 'lib/bytom/api/transactions.rb', line 184 def get_unconfirmed_transaction(tx_id:) params = { tx_id: tx_id, } client.make_request('/get-unconfirmed-transaction', 'post', params: params) end |
#list_transaction_feeds ⇒ Object
Returns the list of all available transaction feeds.
151 152 153 |
# File 'lib/bytom/api/transactions.rb', line 151 def list_transaction_feeds client.make_request('/list-transaction-feeds', 'post', params: {}) end |
#list_transactions(id: nil, account_id: nil, detail: nil, unconfirmed: nil, from: nil, count: nil) ⇒ Object
Returns the sub list of all the account related transactions.
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/bytom/api/transactions.rb', line 29 def list_transactions(id: nil, account_id: nil, detail: nil, unconfirmed: nil, from: nil, count: nil) params = { id: id, account_id: account_id, detail: detail, unconfirmed: unconfirmed, from: from, count: count } client.make_request('/list-transactions', 'post', params: params) end |
#list_unconfirmed_transactions ⇒ Object
Returns the total number of mempool transactions and the list of transaction IDs.
194 195 196 |
# File 'lib/bytom/api/transactions.rb', line 194 def list_unconfirmed_transactions client.make_request('/list-unconfirmed-transactions', 'post', params: {}) end |
#sign_transaction(password:, transaction: {}) ⇒ Object
Sign transaction.
75 76 77 78 79 80 81 |
# File 'lib/bytom/api/transactions.rb', line 75 def sign_transaction(password:, transaction: {}) params = { password: password, transaction: transaction } client.make_request('/sign-transaction', 'post', params: params) end |
#sign_transactions(password: nil, transactions: []) ⇒ Object
83 84 85 86 87 88 89 |
# File 'lib/bytom/api/transactions.rb', line 83 def sign_transactions(password: nil, transactions: []) params = { password: password, transactions: transactions } client.make_request('/sign-transactions', 'post', params: params) end |
#submit_transaction(raw_transaction: {}) ⇒ Object
Submit transaction.
96 97 98 99 100 101 |
# File 'lib/bytom/api/transactions.rb', line 96 def submit_transaction(raw_transaction: {}) params = { raw_transaction: raw_transaction, } client.make_request('/submit-transaction', 'post', params: params) end |
#submit_transactions(raw_transactions: []) ⇒ Object
Submit transactions used for batch submit transactions.
108 109 110 111 112 113 |
# File 'lib/bytom/api/transactions.rb', line 108 def submit_transactions(raw_transactions: []) params = { raw_transactions: raw_transactions, } client.make_request('/submit-transactions', 'post', params: params) end |
#update_transaction_feed(alias_name:, filter:) ⇒ Object
Update transaction feed.
173 174 175 176 177 178 179 |
# File 'lib/bytom/api/transactions.rb', line 173 def update_transaction_feed(alias_name:, filter:) params = { alias: alias_name, filter: filter } client.make_request('/update-transaction-feed', 'post', params: params) end |