Last active
April 2, 2018 15:51
-
-
Save sherlock-shi-x/2d9bd832d4177629bafd26463a90176c to your computer and use it in GitHub Desktop.
Convert
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.21; | |
contract Convert { | |
address owner; | |
address public fromContractAddr; | |
address public toContractAddr; | |
mapping (uint => bool) public isConvert; | |
modifier onlyOwner { | |
require(msg.sender == owner); | |
_; | |
} | |
function Convert() public { | |
owner = msg.sender; | |
} | |
function setFromContractAddr(address _addr) public onlyOwner { | |
fromContractAddr = _addr; | |
} | |
function setToContractAddr(address _addr) public onlyOwner { | |
toContractAddr = _addr; | |
} | |
function getNewToken(uint _tokenId) public { | |
IFrom ifrom = IFrom(fromContractAddr); | |
require(ifrom.ownerOf(_tokenId) == msg.sender); | |
require(isConvert[_tokenId] == false); | |
isConvert[_tokenId] = true; | |
ITo ito = ITo(toContractAddr); | |
ito.issueTokenAndTransfer(1, msg.sender); | |
} | |
/* only read */ | |
} | |
interface IFrom { | |
function ownerOf (uint256 _itemId) public view returns (address _owner); | |
} | |
interface ITo { | |
function issueTokenAndTransfer(uint256 _count, address to) public; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment