File size: 627 Bytes
cc183a1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import {IERC4907} from "./interfaces/IERC4907.sol";

contract GatedUse {
    IERC4907 public immutable collection;
    mapping(uint256 => mapping(address => uint256)) public actions;

    event Action(uint256 indexed tokenId, address indexed user);

    constructor(address collection_) {
        collection = IERC4907(collection_);
    }

    function action(uint256 tokenId) external {
        require(collection.userOf(tokenId) == msg.sender, "caller is not active user");
        actions[tokenId][msg.sender] += 1;
        emit Action(tokenId, msg.sender);
    }
}