Skip to content

Instantly share code, notes, and snippets.

@arpit3210
Created July 26, 2024 19:17
Show Gist options
  • Save arpit3210/c025c968a6cbfe8e41aa7e211950703f to your computer and use it in GitHub Desktop.
Save arpit3210/c025c968a6cbfe8e41aa7e211950703f to your computer and use it in GitHub Desktop.
import React, { useState } from 'react';
import './App.css';
const App = () => {
const [name, setName] = useState('MyToken');
const [symbol, setSymbol] = useState('MTK');
const [supply, setSupply] = useState('1000000');
const [transactionHash, setTransactionHash] = useState('');
const [isSuccessful, setIsSuccessful] = useState(null);
const trimAddress = (address) => {
return `${address.slice(0, 6)}...${address.slice(-4)}`;
};
return (
<div>
<div className="absolute top-0 right-0 p-4">
<button className="mb-2 py-2 px-4 rounded bg-red-500 text-white">
Connect Wallet
</button>
<div className="text-right">
<p className="text-gray-700">Network: Unknown</p>
<p className="text-gray-700">Wallet: {trimAddress('0x0000000000000000000000000000000000000000')}</p>
</div>
</div>
<div className="min-h-screen bg-gray-100 flex flex-col items-center justify-center">
<header className="relative bg-white shadow-lg rounded-lg p-8 w-full max-w-md">
<h1 className="text-2xl font-bold mb-6 text-center">ERC20 Token Deployer</h1>
<div className="space-y-4">
<input
type="text"
placeholder="Token Name"
value={name}
onChange={e => setName(e.target.value)}
className="w-full px-3 py-2 border rounded"
/>
<input
type="text"
placeholder="Token Symbol"
value={symbol}
onChange={e => setSymbol(e.target.value)}
className="w-full px-3 py-2 border rounded"
/>
<input
type="number"
placeholder="Total Supply"
value={supply}
onChange={e => setSupply(e.target.value)}
className="w-full px-3 py-2 border rounded"
/>
<button className="w-full py-2 px-4 bg-blue-500 text-white rounded">
Deploy Token
</button>
</div>
{isSuccessful !== null && (
<div className="mt-6 text-center">
{isSuccessful ? (
<div className='flex flex-col'>
<img src="https://media.giphy.com/media/2u11zpzwyMTy8/giphy.gif?cid=790b76119n2zxhtf2obn4wzgvuw40f8v6k0pk4e35hf0l8vt&ep=v1_gifs_search&rid=giphy.gif&ct=g" alt="Success" />
<p className="text-green-500 mt-4">Token contract deployed successfully!</p>
<p className="text-gray-700 test-sm">Transaction Hash:</p>
<p className="text-gray-700 test-sm">{transactionHash}</p>
</div>
) : (
<div className='flex flex-col'>
<img src="https://media.giphy.com/media/wIAzgC4sqiGaeKMhr2/giphy.gif?cid=790b7611wrlwv1nkd4lk2xr54r9v43k8kszspgtnm5wlgweh&ep=v1_gifs_search&rid=giphy.gif&ct=g" alt="Failure" />
<p className="text-red-500 mt-4">Transaction failed. Please try again.</p>
</div>
)}
</div>
)}
</header>
</div>
</div>
);
};
export default App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment