Skip to content

Instantly share code, notes, and snippets.

@gigamesh
Created November 15, 2020 19:52
Show Gist options
  • Save gigamesh/1a4223701440e81f939f020c10980a2b to your computer and use it in GitHub Desktop.
Save gigamesh/1a4223701440e81f939f020c10980a2b to your computer and use it in GitHub Desktop.
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);
}
}
@xavierlepretre
Copy link

Nice.

BTW, why did you put a payable fallback function?

@gigamesh
Copy link
Author

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)?

@xavierlepretre
Copy link

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.

@gigamesh
Copy link
Author

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