eosは裸のトランザクションとサインを構築します
1.チェーンで取得する必要のあるデータ
- 入手します
ref_block_prefix
get_info
最後の不可逆ブロック番号を取得するには:last_irreversible_block_num
これはスクリーンショットですget_block
ブロックに関する情報を取得します:これはスクリーンショットですref_block_prefix
データを見つけるには
2.1その後、署名されていないトランザクションデータをローカルでオフラインで構築できます
-
次に計算します
ref_block_num
const ref_block_num = (info.last_irreversible_block_num) & 0xFFFF
-
expiration
:- 現在のシステム時間(ノードと同じタイムゾーンで計算)+ 300秒(cleosのデフォルトは30秒)
-
コーディング構造
data
:-
アセンブリオブジェクト
{ "code": "eosio.token", "action": "transfer", "args": { "from": "fromaccount", "to": "toaccount", "quantity": "1.0000 EOS", "memo": "memo" } }
-
コーディング
参照https://developers.eos.io/eosio-nodeos/reference#abi_bin_to_json
-
APIインターフェースを介してアクションを構築するために必要
data
curl http://192.168.1.201:30088/v1/chain/abi_json_to_bin -X POST -d '{"code":"eosio.token", "action":"transfer", "args":{"from":"xxx", "to":"xxx", "quantity":"xxx", "memo":"xxx"}}'
-
-
署名
- chainid
- sha256
- ECDSA-K1
施工結果(符号なし)
{
"compression": "none",
"transaction": {
"expiration": "2018-08-01T06:11:23",
"ref_block_num": 10855,
"ref_block_prefix": 473148127,
"max_net_usage_words": 0,
"max_cpu_usage_ms": 0,
"delay_sec": 0,
"context_free_actions": [],
"actions": [{
"account": "eosio.token",
"name": "transfer",
"authorization": [{
"actor": "fromaccount",
"permission": "active"
}],
"data": "0000000000ea305500000000487a2b9d102700000000000004454f53000000001163726561746564206279206e6f70726f6d"
}],
"transaction_extensions": [],
"signatures": null,
"context_free_data": []
},
"signatures": ["SIG_K1_JwLVG5pRdhvLfJGWkDEBPa7wdLbNeqeRFdvFrKDEryahSwCRpPb75m4auZh8frq6cXsm3dHit8GMbmuuBWxEjH"]
}
2.2符号なしトランザクションデータは、cleosコマンドを使用して作成することもできます
cleos push action eosio.token transfer '{"from":"xxx", "to":"xxx", "quantity":"xxx", "memo":"xxx"}' -p fromaccount@active -jds
-j: print result as json
-d: don't broadcast transaction to the network (just print to stdout)
-s: Specify if unlocked wallet keys should be used to sign transaction
3.トランザクションに署名して送信します
上で作成した[transactionjson]を使用して、渡された秘密鍵で署名し、トランザクションを送信します
./cleos sign -p -k [private-key] '[transaction json]'
-k,--private-key TEXT The private key that will be used to sign the transaction
-p,--push-transaction Push transaction after signing