Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/stockpilelabs/stockpile_react_sdk

SDK for Stockpile v1
https://github.com/stockpilelabs/stockpile_react_sdk

crowdfunding sdk solana

Last synced: 29 days ago
JSON representation

SDK for Stockpile v1

Awesome Lists containing this project

README

        

# StockPile React SDK

## Installation

```bash
npm install @stockpileprotocol/[email protected]
```

```bash
Add a .npmrc file to root of folder with the following details:

registry=https://registry.npmjs.org/
@stockpileprotocol:registry=https://npm.pkg.github.com/
//npm.pkg.github.com/:_authToken=
```

## Usage
The `useStockpile` hook provides the Stockpile SDK instance and the `useCreateUser` hook provides a function to create a new user.

```tsx
import { useStockpile, useCreateUser } from "@stockpileprotocol/react_sdk";
import { AnchorWallet, useAnchorWallet } from "@solana/wallet-adapater-react";
import { Connection, PublicKey } from "@solana/web3.js";
import { useMemo } from "react";

const App = () => {
const anchorWallet = useAnchorWallet() as AnchorWallet;
const connection = useMemo(
() => new Connection("https://api.devnet.solana.com", "confirmed"),
[]
);
const sdk = useStockpile(
anchorWallet,
connection,
{ preflightCommitment: "confirmed" },
"devnet"
);

const { create, error, loading } = useCreateUser(sdk);

return (
{
create(anchorWallet?.publicKey as PublicKey);
}}
>
Create User

);
};

export default App;
```