概要
ローカルでL1 Blockchainを作成して、作成したL1 Blockchainの情報を確認していきます。 注意が必要なのが、あくまでこの章では「L1 Blockchainの雛形」を作成をするだけです。 実際にローカルでL1 Blockchainとして稼働させるためには、デプロイをする必要があります。 この章では「L1 Blockchainの設計図」を作成して、デプロイのステップでその設計図をもとに実際にL1 Blockchainを立ち上げるようなイメージです。
L1作成
まずは、以下のコマンドを実行してしてください。
「chain name」には作成するL1 Blockchainの名前を入れてください。
avalanche blockchain create <chain name>- 例
avalanche blockchain create chain1そうするといくつか質問されるので順番に選択していってください。
Virtual Machineの選択
Which Virtual Machine would you like to use?
Virtual Machineはどうするか聞かれているので、「Subnet-EVM」を選択してください。 「Subnet-EVM」はEVM互換のVMです。 EVMとは、Ethereum Virtual Machineの略称であり、Solidityなどで記述されたスマートコントラクトを実行することができます。 EVM互換とは、このEthereum Virtual Machineと互換性があるということであり、EVM同様スマートコントラクトを実行することができます。
? Which Virtual Machine would you like to use?:
▸ Subnet-EVM
Custom VM
Explain the differenceバリデータマネージャーの選択
Which validator management type would you like to use in your blockchain?
どのバリデータマネージャーにするか聞かれているので、「Proof Of Authority」を選択してください。 「Proof Of Authority」は、特定の選ばれたバリデータがブロックの生成と検証を行います。 そのため、ローカルで作成したL1 Blockchainのブロック生成には最適です。
? Which validator management type would you like to use in your blockchain?:
▸ Proof Of Authority
Proof Of Stake
Explain the differenceValidatorManagerコントラクトの操作権限
Which address do you want to enable as controller of ValidatorManager contract?
ValidatorManagerコントラクトの操作権限を持つアドレスをどれにするか聞かれています。 ValidatorManagerコントラクトは、作成したL1 Blockchainに参加するバリデータ(検証者)を追加・削除・管理する役割を持ちます。 Avalanche CLI側でアドレスを生成、もしくは既に生成されている場合それを再利用することができるので、「Get address from an existing stored key (created from avalanche key create or avalanche key import)」を選択してください。
? Which address do you want to enable as controller of ValidatorManager contract?:
▸ Get address from an existing stored key (created from avalanche key create or avalanche key import)
Custom鍵の選択
Which stored key should be used enable as controller of ValidatorManager contract?
次に以下のような質問をされます。 これは、既に保存済みの鍵が存在するため、どの鍵を使用するか聞かれています。
? Which stored key should be used enable as controller of ValidatorManager contract?:
▸ ewoq
cli-awm-relayer
cli-teleporter-deployer選択肢について簡単に説明します。
- ewoq AvalancheGo に最初から定義されている「デフォルトキー」です。 「EWOQ」は 「Eminence Wallet Of Quorum」の略で、テスト用に使える便利な鍵ですが、秘密鍵が公開されているため誰でもアクセス可能です。 そのため「Do not use EWOQ key in a testnet or production setup」と警告されており、本番やテストネットでは使用してはいけません。 あくまで ローカル開発や学習用の簡易デモのための鍵です。
- cli-awm-relayer Avalanche Warp Messaging(AWM)のリレーヤー用に作られた鍵です。 CLI内で「warp messaging をデプロイ/管理するための専用アカウント」として保存されています。 バリデータ管理用のコントローラーに指定することも可能ですが、本来はAWM関連の処理に用いる想定です。
- cli-teleporter-deployer Avalanche Teleporter(クロスチェーン通信機構)のデプロイ用に作成された鍵です。 Teleporterコントラクトのデプロイや管理に使う想定のアカウントです。 バリデータ管理とは目的が異なりますが、必要であればコントローラーに指定することも可能です。
今回は「ewoq」を選択してください。
もし自身で管理するEOAアドレスを使用したい場合は、「Custom」を選択してください。 そうすると以下のように管理者アドレスの入力が求められうので入力してください。
Enter address (C-Chain address):ブロックチェーンの設定
Do you want to use default values for the Blockchain configuration?
ブロックチェーンの設定(バリデータ数、ネットワークパラメータ、セキュリティ要件など)に、用意されたデフォルトの設定を使用するか聞かれているので、「I want to use defaults for a test environment」を選択してください。
? Do you want to use default values for the Blockchain configuration?:
▸ I want to use defaults for a test environment
I want to use defaults for a production environment
I don't want to use default values
Explain the difference各選択肢について簡単に説明します。
- I want to use defaults for a test environment テスト用の簡易設定を使う設定です。 セキュリティは低く(例えば少数のバリデータでも動作可)で、すぐにチェーンを立ち上げて挙動確認や開発を始められます。 主にローカル環境や短期の実験用に使用されます。
- I want to use defaults for a production environment 本番運用に適した標準設定です。 セキュリティは高く(十分なバリデータ数、安定的なパラメータ)、トークン経済設計やステーキングを前提にしていることが多いです。 実際にSubnetや独自L1を公開する場合はこれを選択してください。
- I don't want to use default values デフォルトの設定は使わず、自分で全ての設定を細かく指定する方法です。 バリデータの初期セットやガス料金、チェーンID、セキュリティパラメータなどを自由に設定することができます。 独自にL1 Blockchainをカスタマイズしたいときに役立ちます。
- Explain the difference 上記の3つの違いについて説明を表示してくれます。
「Explain the difference」では以下のような説明が出力されます。
Blockchain configuration default values:
- Use latest Subnet-EVM release
- Allocate 1 million tokens to:
- a newly created key (production)
- ewoq - 0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC (test)
- Supply of the native token will be hard-capped
- Set gas fee config as low throughput (12 mil gas per block)
- Use constant gas prices
- Disable further adjustments in transaction fee configuration
- Transaction fees are burned
- Enable interoperation with other blockchains
- Allow any user to deploy smart contracts, send transactions, and interact with your blockchain.チェーンID
Chain ID
作成するL1 BlockchainのチェーンIDの入力が求められます。
「1」や「111」、「1234」など好きな数字を入れてください。
既に他にL1 Blockchainを作成している場合は、そのチェーンIDは使用できないので他のチェーンIDを使用してください。
✗ Chain ID:トークンシンボル
Token Symbol
作成するL1 Blockchainのネイティブトークンのトークンシンボル名の入力が求められています。
「TEST」や「L1TK」、「TK01」など好きなシンボル名を入れてください。
✗ Token Symbol:ここまで選択できたら、以下のように「Successfully created blockchain configuration」と出力されるので、これでローカルでL1 Blockchainの設計図の作成ができました。
prefunding address 0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC with balance 1000000000000000000000000
File /Users/<username>/.avalanche-cli/subnets/chain1/chain.json successfully written
✓ Successfully created blockchain configuration
Run 'avalanche blockchain describe' to view all created addresses and what their roles are出力されている内容を確認します。
prefunding address 0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC with balance 1000000000000000000000000これは、0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FCというアドレスに、ネイティブトークンを1000000000000000000000000発行したことを示しています。
ネイティブトークンはガス代として使用できるため、このトークンを他のアドレスなどに送付して使用します。
File /Users/<username>/.avalanche-cli/subnets/chain1/chain.json successfully written作成したL1 Blockchainの設定ファイルが/Users/<username>/.avalanche-cli/subnets/chain1/chain.jsonに保存されていることを示しています。
実際にchain.jsonを見てみると以下のようになっています。
{
"log-level": "debug",
"database-type": "leveldb",
"eth-apis": [
"eth",
"eth-filter",
"net",
"admin",
"web3",
"internal-eth",
"internal-blockchain",
"internal-transaction",
"internal-debug",
"internal-account",
"internal-personal",
"debug",
"debug-tracer",
"debug-file-tracer",
"debug-handler"
]
}createのオプション
avalanche blockchain create [subcommand] [flags]新しいL1 Blockchainのgenesisファイル(初期設定)を生成するコマンド。 チェーン名やVMの種類(Subnet-EVM / カスタム)、トークン仕様、検証ルール(PoA/PoS)などを順に設定できます。 Subnet-EVMだけでなく、独自のVMを指定することも可能です。
--custom use a custom VM template
--custom-vm-branch string custom vm branch or commit
--custom-vm-build-script string custom vm build-script
--custom-vm-path string file path of custom vm to use
--custom-vm-repo-url string custom vm repository url
--debug enable blockchain debugging (default true)
--evm use the Subnet-EVM as the base template
--evm-chain-id uint chain ID to use with Subnet-EVM
--evm-defaults deprecation notice: use '--production-defaults'
--evm-token string token symbol to use with Subnet-EVM
--external-gas-token use a gas token from another blockchain
-f, --force overwrite the existing configuration if one exists
--from-github-repo generate custom VM binary from github repository
--genesis string file path of genesis to use
-h, --help help for create
--icm interoperate with other blockchains using ICM
--icm-registry-at-genesis setup ICM registry smart contract on genesis [experimental]
--latest use latest Subnet-EVM released version, takes precedence over --vm-version
--pre-release use latest Subnet-EVM pre-released version, takes precedence over --vm-version
--production-defaults use default production settings for your blockchain
--proof-of-authority use proof of authority(PoA) for validator management
--proof-of-stake use proof of stake(PoS) for validator management
--proxy-contract-owner string EVM address that controls ProxyAdmin for TransparentProxy of ValidatorManager contract
--reward-basis-points uint (PoS only) reward basis points for PoS Reward Calculator (default 100)
--sovereign set to false if creating non-sovereign blockchain (default true)
--teleporter interoperate with other blockchains using ICM
--test-defaults use default test settings for your blockchain
--validator-manager-owner string EVM address that controls Validator Manager Owner
--vm string file path of custom vm to use. alias to custom-vm-path
--vm-version string version of Subnet-EVM template to use
--warp generate a vm with warp support (needed for ICM) (default true)
--config string config file (default is $HOME/.avalanche-cli/config.json)
--log-level string log level for the application (default "ERROR")
--skip-update-check skip check for new versions--customカスタムVMテンプレートを利用します。--custom-vm-branch <string>カスタムVMをGitHub等から取得する場合のブランチ名またはコミットIDを指定します。--custom-vm-build-script <string>カスタムVMをビルドするスクリプトのパスを指定します。--custom-vm-path <string>利用するカスタムVMバイナリのファイルパス。--custom-vm-repo-url <string>カスタムVMを取得するリポジトリのURL。--debugブロックチェーンのデバッグモードを有効化します(デフォルト:true)。--evmSubnet-EVMをベーステンプレートとして利用します。--evm-chain-id <uint>Subnet-EVMを使う場合のChainIDを指定します。--evm-defaults非推奨。 Subnet-EVM 用のデフォルト設定を使って genesis を生成します。 代わりに--production-defaultsの使用が推奨されています。--evm-token <string>Subnet-EVMで利用するトークンのシンボルを指定します。--external-gas-token他のブロックチェーンのトークンをガス代として利用できるようにします。-f, --force既に同じL1 Blockchain名の設定が存在している場合でも上書きします。--from-github-repoGitHubリポジトリからカスタムVMバイナリを生成します。--genesis <string>任意のgenesisファイルを読み込んで利用します。--icmICM(Interchain Messaging, クロスチェーン通信)を有効化します。--icm-registry-at-genesisICM Registryスマートコントラクトをgenesisに配置します(実験的)。--latestSubnet-EVMの最新版を利用します。--vm-versionより優先されます。--pre-releaseSubnet-EVMの最新プレリリース版を利用します。--vm-versionより優先されます。--production-defaults本番環境用の推奨デフォルト設定を利用します。--proof-of-authorityProof of Authority (PoA)を検証ルールとして選択します。--proof-of-stakeProof of Stake (PoS)を検証ルールとして選択します。--proxy-contract-owner <string>TransparentProxy(ValidatorManager コントラクトの ProxyAdmin)を管理するEVM アドレスを指定します。--reward-basis-points <uint>(PoS専用)報酬計算のベースポイントを設定します。 デフォルトは100。--sovereignサブネットをソブリン(独立)チェーンとして扱うかを指定します。 デフォルトはtrue。--teleporterTeleporterを利用してICM通信を有効化します。--test-defaultsテスト環境向けの推奨デフォルト設定を利用します。--validator-manager-owner <string>ValidatorManagerコントラクトを管理するEVMアドレスを指定します。--vm <string>カスタムVMを利用する場合のファイルパス。--custom-vm-pathの別名。--vm-version <string>Subnet-EVMテンプレートのバージョンを指定します。--warpWarpメッセージングを有効化します(ICMに必要)。 デフォルトはtrue。--skip-update-checkAvalanche CLIのアップデートチェックをスキップします。
