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';
// 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 lamports = 1000000000; // min value 0.01 (SOL)
// partner ID
const source = '99';
// return createStakeAccountTx - Raw Transaction and stakeAccount - address
const createAccount = await Solana.createAccount(address, lamports, source);
// { result: createStakeAccountTx, stakeAccount }
const delegate = await Solana.delegate(
token,
address,
lamports,
createAccount.result.stakeAccount
);
console.log(delegate); // Raw Transaction Object