| Server IP : 167.235.67.158 / Your IP : 216.73.216.95 Web Server : Apache System : Linux ubuntu-8gb-nbg1-1 6.8.0-111-generic #111-Ubuntu SMP PREEMPT_DYNAMIC Sat Apr 11 23:16:02 UTC 2026 x86_64 User : root ( 0) PHP Version : 8.3.6 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/bc.the-word.com/ |
Upload File : |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Sign Message with Phantom</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style>
body {
font-family: system-ui, sans-serif;
max-width: 720px;
margin: 40px auto;
line-height: 1.6;
padding: 0 12px;
}
h2 {
text-align: center;
}
button {
font-size: 16px;
padding: 10px 20px;
border-radius: 8px;
border: none;
background: #8b5cf6;
color: white;
cursor: pointer;
}
button:hover {
background: #7c3aed;
}
pre {
background: #f3f3f3;
padding: 10px;
border-radius: 8px;
word-break: break-all;
margin: 0;
}
.row {
display: grid;
grid-template-columns: 1fr auto;
align-items: center;
gap: 10px;
}
.box {
margin-top: 18px;
}
.muted {
color: #6b7280;
}
.warn {
color: #b45309;
}
.ok {
color: #16a34a;
}
</style>
</head>
<body>
<h2>Phantom Message Signer</h2>
<p class="muted">Open this page inside Phantom’s in-app browser (Saga) or a desktop browser with the Phantom
extension.</p>
<button id="sign">Sign Message</button>
<div id="status" class="box muted"></div>
<div id="output" class="box"></div>
<div id="debug" class="box muted" style="font-size:12px;"></div>
<script>
/************ Base58 encoder (no deps; based on base-x) ************/
(function () {
const ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
const BASE = ALPHABET.length;
const LEADER = ALPHABET[0];
// Expose a global function: window.base58Encode(Uint8Array)
window.base58Encode = function (source) {
if (!(source instanceof Uint8Array)) source = new Uint8Array(source);
if (source.length === 0) return "";
// Count leading zeros
let zeros = 0;
while (zeros < source.length && source[zeros] === 0) zeros++;
// Convert base-256 digits to base-58 digits
const size = ((source.length - zeros) * 138 / 100 + 1) >>> 0; // log(256) / log(58) ≈ 1.365
const b58 = new Uint8Array(size);
let length = 0;
for (let i = zeros; i < source.length; i++) {
let carry = source[i];
let j = 0;
for (let k = size - 1; (carry !== 0 || j < length) && k >= 0; k--, j++) {
carry += (256 * b58[k]) >>> 0;
b58[k] = (carry % BASE) >>> 0;
carry = (carry / BASE) >>> 0;
}
length = j;
}
// Skip leading zeros in base58 result
let it = size - length;
while (it < size && b58[it] === 0) it++;
// Translate to string
let str = LEADER.repeat(zeros);
for (; it < size; it++) str += ALPHABET[b58[it]];
return str;
};
})();
/************ Helpers ************/
const MESSAGE = `STAR 21270155 to addr1qy5gdvyhk8wlm6q46359zsg43hn8645lguafe99fqyhc26ec7sqv2plux6fvwmdsp2fgws4c9shmryjepkvu7xxp6gys2pmfnr 31a6bab50a84b8439adcfb786bb2020f6807e6e8fda629b424110fc7bb1c6b8b`;
const setStatus = (t, cls = "muted") => { const s = document.getElementById("status"); s.textContent = t; s.className = `box ${cls}`; };
const copyText = async (id) => { await navigator.clipboard.writeText(document.getElementById(id).textContent); alert("Copied!"); };
const getProvider = () => {
const p = window.solana || (window.phantom && window.phantom.solana);
return p && p.isPhantom ? p : null;
};
const normalizePublicKey = (pk) => (pk && typeof pk.toBase58 === "function") ? pk.toBase58() : (typeof pk === "string" ? pk : (pk?.toString?.() ?? "(unavailable)"));
function normalizeSignature(sig) {
// Returns { b58, hex, b64 }
if (!sig) throw new Error("Signature missing from wallet response.");
// If already a base58 string, just return it and skip encodings
if (typeof sig === "string") {
return { b58: sig, hex: "(string provided)", b64: "(string provided)" };
}
// Coerce to Uint8Array
let bytes;
if (sig instanceof Uint8Array) bytes = sig;
else if (sig instanceof ArrayBuffer) bytes = new Uint8Array(sig);
else if (Array.isArray(sig)) bytes = new Uint8Array(sig);
else throw new Error("Unknown signature type: " + Object.prototype.toString.call(sig));
const b58 = window.base58Encode(bytes);
const hex = Array.from(bytes).map(b => b.toString(16).padStart(2, "0")).join("");
// base64
let bin = ""; const chunk = 0x8000;
for (let i = 0; i < bytes.length; i += chunk) bin += String.fromCharCode.apply(null, bytes.subarray(i, i + chunk));
const b64 = btoa(bin);
return { b58, hex, b64 };
}
document.getElementById("sign").onclick = async () => {
try {
const provider = getProvider();
if (!provider) {
setStatus("Phantom provider not detected. Open in Phantom’s in-app browser.", "warn");
alert("Phantom not detected.");
return;
}
setStatus("Connecting to wallet…");
await provider.connect({ onlyIfTrusted: false });
const encoded = new TextEncoder().encode(MESSAGE);
setStatus("Requesting signature…");
let res;
try {
res = await provider.signMessage(encoded, "utf8"); // legacy form
} catch {
res = await provider.signMessage(encoded, { display: "utf8" }); // new form
}
// Debug the raw response shape
document.getElementById("debug").innerHTML =
"<details><summary>Raw wallet response</summary><pre>" +
(JSON.stringify(res, (k, v) => (v instanceof Uint8Array ? Array.from(v) : v), 2)) +
"</pre></details>";
const pk58 = normalizePublicKey(res?.publicKey);
const { b58, hex, b64 } = normalizeSignature(res?.signature);
setStatus("Signed ✔", "ok");
document.getElementById("output").innerHTML = `
<h3>Signature Result</h3>
<div class="row"><strong>Public Key (base58)</strong>
<button onclick="copyText('pk')">Copy</button></div>
<pre id="pk">${pk58}</pre>
<div class="row" style="margin-top:10px;"><strong>Signature (base58)</strong>
<button onclick="copyText('sig58')">Copy</button></div>
<pre id="sig58">${b58}</pre>
<details class="box">
<summary>More encodings (debug)</summary>
<div class="row" style="margin-top:10px;"><strong>Signature (base64)</strong>
<button onclick="copyText('sig64')">Copy</button></div>
<pre id="sig64">${b64}</pre>
<div class="row" style="margin-top:10px;"><strong>Signature (hex)</strong>
<button onclick="copyText('sighex')">Copy</button></div>
<pre id="sighex">${hex}</pre>
</details>
`;
} catch (err) {
console.error(err);
setStatus("Error: " + (err?.message || String(err)), "warn");
alert("Error signing message: " + (err?.message || err));
}
};
</script>
</body>
</html>