Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

English version: /en/doc/concepts/accounts-keys.html

Accounts & Keys

TL;DR

  • senderは EthSignedIcSynthetic で導出経路が異なる。
  • expected_nonce_by_address は20 bytes address前提。
  • IcSyntheticfrom をpayloadで受け取らず、caller情報から決定される。

できること

  • Eth signed txの署名senderを使う
  • Principal由来sender(IcSynthetic)を使う

制約

  • bytes32風の値を20 bytes addressとして扱う

EthSignedIcSynthetic の違い

  • EthSigned
    • 署名済みraw txから sender を復元
    • chain id検証を伴う
  • IcSynthetic
    • wrapperが msg_caller()canister_self() を付与して TxIn::IcSynthetic として投入
    • payloadに from を持たない
    • sender導出失敗は AddressDerivationFailed 系エラーになる

IcSynthetic で必ず押さえる点

  • submit_ic_tx の入力は Candid recordto/value/gas_limit/nonce/max_fee_per_gas/max_priority_fee_per_gas/data
  • 内部保存時の canonical bytes は to_flag(0/1) 形式
  • nonce参照は expected_nonce_by_address を使う
  • 戻り値は eth_tx_hash ではなく tx_id
  • 実行確定は submit時点ではなく、後続blockで receipt 参照して判断する

安全な使い方

  1. callerに対応する20 bytesアドレスを確定する
  2. expected_nonce_by_address で nonce を取る
  3. submit_ic_tx を送る
  4. get_pending(tx_id) / get_receipt(tx_id) で追跡する

pending/mempool運用ポリシーの正本は ../rpc/overview.md を参照。

落とし穴

  • Principalエンコード値をそのままaddressとして投入する
  • expected_nonce_by_address に20 bytes以外を渡す
  • tx_ideth_tx_hash と同一視する
  • submit成功を実行成功と誤認する

根拠

  • crates/ic-evm-wrapper/src/lib.rsexpected_nonce_by_address
  • crates/evm-core/src/tx_decode.rsIcSynthetic / EthSigned
  • crates/evm-core/src/chain.rsTxIn::IcSynthetic
  • README.md