Skip to content

Commit

Permalink
chore: setup your first context (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
MatejVukosav authored Sep 17, 2024
1 parent 0a9b4f0 commit b509342
Show file tree
Hide file tree
Showing 9 changed files with 188 additions and 14 deletions.
4 changes: 2 additions & 2 deletions docs/03-getting-started/01-setup.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ Clone repository from GitHub.
git clone https://github.com/calimero-network/core.git
```

or
or

```bash title="Terminal"
git clone [email protected]:calimero-network/core.git
```

Position in the root of the project
Position in the root of the project

```bash title="Terminal"
cd core
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
id: create-context
title: Create Context
---

## Create a context using the Admin Dashboard

1. Navigate to the “Contexts” tab and click the "Start New Context" button.
2. Use the "Browse" button to select an application from the list.
3. Choose the "Template Application" option.
4. Press "Start" to initiate the context creation process with the selected
application.

After the context is created, you will be redirected to the context dashboard.
Keep this page open as you will need the Context ID later.

Since a coordinator node is required for each context, you’ll need to invite the
coordinator to join. Follow the steps in the
[Invite To Context](./02-invite-to-context.mdx) guide. guide to complete this
process.

## Create context with the CLI using meroctl

### Step 1: Install the Application

Run the following command to install the application:

```bash
cargo run -p meroctl -- --node-name node1 --home data app install --url {url} --metadata '{“contractAppId”: {contractApplicationId} }'
```

You can find the application URL and contractApplicationId by opening
Application Details from Applications section of the Admin Dashboard.

![Application details](/admin-dashboard/application-details-for-context-creation.png)

“contractAppId” is the id of application stored in the contract. Value is
optional but if provided, it enables admin-dashboard to extract and display the
application metadata.

```bash title="Example"
cargo run -p meroctl -- --node-name node1 --home data app install --url https://blobby-public.euw3.prod.gcp.calimero.network/bafkreihl5o6etrnpy7dlgixz3onbfb3og4dll2yqsqaebqakuldk6e2qya --metadata '{“contractAppId”: “980265ba072119a9074e429dea477e1c084a94e8d9f645c0158680e6942fb99e” }'
```

### Step 2: Create a New Context

After the application is successfully installed, you can create a new context
with the installed application using this command:

```bash
cargo run -p meroctl -- --node-name node1 --home data context create --application-id {application id}
```

```bash title="Example"
cargo run -p meroctl -- --node-name node1 --home data context create --application-id A357tXwvVU14wikYLwoy4e1FHEXDynxtsXLpqbHRGmFw23w95XmV2fzqeWjFodk6bRwKTHigsJvFh67U5EtqbKQC
```

Since each context requires a coordinator node, you’ll need to invite the
coordinator to join the context. Follow the steps in the
[Invite To Context](./02-invite-to-context.mdx) guide to complete the setup.
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
---
id: invite-to-context
title: Invite To Context
---

## Invite to context with Admin Dashboard

- Currently not available

## Invite to context with the CLI using meroctl

Inviting to the context consists of 3 steps:

1. Identity Exchange: The peer wishing to join (invitee) shares their identity
with the existing member (invitor).
2. Create Invitation: The invitor generates an invitation payload for the
context.
3. Accept Invitation: The invitee signs the invitation payload to confirm their
identity and join the context.

In the example below, Node 2 is the coordinator node (invitee), and Node 1 is
the user node (invitor).

### Step-by-Step Process

1. Invitee Generates and Shares Identity To join the context, the invitee must
first create and share their identity with the invitor. This can be done
using the following command:

```bash title="Node 2"
context identity new
```

This generates a private and public key pair, where the public key is the
inviteeContextIdentity. Share this public key with the invitor.

```bash title="Example"
context identity new
│ Private Key: G5pK45VAegesDwvHqyQsZ6NNQyRPjZ7YQLJSz1XBfpdc
│ Public Key: 21A1pcDPMJTH6bQb1xRw1i1JqDRmvysxYp7eEQMnz3sp
```

2. Invitor Creates an Invitation Once the invitee’s public key is shared, the
invitor generates an invitation to the context using the following command:

```bash title="Node 1"
context invite {contextId} {invitorContextIdentity } {inviteeContextIdentity}
```

```bash title="Example"
context invite GjJEnAwfLVPveyUWaGqJspzUXndyJkNWgD7M5uDNQZqv
62HEbeSo6NKLufZZALVvEUthQGcf6G3A4g1ug2KKjELg
21A1pcDPMJTH6bQb1xRw1i1JqDRmvysxYp7eEQMnz3sp

│ Invited
21A1pcDPMJTH6bQb1xRw1i1JqDRmvysxYp7eEQMnz3sp to context
GjJEnAwfLVPveyUWaGqJspzUXndyJkNWgD7M5uDNQZqv
│ Invitation Payload:
3FdouEaEdTWtP6YBH3tjXgBJixiVF921t9DxTPbie5GVkhxjMQH7ipkB9h3RAA6EjGYEF5eugjuC154WRUx71eDRoZkdJ94ucZdyWXEA461BQyaQjS3GzQtimcqMWG9UbP7eGoci3jKnJycuoadLhVd
```

To check the invitor's identity, use this command:

```bash title="Node 1"
context identity ls {contextId}
```

```bash title="Example"
context identity ls GjJEnAwfLVPveyUWaGqJspzUXndyJkNWgD7M5uDNQZqv

│ Identity | Owned │
21A1pcDPMJTH6bQb1xRw1i1JqDRmvysxYp7eEQMnz3sp | \*
```

Listed identity is invitorContextIdentity used above.

3. Invitee Accepts the Invitation After receiving the invitation payload from
the invitor, the invitee can accept the invitation by signing it with their
private key:

```bash title="Node 2"
context join {inviteePrivateKey} {invitationPayload}
```

```bash title="Example"
context join G5pK45VAegesDwvHqyQsZ6NNQyRPjZ7YQLJSz1XBfpdc
3FdouEaEdTWtP6YBH3tjXgBJixiVF921t9DxTPbie5GVkhxjMQH7ipkB9h3RAA6EjGYEF5eugjuC154WRUx71eDRoZkdJ94ucZdyWXEA461BQyaQjS3GzQtimcqMWG9UbP7eGoci3jKnJycuoadLhVd

│ Joined context GjJEnAwfLVPveyUWaGqJspzUXndyJkNWgD7M5uDNQZqv as 21A1pcDPMJTH6bQb1xRw1i1JqDRmvysxYp7eEQMnz3sp,
waiting for catchup to complete...
```

4. Verifying Context Membership To confirm successful joining of the context,
the invitee can list their contexts with the following command:

```bash title="Node 2"
context ls
```

```bash title="Example"
context ls
│ Context ID | Application ID | Last Transaction │
GjJEnAwfLVPveyUWaGqJspzUXndyJkNWgD7M5uDNQZqv | 3dTQEovDrrTVqFoTXRDef5M2VQM51osB66XRdTnT7uRb | DoQ99Yty1ygPcc4ek4zsMUNpyAEtaA4MnRC8beGaFtd
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
id: explore-the-app
title: Explore the app
---

Congratulations, you now have a working context with the coordinator running! As
you have created context with the core app template application let's access
that frontend. In the table click on the website column of core-app-template ->
https://calimero-network.github.io/core-app-template/

Once the page opens, enter the Application ID you received during the invitation
process, and that's it—you're ready to start using your first SSapp!

It's a simple counter app that allows you and everyone in the context to
increment the counter and view updates from other peers in real time. Though
basic, it’s a powerful introduction to the world of data privacy and ownership,
showcasing how decentralized control works in practice.

![Core App Template](/core-app-template/core-app-home.png)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"label": "Setup your first context"
}
File renamed without changes.
12 changes: 0 additions & 12 deletions docs/03-getting-started/_04-invite-to-context.mdx

This file was deleted.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/core-app-template/core-app-home.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b509342

Please sign in to comment.