CLI Quick Start Guide
Hey, Powerian! Welcome to the Power DCloud CLI! This guide will help you get started with the tpe
CLI to manage your decentralized applications and services on the Power DCloud platform.
Prerequisites
Node.js
must be installed on your machine.- You must have access to terminal or command line interface.
Installation
-
Install the
tpe
CLI:- npm
- Yarn
- pnpm
npm install -g @thepowereco/cli
yarn global add @thepowereco/cli
pnpm add -g @thepowereco/cli
-
Verify the installation:
tpe --version
If the installation was successful, the command returns something like this:
@thepowereco/cli/1.11.131 darwin-arm64 node-v20.12.2
Getting Started
Account Management
-
Register a new account:
tpe acc register --chain 1 --password yourpassword --filePath /path/to/save_a_file.pem
Keys:
--chain
— a chain, where the account will be created,--password
— password for a key file. Ensure, you've remembered it, otherwise you'll lose access to your account!--filePath
— path to save account key file.
NoteMake sure you add
.pem
to your account key file.If the account is created successfully, you'll get a message like:
Account registration... done
{
"chain": 1,
"wif": "ACCOUNT_WIF",
"address": "ACCOUNT_ADDRESS",
"seed": "SEED_PHRASE"
}
File saved at: /Users/usr/new_account_test.pem -
Check wallet balance:
tpe acc get-balance --address YOUR_WALLET_ADDRESS
-
Send SK tokens:
tpe acc send-sk -a 100 -t RECIPIENT_ADDRESS -k /path/to/keyfile.pem --password yourpassword
Keys:
-a
— amount to be sent,-t
— recipient address,-k
— path to your key file,--password
— your key file password.
If the command is successful, you'll get the following message:
Loading... done
{
"txId": "2hcUb7e4QstfpX4W-c1n1.ed",
"res": "ok",
"block": "C67977213CF7C1BEE04935E047C8469FDA1111EA328DB4E93E58D442F1D65FB1"
} -
Send tokens to contracts, without running EVM:
tpe acc send-sk -a 1 -k ./power_wallet_**_***.pem -t AA100002352165683776 -g NORUN -v 0
Keys:
-a
— amount to be sent,-t
— recipient address,-k
— path to your key file,-g
- token used to pay for gas.NORUN
means that EVM will not start,-v
— gas value for deployment.
Container Management
-
Create a new container:
tpe container create --keyFilePath /path/to/keyfile.pem --password yourpassword --containerName "MyContainer"
Keys:
keyFilePath
— path to your key file,--password
— your key file password,containerName
— choose the name for your container.
If a container has been created successfully, you'll get the following message:
Loading... done
Container Container_test created with order ID: 9
Transaction: [TRANSACTION_LINK] -
List your containers:
tpe container list --keyFilePath /path/to/keyfile.pem --password yourpassword
Keys:
keyFilePath
— path to your key file,--password
— your key file password.
If the command is successful, you'll get the following message:
Loading... done
┌────┬────────────────┬─────────┬──────────────────────────────────────────────┬─────────────────────┬─────────────────┬──────────────────────┬───────────┐
│ Id │ Name │ Status │ Pubkey │ Created │ Active provider │ Handover To Provider │ Hold time │
├────┼────────────────┼ ─────────┼──────────────────────────────────────────────┼─────────────────────┼─────────────────┼──────────────────────┼───────────┤
│ 9 │ Container_test │ Pending │ CONTAINER_PUBLIC_KEY │ 16.07.2024 20:23:36 │ 0 │ 0 │ 0 │
└────┴────────────────┴─────────┴──────────────────────────────────────────────┴─────────────────────┴─────────────────┴──────────────────────┴───────────┘ -
Upload files to a container:
tpe container upload --containerId CONTAINER_ID --keyFilePath /path/to/keyfile.pem --password yourpassword --filesPath /path/to/files
Keys:
containerId
— your container ID. You cankeyFilePath
— path to your key file,--password
— your key file password.
-
Update your files in the container:
tpe container update -k ./key.pem -p mypassword -i 123 -n "New Container Name" -f ./containerKey.pem -s containerpassword
Keys:
-k
— path to the key file.-p
— key file password.-i
— container ID.-n
— container name.-f
— path to the container key file.-s
— container key file password.
-
Perform container actions:
container_start
— start the container.container_stop
— stop the container.container_destroy
— destroy the container.container_handover
— handover the container.container_getPort
— get the container port.container_getLogs
— get container logs.
tpe container actions -m "container_getPort" -p "1 web 5000" -f ./path/to/keyfile.pem -s mypassword
Keys:
-m
— action (method),-p
— action parameters,-f
— path to container key file,-s
— container password.
Smart Contract Management
-
Deploy a smart contract:
tpe contract deploy --abiPath /path/to/contract.abi --binPath /path/to/bin --keyFilePath /path/to/keyfile.pem --password yourpassword
Keys:
--abiPath
— path to contract.abi
file. Please, refer to Create and prepare a smart contract section for more information,--binPath
— path to contract.bin
file. Please, refer to Create and prepare a smart contract section for more information,--keyFilePath
— path to your account key file. Please, refer to Account Management section of this document,--password
— your account password.
-
Call a method on a deployed contract:
tpe contract get --abiPath /path/to/contract.abi --address CONTRACT_ADDRESS --method METHOD_NAME --params "param1 param2"
Keys:
--abiPath
— path to contract.abi
file. Please, refer to Create and prepare a smart contract section for more information,--address
— your deployed contract address,--method
— method you'd like to call,--params
— method parameters.
-
Execute a method on a smart contract:
tpe contract set --abiPath /path/to/abi.json --address CONTRACT_ADDRESS --keyFilePath /path/to/keyfile.pem --method METHOD_NAME --params "param1 param2" --password yourpassword
Keys:
--abiPath
— path to contract.abi
file. Please, refer to Create and prepare a smart contract section for more information,--address
— your deployed contract address,--keyFilePath
— path to your account key file. Please, refer to Account Management section of this document,--method
— method you'd like to call,--params
— method parameters,--password
— your account password.
Storage Management
-
Upload application files to storage:
tpe storage upload --configPath /path/to/config.json
-
List storage tasks:
tpe storage tasklist --configPath /path/to/config.json
Provider management
-
Create a new provider with a given name and key pair:
tpe provider create -k ./key.pem -p mypassword -n "NewProvider" -s containerpassword
Keys:
-a
— provider smart contract address,-k
— path to your key file,-n
— provider name,-p
— key file password,-r
— sponsor address.
-
List all providers or filter by key file or address:
tpe provider list -k ./key.pem -p mypassword
Keys:
-a
— provider smart contract address,-k
— key file password,-o
— order smart contract address,-p
— key file password,-r
— filter by address.
-
Set or update the URL for a specific provider using the provider ID.
noteRequires a key file for authentication.
tpe provider set-url -k ./key.pem -p mypassword -i 123 -u "https://provider.example.com"
Keys:
-a
— order smart contract address,-i
— provider ID,-k
— path to the key file,-p
— key file password,-r
— sponsor address,-u
— provider URL.
Additional Commands
-
View all available commands:
tpe help
-
Update the
tpe
CLI:tpe update
-
Display autocomplete installation instructions:
tpe autocomplete [SHELL] [-r]
where
- [SHELL] — shell type (zsh, bash, or powershell)
-r
— refresh cache. This option ignores displaying instructions.