Last active
March 22, 2018 23:42
-
-
Save okwme/a86e32a843bc15453002c5a0229da021 to your computer and use it in GitHub Desktop.
an attempt at an upgradeable metadata function for standard NFT
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.17; | |
pragma experimental ABIEncoderV2; | |
import "zeppelin-solidity/contracts/token/ERC721/ERC721Token.sol"; | |
import "zeppelin-solidity/contracts/ownership/Ownable.sol"; | |
contract NFT is ERC721Token, Ownable { | |
address private metadataContractAddress; | |
function NFT (address _metadataContractAddress) public { | |
metadataContractAddress = _metadataContractAddress; | |
} | |
function updateAddress (address _metadataContractAddress) public onlyOwner { | |
metadataContractAddress = _metadataContractAddress; | |
} | |
function implementation() public view returns (address) { | |
return metadataContractAddress; | |
} | |
function tokenMetadata(uint _tokenId) public view returns (string _infoUrl) { | |
require(ownerOf(_tokenId) != 0); | |
address _impl = implementation(); | |
bytes memory data = msg.data; | |
assembly { | |
let result := delegatecall(gas, _impl, add(data, 0x20), mload(data), 0, 0) | |
let size := returndatasize | |
let ptr := mload(0x40) | |
returndatacopy(ptr, 0, size) | |
switch result | |
case 0 { revert(ptr, size) } | |
default { return(ptr, size) } | |
} | |
// return CloversMetadata(cloversMetadata).tokenMetadata(_tokenId); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment