Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create ounter.sol #9

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions ounter.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@

// 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);
}
}



IGmpReceiver.sol

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

interface IGmpReceiver {
/**
* @dev Handles the receipt of a single GMP message.
* The contract must verify the msg.sender, it must be the Gateway Contract address.
*
* @param id The EIP-712 hash of the message payload, used as GMP unique identifier
* @param network The chain_id of the source chain that send the message
* @param source The pubkey/address which sent the GMP message
* @param payload The message payload with no specified format
* @return 32-byte result, which will be stored together with the GMP message
*/
function onGmpReceived(bytes32 id, uint128 network, bytes32 source, bytes calldata payload)
external
payable
returns (bytes32);
}