Skip to content

Instantly share code, notes, and snippets.

@blueplanet
Last active August 5, 2022 02:50
Show Gist options
  • Save blueplanet/9512971188335a0435b2994fdd5465bf to your computer and use it in GitHub Desktop.
Save blueplanet/9512971188335a0435b2994fdd5465bf to your computer and use it in GitHub Desktop.
web3 とは
sequenceDiagram
  actor user
  participant ws as Web Server
  participant as as Application Server
	participant db as Database
  
  user->>ws: request
  ws->>as: request
  as->>db: Read / Write Data
  db->>as: return data
  as->>ws: return view
  ws->>user: render content
sequenceDiagram
  actor user
  participant ws as Web Server
  participant as as Smart Contact
	participant db as Block Chain
  
  user->>ws: request
  ws->>as: request
  as->>db: Read / Write Data
  db->>as: return data
  as->>ws: return view
  ws->>user: render content
sequenceDiagram
participant ci as クライアント
participant nd as ノード
participant nw as ネットワーク
participant bc as ブロックチェーン

opt スマートコントラクト登録
	ci->>ci: スマートコントラクトをビルド
	ci->>nd: デプロイ
	nd->>nd: 初期化関数実行
	nd->>nw: トランザクション発行
  note over nd, nw: 実行結果を含めてスマートコントラクト作成
  nw->>bc: マイニング
	note over bc: スマートコントラクトが作成された
  bc->>nw: 新しいブロック公開
  nw->>nd: 新しいブロックが同期される
  nd->>ci: 結果を通知する
end

opt スマートコントラクト関数の呼び出し
	alt 読み取りの場合
    ci->>nd: 関数を呼び出す
    nd->>nd: ブロックチェーンから結果を取得する
    nd->>ci: 結果を返す
  end
  alt 書き込みの場合
    ci->>nd: 関数を呼び出す
    nd->>nd: 関数を実行しトランザクション作成
    nd->>nw: トランザクション発行
	  note over nd, nw: 実行結果を含めてスマートコントラクト作成
	  nw->>bc: マイニング
    note over bc: スマートコントラクトが更新された
	  bc->>nw: 新しいブロック公開
	  nw->>nd: 新しいブロックが同期される
	  nd->>ci: 結果を通知する
  end
end

opt スマートコントラクトの消滅
  ci->>nd: 関数を呼び出す
  nd->>nd: 関数を実行しトランザクション作成
  nd->>nw: トランザクション発行
  note over nd, nw: 実行結果を含めてスマートコントラクト作成
  nw->>bc: マイニング
  note over bc: スマートコントラクトが消滅された
	bc->>nw: 新しいブロック公開
	nw->>nd: 新しいブロックが同期される
	nd->>ci: 結果を通知する
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment