You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
949 B
HTML

<script src="/static/js/vendor/web3-1.3.6.min.js"></script>
<script type="text/javascript">
let contractABI = {{ config.CONTRACT_ABI | tojson }};
let contractAddress = "{{ config.CONTRACT_ADDRESS }}";
const w3 = new Web3(Web3.givenProvider);
const contract = new w3.eth.Contract(contractABI, contractAddress);
async function getMetamaskAccount() {
const accounts = await window.ethereum.request({
method: 'eth_requestAccounts',
});
const account = accounts[0];
return account
}
async function getTokenID(ipfsHash) {
if (ipfsHash != '') {
const tokenId = await contract.methods.metadataTokenId(ipfsHash).call();
return tokenId;
}
}
async function isMinted(ipfsHash) {
if (ipfsHash != '') {
const tokenId = await getTokenID(ipfsHash)
if (tokenId == 0) {
return false;
} else {
return true;
}
} else {
return false
}
}
</script>