Git Product home page Git Product logo

sender-bug's Introduction

Steps to Reproduce

git clone [email protected]:sam-goldman/sender-bug.git
cd sender-bug && forge install

Expected Outcome

The following command logs the correct contract address, 0x5FbDB2315678afecb367f032d93F642f64180aa3:

forge script script/Counter.s.sol

You can verify that this is the expected address by running:

cast compute-address 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --nonce 0

Actual Outcome

Using vm.broadcast

Adding --sender to the command above results in a contract address of 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512, which is incorrect.

forge script script/Counter.s.sol --sender 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266

Notice that the --sender is the same address that's broadcasting the deployment, so the deployed contract's address shouldn't change.

The logged contract address is calculated using a sender nonce of 1, which you can verify with the command:

cast compute-address 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --nonce 1

Using vm.prank

Adding --sender to the original command and using vm.prank instead of vm.broadcast results in a contract address of 0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0, which is also not correct, and is different from the address created by vm.broadcast above.

Run Counter2.s.sol, which is the same as the previous script, except it uses vm.prank:

forge script script/Counter2.s.sol --sender 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266

The logged contract address is calculated using a sender nonce of 2, which you can verify with the command:

cast compute-address 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --nonce 2

sender-bug's People

Contributors

sam-goldman avatar

Watchers

 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.