Skip to content

Instantly share code, notes, and snippets.

@xtremetom
Last active October 30, 2021 11:44
Show Gist options
  • Save xtremetom/0a91af7cefc25a888fb98a35ddae58c5 to your computer and use it in GitHub Desktop.
Save xtremetom/0a91af7cefc25a888fb98a35ddae58c5 to your computer and use it in GitHub Desktop.
twitterGame-1
pragma solidity ^0.8.0;
contract A {
address systemAddress;
function setSystemAddress(address systemAddress_) public {
systemAddress = systemAddress_;
}
function fromSystem(address from) public view {
require(
from == systemAddress,
"Invalid transaction source"
);
}
}
contract B {
uint[] data;
A a;
constructor(address contractAddress){
data.push(10);
a = A(contractAddress);
}
modifier fromSystem() {
a.fromSystem(msg.sender);
_;
}
function funcB() public returns (uint[] memory){
data.push(20);
return data;
}
function setData(uint value) public fromSystem {
data.push(value);
}
}
contract C {
A a;
B b;
constructor(address contractAddressA, address contractAddressB){
a = A(contractAddressA);
b = B(contractAddressB);
}
modifier fromSystem() {
a.fromSystem(msg.sender);
_;
}
function funcC() public fromSystem returns (uint[] memory){
return b.funcB();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment