Skip to content

Instantly share code, notes, and snippets.

@pavlovdog
Created July 20, 2022 13:43
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 pavlovdog/3299a4ac04e0ba30f4d84a0402cf1e9b to your computer and use it in GitHub Desktop.
Save pavlovdog/3299a4ac04e0ba30f4d84a0402cf1e9b to your computer and use it in GitHub Desktop.
pragma ton-solidity ^0.57.1;
pragma AbiHeader expire;
pragma AbiHeader pubkey;
interface ISample {
function ping(address recipient) external;
function pong() external;
event Ping(address recipient);
event Pong(address sender);
}
contract Sample is ISample {
uint16 static _nonce;
uint state;
event StateChange(uint _state);
constructor(uint _state) public {
tvm.accept();
setState(_state);
}
function setState(uint _state) public {
tvm.accept();
state = _state;
emit StateChange(_state);
}
function getDetails()
external
view
returns (
uint _state
) {
return state;
}
function ping(address recipient) external override {
tvm.accept();
emit Ping(recipient);
ISample(recipient).pong();
}
function pong() external override {
// FAILS
require(msg.sender == address(this), 10001);
emit Pong(msg.sender);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment