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, amount): Create Account for Delegate user tokens.
  • delegate(token, address, amount, stakeAccount): Delegate user tokens.

Delegate Code Example

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

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

// Token ID.
const token = process.env.TOKEN; // 3155f389-d943-4966-8e18-f159c2a6ef66

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

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

const delegate = await Solana.delegate(
    token, 
    address, 
    amountDelegate, 
    createAccount.result.stakeAccount
);
console.log(delegate); // Raw Transaction Object