Code Monkey home page Code Monkey logo

Comments (4)

RealJohnnyTime avatar RealJohnnyTime commented on July 24, 2024 1

Didn't think about that! Cool! :)

from damn-vulnerable-defi.

BlueAlder avatar BlueAlder commented on July 24, 2024

Lol i'm just dumb never mind

from damn-vulnerable-defi.

RealJohnnyTime avatar RealJohnnyTime commented on July 24, 2024

How did you solve it in 1 tx?
I solved it like this:

it('Execution', async function () {
    /** CODE YOUR SOLUTION HERE */

    [,,this.player2] = await ethers.getSigners();


    const AttackerContractFactory = await ethers.getContractFactory('AttackPuppet', this.player2);
    this.attackerContract = await AttackerContractFactory.deploy(
        token.address, uniswapExchange.address, lendingPool.address
    )

    token.connect(player).transfer(this.attackerContract.address, PLAYER_INITIAL_TOKEN_BALANCE);
    await this.attackerContract.attack({value: 11n * 10n ** 18n});
    await token.connect(this.player2).transfer(player.address, await token.balanceOf(this.player2.address));

});

from damn-vulnerable-defi.

BlueAlder avatar BlueAlder commented on July 24, 2024

Yeah it's possible to solve in 1 transaction. You can handle all the logic required (including the transfers) in the deployment of the contract and that is the single transaction.

Spoiler warning If you just want to see the answer you can see my solution here. It uses `signERC2612Permit()` to allow the contract to transfer the tokens from the player contract

https://github.com/BlueAlder/damn-vulnerable-defi/blob/e90075150d9ba275197d15b62d07a2cbab9f8da1/test/puppet/puppet.challenge.js#L205

from damn-vulnerable-defi.

Related Issues (6)

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.