ユーザ用ツール

サイト用ツール


blockchain:ether.jsを使用したdapps開発

差分

このページの2つのバージョン間の差分を表示します。

この比較画面へのリンク

両方とも前のリビジョン前のリビジョン
次のリビジョン
前のリビジョン
blockchain:ether.jsを使用したdapps開発 [2022/05/11 00:51] dotblockchain:ether.jsを使用したdapps開発 [2022/08/04 08:56] (現在) dot
行 1: 行 1:
- 
 ====== ether.jsを使用したDApps開発 ====== ====== ether.jsを使用したDApps開発 ======
  
行 7: 行 6:
  
 下記手順を実行するか、上記リポジトリを利用してください。 下記手順を実行するか、上記リポジトリを利用してください。
 +
 +===== 前提 =====
 +
 +[[blockchain:truffleを使ったスマートコントラクト開発|Truffleを使ったスマートコントラクト開発]] で作成した Counter スマートコントラクトを使用しますので、先に実施しておいてください。
 +
 +MetaMask を使用しますので、[[blockchain:metamaskの使用|MetaMaskの使用]] を実施しておいてください。
  
 ===== Reactプロジェクトの生成 ===== ===== Reactプロジェクトの生成 =====
行 102: 行 107:
   const [provider, setProvider] = useState(null);   const [provider, setProvider] = useState(null);
   const [counter, setCounter] = useState(null);   const [counter, setCounter] = useState(null);
-  const [account, setAccount] = useState(); +  const [account, setAccount] = useState(null); 
-  const [count, setCount] = useState(); +  const [count, setCount] = useState(null); 
-  const [transactionHash, setTransactionHash] = useState(); +  const [transactionHash, setTransactionHash] = useState(null); 
-  const [transactionInfo, setTransactionInfo] = useState();+  const [transactionInfo, setTransactionInfo] = useState(null);
  
   // counterAddress と counterAbi は環境によって書き換える必要があります。   // counterAddress と counterAbi は環境によって書き換える必要があります。
行 247: 行 252:
 </code> </code>
  
 +「connect」をクリックすると MetaMask が立ち上がりますので、使用するアカウントを選択します。
 +
 +アカウントが選択できたら他のボタンをクリックすることで Counter スマートコントラクトの各メソッドが実行できます。
  
 {{:blockchain:react-etherjs.png?600|}} {{:blockchain:react-etherjs.png?600|}}
blockchain/ether.jsを使用したdapps開発.1652230301.txt.gz · 最終更新: 2022/05/11 00:51 by dot