deploy_bm_wallet.sh
Overview
deploy_bm_wallet.sh is a Bash script designed to automate the deployment and initialization of a Block Manager Node Wallet smart contract on a blockchain network. It interacts with the blockchain through the tvm-cli command-line tool, managing contract deployment, address retrieval, and configuration of signing keys. This script is specifically tailored to work with the Block Manager Contract Root and the AckiNacki Block Manager Node Wallet smart contracts.
Detailed Explanation
Variables and Constants
NET=localhost
Defines the network endpoint to connect to, here set to a local blockchain node.BM_ROOT=0:6666666666666666666666666666666666666666666666666666666666666666
The address of the Block Manager Contract Root smart contract.BM_ROOT_ABI=contracts/bksystem/BlockManagerContractRoot.abi.json
Path to the ABI (Application Binary Interface) file for the Block Manager Contract Root.BM_ROOT_KEYS=config/BlockManagerContractRoot.keys.json
Path to the key file containing cryptographic keys for the Block Manager Contract Root.BM_WALLET_ABI=contracts/bksystem/AckiNackiBlockManagerNodeWallet.abi.json
Path to the ABI file for the Block Manager Node Wallet contract.BM_WALLET_KEYS=config/block_manager.keys.json
Path to the key file for the Block Manager Node Wallet.BM_OWNER_WALLET_PUBKEY=0x$(cat $BM_WALLET_KEYS | jq -r .public)
Extracts the public key from the wallet keys JSON file and prefixes it with0x.SIGNING_KEYS=config/block_manager_signing.keys.json
Path to the signing keys file.SIGNING_PUBKEY=0x$(cat $SIGNING_KEYS | jq -r .public)
Extracts the public signing key from the signing keys JSON file.
Script Workflow
Deploy Block Manager Node Wallet
Executes a contract call viatvm-clito the Block Manager Contract Root ($BM_ROOT) invoking the deployAckiNackiBlockManagerNodeWallet method.Parameters:
pubkey: Public key of the wallet owner.
signingPubkey: Public signing key.whiteListLicense: An empty object passed as a placeholder or default value.
ABI Used: $BM_ROOT_ABI
Signing Key: $BM_ROOT_KEYS
This step initiates the deployment of a new Block Manager Node Wallet contract on the blockchain.
Retrieve Wallet Address
Runs a contract method getAckiNackiBlockManagerNodeWalletAddress on the Block Manager Root contract to obtain the blockchain address of the newly deployed wallet.Parameter: pubkey (wallet owner's public key)
The output is parsed with
jqto extract the wallet address, stored in WALLET_ADDR.
Display Wallet Address
Prints the wallet address to the console for reference.Wait for Blockchain State Update
Introduces a 1-second delay (sleep 1) to allow the blockchain state to reflect the newly deployed wallet.Check Wallet Account State
Queries the blockchain account status of the wallet address usingtvm-cli account. The account type is extracted and printed. Possible states include uninitialized, active, or frozen.Set Signing Public Key on Wallet
Sends a transaction calling thesetSigningPubkeymethod on the wallet contract to configure the signing public key.Parameter: pubkey (signing public key)
ABI Used: $BM_WALLET_ABI
Signing Key: $BM_WALLET_KEYS
Usage Example
To deploy and configure a Block Manager Node Wallet on the local blockchain network, execute the script:
./deploy_bm_wallet.sh
This will:
Deploy the wallet contract
Retrieve and display the wallet address
Show the wallet's blockchain account state
Set the signing public key for the wallet
Implementation Details and Algorithms
The script leverages
tvm-clifor all blockchain interactions, ensuring commands are executed in JSON mode (-j) and on the specified network (-u $NET).JSON parsing is handled with
jqto extract necessary values such as public keys and wallet addresses.The use of public keys as identifiers links the deployment and configuration steps with the cryptographic identity of the wallet owner.
The
sleep 1call is a simple synchronization mechanism to ensure the blockchain has processed prior transactions before querying the account state.
Interaction with Other System Components
Block Manager Contract Root (
BM_ROOT)
Acts as the factory and registry for Block Manager Node Wallets. The script calls methods on this contract to deploy new wallet instances and retrieve their addresses.AckiNacki Block Manager Node Wallet
The actual wallet contract deployed and configured by this script. The script interacts with it to set signing keys, enabling secure transaction signing.Configuration Files and Keys
The script depends on local JSON files containing contract ABIs and cryptographic key pairs. These files enable authenticated and structured interaction with the smart contracts.tvm-cli Tool
Serves as the interface to the blockchain, enabling contract calls, state queries, and transaction signing.
Mermaid Diagram
flowchart TD
A[Start Script] --> B[Set Variables]
B --> C[Deploy Wallet Contract]
C --> D[Retrieve Wallet Address]
D --> E[Display Wallet Address]
E --> F[Wait 1 second]
F --> G[Check Wallet Account State]
G --> H[Set Signing Public Key]
H --> I[End Script]
Description:
This flowchart illustrates the sequence of operations performed by the script from start to finish, highlighting the deployment, retrieval, state checking, and configuration steps.
This documentation provides a clear understanding of the purpose, workflow, and technical details of the deploy_bm_wallet.sh script, facilitating its usage and maintenance within the system. For related topics on smart contract deployment and key management, see Smart Contract Deployment and Key Management.