Skip to content

Instantly share code, notes, and snippets.

@Dan-Nolan
Last active December 6, 2022 10:16
Show Gist options
  • Save Dan-Nolan/02c6cf1e1f6f913256f4518299872061 to your computer and use it in GitHub Desktop.
Save Dan-Nolan/02c6cf1e1f6f913256f4518299872061 to your computer and use it in GitHub Desktop.
// https://goerli.etherscan.io/address/0xa423c1448d195d9cf2e06d343e30b35f501159ed
contract First {
event Winner(address);
function test() external {
emit Winner(msg.sender);
}
}
// https://goerli.etherscan.io/address/0x9a9a776bc00eb386fb56bb3a57e6b78595d93bf3
contract Second {
event Winner(address);
function attempt() external {
require(msg.sender != tx.origin);
emit Winner(tx.origin);
}
}
@krz
Copy link

krz commented Dec 6, 2022

My idea for Second was to call this contract from another contract but it doesn't work.

Here's my code

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

contract Second {
    event Winner(address);

    function attempt() external {
        require(msg.sender != tx.origin);
        emit Winner(tx.origin);
    }
}

contract SecondCaller {

    Second public mySecond;

    constructor(address secondAddress) {
        mySecond = Second(secondAddress);
    }

    function secondCall() external {
        mySecond.attempt();
    }
}

At deployment I specified ´0xb4c4e0c94d539b347f5c1d5693cd49fd677464ff´ as the secondAddress.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment