Created
January 1, 2022 00:28
-
-
Save mxgxw/7aacadee5e3ef07fa7731b501b216562 to your computer and use it in GitHub Desktop.
Código del Visor de Huacales
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
<html> | |
<head> | |
<meta charset="utf-8"/> | |
<title>¡Mira tu Huacal!</title> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/web3/1.7.0-rc.0/web3.min.js" integrity="sha512-/PTXSvaFzmO4So7Ghyq+DEZOz0sNLU4v1DP4gMOfY3kFu9L/IKoqSHZ6lNl3ZoZ7wT20io3vu/U4IchGcGIhfw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script> | |
<script src="https://cdn.jsdelivr.net/npm/@svgdotjs/svg.js@latest/dist/svg.min.js"></script> | |
<script> | |
var huacalInterface = [ | |
{ | |
"inputs": [], | |
"stateMutability": "nonpayable", | |
"type": "constructor" | |
}, | |
{ | |
"anonymous": false, | |
"inputs": [ | |
{ | |
"indexed": true, | |
"internalType": "address", | |
"name": "_owner", | |
"type": "address" | |
}, | |
{ | |
"indexed": true, | |
"internalType": "address", | |
"name": "_approved", | |
"type": "address" | |
}, | |
{ | |
"indexed": true, | |
"internalType": "uint256", | |
"name": "_tokenId", | |
"type": "uint256" | |
} | |
], | |
"name": "Approval", | |
"type": "event" | |
}, | |
{ | |
"anonymous": false, | |
"inputs": [ | |
{ | |
"indexed": true, | |
"internalType": "address", | |
"name": "_owner", | |
"type": "address" | |
}, | |
{ | |
"indexed": true, | |
"internalType": "address", | |
"name": "_operator", | |
"type": "address" | |
}, | |
{ | |
"indexed": false, | |
"internalType": "bool", | |
"name": "_approved", | |
"type": "bool" | |
} | |
], | |
"name": "ApprovalForAll", | |
"type": "event" | |
}, | |
{ | |
"anonymous": false, | |
"inputs": [ | |
{ | |
"indexed": true, | |
"internalType": "address", | |
"name": "previousOwner", | |
"type": "address" | |
}, | |
{ | |
"indexed": true, | |
"internalType": "address", | |
"name": "newOwner", | |
"type": "address" | |
} | |
], | |
"name": "OwnershipTransferred", | |
"type": "event" | |
}, | |
{ | |
"anonymous": false, | |
"inputs": [ | |
{ | |
"indexed": true, | |
"internalType": "address", | |
"name": "_from", | |
"type": "address" | |
}, | |
{ | |
"indexed": true, | |
"internalType": "address", | |
"name": "_to", | |
"type": "address" | |
}, | |
{ | |
"indexed": true, | |
"internalType": "uint256", | |
"name": "_tokenId", | |
"type": "uint256" | |
} | |
], | |
"name": "Transfer", | |
"type": "event" | |
}, | |
{ | |
"inputs": [], | |
"name": "CANNOT_TRANSFER_TO_ZERO_ADDRESS", | |
"outputs": [ | |
{ | |
"internalType": "string", | |
"name": "", | |
"type": "string" | |
} | |
], | |
"stateMutability": "view", | |
"type": "function" | |
}, | |
{ | |
"inputs": [], | |
"name": "NOT_CURRENT_OWNER", | |
"outputs": [ | |
{ | |
"internalType": "string", | |
"name": "", | |
"type": "string" | |
} | |
], | |
"stateMutability": "view", | |
"type": "function" | |
}, | |
{ | |
"inputs": [ | |
{ | |
"internalType": "address", | |
"name": "_approved", | |
"type": "address" | |
}, | |
{ | |
"internalType": "uint256", | |
"name": "_tokenId", | |
"type": "uint256" | |
} | |
], | |
"name": "approve", | |
"outputs": [], | |
"stateMutability": "nonpayable", | |
"type": "function" | |
}, | |
{ | |
"inputs": [ | |
{ | |
"internalType": "address", | |
"name": "_owner", | |
"type": "address" | |
} | |
], | |
"name": "balanceOf", | |
"outputs": [ | |
{ | |
"internalType": "uint256", | |
"name": "", | |
"type": "uint256" | |
} | |
], | |
"stateMutability": "view", | |
"type": "function" | |
}, | |
{ | |
"inputs": [ | |
{ | |
"internalType": "uint256", | |
"name": "_tokenId", | |
"type": "uint256" | |
} | |
], | |
"name": "getApproved", | |
"outputs": [ | |
{ | |
"internalType": "address", | |
"name": "", | |
"type": "address" | |
} | |
], | |
"stateMutability": "view", | |
"type": "function" | |
}, | |
{ | |
"inputs": [ | |
{ | |
"internalType": "address", | |
"name": "_owner", | |
"type": "address" | |
}, | |
{ | |
"internalType": "address", | |
"name": "_operator", | |
"type": "address" | |
} | |
], | |
"name": "isApprovedForAll", | |
"outputs": [ | |
{ | |
"internalType": "bool", | |
"name": "", | |
"type": "bool" | |
} | |
], | |
"stateMutability": "view", | |
"type": "function" | |
}, | |
{ | |
"inputs": [ | |
{ | |
"internalType": "address", | |
"name": "_to", | |
"type": "address" | |
}, | |
{ | |
"internalType": "uint256", | |
"name": "_tokenId", | |
"type": "uint256" | |
}, | |
{ | |
"internalType": "string", | |
"name": "_uri", | |
"type": "string" | |
} | |
], | |
"name": "mint", | |
"outputs": [], | |
"stateMutability": "nonpayable", | |
"type": "function" | |
}, | |
{ | |
"inputs": [], | |
"name": "name", | |
"outputs": [ | |
{ | |
"internalType": "string", | |
"name": "_name", | |
"type": "string" | |
} | |
], | |
"stateMutability": "view", | |
"type": "function" | |
}, | |
{ | |
"inputs": [], | |
"name": "owner", | |
"outputs": [ | |
{ | |
"internalType": "address", | |
"name": "", | |
"type": "address" | |
} | |
], | |
"stateMutability": "view", | |
"type": "function" | |
}, | |
{ | |
"inputs": [ | |
{ | |
"internalType": "uint256", | |
"name": "_tokenId", | |
"type": "uint256" | |
} | |
], | |
"name": "ownerOf", | |
"outputs": [ | |
{ | |
"internalType": "address", | |
"name": "_owner", | |
"type": "address" | |
} | |
], | |
"stateMutability": "view", | |
"type": "function" | |
}, | |
{ | |
"inputs": [ | |
{ | |
"internalType": "address", | |
"name": "_from", | |
"type": "address" | |
}, | |
{ | |
"internalType": "address", | |
"name": "_to", | |
"type": "address" | |
}, | |
{ | |
"internalType": "uint256", | |
"name": "_tokenId", | |
"type": "uint256" | |
} | |
], | |
"name": "safeTransferFrom", | |
"outputs": [], | |
"stateMutability": "nonpayable", | |
"type": "function" | |
}, | |
{ | |
"inputs": [ | |
{ | |
"internalType": "address", | |
"name": "_from", | |
"type": "address" | |
}, | |
{ | |
"internalType": "address", | |
"name": "_to", | |
"type": "address" | |
}, | |
{ | |
"internalType": "uint256", | |
"name": "_tokenId", | |
"type": "uint256" | |
}, | |
{ | |
"internalType": "bytes", | |
"name": "_data", | |
"type": "bytes" | |
} | |
], | |
"name": "safeTransferFrom", | |
"outputs": [], | |
"stateMutability": "nonpayable", | |
"type": "function" | |
}, | |
{ | |
"inputs": [ | |
{ | |
"internalType": "address", | |
"name": "_operator", | |
"type": "address" | |
}, | |
{ | |
"internalType": "bool", | |
"name": "_approved", | |
"type": "bool" | |
} | |
], | |
"name": "setApprovalForAll", | |
"outputs": [], | |
"stateMutability": "nonpayable", | |
"type": "function" | |
}, | |
{ | |
"inputs": [ | |
{ | |
"internalType": "bytes4", | |
"name": "_interfaceID", | |
"type": "bytes4" | |
} | |
], | |
"name": "supportsInterface", | |
"outputs": [ | |
{ | |
"internalType": "bool", | |
"name": "", | |
"type": "bool" | |
} | |
], | |
"stateMutability": "view", | |
"type": "function" | |
}, | |
{ | |
"inputs": [], | |
"name": "symbol", | |
"outputs": [ | |
{ | |
"internalType": "string", | |
"name": "_symbol", | |
"type": "string" | |
} | |
], | |
"stateMutability": "view", | |
"type": "function" | |
}, | |
{ | |
"inputs": [ | |
{ | |
"internalType": "uint256", | |
"name": "_tokenId", | |
"type": "uint256" | |
} | |
], | |
"name": "tokenURI", | |
"outputs": [ | |
{ | |
"internalType": "string", | |
"name": "", | |
"type": "string" | |
} | |
], | |
"stateMutability": "view", | |
"type": "function" | |
}, | |
{ | |
"inputs": [ | |
{ | |
"internalType": "address", | |
"name": "_from", | |
"type": "address" | |
}, | |
{ | |
"internalType": "address", | |
"name": "_to", | |
"type": "address" | |
}, | |
{ | |
"internalType": "uint256", | |
"name": "_tokenId", | |
"type": "uint256" | |
} | |
], | |
"name": "transferFrom", | |
"outputs": [], | |
"stateMutability": "nonpayable", | |
"type": "function" | |
}, | |
{ | |
"inputs": [ | |
{ | |
"internalType": "address", | |
"name": "_newOwner", | |
"type": "address" | |
} | |
], | |
"name": "transferOwnership", | |
"outputs": [], | |
"stateMutability": "nonpayable", | |
"type": "function" | |
} | |
]; | |
var huacalNFT = {}; | |
if (window.ethereum) { | |
window.web3 = new Web3(window.ethereum); | |
huacalNFT = new web3.eth.Contract( | |
huacalInterface, | |
"0xcd3672ce7c54bf71ecbe21a2093a495490a2ae8a" | |
); | |
c.defaultChain = 'ropsten'; | |
} | |
function showHuacal() { | |
huacalId = document.getElementById("huacalId").value; | |
huacalNFT.methods.tokenURI(huacalId).call() | |
.then( | |
function(result) { | |
document.getElementById("outputImage").src = result; | |
} | |
).catch(function() { | |
document.getElementById("outputImage").src = ""; | |
}) | |
} | |
</script> | |
</head> | |
<body> | |
<h1>¡Mira tu Huacal NFT!</h1> | |
<p>(Recuerda que tienes que tener Metamask instalado en el navegador)</p> | |
#ID del Huacal: <input id="huacalId" type="text" /></br> | |
<input type="button" value="Mostrar Huacal" onclick="javascript:showHuacal()" /><br /> | |
<img id="outputImage" width="400px" height="400px" border="0px" src=""/> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment