forked from OpenZeppelin/damn-vulnerable-defi
-
Notifications
You must be signed in to change notification settings - Fork 861
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Puppet Unsolvable in 1 Transaction #29
Comments
Lol i'm just dumb never mind |
How did you solve it in 1 tx? 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));
}); |
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 warningIf 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 |
Didn't think about that! Cool! :) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am updating all my solutions to the new v3 implementation (nice job by the way!). I am making my way through and am stuck on the new requirement of the
puppet
problem. Specifically the requirement for the entire solution to be solved in 1 transaction.https://github.com/tinchoabbate/damn-vulnerable-defi/blob/a5d47759c2132175ed8b5b42a6ba28c1e436032d/test/puppet/puppet.challenge.js#L103
I think this was introduced due to this PR.
I am not sure if I am just dumb and can't work it out but as far as I can tell, at least 2 transactions are required and if you use a contract to do this all for you then you will need to transfer tokens to the contract as well as create the contract.
The text was updated successfully, but these errors were encountered: