0.1.16 • Published 10 months ago

@sunrisestake/client v0.1.16

Weekly downloads
-
License
-
Repository
-
Last release
10 months ago

Sunrise Stake Client

A client library for the Sunrise Stake Solana programs.

What is Sunrise Stake?

Sunrise Stake is a climate-positive staking platform on Solana, that allows you to stake your SOL and redirects staking yield to offset your carbon footprint.

For more details, visit sunrisestake.com.

To stake, visit the app.

Quick Start

yarn add @sunrisestake/client

Usage in a browser (React app):

import { SunriseStakeClient } from '@sunrisestake/client';
import { AnchorProvider } from "@coral-xyz/anchor";
import { useAnchorWallet, useConnection } from "@solana/wallet-adapter-react";

// inside your app
const connection = useConnection()
const anchorWallet = useAnchorWallet()
const anchorProvider = new AnchorProvider(connection, anchorWallet, {});
const client = SunriseStakeClient.get(provider, 'mainnet-beta');

Usage in Node:

import { SunriseStakeClient } from '@sunrisestake/client';
import { Connection } from "@solana/web3.js";

const connection = new Connection(/* mainnet RPC endpoint */);
const provider = AnchorProvider.env();
const client = SunriseStakeClient.get(provider, 'mainnet-beta');

Usage

Details

Almost all information is available via the details() function

const details = await client.details()

// user's current staked balance
details.balances.gsolBalance

// total staked balance
details.balances.gsolSupply

// amount of gsol a user has locked
details.lockDetails.amountLocked

// if a user has an impact NFT, this is the mint address
details.impactNFTDetails.mint

Staking

Stake SOL to receive gSOL

await client.sendAndConfirmTransaction(
    client.deposit(amountInLamports)
);

Unstaking

Unstake gSOL to receive SOL back

await client.sendAndConfirmTransaction(
    await client.unstake(amountInLamports)
);

Advanced Usage

For more advanced usage view the test files in the source code.

0.1.10

10 months ago

0.1.11

10 months ago

0.1.12

10 months ago

0.1.13

10 months ago

0.1.14

10 months ago

0.1.15

10 months ago

0.1.1-7.module.2

10 months ago

0.1.16

10 months ago

0.1.8

10 months ago

0.1.9

10 months ago

0.1.7

1 year ago

0.1.6

1 year ago

0.1.5

1 year ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago