# Getting Started

#### Installation

To begin working with Actions, you'll need to install the Actions SDK. This can be done using npm, the Node.js package manager. Open your terminal and run the following command:

```bash
npm install @actions/sdk

```

This command installs the latest version of the Actions SDK in your project.

#### Basic Usage

Once you have installed the SDK, you can start creating and deploying Actions. Here's a step-by-step guide to creating, validating, and deploying a simple Action:

1. **Import the necessary functions from the SDK:**

```jsx
import { validateAction, deployToIpfs } from '@actions/sdk';

```

1. **Create your Action:**

Define your Action object according to the Actions specification. Here's a simple example:

```jsx
const myAction = {
    title: "Donate ETH",
    icon: "<https://example.com/donate-icon.png>",
    description: "Donate ETH to support our project",
    label: "Donate Now",
    links: [
        {
            type: "transfer-action",
            label: "Donate 0.1 ETH",
            address: {
                type: "constant",
                id: "projectAddress",
                value: "0x742d35Cc6634C0532925a3b844Bc454e4438f44e"
            },
            value: "100000000000000000", // 0.1 ETH in wei
            success: {
                message: "Thank you for your donation!"
            },
            error: {
                message: "Donation failed. Please try again."
            }
        }
    ]
};

```

1. **Validate the Action:**

Before deploying, it's crucial to validate your Action to ensure it conforms to the specification:

```jsx
const { valid, errors } = validateAction(myAction);
if (!valid) {
    console.error('Action validation failed:', errors);
    return;
}

```

1. **Deploy the Action to IPFS:**

If the Action is valid, you can deploy it to IPFS. This example uses Pinata as the IPFS pinning service:

```jsx
const pinataCredentials = {
    apiKey: 'YOUR_PINATA_API_KEY',
    apiSecretKey: 'YOUR_PINATA_API_SECRET_KEY',
};

try {
    const ipfsHash = await deployToIpfs(myAction, pinataCredentials);
    console.log('Action deployed successfully! IPFS CID:', ipfsHash);
} catch (error) {
    console.error('Deployment failed:', error);
}

```

1. **Full Example:**

Putting it all together, here's a complete example of creating, validating, and deploying an Action:

```jsx
import { validateAction, deployToIpfs } from '@actions/sdk';

const myAction = {
    title: "Donate ETH",
    icon: "<https://example.com/donate-icon.png>",
    description: "Donate ETH to support our project",
    label: "Donate Now",
    links: [
        {
            type: "transfer-action",
            label: "Donate 0.1 ETH",
            address: {
                type: "constant",
                id: "projectAddress",
                value: "0x742d35Cc6634C0532925a3b844Bc454e4438f44e"
            },
            value: "100000000000000000", // 0.1 ETH in wei
            success: {
                message: "Thank you for your donation!"
            },
            error: {
                message: "Donation failed. Please try again."
            }
        }
    ]
};

async function deployMyAction() {
    // Validate the action
    const { valid, errors } = validateAction(myAction);
    if (!valid) {
        console.error('Action validation failed:', errors);
        return;
    }

    // Deploy to IPFS
    const pinataCredentials = {
        apiKey: 'YOUR_PINATA_API_KEY',
        apiSecretKey: 'YOUR_PINATA_API_SECRET_KEY',
    };

    try {
        const ipfsHash = await deployToIpfs(myAction, pinataCredentials);
        console.log('Action deployed successfully! IPFS CID:', ipfsHash);
    } catch (error) {
        console.error('Deployment failed:', error);
    }
}

deployMyAction();

```

This basic usage guide provides a foundation for working with Actions. As you become more familiar with the specification and SDK, you can create more complex Actions with multiple steps, computed inputs, and contract interactions.


---

# 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://blinkz.gitbook.io/blinkz/sdk/blinkz-actions-sdk/getting-started.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.
