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

Update README with detailed examples, improved formatting, and clearer instructions #53

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
85 changes: 85 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Solana Actions and Blockchain Links (Blinks)

![npm](https://img.shields.io/npm/dm/@solana/actions)

## Documentation

Access the full API documentation
[here](https://solana-developers.github.io/solana-actions/).

[Read the docs to get started](https://solana.com/docs/advanced/actions)

Watch this video tutorial on
Expand All @@ -24,6 +31,83 @@ npm add @solana/actions
- Typedocs for the `@solana/actions` SDK:
- https://solana-developers.github.io/solana-actions/

## Usage

### `createActionHeaders`

This function helps create headers for API calls by accepting key-value pairs as
input.

Example Code Snippet is just below!

```javascript
import { createActionHeaders } from "@solana/actions";

const headers = createActionHeaders({
authorization: "Bearer YOUR_TOKEN",
"content-type": "application/json",
});

console.log(headers); // Output: { authorization: 'Bearer YOUR_TOKEN','content-type': 'application/json' }
```

### `Creating a Typed actions.json Payload`

This function helps structure an actions.json payload with type safety, ensuring
parameters match the expected format. Check out the code snipets below!

```javascript
import { createTypedPayload } from "@solana/actions";

const actionsPayload = createTypedPayload({
action: "transfer",
params: {
from: "source_wallet_address",
to: "destination_wallet_address",
amount: 10,
},
});

console.log(actionsPayload);
```

### `Creating a Typed GET Request Payload`

This function simplifies creating typed GET request payloads for API calls. Code
snipets below!

```javascript
import { createGetRequest } from "@solana/actions";

const getRequestPayload = createGetRequest({
endpoint: "/wallets",
params: {
walletId: "12345",
},
});

console.log(getRequestPayload);
```

### `Creating a Typed POST Response Payload Using createPostResponse`

Use this function to create structured responses for POST requests with a
standardized format. Code snipets below!

```javascript
import { createPostResponse } from '@solana/actions';

const postResponse = createPostResponse({
success: true,
data: {
id: '12345',
status: 'completed',
},
});

console.log(postResponse);
```

## What are Solana Actions?

[Solana Actions](https://solana.com/docs/advanced/actions#actions) are
Expand All @@ -49,3 +133,4 @@ a URL.

The Solana Actions JavaScript SDK is open source and available under the Apache
License, Version 2.0. See the [LICENSE](./LICENSE) file for more info.
```
76 changes: 76 additions & 0 deletions packages/solana-actions/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Solana Actions and Blockchain Links (Blinks)

![npm](https://img.shields.io/npm/dm/@solana/actions)

## Documentation

Access the full API documentation
[here](https://solana-developers.github.io/solana-actions/).

[Read the docs to get started](https://solana.com/docs/advanced/actions)

Install the `@solana/actions` SDK into your application:
Expand All @@ -13,6 +20,75 @@ npm add @solana/actions
- Typedocs for the `@solana/actions` SDK:
- https://solana-developers.github.io/solana-actions/

## Usage

### `createActionHeaders`

This function helps create headers for API calls by accepting key-value pairs as input.

Example Code Snippet is just below!

```javascript
import { createActionHeaders } from '@solana/actions';

const headers = createActionHeaders({ authorization: 'Bearer YOUR_TOKEN',
'content-type': 'application/json', });

console.log(headers); // Output: { authorization: 'Bearer YOUR_TOKEN','content-type': 'application/json' }
```

### `Creating a Typed actions.json Payload`
This function helps structure an actions.json payload with type safety, ensuring parameters match the expected format. Check out the code snipets below!

```javascript
import { createTypedPayload } from '@solana/actions';

const actionsPayload = createTypedPayload({
action: 'transfer',
params: {
from: 'source_wallet_address',
to: 'destination_wallet_address',
amount: 10,
},
});

console.log(actionsPayload);
```

### `Creating a Typed GET Request Payload`
This function simplifies creating typed GET request payloads for API calls. Code snipets below!

```javascript
import { createGetRequest } from '@solana/actions';

const getRequestPayload = createGetRequest({
endpoint: '/wallets',
params: {
walletId: '12345',
},
});

console.log(getRequestPayload);
```

### `Creating a Typed POST Response Payload Using createPostResponse`
Use this function to create structured responses for POST requests with a standardized format.

```javascript
import { createPostResponse } from '@solana/actions';

const postResponse = createPostResponse({
success: true,
data: {
id: '12345',
status: 'completed',
},
});

console.log(postResponse);
```


## Developer resources

Watch this video tutorial on
Expand Down
1 change: 1 addition & 0 deletions solana-actions
Submodule solana-actions added at fb0c6f