Back

Version 2

10/31/2024
/** @jsxImportSource https://esm.sh/react */
import React, { useState, useEffect } from "https://esm.sh/react";
import { createRoot } from "https://esm.sh/react-dom/client";
import { ethers } from "https://esm.sh/ethers@5.7.2";

function CopyableField({ label, value }) {
const copyToClipboard = () => {
navigator.clipboard.writeText(value).then(() => {
alert(`${label} copied to clipboard!`);
});
};

return (
<div className="field">
<label>{label}:</label>
<div className="field-value">
<input type="text" value={value} readOnly />
<button onClick={copyToClipboard} className="copy-button">Copy</button>
</div>
</div>
);
}

function App() {
const [wallet, setWallet] = useState(null);

useEffect(() => {
generateWallet();
}, []);

const generateWallet = () => {
const newWallet = ethers.Wallet.createRandom();
setWallet(newWallet);
};

return (