nftbench / contracts /src /GatedUse.sol
OniReimu's picture
NFTBench 0.9.0 preview (part 3)
cc183a1 verified
Raw History Blame Contribute Delete
627 Bytes
// 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);
}
}