buy ticket complete

This commit is contained in:
Sewmina 2024-09-02 23:22:27 +05:30
parent 37bb06ab1f
commit 420ad73207
9 changed files with 5293 additions and 9248 deletions

12814
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -18,7 +18,7 @@
"@fortawesome/react-fontawesome": "^0.2.2",
"@headlessui/react": "^1.7.3",
"@heroicons/react": "^2.0.12",
"@privy-io/react-auth": "^1.76.4",
"@privy-io/react-auth": "^1.81.2",
"@privy-io/server-auth": "1.9.5",
"@privy-io/wagmi": "^0.2.12",
"@privy-io/wagmi-connector": "^0.1.13",
@ -26,8 +26,10 @@
"@tanstack/react-query": "^5.51.15",
"axios": "^1.7.2",
"next": "latest",
"promises": "^0.2.5",
"react": "18.2.0",
"react-dom": "18.2.0",
"viem": "^2.21.0",
"wagmi": "^1.4.13"
},
"devDependencies": {

View File

@ -9,7 +9,7 @@ import { mainnet, sepolia, configureChains } from 'wagmi';
import { alchemyProvider } from 'wagmi/providers/alchemy';
import { infuraProvider } from 'wagmi/providers/infura';
import { jsonRpcProvider } from 'wagmi/providers/jsonRpc';
import { arbitrum, arbitrumSepolia, base, baseSepolia } from "viem/chains";
// Configure chains and providers
const configureChainsConfig = configureChains(
[mainnet, sepolia],
@ -69,6 +69,8 @@ function MyApp({ Component, pageProps }: AppProps) {
embeddedWallets: {
createOnLogin: "all-users",
},
defaultChain:arbitrumSepolia,
supportedChains:[baseSepolia, base,sepolia,mainnet,arbitrum, arbitrumSepolia]
}}
>
<PrivyWagmiConnector wagmiChainsConfig={configureChainsConfig}>

View File

@ -34,7 +34,8 @@ const Home: React.FC = () => {
withCredentials: false,
params: {
id: result,
wallet: wallet
wallet: wallet,
init: "true"
},
});
} catch (error) {

27
pages/buy_tickets.tsx Normal file
View File

@ -0,0 +1,27 @@
import { usePrivy } from "@privy-io/react-auth";
import Head from "next/head";
import { useRouter } from "next/router";
import { SetStateAction, useEffect, useState } from "react";
export default function BuyTickets() {
return (
<>
<Head>
<title>Buy MHUNT Tickets</title>
</Head>
<div className="bg-black h-screen text-white">
<div className="flex justify-center items-center h-full flex-col">
<div className="rounded-xl bg-gray-900 p-20">
<p className="text-3xl pb-10">Purchase Tickets</p>
<p>Enter your unique username</p>
</div>
</div>
</div>
</>
);
}

View File

@ -4,54 +4,86 @@ import { getAccessToken, getEmbeddedConnectedWallet, usePrivy, useWallets } from
import Head from "next/head";
import { useBalance } from 'wagmi';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import {faDiscord, faGoogle, faMeta, faTwitter, faXTwitter } from "@fortawesome/free-brands-svg-icons";
import {faAdd, faFileExport, faLink, faTrash, faUnlink, faWallet } from "@fortawesome/free-solid-svg-icons";
import { faDiscord, faGoogle, faMeta, faTwitter, faXTwitter } from "@fortawesome/free-brands-svg-icons";
import { faAdd, faFileExport, faLink, faTrash, faUnlink, faWallet } from "@fortawesome/free-solid-svg-icons";
import { useSetActiveWallet } from "@privy-io/wagmi";
async function verifyToken() {
const url = "/api/verify";
const accessToken = await getAccessToken();
const result = await fetch(url, {
headers: {
...(accessToken ? { Authorization: `Bearer ${accessToken}` } : undefined),
},
});
return await result.json();
}
import { encodeFunctionData, parseAbi } from 'viem';
import { gameDataABI } from "./data";
import { arbitrumSepolia, baseSepolia } from "viem/chains";
export default function DashboardPage() {
const [verifyResult, setVerifyResult] = useState(0);
const [username, setUsername] = useState('');
const [vaultData, setVaultData] = useState({ prehp: "0", vc: "0" });
const [showPopup, setShowPopup] = useState(false);
const [ticketAmount, setTicketAmount] = useState(1);
const router = useRouter();
const { ready, authenticated, user, logout,exportWallet, linkWallet,unlinkWallet, linkDiscord, unlinkDiscord, linkTwitter, unlinkTwitter,linkGoogle, unlinkGoogle } = usePrivy();
const { ready, authenticated, user, logout, exportWallet, linkWallet, unlinkWallet, linkDiscord, unlinkDiscord, linkTwitter, unlinkTwitter, linkGoogle, unlinkGoogle } = usePrivy();
const { wallets } = useWallets();
const [activeWallet, setActiveWallet] = useState(user?.wallet?.address);
const [activeWalletObj, setActiveWalletObj] = useState(wallets[0]);
const [ticketsCount, setTicketsCount] = useState(0);
const { data: balanceData } = useBalance({
const { data: balanceData } = useBalance({
address: activeWallet as `0x${string}`,
token: "0x22b6c31c2beb8f2d0d5373146eed41ab9ede3caf"
});
const balance = balanceData?.formatted;
const token = balanceData?.symbol;
function ToggleDiscord() {
if (user?.discord) {
unlinkDiscord(user?.discord.subject);
} else {
linkDiscord();
}
}
function ToggleTwitter() {
if (user?.twitter) {
unlinkTwitter(user?.twitter.subject);
} else {
linkTwitter();
}
}
function ToggleGoogle() {
if (user?.google) {
unlinkGoogle(user?.google.subject);
} else {
linkGoogle();
}
}
async function handleWalletClick(address: string) {
setActiveWallet(address);
const url = `http://vps.playpoolstudios.com/metahunt/api/launcher/set_wallet.php?id=${user?.id}&wallet=${address}`;
const response = await fetch(url);
console.log(url);
wallets.forEach((element) => {
if (element.address == address) {
setActiveWalletObj(element);
element.switchChain(chainId);
}
});
}
useEffect(() => {
if (ready && !authenticated) {
router.push("/");
}
if(ready){
if(username == "-1"){
console.log(user?.id);
router.push("/logincomplete");
if (ready) {
if (username == "-1") {
console.log(user?.id);
router.push("/logincomplete");
}
}
}, [ready, authenticated, router, username]);
useEffect(() => {
@ -60,7 +92,7 @@ export default function DashboardPage() {
try {
const response = await fetch(`https://vps.playpoolstudios.com/metahunt/api/launcher/get_display_name_public.php?id=${user?.id}`);
const data = await response.text();
setUsername(data); // Assuming the response contains the display name under `display_name`
setUsername(data);
} catch (error) {
console.error("Error fetching username:", error);
}
@ -81,53 +113,127 @@ export default function DashboardPage() {
fetchUsername();
fetchVaultData();
}, [ready]);
useEffect(()=>{
setActiveWallet(getEmbeddedConnectedWallet(wallets)?.address);
wallets.map((wallet)=>{
if(activeWallet == wallet.address){
if(!wallet.linked){
async function autoSetActiveWallet(){
try {
const response = await fetch(`http://vps.playpoolstudios.com/metahunt/api/launcher/get_active_wallet.php?id=${user?.id}`);
const activeWalletString = await response.text();
wallets.forEach((element)=>{
if(element.address == activeWalletString){
setActiveWallet(element.address);
setActiveWalletObj(element);
}
});
if(activeWalletString != activeWallet){
setActiveWalletObj(wallets[0]);
}
} catch (error) {
console.error("Error fetching vault data:", error);
}
}
const chainId = arbitrumSepolia.id;
useEffect(() => {
setActiveWallet(getEmbeddedConnectedWallet(wallets)?.address);
autoSetActiveWallet();
getTickets();
}, [wallets]);
useEffect(() => {
getTickets();
}, [activeWalletObj]);
const contractAddress = "0x21dfDE84E7F643697E8bBE5b9a97e8B0326775A8";
async function buyTicket(amount: number) {
const isEmbedded = getEmbeddedConnectedWallet(wallets)?.address == activeWalletObj?.address;
const provider = await activeWalletObj?.getEthereumProvider();
if (!provider) {
console.error("Ethereum provider not found");
return;
}
const data = encodeFunctionData({
abi: gameDataABI,
functionName: 'buyTickets',
args: [amount],
});
},[wallets])
const value = 1000000000000 * amount;
console.log(`isEmbbedded : ${isEmbedded}`)
const transactionRequest = {
from: activeWalletObj?.address,
to: contractAddress,
data: data,
value: isEmbedded ? value : value.toString(),
};
const numAccounts = user?.linkedAccounts?.length || 0;
const canRemoveAccount = numAccounts > 1;
try {
const transactionHash = await provider.request({
method: 'eth_sendTransaction',
params: [transactionRequest],
});
// Polling for the transaction receipt
const checkTransactionReceipt = async () => {
const receipt = await provider.request({
method: 'eth_getTransactionReceipt',
params: [transactionHash],
});
const email = user?.email;
const phone = user?.phone;
const wallet = user?.wallet;
if (receipt && receipt.status) {
if (receipt.status === '0x1') { // Transaction was successful
console.log('Transaction confirmed:', receipt);
getTickets(); // Call getTickets() after the transaction is confirmed
//setShowPopup(false); // Close the popup after successful transaction
} else {
console.error('Transaction failed:', receipt);
}
} else {
// Retry after some delay if the receipt is not available yet
setTimeout(checkTransactionReceipt, 2000); // Poll every 2 seconds
}
};
const googleSubject = user?.google?.subject || null;
const twitterSubject = user?.twitter?.subject || null;
const discordSubject = user?.discord?.subject || null;
function ToggleDiscord(){
if(user?.discord){
unlinkDiscord(user?.discord.subject);
}else{
linkDiscord();
checkTransactionReceipt();
setShowPopup(false); // Close the popup after successful transaction
} catch (error) {
console.error('Transaction failed:', error);
}
}
function ToggleTwitter(){
if(user?.twitter){
unlinkTwitter(user?.twitter.subject);
}else{
linkTwitter();
async function getTickets() {
const provider = await activeWalletObj?.getEthereumProvider();
if (!provider) {
console.error("Ethereum provider not found");
return;
}
}
function ToggleGoogle(){
if(user?.google){
unlinkGoogle(user?.google.subject);
}else{
linkGoogle();
try {
const data = encodeFunctionData({
abi: gameDataABI,
functionName: 'balanceOf',
args: [activeWalletObj?.address, 0],
});
const callRequest = {
from: activeWalletObj?.address,
to: contractAddress,
data: data,
};
const result = await provider.request({
method: 'eth_call',
params: [callRequest],
});
const balanceHex = result;
const balance = parseInt(balanceHex, 16);
setTicketsCount(balance);
} catch (error) {
console.error('Call failed:', error);
}
}
@ -155,8 +261,18 @@ export default function DashboardPage() {
<h1 className="text-4xl flex justify-center">{vaultData.vc || "0"} VC</h1>
</div>
<div className="items-center justify-center p-20">
<h1 className="text-xs">{activeWallet}</h1>
<h1 className="text-4xl flex justify-center">{balance || 0} {token}</h1>
<h1 className="text-xs">{activeWallet}</h1>
<h1 className="text-4xl flex justify-center">{balance || 0} {token}</h1>
</div>
<div className="items-center justify-center p-20">
<h1 className="text-s">Hunt Tickets</h1>
<h1 className="text-4xl flex justify-center">{ticketsCount || "0"}</h1>
<button
onClick={() => setShowPopup(true)}
className="mt-2 bg-blue-500 hover:bg-blue-700 py-2 px-4 rounded-md text-white"
>
Buy Tickets
</button>
</div>
<div className="items-center justify-center p-20">
<h1 className="text-s">Pre-hunt Points</h1>
@ -170,11 +286,11 @@ export default function DashboardPage() {
<div className="h-5"></div>
<div className="flex h-12 items-center">
<FontAwesomeIcon className="p-2 w-12" icon={faXTwitter} size={'2x'}/>
<FontAwesomeIcon className="p-2 w-12" icon={faXTwitter} size={'2x'} />
<p className="w-16">Twitter</p>
<div className="px-5"></div>
<div className={`bg-gray-${user?.twitter ? "8" : "7"}00 rounded-xl items-center justify-center flex w-64 p-1`}>
<p>{user?.twitter ? "@"+user?.twitter.username : "-"}</p>
<p>{user?.twitter ? "@" + user?.twitter.username : "-"}</p>
</div>
<div className="p-5" />
<button className={`rounded-full ${user?.twitter ? "bg-red-700" : "bg-green-700"} px-4 py-1`} onClick={ToggleTwitter}>
@ -182,11 +298,11 @@ export default function DashboardPage() {
</button>
</div>
<div className="flex h-12 items-center">
<FontAwesomeIcon className="p-2 w-12" icon={faDiscord} size={'2x'}/>
<FontAwesomeIcon className="p-2 w-12" icon={faDiscord} size={'2x'} />
<p className="w-16">Discord</p>
<div className="px-5"></div>
<div className={`bg-gray-${user?.discord ? "8" : "7"}00 rounded-xl items-center justify-center flex w-64 p-1`}>
<p>{user?.discord ? "@"+user?.discord?.username : "-"}</p>
<p>{user?.discord ? "@" + user?.discord?.username : "-"}</p>
</div>
<div className="p-5" />
<button className={`rounded-full ${user?.discord ? "bg-red-700" : "bg-green-700"} px-4 py-1`} onClick={ToggleDiscord}>
@ -194,11 +310,11 @@ export default function DashboardPage() {
</button>
</div>
<div className="flex h-12 items-center">
<FontAwesomeIcon className="p-2 w-12" icon={faGoogle} size={'2x'}/>
<FontAwesomeIcon className="p-2 w-12" icon={faGoogle} size={'2x'} />
<p className="w-16">Google</p>
<div className="px-5"></div>
<div className={`bg-gray-${user?.google ? "8" : "7"}00 rounded-xl items-center justify-center flex w-64 p-1`}>
<p>{user?.google ? "@"+user?.google?.email : "-"}</p>
<p>{user?.google ? "@" + user?.google?.email : "-"}</p>
</div>
<div className="p-5" />
<button className={`rounded-full ${user?.google ? "bg-red-700" : "bg-green-700"} px-4 py-1`} onClick={ToggleGoogle}>
@ -206,26 +322,26 @@ export default function DashboardPage() {
</button>
</div>
</div>
<div className="bg-opacity-40 bg-gray-900 rounded-3xl itmes-center justify-center p-5 grid">
<h1 className="text-xl flex justify-center mb-5">Wallets</h1>
<div>
<div>
<div className={`grid grid-cols-6 ${activeWallet == getEmbeddedConnectedWallet(wallets)?.address ? "bg-gray-600" : "bg-gray-800"} rounded-full py-2 px-20 items-center h-20`} onClick={()=>{setActiveWallet(getEmbeddedConnectedWallet(wallets)?.address)}}>
<div className={`grid grid-cols-6 ${activeWallet == getEmbeddedConnectedWallet(wallets)?.address ? "bg-gray-600" : "bg-gray-800"} rounded-full py-2 px-20 items-center h-20`} onClick={() => { handleWalletClick(getEmbeddedConnectedWallet(wallets)?.address ?? ""); }}>
<button className="w-12">
<FontAwesomeIcon icon={faLink}/>
<FontAwesomeIcon icon={faLink} />
</button>
<div className="grid col-span-4">
<p className="flex justify-center items-center">W3B Wallet</p>
<div className="h-2"></div>
<p>{getEmbeddedConnectedWallet(wallets)?.address }</p>
<p>{getEmbeddedConnectedWallet(wallets)?.address}</p>
</div>
{/* <button className="justify-center items-center flex bg-red-400 ml-8 rounded-full h-10" onClick={()=>{unlinkWallet(wallet.address)}}>
<FontAwesomeIcon icon={faUnlink}/>
</button> */}
<button className="justify-center items-center flex bg-purple-400 ml-8 rounded-full h-10" onClick={exportWallet}>
<FontAwesomeIcon icon={faFileExport} className="w-6"/>
<FontAwesomeIcon icon={faFileExport} className="w-6" />
</button>
</div>
</div>
@ -233,14 +349,14 @@ export default function DashboardPage() {
<div className="h-7"></div>
<div className="grid gap-2 p-2">
{
wallets.map((wallet)=>{
if(wallet.connectorType == "embedded"){return "";}
wallets.map((wallet) => {
if (wallet.connectorType == "embedded") { return ""; }
const address = wallet.address;
return (
<div>
<div className={`grid grid-cols-6 ${wallet.linked ? (address == activeWallet ? "bg-gray-600" :"bg-gray-800") : "bg-gray-900 bg-opacity-30 text-gray-600"} rounded-full py-2 px-20 items-center h-20`} onClick={()=>{setActiveWallet(address)}}>
<div className={`grid grid-cols-6 ${wallet.linked ? (address == activeWallet ? "bg-gray-600" : "bg-gray-800") : "bg-gray-900 bg-opacity-30 text-gray-600"} rounded-full py-2 px-20 items-center h-20`} onClick={() => { handleWalletClick(address) }}>
<button className="w-8">
<FontAwesomeIcon icon={faWallet}/>
<FontAwesomeIcon icon={faWallet} />
</button>
<div className="grid col-span-4">
<p className="flex justify-center items-center">{wallet.walletClientType}</p>
@ -248,12 +364,12 @@ export default function DashboardPage() {
<p>{wallet.address}</p>
</div>
{ wallet.linked ? <button className="justify-center items-center flex bg-red-400 ml-8 rounded-full h-10" onClick={()=>{unlinkWallet(wallet.address)}}>
<FontAwesomeIcon icon={faUnlink} className="w-6"/>
</button> :
<FontAwesomeIcon icon={faUnlink} className="w-6 justify-center items-center flex ml-8 rounded-full h-10"/>
{wallet.linked ? <button className="justify-center items-center flex bg-red-400 ml-8 rounded-full h-10" onClick={() => { unlinkWallet(wallet.address) }}>
<FontAwesomeIcon icon={faUnlink} className="w-6" />
</button> :
<FontAwesomeIcon icon={faUnlink} className="w-6 justify-center items-center flex ml-8 rounded-full h-10" />
}
</div>
</div>
);
@ -273,53 +389,57 @@ export default function DashboardPage() {
</button>
</div>
</div>
{/* <div className="mt-12 flex gap-4 flex-wrap">
{discordSubject ? (
<button
onClick={() => {
unlinkDiscord(discordSubject);
}}
className="text-sm border border-violet-600 hover:border-violet-700 py-2 px-4 rounded-md text-violet-600 hover:text-violet-700 disabled:border-gray-500 disabled:text-gray-500 hover:disabled:text-gray-500"
disabled={!canRemoveAccount}
>
Unlink Discord
</button>
) : (
<button
className="text-sm bg-violet-600 hover:bg-violet-700 py-2 px-4 rounded-md text-white"
onClick={() => {
linkDiscord();
}}
>
Link Discord
</button>
)}
{wallet ? (
<button
onClick={() => {
unlinkWallet(wallet.address);
}}
className="text-sm border border-violet-600 hover:border-violet-700 py-2 px-4 rounded-md text-violet-600 hover:text-violet-700 disabled:border-gray-500 disabled:text-gray-500 hover:disabled:text-gray-500"
disabled={!canRemoveAccount}
>
Unlink wallet
</button>
) : (
<button
onClick={linkWallet}
className="text-sm bg-violet-600 hover:bg-violet-700 py-2 px-4 rounded-md text-white border-none"
>
Connect wallet
</button>
)}
<button onClick={linkWallet}>
Wallet
</button>
</div> */}
{showPopup && (
<div className="fixed inset-0 bg-black bg-opacity-75 flex justify-center items-center">
<div className="bg-gray-800 p-8 rounded-lg">
<h2 className="text-xl mb-4">Enter Ticket Amount</h2>
<div className="flex items-center">
<button
onClick={() => setTicketAmount(ticketAmount > 1 ? ticketAmount - 1 : 1)}
className="text-lg bg-gray-600 hover:bg-gray-500 text-white py-1 px-3 rounded-l"
>
-
</button>
<input
type="number"
value={ticketAmount}
onChange={(e) => setTicketAmount(Number(e.target.value))}
className="w-16 text-center text-white bg-black appearance-none"
style={{
appearance: 'textfield',
WebkitAppearance: 'none',
MozAppearance: 'textfield',
}}
/>
<button
onClick={() => setTicketAmount(ticketAmount + 1)}
className="text-lg bg-gray-600 hover:bg-gray-500 text-white py-1 px-3 rounded-r"
>
+
</button>
</div>
<div className="mt-4 flex justify-between">
<button
onClick={() => buyTicket(ticketAmount)}
className="bg-green-600 hover:bg-green-700 text-white py-2 px-4 rounded-md"
>
Buy
</button>
<button
onClick={() => setShowPopup(false)}
className="bg-red-600 hover:bg-red-700 text-white py-2 px-4 rounded-md"
>
Cancel
</button>
</div>
</div>
</div>
)}
</>
) : null}
) : (
<p>Loading...</p>
)}
</main>
</>
);

728
pages/data.tsx Normal file
View File

@ -0,0 +1,728 @@
export const gameDataABI = [
{
"inputs": [
{
"internalType": "address",
"name": "sender",
"type": "address"
},
{
"internalType": "uint256",
"name": "balance",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "needed",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
}
],
"name": "ERC1155InsufficientBalance",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "approver",
"type": "address"
}
],
"name": "ERC1155InvalidApprover",
"type": "error"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "idsLength",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "valuesLength",
"type": "uint256"
}
],
"name": "ERC1155InvalidArrayLength",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "operator",
"type": "address"
}
],
"name": "ERC1155InvalidOperator",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "receiver",
"type": "address"
}
],
"name": "ERC1155InvalidReceiver",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "sender",
"type": "address"
}
],
"name": "ERC1155InvalidSender",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "operator",
"type": "address"
},
{
"internalType": "address",
"name": "owner",
"type": "address"
}
],
"name": "ERC1155MissingApprovalForAll",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "owner",
"type": "address"
}
],
"name": "OwnableInvalidOwner",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "account",
"type": "address"
}
],
"name": "OwnableUnauthorizedAccount",
"type": "error"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "account",
"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": "operator",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "from",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "to",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256[]",
"name": "ids",
"type": "uint256[]"
},
{
"indexed": false,
"internalType": "uint256[]",
"name": "values",
"type": "uint256[]"
}
],
"name": "TransferBatch",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "operator",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "from",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "to",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "id",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "TransferSingle",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "string",
"name": "value",
"type": "string"
},
{
"indexed": true,
"internalType": "uint256",
"name": "id",
"type": "uint256"
}
],
"name": "URI",
"type": "event"
},
{
"inputs": [
{
"internalType": "address",
"name": "account",
"type": "address"
},
{
"internalType": "uint256",
"name": "id",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "burn",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "account",
"type": "address"
},
{
"internalType": "uint256[]",
"name": "ids",
"type": "uint256[]"
},
{
"internalType": "uint256[]",
"name": "values",
"type": "uint256[]"
}
],
"name": "burnBatch",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "buyTickets",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [],
"name": "renounceOwnership",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "from",
"type": "address"
},
{
"internalType": "address",
"name": "to",
"type": "address"
},
{
"internalType": "uint256[]",
"name": "ids",
"type": "uint256[]"
},
{
"internalType": "uint256[]",
"name": "values",
"type": "uint256[]"
},
{
"internalType": "bytes",
"name": "data",
"type": "bytes"
}
],
"name": "safeBatchTransferFrom",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "from",
"type": "address"
},
{
"internalType": "address",
"name": "to",
"type": "address"
},
{
"internalType": "uint256",
"name": "id",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "value",
"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": "address",
"name": "newOp",
"type": "address"
}
],
"name": "setOperator",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "newPrice",
"type": "uint256"
}
],
"name": "setTicketPrice",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "tournament_id",
"type": "uint256"
}
],
"name": "startTournament",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "newOwner",
"type": "address"
}
],
"name": "transferOwnership",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "user",
"type": "address"
},
{
"internalType": "uint256",
"name": "tournament_id",
"type": "uint256"
}
],
"name": "useTicket",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "withdraw",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"inputs": [
{
"internalType": "address",
"name": "account",
"type": "address"
},
{
"internalType": "uint256",
"name": "id",
"type": "uint256"
}
],
"name": "balanceOf",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address[]",
"name": "accounts",
"type": "address[]"
},
{
"internalType": "uint256[]",
"name": "ids",
"type": "uint256[]"
}
],
"name": "balanceOfBatch",
"outputs": [
{
"internalType": "uint256[]",
"name": "",
"type": "uint256[]"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "getExpiredTournaments",
"outputs": [
{
"internalType": "uint256[]",
"name": "",
"type": "uint256[]"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "tournamentId",
"type": "uint256"
}
],
"name": "getTournamentParticipants",
"outputs": [
{
"internalType": "address[]",
"name": "",
"type": "address[]"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "account",
"type": "address"
},
{
"internalType": "address",
"name": "operator",
"type": "address"
}
],
"name": "isApprovedForAll",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "operator",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "owner",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "PP",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "SafeCoins",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes4",
"name": "interfaceId",
"type": "bytes4"
}
],
"name": "supportsInterface",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "ticketPrice",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "TOURNAMENT_TICKETS",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "TOURNAMENT_TROPHIES",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_tokenid",
"type": "uint256"
}
],
"name": "uri",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "pure",
"type": "function"
}
];

