Created
July 20, 2022 13:43
-
-
Save pavlovdog/3299a4ac04e0ba30f4d84a0402cf1e9b to your computer and use it in GitHub Desktop.
This file contains 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 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