Skip to content
On this page

Delegate Solana

The delegate namespace contains method used for sending transactions on delegation. The unique method to the delegate namespace is:

  • createAccount(address, lamports): Create Account for Delegate user tokens.
  • delegate(token, address, lamports, stakeAccount): Delegate user tokens.

Delegate Code Example

ts
// Import SDK
import { Solana } from "@everstake/wallet-sdk-solana";

// Select network: "mainnet-beta" | "devnet"
const network = "mainnet-beta";

// Create SDK instance
const solanaClient = new Solana(network);

// User wallet address.
const address = "exampleCnpYVG5ukLQsfusLqMGFRm5kJwcNhVdA3NS94";

// The amount that the user delegates.
const lamports = 1000000000; // min value 0.01 (SOL)

// partner ID
const source = "99";

// return createStakeAccountTx - Raw Transaction and stakeAccount - address
const createAccount = await solanaClient.createAccount(
  address,
  lamports,
  source
);
// { result: createStakeAccountTx, stakeAccount }

const delegate = await solanaClient.delegate(
  address,
  lamports,
  createAccount.result.stakeAccount
);
console.log(delegate); // Raw Transaction Object