Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tulsidasji zkthon #389

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions solution-1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Twitter URL-https://twitter.com/TulsiDas685618/status/1640067449692225538?s=20
16 changes: 16 additions & 0 deletions solution-2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;

import "@openzeppelin/[email protected]/token/ERC20/ERC20.sol";
import "@openzeppelin/[email protected]/token/ERC20/extensions/ERC20Burnable.sol";
import "@openzeppelin/[email protected]/access/Ownable.sol";

contract TULSI is ERC20, ERC20Burnable, Ownable {
constructor() ERC20("TULSI", "TUL") {
_mint(msg.sender, 10000 * 10 ** decimals());
}

function mint(address to, uint256 amount) public onlyOwner {
_mint(to, amount);
}
}
112 changes: 112 additions & 0 deletions solution-3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
TXN ID-0xc03b5bdd1ab3513d4f21d385beb4c23bd3d77186c98c8b83e8b4189a70bf1f94
URL-https://testnet-zkevm.polygonscan.com/tx/0xc03b5bdd1ab3513d4f21d385beb4c23bd3d77186c98c8b83e8b4189a70bf1f94
Contract-0x566978c655E21657B8256AB455452E557b1049fd



<!DOCTYPE html>
<html>
<head>
</head>
<body>
<h1></h1>
<p> <span id=""></span></p>
<label for=""></label>
<input type="text" id="newUsername" />
<button class="submit-btn"></button>

<script>
// Check if MetaMask is installed and connected
if (window.ethereum) {
const web3 = new Web3(window.ethereum);

// Request account access if needed
window.ethereum
.request({ method: "eth_requestAccounts" })
.then(() => {
// Define contract ABI
const abi = [
{
inputs: [
{
internalType: "string",
name: "_username",
type: "string",
},
],
stateMutability: "nonpayable",
type: "constructor",
},
{
inputs: [],
name: "getCurrentSubmission",
outputs: [
{
internalType: "string",
name: "",
type: "string",
},
],
stateMutability: "view",
type: "function",
},
{
inputs: [
{
internalType: "string",
name: "_username",
type: "string",
},
],
name: "submitUsername",
outputs: [],
stateMutability: "nonpayable",
type: "function",
},
];

// Define contract address
const contractAddress =
"0x566978c655E21657B8256AB455452E557b1049fd";

// Create contract instance
const contract = new web3.eth.Contract(abi, contractAddress);
console.log(contract);

// Display current submission on page load
contract.methods.getCurrentSubmission().call((error, result) => {
if (error) {
console.error(error);
return;
}
document.getElementById("currentSubmission").textContent = result;
});

// Submit new username on button click
const btn = document.querySelector(".submit-btn");
function submitUsername() {
const newUsername = document.getElementById("newUsername").value;
contract.methods
.submitUsername(newUsername)
.send(
{ from: web3.eth.defaultAccount },
(error, transactionHash) => {
if (error) {
console.error(error);
return;
}
console.log("Transaction hash:", transactionHash);
}
);
}
btn.addEventListener("click", submitUsername);
})
.catch((error) => {
console.error(error);
});
} else {
console.error("MetaMask not detected");
}
</script>
</body>
</html>