Interact and view your private deployment from your commandline.
To use the Partisia CLI tool with a private deployment you must first configure it to target your chain. This can be done by running the following command
cargo pbc config net local "http://localhost:9432,http://localhost:8300,0" --default
Where
http://localhost:9432
is the url of the reader endpointhttp://localhost:8300
is the url of the browser- 0 is the number of shards
Any following command will now target the private deployment
Partisia CLI commands
You can get information about the usage or option for any command by using the option --help.
Below are some commonly used commands.
Deploy a contract
cargo pbc transaction deploy --pk=./key.pk token.wasm token.abi Test Test 3 1050
Where
./key.pk
is the path to your private key filetoken.wasm
is the wasm byte code of your contracttoken.abi
is the abi byte code of your contractTest Test 3 1050
are the RPC arguments to the init function of your contract. In this case two strings and two numbers.
Response from example command
Deployed contract successfully.
Contract deployed at: 021c79a1b80a9f30ac49675a834f532fcb70276f8b
View it in browser here: http://localhost:8300/contracts/021c79a1b80a9f30ac49675a834f532fcb70276f8b
Send a transaction to a contract
cargo pbc transaction action --pk=./key.pk 021c79a1b80a9f30ac49675a834f532fcb70276f8b transfer 00db4eb445882bdb5c40c5959d1260d9383035b4e5 100
Where
./key.pk
is the path to your private key file021c79a1b80a9f30ac49675a834f532fcb70276f8b
is the address of the contracttransfer
is the name of the action you are trying to invoke00db4eb445882bdb5c40c5959d1260d9383035b4e5 100
are the RPC arguments of that action. In this case an address and an amount.
Response from example command
Transaction successfully sent: http://localhost:8300/transactions/220f27415e1781eda864decc53b3362345efaedb4e5ed79b2ea2d8d0297015ee
Show the state of a contract
cargo pbc contract show 021c79a1b80a9f30ac49675a834f532fcb70276f8b --state
Where
021c79a1b80a9f30ac49675a834f532fcb70276f8b
is the address of the contract--state
is the option for showing the state of the contract
Response from example command
{
"contractState" : {
"name" : "Test",
"decimals" : 3,
"symbol" : "Test",
"owner" : "00e72e44eab933faaf1fd4ce94bb57e08bff98a1ed",
"total_supply" : "1050",
"balances" : [ {
"key" : "00db4eb445882bdb5c40c5959d1260d9383035b4e5",
"value" : "100"
}, {
"key" : "00e72e44eab933faaf1fd4ce94bb57e08bff98a1ed",
"value" : "950"
} ],
"allowed" : [ ]
}
}
Show list of owned secret variables
cargo pbc contract --pk=./key.pk secret list 03728784c957e46f7f428dc8b8348ce1e7d1d709bc
Where
./key.pk
is the path to your private key file021c79a1b80a9f30ac49675a834f532fcb70276f8b
is the address of the contract
Response from example command
[ {
"id" : 1,
"owner" : "00e72e44eab933faaf1fd4ce94bb57e08bff98a1ed",
"sealed" : false,
"transaction" : "044b7860c2d118d708c7a2b5136941d66ebbf89709e69b7f773f6f721caa0ba5",
"information" : {
"data" : "AA=="
}
} ]
Get value of owned secret
cargo pbc contract --pk=./key.pk secret show 03728784c957e46f7f428dc8b8348ce1e7d1d709bc 1 i32
Where
./key.pk
is the path to your private key file021c79a1b80a9f30ac49675a834f532fcb70276f8b
is the address of the contract1
is the id of the variablei32
is the type of the variable. Can be a number type or a named type defined in the abi.
Response from example command
Secret: 400
ABI commands
The abi
command contains subcommands useful for working with ABIs.
Show the structure of an ABI
cargo pbc abi show ./token.abi
Where
./token.abi
is the path to your ABI file
Response from example command
// Version Binder: 10.2.0
// Version Client: 5.5.0
pub struct EventSubscriptionId {
raw_id: i32,
}
pub struct ExternalEventId {
raw_id: i32,
}
pub struct SecretVarId {
raw_id: u32,
}
pub struct Transfer {
to: Address,
amount: u128,
}
#[state]
pub struct TokenState {
name: String,
decimals: u8,
symbol: String,
owner: Address,
total_supply: u128,
balances: Map<Address, u128>,
allowed: Map<Address, Map<Address, u128>>,
}
#[init]
pub fn initialize (
name: String,
symbol: String,
decimals: u8,
total_supply: u128,
)
#[action(shortname = 0x01)]
pub fn transfer (
to: Address,
amount: u128,
)
#[action(shortname = 0x02)]
pub fn bulk_transfer (
transfers: Vec<Transfer>,
)
#[action(shortname = 0x03)]
pub fn transfer_from (
from: Address,
to: Address,
amount: u128,
)
#[action(shortname = 0x04)]
pub fn bulk_transfer_from (
from: Address,
transfers: Vec<Transfer>,
)
#[action(shortname = 0x05)]
pub fn approve (
spender: Address,
amount: u128,
)
#[action(shortname = 0x07)]
pub fn approve_relative (
spender: Address,
delta: i128,
)
Generate code for a contract interactions
cargo pbc abi codegen --ts ./token.abi Token.ts
Where
--ts
is the language to generate. Supported languages are--ts
and--java
../token.abi
is the path to your ABI fileToken.ts
is the name of the generated file.
This generates a file able to serialize RPC payloads or deserialize state.