Skip to content

Commit

Permalink
docs: include call contract improvements in the existing docs
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexD10S committed Dec 10, 2024
1 parent 3c1dffa commit 30961de
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
20 changes: 18 additions & 2 deletions pop-cli-for-smart-contracts/guides/calling-your-contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,30 @@

Now that your contract is deployed locally, we can start interacting with it.

Grab the contract address that was outputted from the [previous step](deploy-your-contract-locally/deploy-locally-on-a-solochain.md).
### Interactive Guidance (Recommended)

Interact with your deployed contract **with** Pop CLI's interactive guidance by simply entering:

```shell
pop call contract -p ./flipper --contract 5CLPm1CeUvJhZ8GCDZCR7nWZ2m3XXe4X5MtAQK69zEjut36A --message get --suri //Alice
pop call contract
```

Grab the contract address that was outputted from the [previous step](deploy-your-contract-locally/deploy-locally-on-a-solochain.md).

> If you lost the address, you can always pull up [PolkadotJs Apps](https://polkadot.js.org/apps/) and check the chain state for the contract address.
You will be prompted to select a contract, choose messages, and configure additional options interactively.

<figure><img src="../../.gitbook/assets/call-contract.gif" alt="pop call contract"><figcaption><p>pop call contract</p></figcaption></figure>

### Manual (non-interactive)

If you prefer not to use the interactive prompts, you can call your contract by specifying all the required arguments directly.

```shell
pop call contract -p ./flipper --contract 5CLPm1CeUvJhZ8GCDZCR7nWZ2m3XXe4X5MtAQK69zEjut36A --message get --suri //Alice
```

```
┌ Pop CLI : Calling a contract
Expand Down
12 changes: 12 additions & 0 deletions pop-cli-for-smart-contracts/pop-cli/call.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ pop call <COMMAND>

**Interacting with the smart contract**

```bash
pop call contract
```
The above will provide interactive guidance to interact with the smart contract.

If interactive guidance is not desired than one can proceed with:

Read-only Operations: For operations that only require reading from the blockchain state. This approach does not require to submit an extrinsic. Example using the get() message:

```bash
Expand Down Expand Up @@ -69,9 +76,14 @@ Options:
e.g. - for a dev account "//Alice" - with a password "//Alice///SECRET_PASSWORD"
[default: //Alice]
-x, --execute
Submit an extrinsic for on-chain execution
--dry-run
Perform a dry-run via RPC to estimate the gas usage. This does not submit a transaction
-d, --dev
Enables developer mode, bypassing certain user prompts for faster testing. Recommended for testing and local development only
```

0 comments on commit 30961de

Please sign in to comment.