Created
November 15, 2020 19:52
-
-
Save gigamesh/1a4223701440e81f939f020c10980a2b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity 0.4.24; | |
contract NostrodamusI { | |
function prophecise(bytes32 exact, bytes32 braggingRights) public; | |
function theWord() public view returns (bytes32 exact); | |
} | |
contract NostradamusCaller { | |
event LogDepositReceived(address sender, uint256 value); | |
constructor() public {} | |
function propheciseExecute(address theAddress) | |
public | |
returns (bytes32 exact) | |
{ | |
NostrodamusI nostrodamusI = NostrodamusI(theAddress); | |
//Get resulting address | |
bytes32 resultingAddress = keccak256( | |
abi.encodePacked( | |
address(this), | |
block.number, | |
blockhash(block.number), | |
block.timestamp, | |
theAddress | |
) | |
); | |
nostrodamusI.prophecise(resultingAddress, "(づ ◕‿◕ )づ"); | |
return (resultingAddress); | |
} | |
function() public payable { | |
emit LogDepositReceived(msg.sender, msg.value); | |
} | |
} |
That's so the contract can be funded, to pay for gas.
Is it not necessary (ie: is it possible to fund a contract when its instantiated)?
When a contract sends an internal transaction, it is the address that created the initial (outer) transaction that pays the gas. At least at the current state of the protocol.
And because your contract can receive Ether but not pay it out, it is what we call an Ether sink.
Oh wow that makes things easier. thanks!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice.
BTW, why did you put a payable fallback function?