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

Improve README Documentation for @solana/actions SDK #54

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
51 changes: 51 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,58 @@ Discord, a bot might expand the blink into an interactive set of buttons. This
pushes the ability to interact on-chain to any web surface capable of displaying
a URL.

## Example Code Snippets
## Create Action Headers
Generate the headers required for Solana Action requests.

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

const headers = createActionHeaders({
key: 'your-api-key',
secret: 'your-api-secret',
});

console.log(headers);

## Create a Typed actions.json Payload
Define and validate a payload for an action.

import { ActionPayload } from '@solana/actions';

const payload: ActionPayload = {
type: 'TRANSFER',
sender: 'sender-public-key',
receiver: 'receiver-public-key',
amount: 1000,
};

console.log(payload);

## Create a Typed GET Request Payload
Build a properly typed payload for GET requests.

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

const getRequest = createGetRequest('/endpoint', { query: 'value' });

console.log(getRequest);

## Create a Typed POST Response Payload
Generate a typed response for POST requests.

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

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

console.log(postResponse);

## License

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.