كيفية استخدام المحفظة في وضع سطر الأوامر؟

Preface

The Pactus Blockchain provides a wallet application that allows users to interact with the Pactus blockchain without the need to run a node. This is ideal for users who do not wish to operate a node but still want to create a personal wallet to manage their funds. This tutorial will guide you step-by-step on how to use the wallet application.

Download

To get started, download and extract the Pactus CLI file from here.


Wallet commands

In this section, we will explore various wallet commands that help you create, manage, and recover your Pactus wallet.

Create a wallet

First, you need to create a wallet. To create a new wallet, run the following command:

./pactus-wallet ~/pactus/wallets/wallet_1 create

This command creates a new wallet and store it in the ~/pactus/wallets/wallet_1.

./pactus-wallet ~/pactus/wallets/wallet_1 create

This command creates a new wallet and store it in the ~/pactus/wallets/wallet_1.

pactus-wallet.exe c:\pactus\wallets\wallet_1 create --testnet

This command creates a new wallet and save it in the c:\pactus\wallets\wallet_1 directory. This command creates a new wallet and store it in the c:\pactus\wallets\wallet_1.

Don’t forget to back up your wallet seed, as it allows you to recover your wallet if you lose it.

Wallet password

You can change the wallet password by tunning this command:

./pactus-wallet ~/pactus/wallets/wallet_1 password
./pactus-wallet ~/pactus/wallets/wallet_1 password
pactus-wallet.exe c:\pactus\wallets\wallet_1 password

If you forget your password, you can still recover your wallet using the wallet seed.

Wallet seed

You can obtain the wallet seed by running this command:

./pactus-wallet ~/pactus/wallets/wallet_1 seed
./pactus-wallet ~/pactus/wallets/wallet_1 seed
pactus-wallet.exe c:\pactus\wallets\wallet_1 seed

The wallet seed is encrypted within your wallet, and you’ll need to enter the wallet password to access it.

Recovering Wallet

If you lose your wallet, you can recover it by running this command:

./pactus-wallet ~/pactus/wallets/recovered_wallet recover
./pactus-wallet ~/pactus/wallets/recovered_wallet recover
pactus-wallet.exe c:\pactus\wallets\recovered_wallet recover

Please note that if you lose your seed, there is no way to recover your wallet.


Address commands

In this section, we’ll cover address commands that help you manage your wallet addresses.

Creating new address

You can create a new address by running this command:

./pactus-wallet ~/pactus/wallets/wallet_1 address new
./pactus-wallet ~/pactus/wallets/wallet_1 address new
pactus-wallet.exe c:\pactus\wallets\wallet_1 address new

You can also assign a label to your address to better organize your address book.

List of addresses

To view the list of wallet addresses, use this command:

./pactus-wallet ~/pactus/wallets/wallet_1 address all
./pactus-wallet ~/pactus/wallets/wallet_1 address all
pactus-wallet.exe c:\pactus\wallets\wallet_1 address all

Get Public key

To obtain the public key for a specific address, run this command:

./pactus-wallet ~/pactus/wallets/wallet_1 address pub <ADDRESS>
./pactus-wallet ~/pactus/wallets/wallet_1 address pub <ADDRESS>
pactus-wallet.exe c:\pactus\wallets\wallet_1 address pub <ADDRESS>

Replace <ADDRESS> with the address for which you want to retrieve its public key.

Get Private key

You can get the public key of your address by this command:

./pactus-wallet ~/pactus/wallets/wallet_1 address pub <ADDRESS>
./pactus-wallet ~/pactus/wallets/wallet_1 address pub <ADDRESS>
pactus-wallet.exe c:\pactus\wallets\wallet_1 address pub <ADDRESS>

Replace <ADDRESS> with the address for which you want to retrieve its private key. Keep your private key secure. If someone gains access to your private key, they will have full control over that address.


Transaction commands

In this section, we’ll cover transaction commands that help you create, sign, and broadcast transactions on the Pactus Blockchain. You’ll need to provide the password to sign the transaction. Please note that once a transaction is broadcasted, it cannot be reversed.

Sending Transfer transaction

To create, sign, and broadcast a Transfer transaction, use the following command:

./pactus-wallet ~/pactus/wallets/wallet_1 tx transfer <FROM> <TO> <AMOUNT>
./pactus-wallet ~/pactus/wallets/wallet_1 tx transfer <FROM> <TO> <AMOUNT>
pactus-wallet.exe c:\pactus\wallets\wallet_1 tx transfer <FROM> <TO> <AMOUNT>

In this command, <FROM> should be one of the addresses in your wallet as the sender address, and <TO> is the receiver address.

Sending Bond transaction

To create, sign, and broadcast a Bond transaction, use the following command:

./pactus-wallet ~/pactus/wallets/wallet_1 tx bond <FROM> <TO> <AMOUNT>
./pactus-wallet ~/pactus/wallets/wallet_1 tx bond <FROM> <TO> <AMOUNT>
pactus-wallet.exe c:\pactus\wallets\wallet_1 tx bond <FROM> <TO> <AMOUNT>

In this command, <FROM> should be one of the addresses in your wallet as the sender address, and <TO> is the receiver validator address.

If the validator associated with this address does not exist yet, you need to provide the public key to create it:

./pactus-wallet ~/pactus/wallets/wallet_1 tx bond --pub <PUBLIC_KEY> <FROM> <TO> <AMOUNT>
./pactus-wallet ~/pactus/wallets/wallet_1 --pub <PUBLIC_KEY> <FROM> <TO> <AMOUNT>
pactus-wallet.exe c:\pactus\wallets\wallet_1 --pub <PUBLIC_KEY> <FROM> <TO> <AMOUNT>

Replace <PUBLIC_KEY> with the validator’s public key, which is the public key of the <TO> address.

Sending Unbond transaction

To create, sign, and broadcast a Unbond transaction, use the following command:

./pactus-wallet ~/pactus/wallets/wallet_1 tx unbond <ADDRESS>
./pactus-wallet ~/pactus/wallets/wallet_1 tx unbond <ADDRESS>
pactus-wallet.exe c:\pactus\wallets\wallet_1 tx unbond <ADDRESS>

In this command, <ADDRESS> is the address of the validator that you want to unbond.

Sending Withdraw transaction

To create, sign, and broadcast a Withdraw transaction, use the following command:

./pactus-wallet ~/pactus/wallets/wallet_1 tx unbond <FROM> <TO> <AMOUNT>
./pactus-wallet ~/pactus/wallets/wallet_1 tx unbond <FROM> <TO> <AMOUNT>
pactus-wallet.exe c:\pactus\wallets\wallet_1 tx withdraw <FROM> <TO> <AMOUNT>