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 all 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.
2 changes: 1 addition & 1 deletion pop-cli-for-smart-contracts/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* [Deploy your contract locally](guides/deploy-your-contract-locally/README.md)
* [Deploy locally on a Solochain](guides/deploy-your-contract-locally/deploy-locally-on-a-solochain.md)
* [Deploy locally on Pop](guides/deploy-your-contract-locally/deploy-locally-on-pop.md)
* [Calling your contract](guides/calling-your-contract.md)
* [Call your contract](guides/call-your-contract.md)
* [Running E2E tests](guides/running-e2e-tests.md)
* [Deploy on Pop](guides/deploy-on-pop-testnet.md)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,31 @@
# Calling your contract
# Call your contract

Now that your contract is deployed locally, we can start interacting with it.
Now that your contract is deployed, we can interact 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 the path to your contract, choose which contract message to call, and provide the arguments for the message.

<figure><img src="../.gitbook/assets/callcontract.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
13 changes: 12 additions & 1 deletion pop-cli-for-smart-contracts/pop-cli/call.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ description: Call a contract
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 required, you have to provide all the required arguments.

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:

Expand Down Expand Up @@ -69,9 +75,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