create_block_keeper_wallet.sh

Overview

This shell script automates the creation and deployment of a Block Keeper wallet within the Acki Nacki blockchain ecosystem. It generates or reads cryptographic keys, deploys a wallet smart contract, and associates license numbers with the wallet. The script utilizes the tvm-cli command-line tool for interacting with the blockchain, including generating keys, deploying contracts, and querying contract state.

Key features include:

This script primarily interfaces with smart contracts related to the Block Keeper system and license management, using ABI files and contract addresses.


Usage

create_block_keeper_wallet.sh [options]

Options

Example:

./create_block_keeper_wallet.sh -nk ./node_owner.json -l 1,2,3

Detailed Description

Global Variables


Functions

print_usage

Prints the usage instructions and describes required options for the script.


get_options

Parses command-line options and assigns values to global variables.


gen_key

Generates node owner keys using tvm-cli if the specified key file does not exist.


read_key

Reads the public key from the node owner key file and constructs JSON objects needed for wallet deployment.


Main Execution Flow

  1. Option Parsing: Calls get_options with command line arguments.

  2. Input Validation: Checks argument count to ensure proper usage.

  3. Dependency Check: Verifies that tvm-cli is installed; exits if missing.

  4. Key Generation: Calls gen_key to create node owner keys if needed.

  5. Key Reading: Calls read_key to prepare public key JSONs.

  6. Wallet Deployment: Uses tvm-cli callx command to deploy the Block Keeper node wallet contract on the blockchain, passing the public key and license whitelist.

  7. Wallet Address Retrieval: Queries the deployed wallet address by calling the root contract with the public key.

  8. License Address Lookup: Iterates over each license number, fetching its contract address using the LicenseRoot contract.

  9. Wallet Balance Check: Queries the deployed wallet contract to get wallet details, including the current balance.

  10. Output: Displays wallet address, node ID, license addresses, and balance information.


Important Implementation Details


Interaction with Other System Components


Visual Diagram

flowchart TD
Start[Start Script]
ParseOpts[get_options]
ValidateOpts[Validate Options]
CheckTVMCLI{Is tvm-cli installed?}
GenKey[gen_key: Generate Node Owner Keys]
ReadKey[read_key: Read and Prepare Keys]
DeployWallet[Deploy Block Keeper Wallet Contract]
GetWalletAddr[Get Wallet Address]
GetLicenseAddr[Get License Addresses]
CheckBalance[Check Wallet Balance]
OutputInfo[Output Wallet and Node Info]
End[End Script]
Start --> ParseOpts --> ValidateOpts --> CheckTVMCLI
CheckTVMCLI -- No --> End
CheckTVMCLI -- Yes --> GenKey --> ReadKey --> DeployWallet --> GetWalletAddr --> GetLicenseAddr --> CheckBalance --> OutputInfo --> End

This flowchart illustrates the main execution steps of the script from option parsing to final output.


Notes on Script Structure and Algorithms


References