blockchain:hardhatを使ったスマートコントラクト開発
差分
このページの2つのバージョン間の差分を表示します。
| 両方とも前のリビジョン前のリビジョン | |||
| blockchain:hardhatを使ったスマートコントラクト開発 [2022/05/22 03:02] – dot | blockchain:hardhatを使ったスマートコントラクト開発 [2022/05/24 06:42] (現在) – dot | ||
|---|---|---|---|
| 行 312: | 行 312: | ||
| > signers[0].address | > signers[0].address | ||
| ' | ' | ||
| + | </ | ||
| + | |||
| + | |||
| + | ===== hardhat console でアカウントの切り替え ===== | ||
| + | |||
| + | TODO: もっと良い方法があるはず! | ||
| + | |||
| + | Hardhat はデフォルトでアカウント一覧の先頭のアカウントが使用される。 | ||
| + | hardhat console でトランザクションが発生するような処理を行った場合、上記のアカウントが sender として使用されることになる。 | ||
| + | |||
| + | hardhat.config.js の network 設定で「アカウント一覧」を絞ることで「先頭のアカウント」を変更し、トランザクションの sender を変更する。 | ||
| + | |||
| + | <code PowerShell> | ||
| + | > code hardhat.config.js | ||
| + | </ | ||
| + | |||
| + | hardhat.confg.js の network 設定に以下を追記。 | ||
| + | |||
| + | <code JavaScript> | ||
| + | networks: { | ||
| + | localhost_account2: | ||
| + | url: ' | ||
| + | //from: ' | ||
| + | accounts: [ | ||
| + | ' | ||
| + | ' | ||
| + | ], | ||
| + | }, | ||
| + | </ | ||
| + | |||
| + | hardhat console 使用時に以下のように「localhost_account2」を選択すれば、上記 accounts の先頭が sender として使用される。 | ||
| + | |||
| + | <code PowerShell> | ||
| + | > npx hardhat console --network localhost_account2 | ||
| </ | </ | ||
blockchain/hardhatを使ったスマートコントラクト開発.1653188559.txt.gz · 最終更新: by dot
