Security News
Cloudflare Adds Security.txt Setup Wizard
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
@marinade.finance/native-staking-sdk
Advanced tools
This is SDK for interaction with Marinade Native Staking product.
Staking through this product is done by changing the stake authority
of user's stake account(s) for example through this SDK.
Unstaking can be always done by user manually through Solana CLI - but that would be tedious as Marinade splits the user stake accounts into 100+ stake accounts. Marinade accepts requests from users to unstake part or all stake accounts and merge them into a single one, so the user flow is simplified (but Marinade charges a small fee). This is also handled by the SDK.
Install the package:
pnpm i @marinade.finance/native-staking-sdk
Initialize the SDK:
import { Connection } from '@solana/web3.js'
import { NativeStakingConfig, NativeStakingSDK } from '@marinade.finance/native-staking-sdk'
const config = new NativeStakingConfig({ connection: new Connection('...') })
const sdk = new NativeStakingSDK(config)
const { connection } = useConnection() // from @solana/wallet-adapter-react
const { sendTransaction, signTransaction, publicKey } = useWallet() // from @solana/wallet-adapter-react
const amount = new BN('1000000000') // 1 SOL
const { createAuthorizedStake, stakeKeypair } = sdk.buildCreateAuthorizedStakeInstructions(publicKey, amount)
const { blockhash } = await connection.getLatestBlockhash()
const versionedMessage = ;
const tx = new VersionedTransaction(new TransactionMessage({
payerKey: publicKey,
recentBlockhash: blockhash,
instructions: createAuthorizedStake,
}).compileToV0Message())
tx.sign([stakeKeypair]) // add signature of the stake account
await signTransaction(tx) // add signature of the user
await sendTransaction(tx, connection)
const { connection } = useConnection() // from @solana/wallet-adapter-react
const { sendTransaction, signTransaction, publicKey } = useWallet() // from @solana/wallet-adapter-react
const stakeAccount = new PublicKey('...') // stake account to migrate
const authorizeInstructions = sdk.buildAuthorizeInstructions(publicKey, [stakeAccount])
const { blockhash } = await connection.getLatestBlockhash()
const versionedMessage = ;
const tx = new VersionedTransaction(new TransactionMessage({
payerKey: publicKey,
recentBlockhash: blockhash,
instructions: authorizeInstructions,
}).compileToV0Message())
await signTransaction(tx) // add signature of the user
await sendTransaction(tx, connection)
const { connection } = useConnection() // from @solana/wallet-adapter-react
const { sendTransaction, signTransaction, publicKey } = useWallet() // from @solana/wallet-adapter-react
const amount = new BN('1000000000') // 1 SOL
const { payFees, onPaid } = await sdk.initPrepareForRevoke(publicKey, amount) // pass `null` instead of `amount` to prepare everything for unstake
// sdk.config.prepareForRevokeCost - fee in lamports
const { blockhash } = await connection.getLatestBlockhash()
const tx = new VersionedTransaction(new TransactionMessage({
payerKey: publicKey,
recentBlockhash: blockhash,
instructions: payFees,
}).compileToV0Message())
await signTransaction(tx) // add signature of the user
const signature = await sendTransaction(tx, connection)
await connection.confirmTransaction(signature, 'finalized') // wait for the payment to go through
await onPaid(signature) // notify our BE that the user has paid, so we can prepare some/all stake accounts (based on the input amount) to be merged them into a single stake account (at the beginning of the next epoch), so the SOL can be easily withdrawn (or stake account claimed if it is Locked).
const { publicKey } = useWallet() // from @solana/wallet-adapter-react
await sdk.getStakeAccounts(publicKey) // fetches stake accounts ready to be revoked, stake acccount that are being prepared to be revoked, stake accounts that Marinade manages
const { publicKey } = useWallet() // from @solana/wallet-adapter-react
await sdk.fetchRewards(publicKey) // fetches rewards of user's stake accounts in the Marinade Native Staking (note: apy will be `null` if there are no active stake accounts yet)
FAQs
Marinade SDK for the Native Staking
The npm package @marinade.finance/native-staking-sdk receives a total of 213 weekly downloads. As such, @marinade.finance/native-staking-sdk popularity was classified as not popular.
We found that @marinade.finance/native-staking-sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.
Security News
ENISA’s 2024 report highlights the EU’s top cybersecurity threats, including rising DDoS attacks, ransomware, supply chain vulnerabilities, and weaponized AI.