メインコンテンツまでスキップ
バージョン: 3.3.3

Transaction

Transactionクラスは、IOSTブロックチェーンやIOSTのスマートコントラクトを使って、トランザクションを送信したり、トランザクションを取得したりするためのクラスです。

constructor

constructorメソッドは、特殊なメソッドで、Transactionクラスを作成し、初期化します。 ユーザは初期化する必要はありません。ユーザはrpc.transactionでTransactionクラスを使えます。

getTxByHash

ブロックチェーンからハッシュを取得します。

パラメータ

名前説明
hashStringBase58エンコードしたトランザクションハッシュ

戻り値

トランザクションオブジェクトを返すPromise。

名前説明
statusStringトランザクションステータス
transactionObjectTransactionオブジェクト

Transactionオブジェクト

名前説明
hashStringトランザクションハッシュ
timeNumberトランザクションのタイムスタンプ
expirationNumber有効期限gas_ratio
gas_ratioNumberGASの割合
gas_limitNumber使用するGASの上限
delayNumberdelay nanoseconds
actionsArrayActionオブジェクト配列
signersArray署名者の配列
publisherStringトランザクションパブリッシャー
referred_txString参照トランザクションハッシュ
amount_limitArrayAmountLimitオブジェクト配列
tx_receiptObjectTxReceiptオブジェクト

Actionオブジェクト

名前説明
contractStringコントラクト名
action_nameStringアクション名
dataStringデータ

AmountLimitオブジェクト

名前説明
tokenStringトークン名
valueNumber上限値

TxReceiptオブジェクト

名前説明
tx_hashStringトランザクションハッシュ
gas_usageNumberGAS使用量
ram_usageMapRAM使用量
status_codeStringステータスコード
messageStringメッセージ
returnsArrayトランザクションの戻り値配列
receiptsArrayReceiptオブジェクト配列

Receiptオブジェクト

名前説明
func_nameString関数名
contentString内容

const rpc = new IOST.RPC(new IOST.HTTPProvider('http://127.0.0.1:30001'));
rpc.transaction.getTxByHash("5YdA8qPq5N6W47rZV4u31FdbQzeMt2QX9KGj4uPyERZa").then(console.log);

/*{
"status": "IRREVERSIBLE",
"transaction": {
"hash": "5YdA8qPq5N6W47rZV4u31FdbQzeMt2QX9KGj4uPyERZa",
"time": "0",
"expiration": "0",
"gas_ratio": 1,
"gas_limit": 1000000,
"delay": "0",
"actions": [
{
"contract": "base.iost",
"action_name": "Exec",
"data": "[{\"parent\":[\"IOST2FpDWNFqH9VuA8GbbVAwQcyYGHZxFeiTwSyaeyXnV84yJZAG7A\", \"0\"]}]"
}
],
"signers": [],
"publisher": "_Block_Base",
"referred_tx": "",
"amount_limit": [],
"tx_receipt": null
}
}*/

getTxReceiptByTxHash

トランザクションハッシュからトランザクションを取得します。

パラメータ

名前説明
hashStringBase58エンコードしたトランザクションハッシュ

戻り値

TxReceiptオブジェクトを返すPromise。

const rpc = new IOST.RPC(new IOST.HTTPProvider('http://127.0.0.1:30001'));
rpc.transaction.getTxByHash("5YdA8qPq5N6W47rZV4u31FdbQzeMt2QX9KGj4uPyERZa").then(console.log);

/*{
"tx_hash": "5YdA8qPq5N6W47rZV4u31FdbQzeMt2QX9KGj4uPyERZa",
"gas_usage": 0,
"ram_usage": {
"_Block_Base": "0",
"base.iost": "284",
"bonus.iost": "107"
},
"status_code": "SUCCESS",
"message": "",
"returns": [
"[\"\"]"
],
"receipts": [
{
"func_name": "token.iost/issue",
"content": "[\"contribute\",\"IOST2FpDWNFqH9VuA8GbbVAwQcyYGHZxFeiTwSyaeyXnV84yJZAG7A\",\"900\"]"
}
]
}*/

sendTx

IOSTブロックチェーンにトランザクションを送信します。