View File

View File

@ -0,0 +1,593 @@
[
{
"inputs": [],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"inputs": [
{
"internalType": "address",
"name": "sender",
"type": "address"
},
{
"internalType": "uint256",
"name": "balance",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "needed",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
}
],
"name": "ERC1155InsufficientBalance",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "approver",
"type": "address"
}
],
"name": "ERC1155InvalidApprover",
"type": "error"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "idsLength",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "valuesLength",
"type": "uint256"
}
],
"name": "ERC1155InvalidArrayLength",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "operator",
"type": "address"
}
],
"name": "ERC1155InvalidOperator",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "receiver",
"type": "address"
}
],
"name": "ERC1155InvalidReceiver",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "sender",
"type": "address"
}
],
"name": "ERC1155InvalidSender",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "operator",
"type": "address"
},
{
"internalType": "address",
"name": "owner",
"type": "address"
}
],
"name": "ERC1155MissingApprovalForAll",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "owner",
"type": "address"
}
],
"name": "OwnableInvalidOwner",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "account",
"type": "address"
}
],
"name": "OwnableUnauthorizedAccount",
"type": "error"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "account",
"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": "operator",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "from",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "to",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256[]",
"name": "ids",
"type": "uint256[]"
},
{
"indexed": false,
"internalType": "uint256[]",
"name": "values",
"type": "uint256[]"
}
],
"name": "TransferBatch",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "operator",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "from",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "to",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "id",
"type": "uint256"
},
{
"indexed": false,
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "TransferSingle",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "string",
"name": "value",
"type": "string"
},
{
"indexed": true,
"internalType": "uint256",
"name": "id",
"type": "uint256"
}
],
"name": "URI",
"type": "event"
},
{
"inputs": [],
"name": "PP",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "SafeCoins",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "TOURNAMENT_TICKETS",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "TOURNAMENT_TROPHIES",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "account",
"type": "address"
},
{
"internalType": "uint256",
"name": "id",
"type": "uint256"
}
],
"name": "balanceOf",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address[]",
"name": "accounts",
"type": "address[]"
},
{
"internalType": "uint256[]",
"name": "ids",
"type": "uint256[]"
}
],
"name": "balanceOfBatch",
"outputs": [
{
"internalType": "uint256[]",
"name": "",
"type": "uint256[]"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "buyTickets",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "account",
"type": "address"
},
{
"internalType": "address",
"name": "operator",
"type": "address"
}
],
"name": "isApprovedForAll",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "owner",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "renounceOwnership",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "from",
"type": "address"
},
{
"internalType": "address",
"name": "to",
"type": "address"
},
{
"internalType": "uint256[]",
"name": "ids",
"type": "uint256[]"
},
{
"internalType": "uint256[]",
"name": "values",
"type": "uint256[]"
},
{
"internalType": "bytes",
"name": "data",
"type": "bytes"
}
],
"name": "safeBatchTransferFrom",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "from",
"type": "address"
},
{
"internalType": "address",
"name": "to",
"type": "address"
},
{
"internalType": "uint256",
"name": "id",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "value",
"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": "uint256",
"name": "newPrice",
"type": "uint256"
}
],
"name": "setTicketPrice",
"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": "ticketPrice",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "newOwner",
"type": "address"
}
],
"name": "transferOwnership",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_tokenid",
"type": "uint256"
}
],
"name": "uri",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [],
"name": "withdraw",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
]