Skip to content

Instantly share code, notes, and snippets.

@Drblessing
Created May 4, 2023 00:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Drblessing/ae555152cbe3abe6bcc9db90efe1a9a6 to your computer and use it in GitHub Desktop.
Save Drblessing/ae555152cbe3abe6bcc9db90efe1a9a6 to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.18+commit.87f61d96.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: GPL-2.0
pragma solidity >=0.8.9;
contract PayableForward {
Forwardee forwardee;
constructor(Forwardee forwardee_) {
forwardee = forwardee_;
}
function payableFunction() public payable {
forwardee.payableForwardee{value: msg.value}(msg.value);
}
}
contract Forwardee {
uint public balance;
function payableForwardee(uint msgValue) public payable {
balance = msg.value;
require(msg.value != 0, "Error: msg.value is empty.");
require(balance == msg.value,"Error: balance does not equal msg.value.");
require(msgValue == msg.value, "Error: msg.value does not equal forwarded value.");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment