TruffleでGoerliネットワークにコントラクトをデプロイする

2021/12/02

Truffle で Geth で接続している Goerli ネットワークにコントラクトをデプロイしてみます。

目次

手順概要

  1. Geth で Goerli に接続する際に、HTTP API を有効にする。
  • 上記の際に、利用したい web3 コマンドのネームスペースを有効にする。
  1. truffle-config.jsに Goerli 用のネットワーク設定を追加する。
  2. truffle migrate--networkオプションで Goerli 用ネットワークを指定して実行することで、デプロイが完了する。

1. Geth で Goerli に接続

> geth --goerli --syncmode "light" --http --http.port 3334 --http.api personal,eth,web3,net --allow-insecure-unlock console

上記実行後に、デプロイ時に利用するアカウントのロック解除をしておく。(以下は Geth コンソールです)

> personal.unlockAccount(eth.accounts[0],'*******')

2. truffle-config.js でネットワークの設定

networks: {
  goerli: {
    host: '127.0.0.1',
    port: 3334,
    network_id: 5
  }
}

3.migrate の実行

> truffle migrate --network goerli
Rust🦀, Network⚡, PostgreSQL🐘, Unity🎮

Tags

rust  (9)
rocket  (7)
svelte  (5)
c++  (4)
ethereum  (3)
solidity  (3)
vscode  (3)
sqlx  (3)
glfw  (2)
opengl  (2)
nestjs  (2)
graphql  (2)
render  (2)
wsl2  (2)
truffle  (1)
goerli  (1)
geth  (1)
hardhat  (1)
nft  (1)
gui  (1)
tetris  (1)
next.js  (1)
jwt  (1)
nextauth  (1)
node.js  (1)
prisma  (1)
passport  (1)
urql  (1)
codegen  (1)
mdsvex  (1)
markdown  (1)
tmux  (1)
nvim  (1)
axum  (1)
atcoder  (1)
vim  (1)
pacman  (1)
tracing  (1)
Cursor  (1)
VSCode  (1)
PHP  (1)
Laravel  (1)