Code Monkey home page Code Monkey logo

compromisedwallettokenrescue's Introduction

CompromisedWalletTokenRescue

Rescue Funds (Staking Rewards, NFTs, Tokens) From Compromised Wallets

Getting Started

Run npm install to install packages

Main file is scripts/claim.ts

Process to rescue staked funds in a compromised wallet

Transfer eth to compromised wallet

    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
            }
        )
    

Transfer tokens out of compromised wallet to safe wallet

    const _transferStakeRewardsOut = await vlaunch.populateTransaction.transfer(
        safeAccountAddress,amountOfStakeRewards,
        {
            nonce:compromisedAccountNonce + 1
        }
        );

Sign and bundle transactions

    const signTransactions = await flashbotsProvider.signBundle([
        {signer : safeAccountWallet, transaction : transferEthToCompromisedWallet},
        {signer : compromisedWallet, transaction : callClaim},
        {signer : compromisedWallet, transaction : transferStakeRewardsOut}
    ])

Simulate transactions

        const targetBlock = blockNumber + BLOCK_IN_THE_FUTURE;

        const simulateTx = await flashbotsProvider.simulate(signTransactions,targetBlock);

Send bundle to private relay e.g Flashbots

        const bundleSubmission = await flashbotsProvider.sendRawBundle(signTransactions,targetBlock);

Congrats! You just rescued your staked funds from a compromised wallet!

Same process can be replicated in other blockchains e.g BSC,XDAI

I will be adding more scenerios like rescuing NFTs, so stay stuned.

Follow me on Twitter

compromisedwallettokenrescue's People

Contributors

eniolasonowo avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.