Skip to content

Commit 3604b27

Browse files
authored
Merge pull request #27 from fabricwave/update/july_2024
July 2024 Documentation Update
2 parents 017a457 + f0020f9 commit 3604b27

File tree

7 files changed

+61
-50
lines changed

7 files changed

+61
-50
lines changed

docs/for_developers/smart_contracts/getting_started.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ You can deploy the contract using the pchain_client command line tool. You shoul
139139

140140
=== "Linux / macOS"
141141
```bash
142-
./pchain_client transaction create
142+
./pchain_client transaction create \
143143
--nonce <NONCE> \
144144
--gas-limit <GAS_LIMIT> \
145145
--max-base-fee-per-gas <MAX_BASE_FEE_PER_GAS> \
@@ -160,7 +160,7 @@ You can deploy the contract using the pchain_client command line tool. You shoul
160160
--cbi-version <CBI_VERSION>
161161
```
162162

163-
You can follow the instruction in [Create Transaction](../../for_users/pchain_client_cli/creating_transaction.md) about submiting a transaction through `pchain-client`.
163+
You can refer to the instruction and example arguments in [Create & Submit Transaction](../../for_users/pchain_client_cli/creating_transaction.md) to create and submit a transaction through `pchain-client`.
164164

165165
## Checking Contract In State
166166

@@ -237,7 +237,7 @@ The command argument `arguments` is the JSON file that contains the method argum
237237

238238
The gas limit required for the transaction depends on the complexity of the smart contract. For safety reasons, you can always set a higher gas limit. You can also test contract calls on testnet to reassure.
239239

240-
You can follow the instruction in [Create Transaction](../../for_users/pchain_client_cli/creating_transaction.md) about submiting a transaction through `pchain-client`.
240+
You can refer to the instruction and example arguments in [Create & Submit Transaction](../../for_users/pchain_client_cli/creating_transaction.md) to create and submit a transaction through `pchain-client`.
241241

242242
To query the resulting receipt of the transaction,
243243

@@ -256,15 +256,15 @@ The commands stored in `transaction` and command receipts in `receipt` are follo
256256

257257
To parse the response from the contract method, represented in the field named `return value` , which is in `CallResult` format, you can use the `parse call-result` command in ParallelChain Client.
258258

259-
For example, if the contract method returns a u32 integer, the `return value` is "BAAAAAUAAAA" you can parse the `CallResult` data structure using the `--data-type u32` flag:
259+
For example, if the contract method returns a u32 integer, the `return value` is "BQAAAA" you can parse the `CallResult` data structure using the `--data-type u32` flag:
260260

261261
=== "Linux / macOS"
262262
```bash
263-
pchain_client parse call-result --value BAAAAAUAAAA --data-type u32
263+
pchain_client parse call-result --value BQAAAA --data-type u32
264264
```
265265
=== "Windows PowerShell"
266266
```PowerShell
267-
./pchain_client.exe parse call-result --value BAAAAAUAAAA --data-type u32
267+
./pchain_client.exe parse call-result --value BQAAAA --data-type u32
268268
```
269269

270-
The output will be the parsed value of the `CallResult`, which in this case is `4`. For more details, you can use the `help` command to see the usage of the tool or take a look at the example `argument,json`.
270+
The output will be the parsed value of the `CallResult`, which in this case is `5`. For more details, you can use the `help` command to see the usage of the tool or take a look at the example `argument,json`.

docs/for_developers/smart_contracts/smart_contract_examples/4_contract_proxy.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,16 @@ Recall that we have a deployed contract called `MyLittlePony` that consists of t
2020
`self_introduction()`, `grow_up()`, and `change_person()`. We are going to use `grow_up()` in
2121
`ContractProxy`, so we can comment out the rest of them.
2222

