Rescue Funds (Staking Rewards, NFTs, Tokens) From Compromised Wallets
Run npm install
to install packages
Main file is scripts/claim.ts
const _transferEthToCompromisedWallet = {
to : compromisedAccountAddress,
value : _value, //gasPrice * getRewardGasLimit
nonce : account1Nonce,
gasPrice : gasPrice
}
Staking contract custom function to call, can be (claimRewards, withdraw,unstake). The compromised wallet calls this function and tokens are released to the compromised wallet by the staking contract.
const _callClaim = await vlaunch.populateTransaction.buyAndClaimTickets(
info,
sig,
{
gasLimit : stakingContractGasUsage,
gasPrice : gasPrice,
nonce : compromisedAccountNonce
}
)
const _transferStakeRewardsOut = await vlaunch.populateTransaction.transfer(
safeAccountAddress,amountOfStakeRewards,
{
nonce:compromisedAccountNonce + 1
}
);
const signTransactions = await flashbotsProvider.signBundle([
{signer : safeAccountWallet, transaction : transferEthToCompromisedWallet},
{signer : compromisedWallet, transaction : callClaim},
{signer : compromisedWallet, transaction : transferStakeRewardsOut}
])
const targetBlock = blockNumber + BLOCK_IN_THE_FUTURE;
const simulateTx = await flashbotsProvider.simulate(signTransactions,targetBlock);
const bundleSubmission = await flashbotsProvider.sendRawBundle(signTransactions,targetBlock);
I will be adding more scenerios like rescuing NFTs, so stay stuned.