Last active
June 17, 2020 16:01
-
-
Save anurag-arjun/c7382e2abaf0822e6ec7e988eb46c92e 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 solidity ^0.4.24; | |
//interface for parent contract of any child token | |
/* | |
- Parent contract interface for adding custom logic before calling the 'transfer' function | |
in the ERC721/ERC20 child chain contract on the Matic chain | |
- 'transfer' executes the 'beforeTransfer' of this interface contract | |
- It must follow this interface and return a bool value and | |
- in case of ERC20 contracts, it should not have 'require' statements and instead return 'false' | |
- IParentToken contract address in childchain contract can be updated by owner set in rootchain contract only | |
while mapping new token in rootchain | |
*/ | |
interface IParentToken { | |
function beforeTransfer(address sender, address to, uint256 value) public returns(bool); | |
} | |
// | |
// sample 'parentContract' implementation can contain any logic, but it must implement the 'beforeTransfer' function | |
// | |
pragma solidity ^0.4.24; | |
import "openzeppelin-solidity/contracts/ownership/Ownable.sol"; | |
import "./IParentToken.sol"; | |
// demo token parent contract | |
contract ParentTokenMock is IParentToken, Ownable { | |
mapping (address => bool) isAllowed; | |
function beforeTransfer(address sender, address to, uint256 value) public returns(bool) { | |
return isAllowed[sender]; | |
} | |
function updatePermission(address user) public onlyOwner { | |
require(user != address(0x0)); | |
isAllowed[user] = !isAllowed[user]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment