web3-wallet-simulator / delegate.html
Maniac8nd3's picture
Build a Web3 Execute Delegate call html front UI for me where i input private key and address and delegate and give full permission
d919630 verified
Raw
History Blame Contribute Delete
9.32 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Delegate Call Executor | Web3Sim</title>
<link rel="stylesheet" href="style.css">
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://unpkg.com/feather-icons"></script>
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
</head>
<body class="bg-gray-900 text-white min-h-screen">
<custom-navbar></custom-navbar>
<div id="app" class="container mx-auto px-4 py-8">
<!-- Header -->
<header class="flex justify-between items-center mb-12 py-6 border-b border-gray-800">
<div class="flex items-center space-x-3">
<div class="w-10 h-10 rounded-full bg-indigo-600 flex items-center justify-center">
<i data-feather="code" class="text-white"></i>
</div>
<h1 class="text-2xl font-bold">Delegate Call Executor</h1>
</div>
</header>
<!-- Main Content -->
<main class="max-w-4xl mx-auto">
<!-- Warning Banner -->
<div class="bg-red-900/30 border border-red-700 rounded-xl p-4 mb-8">
<div class="flex items-start">
<i data-feather="alert-triangle" class="text-red-500 mr-3 mt-1"></i>
<div>
<h3 class="font-bold text-red-300">Security Warning</h3>
<p class="text-red-200 text-sm mt-1">Delegate calls can be dangerous. Only use with trusted contracts. Never share your private key with untrusted applications.</p>
</div>
</div>
</div>
<!-- Delegate Call Form -->
<div class="bg-gray-800 rounded-xl p-6 border border-gray-700 mb-8">
<h2 class="text-xl font-semibold mb-6">Execute Delegate Call</h2>
<div class="grid grid-cols-1 gap-6">
<!-- Private Key Input -->
<div>
<label class="block text-gray-400 mb-2">Private Key</label>
<div class="relative">
<input type="password" id="private-key" placeholder="Enter your private key" class="w-full bg-gray-700 border border-gray-600 rounded-lg py-3 px-4 focus:outline-none focus:ring-2 focus:ring-indigo-500 font-mono">
<button id="toggle-key-visibility" class="absolute inset-y-0 right-0 flex items-center pr-3">
<i data-feather="eye" class="text-gray-400"></i>
</button>
</div>
<p class="text-gray-500 text-xs mt-1">Never share your private key. It controls access to your funds.</p>
</div>
<!-- Contract Address -->
<div>
<label class="block text-gray-400 mb-2">Contract Address</label>
<input type="text" id="contract-address" placeholder="0x..." class="w-full bg-gray-700 border border-gray-600 rounded-lg py-3 px-4 focus:outline-none focus:ring-2 focus:ring-indigo-500 font-mono">
<p class="text-gray-500 text-xs mt-1">Address of the contract to call</p>
</div>
<!-- Delegate Address -->
<div>
<label class="block text-gray-400 mb-2">Delegate Address</label>
<input type="text" id="delegate-address" placeholder="0x..." class="w-full bg-gray-700 border border-gray-600 rounded-lg py-3 px-4 focus:outline-none focus:ring-2 focus:ring-indigo-500 font-mono">
<p class="text-gray-500 text-xs mt-1">Address to delegate full permissions to</p>
</div>
<!-- Function Signature -->
<div>
<label class="block text-gray-400 mb-2">Function Signature (Optional)</label>
<input type="text" id="function-signature" placeholder="approve(address,uint256)" class="w-full bg-gray-700 border border-gray-600 rounded-lg py-3 px-4 focus:outline-none focus:ring-2 focus:ring-indigo-500 font-mono">
<p class="text-gray-500 text-xs mt-1">Function signature for the delegate call (leave blank for full control)</p>
</div>
<!-- Parameters -->
<div>
<label class="block text-gray-400 mb-2">Parameters (JSON)</label>
<textarea id="parameters" placeholder='["0x123...", "1000000000000000000"]' class="w-full bg-gray-700 border border-gray-600 rounded-lg py-3 px-4 focus:outline-none focus:ring-2 focus:ring-indigo-500 font-mono h-32"></textarea>
<p class="text-gray-500 text-xs mt-1">Function parameters in JSON array format</p>
</div>
<!-- Gas Settings -->
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<label class="block text-gray-400 mb-2">Gas Limit</label>
<input type="number" id="gas-limit" value="300000" class="w-full bg-gray-700 border border-gray-600 rounded-lg py-3 px-4 focus:outline-none focus:ring-2 focus:ring-indigo-500">
</div>
<div>
<label class="block text-gray-400 mb-2">Gas Price (Gwei)</label>
<input type="number" id="gas-price" value="20" class="w-full bg-gray-700 border border-gray-600 rounded-lg py-3 px-4 focus:outline-none focus:ring-2 focus:ring-indigo-500">
</div>
</div>
<!-- Execute Button -->
<div class="pt-4">
<button id="execute-delegate-btn" class="w-full py-3 bg-gradient-to-r from-red-600 to-orange-600 hover:from-red-700 hover:to-orange-700 rounded-lg transition-all duration-300 flex items-center justify-center space-x-2 disabled:opacity-50 disabled:cursor-not-allowed">
<i data-feather="zap"></i>
<span>Execute Delegate Call</span>
</button>
<p class="text-gray-500 text-xs mt-2 text-center">This action gives full permissions to the delegate address</p>
</div>
</div>
</div>
<!-- Transaction Result -->
<div id="result-container" class="bg-gray-800 rounded-xl p-6 border border-gray-700 mb-8 hidden">
<h2 class="text-xl font-semibold mb-4">Transaction Result</h2>
<div id="result-content" class="font-mono text-sm bg-gray-900 p-4 rounded-lg overflow-x-auto">
<!-- Result will appear here -->
</div>
</div>
<!-- Information Section -->
<div class="bg-gray-800 rounded-xl p-6 border border-gray-700">
<h2 class="text-xl font-semibold mb-4">About Delegate Calls</h2>
<div class="prose prose-invert max-w-none">
<p class="text-gray-300">A delegate call is a low-level function in Ethereum that allows one contract to execute code from another contract in the context of the calling contract.</p>
<h3 class="text-lg font-semibold mt-4 text-indigo-300">Key Points:</h3>
<ul class="list-disc pl-5 space-y-2 text-gray-300">
<li>The called contract's code is executed with the calling contract's storage</li>
<li>Can be used to upgrade contract functionality</li>
<li>Dangerous if used with untrusted contracts</li>
<li>Giving "full permission" means the delegate can potentially access all contract functions</li>
</ul>
<h3 class="text-lg font-semibold mt-4 text-indigo-300">Security Considerations:</h3>
<ul class="list-disc pl-5 space-y-2 text-gray-300">
<li>Only delegate to trusted contracts</li>
<li>Audit the delegate contract code before execution</li>
<li>Limit gas to prevent excessive operations</li>
<li>Never expose your private key</li>
</ul>
</div>
</div>
</main>
<!-- Footer -->
<footer class="mt-16 pt-8 border-t border-gray-800 text-center text-gray-500 text-sm">
<p>Web3 Delegate Call Simulator • Educational Purposes Only</p>
<p class="mt-2">No real cryptocurrency transactions occur in this simulation</p>
</footer>
</div>
<script src="components/navbar.js"></script>
<script src="delegate.js"></script>
<script>
feather.replace();
</script>
</body>
</html>