23+
!!! Pre-requisites
24+
Deploy [My Little Pony](./2_my_little_pony.md) smart contract, and then replace the address supplied to `use_contract` macro with the smart contract address of My Little Pony.
25+
2326
### lib.rs: define a trait
2427
```rust
2528
use pchain_sdk::{
2629
use_contract, call, contract, contract_methods
2730
};
2831

29-
#[use_contract("-jUt6jrEfMRD1JM9n6_yAASl2cwsc4tg1Bqp07gvQpU")]
32+
#[use_contract("xxT5OXMonFm8wcDw-io1jeyAEnxSddGPOG-ZezArCV4")]
3033
pub trait MyLittlePony {
3134
//fn self_introduction() -> String;
3235
fn grow_up();
@@ -59,11 +62,14 @@ The above example has shown how we can use the `use_contract` macro to do [cross
5962
to use `pchain_sdk::call_untyped()` to do so. We pass the contract address as an argument so that the contract
6063
address does not need to be hard-coded in the contract.
6164

65+
!!! note
66+
Add `base64url = "0.1.0"` under `[Dependency]` in `Cargo.toml` for the project.
67+
6268
### lib.rs: pchain_sdk::call_untyped()
6369
```rust
6470
#[call]
6571
fn grow_up_2(address: String) {
66-
let contract_address = base64url::decode(address).unwrap().try_into().unwrap();
72+
let contract_address = base64url::decode(&address).unwrap().try_into().unwrap();
6773
pchain_sdk::call_untyped(
6874
contract_address,
6975
"grow_up",
@@ -80,7 +86,7 @@ contract to a specific address by `pchain_sdk::transfer()` (see [Transferring Ba
8086
```rust
8187
#[call]
8288
fn send_tokens(to_address: String, value :u64){
83-
let contract_address = base64url::decode(to_address).unwrap().try_into().unwrap();
89+
let contract_address = base64url::decode(&to_address).unwrap().try_into().unwrap();
8490
pchain_sdk::transfer(
8591
contract_address,
8692
value

docs/for_developers/smart_contracts/smart_contract_examples/5_my_collections.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ We are going to demonstrate the use of module [collections](https://github.com/p
1111

1212
`collections` are designed as a data structure for gas efficiency:
1313

14-
- Cacher: allows lazy initialization
14+
- Cacher: allows lazy loading of a field in contract storage
1515
- Vector: lazily stores a list of items
1616
- FastMap: lazily stores items into a key-value map
1717
- IterableMap: lazily stores items into an iterable key-value map
@@ -37,7 +37,7 @@ pub struct MyCollections {
3737
```
3838

3939
### Cacher
40-
`Cacher` is a data wrapper to support Lazy Read and Lazy Write to Contract Storage.
40+
`Cacher` is a data wrapper to support Lazy Read and Lazy Write to a field in Contract Storage.
4141

4242
```rust
4343
#[contract_methods]

docs/for_developers/smart_contracts/smart_contract_examples/6_my_pool.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ After adding the `init()` function, we can try creating a deposit into the pool.
5959
The staking commands are "deferred" because the actual execution of such commands occurs after the execution of a successful call.
6060

6161
!!! Note
62-
The deposit is created on behalf of the contract address, not from your account address, so make sure to transfer
63-
sufficient balance to the contract for the operation.
62+
The deposit is created on behalf of the contract address, not from your account address, so make sure to transfer sufficient balance to the contract for the operation.
6463

6564

6665
To check if the deposit is successful, you can check the deposit using `pchain-client` with the following [command](../../../for_users/pchain_client_cli/querying_blockchain.md#get-deposit-and-stake):

docs/for_users/pchain_client_cli/creating_transaction.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ Example - Deploy contract and save to designated file `deposit-tx.json`:
9999
./pchain_client transaction create \
100100
--destination ~/Documents/deposit-tx.json \
101101
--nonce 0 \
102-
--gas-limit 100000 \
102+
--gas-limit 500000000 \
103103
--max-base-fee-per-gas 8 \
104104
--priority-fee-per-gas 0 \
105105
deploy \
@@ -111,7 +111,7 @@ Example - Deploy contract and save to designated file `deposit-tx.json`:
111111
./pchain_client.exe transaction create `
112112
--destination ~/Documents/deposit-tx.json `
113113
--nonce 0 `
114-
--gas-limit 100000 `
114+
--gas-limit 500000000 `
115115
--max-base-fee-per-gas 8 `
116116
--priority-fee-per-gas 0 `
117117
deploy `
@@ -144,7 +144,10 @@ Example:
144144
```
145145

146146
### Submit Transaction to ParallelChain
147-
After preparing the transaction json file, you can now submit the transaction with keypair.
147+
After preparing the transaction json file, you can now submit the transaction with [keypair](../../for_users/pchain_client_cli/managing_account.md/).
148+
149+
!!! Note
150+
Executing transactions may require paying for gas fees. If you are testing transactions on Parallelchain Testnet, you can get free testnet tokens from the [Faucet Service](../../fundamentals/networks.md#faucet-service) to pay for the gas fees.
148151

149152
Example:
150153

docs/for_users/pchain_client_cli/getting_started.md

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ For a detailed description of all available commands, execute `pchain_client --h
1111
**Usage**
1212

1313
```terminal
14-
ParallelChain Client CLI 0.4.3
14+
ParallelChain Client CLI 0.4.4
1515
<ParallelChain Lab>
1616
ParallelChain client (`pchain_client`) is a command-line tool for you to connect and interact with
1717
the ParallelChain Mainnet/Testnet.
@@ -44,7 +44,7 @@ SUBCOMMANDS:
4444
2. Unzip the file to extract the executable `pchain_client.exe`.
4545
3. Open Powershell by pressing *WIN+R* and typing `powershell`.
4646
4. Navigate to the directory where `pchain_client.exe` is located using the `cd` command. For example, if the executable is located at `C:\Development`, type `cd C:\Development`.
47-
5. Follow the instructions in Section [Prepare Environment](#prepare-environment) to get ready for interacting with the blockchain.
47+
5. Follow the instructions in Section [Preparing Environment](#preparing-environment) to get ready for interacting with the blockchain.
4848

4949
### Linux / macOS
5050

@@ -56,14 +56,14 @@ The installation process for Linux and macOS is similar. To install `pchain_clie
5656

5757
=== "Linux"
5858
```bash
59-
tar -xvf pchain_client_linux_v0.4.3.tar.gz
59+
tar -xvf pchain_client_linux_v0.4.4.tar.gz
6060
```
6161
=== "macOS"
6262
```bash
63-
tar -xvf pchain_client_mac_v0.4.3.tar.gz
63+
tar -xvf pchain_client_mac_v0.4.4.tar.gz
6464
```
6565

66-
3. Follow the instructions in Section [Prepare Environment](#prepare-environment) to get ready for interacting with the blockchain.
66+
3. Follow the instructions in Section [Preparing Environment](#preparing-environment) to get ready for interacting with the blockchain.
6767

6868

6969
!!! Tips
@@ -85,34 +85,6 @@ The installation process for Linux and macOS is similar. To install `pchain_clie
8585
!!! note
8686
If this is your first time using `pchain_client`, you need to set up `$PCHAIN_CLI_HOME` in environment variables to specify the home path. See more [here](https://chlee.co/how-to-setup-environment-variables-for-windows-mac-and-linux/).
8787

88-
## Running pchain_client
89-
90-
### Create Password
91-
92-
For the first time to use `pchain_client`, you need to create your password for using it. The terminal should prompt you as follows:
93-
94-
```text
95-
First time using ParallelChain Client CLI. Please set up a password to protect your keypairs.
96-
Your password:
97-
```
98-
99-
This password is only used by the CLI, and **NOT** associated with the blockchain. It is used for encryption and decryption of your keypairs so that the keypairs are stored in your computer more securely. Alternatively, you can skip the password protection by simply pressing **Enter**.
100-
101-
You will be required to enter your password twice. If your password is set successfully, you will see a return message with the `pchain_client` version shown on the console.
102-
103-
=== "Linux / macOS"
104-
```bash
105-
./pchain_client --version
106-
```
107-
=== "Windows PowerShell"
108-
```PowerShell
109-
./pchain_client.exe --version
110-
```
111-
112-
!!! warning
113-
The password is not sent and saved anywhere. You won't be able to recover the password if you lose it. Please keep your password safe. You will be required to provide this password to submit transactions and manage keypairs later.
114-
115-
11688
## Preparing Environment
11789

11890
### Set Environmental Variables
@@ -179,3 +151,30 @@ This would check the status of your chosen provider. If `pchain_client` cannot c
179151
A `config.toml` file will be created in the folder specified by the environment variable `PCHAIN_CLI_HOME` upon success. It only needs to be executed once.
180152

181153
Now you can start the journey to play around with `pchain_client`!
154+
155+
## Running pchain_client
156+
157+
### Create Password
158+
159+
For the first time to use `pchain_client`, you need to create your password for using it. The terminal should prompt you as follows:
160+
161+
```text
162+
First time using ParallelChain Client CLI. Please set up a password to protect your keypairs.
163+
Your password:
164+
```
165+
166+
This password is only used by the CLI, and **NOT** associated with the blockchain. It is used for encryption and decryption of your keypairs so that the keypairs are stored in your computer more securely. Alternatively, you can skip the password protection by simply pressing **Enter**.
167+
168+
You will be required to enter your password twice. If your password is set successfully, you will see a return message with the `pchain_client` version shown on the console.
169+
170+
=== "Linux / macOS"
171+
```bash
172+
./pchain_client --version
173+
```
174+
=== "Windows PowerShell"
175+
```PowerShell
176+
./pchain_client.exe --version
177+
```
178+
179+
!!! warning
180+
The password is not sent and saved anywhere. You won't be able to recover the password if you lose it. Please keep your password safe. You will be required to provide this password to submit transactions and manage keypairs later.

docs/for_users/pchain_client_cli/querying_blockchain.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ tags:
1010
Use `pchain_client query --help` to check the full list available to query.
1111

1212
### Check Account Related Information
13+
14+
!!! Note
15+
If you don't have access to an account yet, check "See also" under [How Account Works](../../fundamentals/accounts.md#how-account-works) to create an account.
16+
1317
To check Externally Owned Accounts (EOA) information such as balance and nonce, your account address (public key) is always needed.
1418

1519
Commands:

0 commit comments

Comments
 (0)