# Developer Guide

### **Introduction**&#x20;

STRIKE is designed to streamline interactions with canisters (smart contracts) on the Internet Computer Protocol (ICP).&#x20;

This guide provides an overview of how STRIKE operates, including setup instructions, action creation, and sharing through platforms like Twitter (X).

To interact with STRIKE URLs and the canisters they reference, you must install the STRIKE Chrome extension.

### **Getting Started with a Simple Example**

Let's begin with a fundamental example: a "Hello" backend on the Internet Computer.

```
use candid::Principal;
use ic_cdk::{query, update};
use std::cell::RefCell;

struct State {
    owner: Principal,
}

impl Default for State {
    fn default() -> Self {
        Self {
            owner: Principal::anonymous(),
        }
    }
}

thread_local! {
    static STATE: RefCell<State> = RefCell::new(State::default());
}

#[query]
fn hello() -> String {
    let caller = ic_cdk::caller();
    format!("Hello, {}!", caller)
}

#[update]
fn set_owner(owner: Principal) -> String {
    STATE.with(|s| s.borrow_mut().owner = owner);
    format!("Owner is {}!", owner)
}

#[query]
fn get_owner() -> Principal {
    STATE.with(|s| s.borrow().owner)
}

ic_cdk::export_candid!();
```

This canister implementation includes three functions: `hello`, `set_owner`, and `get_owner`.&#x20;

We will now proceed with implementing these functions.

### **Creating the Actions JSON File**&#x20;

To enable interactions with the canister, we need to create an `actions.json` file that defines the permitted actions.&#x20;

This JSON file includes metadata such as action labels, descriptions, canister IDs, and the available actions (`"Hello"`, `"Get Owner"`, and `"Set Owner"`).

Create a new file named `actions.json` and add the following configuration:

```
{
  "icon": "https://strike.oranj.co/hello-strike.png",
  "homepage": "https://strike.oranj.co",
  "label": "Simple Ownership",
  "title": "Simple Ownership",
  "description": "Demo canister integration with STRIKE",
  "canisterId": "ea6rm-nyaaa-aaaak-ak2wa-cai"
}
```

* **`icon`**: A URL linking to the image that will be displayed at the top of the interface.
* **`homepage`**: A string that represents the canister’s homepage.
* **`canisterId`**: The identifier of the canister.

For further details on these values, refer to the [Actions ](/installation-and-development/actions.md)page.

### **Implementing the Functions for Interaction**&#x20;

Next, we need to define the available actions in the JSON file.&#x20;

Append the following script to `actions.json`:

```
{
  ...
  "actions": [
    {
      "label": "Hello",
      "method": "hello",
      "type": "query",
      "uiParameters": [],
      "input": [],
      "inputParameters": [],
      "output": ["Text"]
    },
    {
      "label": "Get Owner",
      "method": "get_owner",
      "type": "query",
      "uiParameters": [],
      "input": [],
      "inputParameters": [],
      "output": ["Principal"]
    },
    {
      "label": "Set Owner",
      "method": "set_owner",
      "type": "update",
      "uiParameters": [
        {
          "name": "owner",
          "label": "Enter a new owner",
          "candidType": "Principal"
        }
      ],
      "input": ["Principal"],
      "inputParameters": ["{owner}"],
      "output": []
    }
  ]
}
```

This configuration defines three actions:

* **`Hello`**: A query method that returns a greeting message.
* **`Get Owner`**: A query method that retrieves the current canister owner.
* **`Set Owner`**: An update method that allows modifying the canister owner.

By setting up these actions, we enable seamless interaction with the canister through STRIKE.

### **Hosting and Deployment**&#x20;

Once the `actions.json` file is created, it can be hosted on any public platform (e.g., GitHub, a custom domain, or any publicly accessible location).&#x20;

Deploy the code and use the generated link to test it on [strike.oranj.co](https://strike.oranj.co/).

<figure><img src="/files/KY6q4Ql2YnE0NAlryOQt" alt=""><figcaption></figcaption></figure>

### **R**egistering on the STRIKE registry

&#x20;To enable STRIKE card unfurling on Twitter/X, you must register it in the STRIKE registry. Once your STRIKE card is ready, you can fill out [**this form**](https://forms.gle/XLYKtsLABGmzo7Ne8) for registration.

<figure><img src="/files/Gu0wSNlGEqizZ2brPwFY" alt=""><figcaption></figcaption></figure>

### **Conclusion**

&#x20;In this guide, we explored the fundamentals of STRIKE, canister integration, and strike card routing. We also demonstrated a simple ownership model using STRIKE Actions.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.strike.oranj.co/installation-and-development/developer-guide.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
