Analog-Labs / analog-gmp-examples

Gateway smart contract and GMP testing suites
MIT License
21 stars 28 forks source link

Create ounter.sol #9

Open buv22 opened 1 month ago

buv22 commented 1 month ago

ounter.sol

// SPDX-License-Identifier: MIT pragma solidity ^0.8.0;

import {IGmpReceiver} from "contracts/IGmpReceiver.sol";

contract Counter is IGmpReceiver { address private immutable _gateway; uint256 public number;

constructor(address gateway) {
    _gateway = gateway;
}

function onGmpReceived(bytes32, uint128, bytes32, bytes calldata) external payable returns (bytes32) {
    require(msg.sender == _gateway, "unauthorized");
    number++;
    return bytes32(number);
}

}