Last active
June 2, 2021 21:05
-
-
Save ekim2077/4274c1844f92fdc948077246a4e3806d to your computer and use it in GitHub Desktop.
Shiba Burn Token Code
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset='utf-8'> | |
<meta http-equiv='X-UA-Compatible' content='IE=edge'> | |
<title>Shiba Inu Token Burn Hero</title> | |
<meta name='viewport' content='width=device-width, initial-scale=1'> | |
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous"> | |
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/js/bootstrap.bundle.min.js" integrity="sha384-gtEjrD/SeCtmISkJkNUaaKMoLD0//ElJ19smozuHV6z3Iehds+3Ulb9Bn9Plx0x4" crossorigin="anonymous"></script> | |
<script type="text/javascript" src="https://unpkg.com/jquery@3.3.1/dist/jquery.js"></script> | |
<script type="text/javascript" src="https://unpkg.com/web3@latest/dist/web3.min.js"></script> | |
</head> | |
<body> | |
<div class="bg-dark text-secondary px-4 py-5 text-center" style="height: 100vh"> | |
<div class="py-5"> | |
<h1 class="display-5 fw-bold text-white">Shiba Inu Token Burn Hero</h1> | |
<div class="col-lg-6 mx-auto"> | |
<p class="fs-5 mb-4">Quickly burn tokens from your wallet. This page is hosted on IPFS.<BR> | |
When first loaded it will try to connect with your MetaMask. You need to select the account that contains your Shiba Inu tokens and some ETH to do the burn.<br><br> | |
1: Connect With MetaMask<BR> | |
2: Enter Burn Amount (if you want to burn whole coins add write 123.999999998198279378, need to include all the 18 decimal places)<BR> | |
3: Hit Burn button<BR> | |
4: Approve Transaction Form Metamask<BR> | |
</p> | |
<div class="d-grid gap-2 d-sm-flex justify-content-sm-center"> | |
<input type="text" class="form-control" id="burnAmount" placeholder="" value="123.999999998198279378" required="" style="font-size:30px;"> | |
<button type="button" onclick="changeCoolNumber();" id="burnButton" class="btn btn-outline-info btn-lg px-4 me-sm-3 fw-bold">Burn Tokens</button> | |
<button type="button" onclick="printTotalSupply();" id="totalButton" class="btn btn-outline-info btn-lg px-4 me-sm-3 fw-bold">Read Total Supply</button> | |
</div> | |
<p class="fs-5 mb-4 mt-4"> | |
Total Supply: <span id="total">...</span> | |
<br /> | |
Status: <span id="status">Loading...</span> | |
</p> | |
</div> | |
</div> | |
</div> | |
<script type="text/javascript"> | |
async function loadWeb3() { | |
if (window.ethereum) { | |
window.web3 = new Web3(window.ethereum); | |
window.ethereum.enable(); | |
} | |
} | |
async function loadContract() { | |
return await new window.web3.eth.Contract([{ | |
"constant": true, | |
"inputs": [], | |
"name": "name", | |
"outputs": [{"name": "", "type": "string"}], | |
"payable": false, | |
"stateMutability": "view", | |
"type": "function" | |
}, { | |
"constant": false, | |
"inputs": [{"name": "spender", "type": "address"}, {"name": "value", "type": "uint256"}], | |
"name": "approve", | |
"outputs": [{"name": "", "type": "bool"}], | |
"payable": false, | |
"stateMutability": "nonpayable", | |
"type": "function" | |
}, { | |
"constant": true, | |
"inputs": [], | |
"name": "totalSupply", | |
"outputs": [{"name": "", "type": "uint256"}], | |
"payable": false, | |
"stateMutability": "view", | |
"type": "function" | |
}, { | |
"constant": false, | |
"inputs": [{"name": "sender", "type": "address"}, {"name": "recipient", "type": "address"}, {"name": "amount", "type": "uint256"}], | |
"name": "transferFrom", | |
"outputs": [{"name": "", "type": "bool"}], | |
"payable": false, | |
"stateMutability": "nonpayable", | |
"type": "function" | |
}, { | |
"constant": true, | |
"inputs": [], | |
"name": "decimals", | |
"outputs": [{"name": "", "type": "uint8"}], | |
"payable": false, | |
"stateMutability": "view", | |
"type": "function" | |
}, { | |
"constant": false, | |
"inputs": [{"name": "spender", "type": "address"}, {"name": "addedValue", "type": "uint256"}], | |
"name": "increaseAllowance", | |
"outputs": [{"name": "", "type": "bool"}], | |
"payable": false, | |
"stateMutability": "nonpayable", | |
"type": "function" | |
}, { | |
"constant": false, | |
"inputs": [{"name": "value", "type": "uint256"}], | |
"name": "burn", | |
"outputs": [], | |
"payable": false, | |
"stateMutability": "nonpayable", | |
"type": "function" | |
}, { | |
"constant": true, | |
"inputs": [{"name": "account", "type": "address"}], | |
"name": "balanceOf", | |
"outputs": [{"name": "", "type": "uint256"}], | |
"payable": false, | |
"stateMutability": "view", | |
"type": "function" | |
}, { | |
"constant": true, | |
"inputs": [], | |
"name": "symbol", | |
"outputs": [{"name": "", "type": "string"}], | |
"payable": false, | |
"stateMutability": "view", | |
"type": "function" | |
}, { | |
"constant": false, | |
"inputs": [{"name": "spender", "type": "address"}, {"name": "subtractedValue", "type": "uint256"}], | |
"name": "decreaseAllowance", | |
"outputs": [{"name": "", "type": "bool"}], | |
"payable": false, | |
"stateMutability": "nonpayable", | |
"type": "function" | |
}, { | |
"constant": false, | |
"inputs": [{"name": "recipient", "type": "address"}, {"name": "amount", "type": "uint256"}], | |
"name": "transfer", | |
"outputs": [{"name": "", "type": "bool"}], | |
"payable": false, | |
"stateMutability": "nonpayable", | |
"type": "function" | |
}, { | |
"constant": true, | |
"inputs": [{"name": "owner", "type": "address"}, {"name": "spender", "type": "address"}], | |
"name": "allowance", | |
"outputs": [{"name": "", "type": "uint256"}], | |
"payable": false, | |
"stateMutability": "view", | |
"type": "function" | |
}, { | |
"inputs": [{"name": "name", "type": "string"}, {"name": "symbol", "type": "string"}, {"name": "decimals", "type": "uint8"}, { | |
"name": "totalSupply", | |
"type": "uint256" | |
}, {"name": "feeReceiver", "type": "address"}, {"name": "tokenOwnerAddress", "type": "address"}], | |
"payable": true, | |
"stateMutability": "payable", | |
"type": "constructor" | |
}, { | |
"anonymous": false, | |
"inputs": [{"indexed": true, "name": "from", "type": "address"}, {"indexed": true, "name": "to", "type": "address"}, { | |
"indexed": false, | |
"name": "value", | |
"type": "uint256" | |
}], | |
"name": "Transfer", | |
"type": "event" | |
}, { | |
"anonymous": false, | |
"inputs": [{"indexed": true, "name": "owner", "type": "address"}, {"indexed": true, "name": "spender", "type": "address"}, { | |
"indexed": false, | |
"name": "value", | |
"type": "uint256" | |
}], | |
"name": "Approval", | |
"type": "event" | |
}], '0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE'); | |
} | |
async function printTotalSupply() { | |
updateStatus('fetching Total Supply...'); | |
var coolNumber = await window.contract.methods.totalSupply().call(); | |
var position = coolNumber.length-18; | |
coolNumber = [coolNumber.slice(0, position), ".", coolNumber.slice(position)].join(''); | |
updateTotalSupply(coolNumber); | |
} | |
async function getCurrentAccount() { | |
const accounts = await window.web3.eth.getAccounts(); | |
return accounts[0]; | |
} | |
async function changeCoolNumber() { | |
var BN = web3.utils.BN; | |
let BurnAmount = new BN(document.getElementById("burnAmount").value); | |
updateStatus("Burning "+document.getElementById("burnAmount").value+" tokens.."); | |
const account = await getCurrentAccount(); | |
const coolNumber = await window.contract.methods.burn( BurnAmount ).send({ from: account }); | |
updateStatus("Burned "+document.getElementById("burnAmount").value+" tokens.."); | |
updateTotalSupply(coolNumber); | |
} | |
async function load() { | |
await loadWeb3(); | |
window.contract = await loadContract(); | |
updateStatus('Ready!'); | |
} | |
function updateStatus(status) { | |
const statusEl = document.getElementById('status'); | |
statusEl.innerHTML = status; | |
console.log(status); | |
} | |
function updateTotalSupply(status) { | |
const statusEl = document.getElementById('total'); | |
statusEl.innerHTML = status; | |
console.log(status); | |
} | |
load(); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment