Challenge 9 - forge questions (SPOILERS!!!!) #385
Replies: 8 comments 34 replies
-
Hey, have you tried using |
Beta Was this translation helpful? Give feedback.
-
To be a little more clear: A single private key may use many active public addresses that it signs for. How do I run operations as one public address or another within a script, while operating and broadcasting to a live public chain (i.e., not a fork, though I'd also want to know how to do this on a fork). |
Beta Was this translation helpful? Give feedback.
-
Am I wrong in observing that there has been no successful challenge 9 solution? I look on Sepolia etherscan and arbiscan and it appears all transactions are failed / reverted. |
Beta Was this translation helpful? Give feedback.
-
I think what you are trying to do is to force your contract to solve the challenge pretending to be your account, so that the reward NFT will be sent to your account. You can't do that. The msg.sender will always be the address of your contract calling the solveChallenge() function. There is however a way to solve the challenge using a contract and still receive the NFT to your specified account. Here's a hint: If your contract will indisputably be the msg.sender in solveChallenge() function, it will be the one to receive NFT. Can you then maybe make your contract transfer the token to your account upon receiving it...? |
Beta Was this translation helpful? Give feedback.
-
Try using the following: Please share more details on the error to help you better. Check the following links as well: |
Beta Was this translation helpful? Give feedback.
-
I've been looking at this contract for some time to try and solve it without deploying an attack contract. I believe it (obviously) has to do with abi-decoding "correctAnswer" and the opcodes.
We have the contract ABI, the deployed bytecode, and the block info. We know the msg.sender and the block.timestamp, so we need the block.prevrandao. I've been looking at the block.prevrandao EIP-4399 opcode; there seems to be something about the most recent block or parent block and finding the random number that way. As of EVM < Paris block.prevrandao has deprecated ; it's now block.difficulty (uint)
Revisiting: Using only Foundry, I think it's just a long intricate |
Beta Was this translation helpful? Give feedback.
-
Although I have not solved it, but I have come close to solving it without deploying the contract. We can use
This command will first query and output the latest block's timestamp and then convert it into hex. We can make similar commands for the rest of the I have also made the entire command to do so. But I am stuck at the final step. When I try to call the contract locally using the command line via |
Beta Was this translation helpful? Give feedback.
-
I just solved this challenge with |
Beta Was this translation helpful? Give feedback.
-
I'm attempting to use a forge script to solve the challenge, but it keeps failing.
For example, I have an interface to the challenge contract and the following function to attempt to solve the challenge:
I can see that msg.sender in the script itself is correct, but do scripts work like a regular deployed contract where the msg.sender becomes tx.origin when calling the challenge contract?
If so, are there any Foundry/forge cheatcodes or techniques so my actual wallet address is set as msg.sender when solving the challenge?
Beta Was this translation helpful? Give feedback.
All reactions