Skip to content
Draft
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
82 changes: 40 additions & 42 deletions docs/getting-started/calling.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,85 +52,83 @@ are emitted if they want clients to be able to pick up on them.

![Contract execution via transaction](/img/events-revive.svg)

## Using the Terminal

When you deployed your contract you received the contract address. Use this to interact with the contract.
```bash
Contract Address: 5DXR2MxThkyZvG3s4ubu9yRdNiifchZ9eNV8i6ErGx6u1sea
```

### 1. `get()` function
Choose your preferred method to call your contract:

<Tabs>
<TabItem value="cargo-contract" label="cargo-contract" default>
```bash
cargo contract call
--contract <insert-contract-address>
--message get
--suri //Alice
```
</TabItem>
<TabItem value="pop" label="Pop">
<TabItem value="pop" label="Pop" default>
Pop CLI provides a simple way to interact with your deployed contracts.

### Read contract state (`get()` function)

```bash
pop call contract
--contract <insert-contract-address>
--message get
--suri //Alice
```
</TabItem>
</Tabs>

### 2. `flip()` function
### Modify contract state (`flip()` function)

<Tabs>
<TabItem value="cargo-contract" label="cargo-contract" default>
```bash
cargo contract call
pop call contract
--contract <insert-contract-address>
--message flip
--execute
--suri //Alice
```

For more detailed information about Pop CLI contract interaction, see the [Pop CLI call guide](https://learn.onpop.io/contracts/guides/call-your-contract).
</TabItem>
<TabItem value="pop" label="Pop">
<TabItem value="cargo-contract" label="cargo-contract">
### Read contract state (`get()` function)

```bash
pop call contract
cargo contract call
--contract <insert-contract-address>
--message get
--suri //Alice
```

### Modify contract state (`flip()` function)

```bash
cargo contract call
--contract <insert-contract-address>
--message flip
--execute
--suri //Alice
```
</TabItem>
</Tabs>

:::tip
For more info about interacting with your smart contract using the Pop CLI, [check this out](https://learn.onpop.io/contracts/guides/call-your-contract)!
:::
<TabItem value="contracts-ui" label="Contracts UI">
Go to https://ui.use.ink/

## Using the Contracts UI
### Read contract state (`get()` function)

Go to https://ui.use.ink/
We set the initial value of the Flipper contract
`value` to `false` when we instantiated the contract. Let's check that this is the case.

### 1. `get()` function
In the **Message to Send** section, select the "**get(): bool**" message and accept the default
values for the other options.

We set the initial value of the Flipper contract
`value` to `false` when we instantiated the contract. Let's check that this is the case.
Press **"Read"** and confirm that it returns the value `false`:

In the **Message to Send** section, select the "**get(): bool**" message and accept the default
values for the other options.
![An image of Flipper RPC call with false](/img/contracts-ui-4.png)

Press **"Read"** and confirm that it returns the value `false`:
### Modify contract state (`flip()` function)

![An image of Flipper RPC call with false](/img/contracts-ui-4.png)
So let's make the value turn `true` now!

### 2. `flip()` function
The alternative message to send with the UI is `flip()`. Again, accept the default values for the other options and click **Call contract**

So let's make the value turn `true` now!
![An image of a Flipper transaction](/img/contracts-ui-5.png)

The alternative message to send with the UI is `flip()`. Again, accept the default values for the other options and click **Call contract**
If the transaction was successful, we should then be able to go back to the `get()` function and see our updated storage:

![An image of a Flipper transaction](/img/contracts-ui-5.png)

If the transaction was successful, we should then be able to go back to the `get()` function and see our updated storage:

![An image of Flipper RPC call with true](/img/contracts-ui-6.png)
![An image of Flipper RPC call with true](/img/contracts-ui-6.png)
</TabItem>
</Tabs>
24 changes: 12 additions & 12 deletions docs/getting-started/compiling.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ import TabItem from '@theme/TabItem';
Run the following command in your `flipper` directory to compile your smart contract:

<Tabs>
<TabItem value="cargo-contract" label="cargo-contract" default>
<TabItem value="pop" label="Pop" default>
```bash
cargo contract build
pop build
```
</TabItem>
<TabItem value="pop" label="Pop">
<TabItem value="cargo-contract" label="cargo-contract">
```bash
pop build
cargo contract build
```
</TabItem>
</Tabs>
Expand Down Expand Up @@ -134,14 +134,14 @@ For contracts that are supposed to run in production you should always build the
contract with `--release`:

<Tabs>
<TabItem value="cargo-contract" label="cargo-contract" default>
<TabItem value="pop" label="Pop" default>
```bash
cargo contract build --release
pop build --release
```
</TabItem>
<TabItem value="pop" label="Pop">
<TabItem value="cargo-contract" label="cargo-contract">
```bash
pop build --release
cargo contract build --release
```
</TabItem>
</Tabs>
Expand All @@ -158,14 +158,14 @@ the `--release` flag has to be passed explicitly to `cargo build`.
If you created a new project using a template, you can find at the bottom of the lib.rs simple test cases which verify the functionality of the contract. We can quickly test this code is functioning as expected:

<Tabs>
<TabItem value="cargo-contract" label="cargo-contract" default>
<TabItem value="pop" label="Pop" default>
```bash
cargo contract test
pop test
```
</TabItem>
<TabItem value="pop" label="Pop">
<TabItem value="cargo-contract" label="cargo-contract">
```bash
pop test
cargo contract test
```
</TabItem>
</Tabs>
Expand Down
8 changes: 4 additions & 4 deletions docs/getting-started/creating.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ import TabItem from '@theme/TabItem';
Make sure you have [installed the tooling](./setup.md) and that you are in the working directory, and then run:

<Tabs>
<TabItem value="cargo-contract" label="cargo-contract" default>
<TabItem value="pop" label="Pop" default>
```bash
cargo contract new flipper
pop new contract
```
</TabItem>
<TabItem value="pop" label="Pop">
<TabItem value="cargo-contract" label="cargo-contract">
```bash
pop new contract
cargo contract new flipper
```
</TabItem>
</Tabs>
Expand Down
Loading