Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: include call contract improvements in the existing docs #11

Merged
merged 4 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 @@

AlexD10S marked this conversation as resolved.
Show resolved Hide resolved
Now that your contract is deployed locally, we can start interacting with it.
AlexD10S marked this conversation as resolved.
Show resolved Hide resolved

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:
AlexD10S marked this conversation as resolved.
Show resolved Hide resolved

```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).
AlexD10S marked this conversation as resolved.
Show resolved Hide resolved

> 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.
AlexD10S marked this conversation as resolved.
Show resolved Hide resolved

<figure><img src="../.gitbook/assets/callcontract.gif" alt="pop call contract"><figcaption><p>pop call contract</p></figcaption></figure>
AlexD10S marked this conversation as resolved.
Show resolved Hide resolved

### Manual (non-interactive)
AlexD10S marked this conversation as resolved.
Show resolved Hide resolved

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**
AlexD10S marked this conversation as resolved.
Show resolved Hide resolved

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

If interactive guidance is not required, you can proceed as follows:
AlexD10S marked this conversation as resolved.
Show resolved Hide resolved

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
```
Loading