How to Use the Command 'hsw-cli' (with Examples)
The hsw-cli
is a command-line REST tool for managing and interacting with a Handshake wallet. Handshake is a decentralized protocol designed to create an alternative to existing processes for the internet’s naming systems and certificate authorities. The hsw-cli
tool offers various commands that allow users to manipulate their wallets, view transaction history, manage funds, and more, all through straightforward command-line inputs.
Use case 1: Unlock the current wallet (timeout in seconds)
Code:
hsw-cli unlock passphrase 60
Motivation:
Unlocking your wallet is crucial when you want to perform transactions or view detailed information that needs your wallet to be in an ‘unlocked’ state. This ensures that sensitive operations can be carried out securely.
Explanation:
unlock
: This subcommand is used to unlock your wallet, enabling further operations that require a non-locked state.passphrase
: The passphrase argument is crucial, as it is the protective key that grants access.60
: This number specifies the timeout in seconds, meaning the wallet will remain unlocked for 60 seconds unless locked earlier. This timeout provides an additional security layer by limiting the time the wallet can perform sensitive operations.
Example Output:
Wallet unlocked for 60 seconds
Use case 2: Lock the current wallet
Code:
hsw-cli lock
Motivation:
Locking your wallet after completing sensitive operations ensures the safety and security of your assets. It’s a good practice to lock your wallet to prevent unauthorized access.
Explanation:
lock
: This command locks the wallet, preventing any operations that require access without re-entering the passphrase. No additional arguments are needed.
Example Output:
Wallet locked
Use case 3: View the current wallet’s details
Code:
hsw-cli get
Motivation:
Viewing wallet details is essential for understanding the current state of your wallet. This could include information such as the wallet’s address, network settings, and more. Regularly checking this information helps maintain control and awareness of your wallet’s condition.
Explanation:
get
: This command fetches and displays relevant information about the current wallet.
Example Output:
{
"id": "wallet-id",
"network": "main",
"accountDepth": 3,
"address": "hs1q...address",
"balance": {...}
}
Use case 4: View the current wallet’s balance
Code:
hsw-cli balance
Motivation:
Checking the balance of your wallet frequently ensures that you are aware of your available funds. This information is crucial before proceeding with transactions or financial decisions based on your wallet’s holdings.
Explanation:
balance
: This command outputs the balance of your current wallet.
Example Output:
Balance: 2.030 HNS
Use case 5: View the current wallet’s transaction history
Code:
hsw-cli history
Motivation:
Reviewing transaction history is necessary for tracking past transactions, managing finances, and identifying any unauthorized transaction activities. It provides a comprehensive view of all monetary movements in and out of the wallet.
Explanation:
history
: This command retrieves and displays a list of the wallet’s past transactions.
Example Output:
[
{"txid": "abcd1234", "amount": "-1.05", "type": "send", "date": "2023-10-01"},
{"txid": "efgh5678", "amount": "+0.03", "type": "receive", "date": "2023-09-30"}
]
Use case 6: Send a transaction with the specified coin amount to an address
Code:
hsw-cli send hs1qreceiveraddress 1.05
Motivation:
Sending transactions is at the heart of using cryptocurrency. Whether paying for services, transferring funds, or investing, the ability to send transactions securely and confirm recipient addresses is vital.
Explanation:
send
: This subcommand initiates a transaction sending coins from your wallet.hs1qreceiveraddress
: This is the destination address where you wish to send the funds. It’s imperative to verify the accuracy of this address to avoid loss of funds.1.05
: The amount of cryptocurrency you wish to send, specified in Handshake’s native currency (HNS).
Example Output:
Transaction sent with ID: 123abc456def
Use case 7: View the current wallet’s pending transactions
Code:
hsw-cli pending
Motivation:
Pending transactions are those that have been initiated but not yet confirmed on the network. Understanding pending transactions helps manage expectations of transaction completion and determines if further action or patience is required.
Explanation:
pending
: This command fetches a list of transactions that are currently awaiting confirmation.
Example Output:
[
{"txid": "pending1234", "amount": "-0.5", "type": "send", "date": "2023-10-02"}
]
Use case 8: View details about a transaction
Code:
hsw-cli tx fghij67890klmnop12345
Motivation:
Viewing transaction details is immensely useful for verifying the status and specifics of a transaction. This command can reveal whether a transaction was successful, its confirmation count, and other crucial details.
Explanation:
tx
: This command displays detailed information about a specific transaction.fghij67890klmnop12345
: This is the transaction hash identifying the unique transaction you wish to inquire about.
Example Output:
{
"txid": "fghij67890klmnop12345",
"status": "confirmed",
"amount": "-1.05",
"type": "send",
"confirmations": 6,
"date": "2023-10-01"
}
Conclusion:
Using the hsw-cli
command-line tool allows users to effectively manage their Handshake wallets through various commands. Each use case detailed above highlights important functions that users will find beneficial for overseeing their cryptocurrency assets efficiently and securely. With these commands, users can unlock and lock their wallets, check balances and transaction histories, send funds, and much more — all contributing to a seamless experience of managing decentralized financial activities.