services
Get a key

library / Integrations / I0067

Minecraft wallet link by memo

A Node file that issues a one-time code per player, finds it as a memo in your receiving address's signature list, and links the player to the fee payer of that transaction, with no wallet plugin in the game.

By Carbium · Game engines · I0067 · updated 2026-11-22

02

Reading memos from the signature list

A row from getSignaturesForAddress carries signature, slot, err, blockTime and memo. The memo is the Memo program's text with a length prefix, as in [6] K7M2QX, and a transaction with two memos joins them with ; . The memos helper strips the prefix. One call on the receiving address finds the code, with no call per transaction.

A transaction is listed under every address in its account list. A memo attached to a transfer to your address shows up, and so does a memo from someone who only mentions your address. So the matcher also checks the lamports your address gained before it links anyone.

Rows arrive newest first. The first poll remembers the newest signature and each later poll passes it as until, so a poll returns only new rows. A row with err set is skipped. The page size is 50. If more than 50 rows can land between two polls, page backwards as in Signature history pagination, which this file does not do.

Carbium answers the call from an address index that keeps up to 30 days. A code lives minutes, so the matcher never needs older rows. Both calls pass commitment confirmed explicitly.

03

Proving who sent it

The first account key of a transaction is its fee payer, and the fee payer must sign. A candidate row is read with getTransaction using jsonParsed encoding and maxSupportedTransactionVersion: 1. Mainnet carries v1 transactions, and a call without that value answers -32015 for them.

payerOf returns accountKeys[0] as the payer. It also reads the change in the receiving address's balance from preBalances and postBalances. That change proves lamports reached the address, which a memo alone does not. A transaction whose meta.err is set is rejected.

getTransaction can answer null for a signature the list shows, because list pages reach below the validator's ledger floor. A row minutes old reads fine. Null appears when you scan older rows. The file logs it, leaves the code open and polls that row again.

!The fee payer is the sender only when the sender pays their own fee. A wallet app with a fee sponsor, or a transaction another party built, has a payer that differs from the account the lamports left. For that case read the transfer instruction's source from the parsed instructions.
04

Code expiry and reuse

A code is six symbols from a 32-symbol alphabet without 0, O, 1 and I, drawn from crypto.getRandomValues. That is about a billion codes, and a code is only guessable while it is open. Each lives 10 minutes. open drops an expired code the first time anything asks for it.

A match deletes the code, so a later transaction with the same memo finds nothing. When two signatures carry one code in the same poll, the file walks rows oldest first and the earliest signature wins. A viewer who sees a code on a stream can use it inside its 10 minutes, so show it only in the player's own chat.

issueCode adds a code and never removes an older one for the same player. A player who types the command twice holds two open codes until they expire. Keep one open code per player in your own store. A restart empties pending, so persist codes if a restart can land inside the 10 minutes.

05

The matcher

Install with npm install @solana/[email protected] and set "type": "module" in package.json. Node 24 strips the types on load. CARBIUM_KEY is required and the file exits with a message without it. CARBIUM_RPC_URL is optional.

main.ts
// I0067 · Minecraft wallet link by memo// https://carbium.sh/library/integrate/minecraft-wallet-link-by-memo// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.// SPDX-License-Identifier: MITimport { address, createDefaultRpcTransport, createSolanaRpcFromTransport, type Signature } from "@solana/kit";const key = process.env.CARBIUM_KEY;if (!key) {  console.error("Set CARBIUM_KEY to your Carbium API key.");  process.exit(1);}const rpc = createSolanaRpcFromTransport(  createDefaultRpcTransport({ url: process.env.CARBIUM_RPC_URL ?? "https://services.carbium.sh", headers: { "x-api-key": key } }),);const serving = Boolean(process.argv[2]); // with no argument: a sample run on the Memo programconst target = address(process.argv[2] ?? "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr");const TTL_MS = 10 * 60_000;const minPaid = serving ? 1_000n : 0n; // lamports; the Memo program receives noneconst pending = new Map<string, { player: string; expires: number }>(); // open code -> playerconst linked = new Map<string, string>(); // player -> walletfunction issueCode(player: string) {  const letters = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789"; // 32 symbols, no 0 O 1 I  const code = Array.from(crypto.getRandomValues(new Uint8Array(6)), (b) => letters[b % 32]).join("");  pending.set(code, { player, expires: Date.now() + TTL_MS });  return code;}function open(code: string) {  if ((pending.get(code)?.expires ?? Infinity) <= Date.now()) pending.delete(code);  return pending.get(code);}// "[6] K7M2QX; [3] abc" -> ["K7M2QX", "abc"]const memos = (m: string | null) => (m ?? "").split("; ").map((s) => s.replace(/^\[\d+\] /, "").trim()).filter(Boolean);async function newest(until?: Signature) {  const rows = await rpc.getSignaturesForAddress(target, { limit: 50, until, commitment: "confirmed" }).send();  return rows.map((r) => ({ sig: r.signature, memos: r.err ? [] : memos(r.memo) }));}async function payerOf(sig: Signature) {  const tx = await rpc.getTransaction(sig, { encoding: "jsonParsed", maxSupportedTransactionVersion: 1, commitment: "confirmed" }).send();  if (!tx?.meta || tx.meta.err) return null; // null: below the ledger floor, or failed  const keys = tx.transaction.message.accountKeys;  const i = keys.findIndex((k) => k.pubkey === target);  return { payer: keys[0].pubkey, paid: i < 0 ? 0n : tx.meta.postBalances[i] - tx.meta.preBalances[i] };}// Returns true when a candidate could not be read, so the caller polls that row again.async function match(rows: { sig: Signature; memos: string[] }[]) {  let retry = false;  for (const r of [...rows].reverse()) { // oldest first: the earliest signature wins a code    for (const m of r.memos) {      const p = open(m);      if (!p) continue;      try {        const tx = await payerOf(r.sig);        if (!tx) { retry = true; console.log(`${r.sig}: no transaction to read yet`); }        else if (tx.paid < minPaid) console.log(`${r.sig}: memo matched, but only ${tx.paid} lamports reached ${target}`);        else {          pending.delete(m);          linked.set(p.player, tx.payer);          console.log(`${r.sig} memo ${m} payer ${tx.payer} paid ${tx.paid} -> ${p.player} linked`);        }      } catch (e) {        retry = true;        console.error(`${r.sig}: read failed:`, e instanceof Error ? e.message : e);      }    }  }  return retry;}const first = await newest();console.log(`${target}: ${first.length} newest signatures`);for (const r of first.slice(0, 5)) console.log(r.sig, JSON.stringify(r.memos));if (serving) {  console.log(`Send a small transfer to ${target} with the memo ${issueCode("console-player")}`);  let last = first[0]?.sig;  while (!linked.size) {    await new Promise((r) => setTimeout(r, 5_000));    try {      const fresh = await newest(last);      if (!(await match(fresh))) last = fresh[0]?.sig ?? last;    } catch (e) {      console.error("poll failed:", e instanceof Error ? e.message : e);    }  }} else {  const sample = first.flatMap((r) => r.memos)[0]; // pretend the newest memo is an issued code  if (sample) pending.set(sample, { player: "sample-player", expires: Date.now() + TTL_MS });  await match(first);}

run: node main.ts <receiving-wallet-address>

With your receiving address as the argument, the file prints an instruction line with a fresh code, polls every 5 seconds and exits once one player is linked. A server keeps running and calls issueCode from the plugin. With no argument it reads the newest signatures of the Memo program, treats the newest memo as an issued code and prints the signature, memo, payer and the match. That run proves the reads and the decoding without a wallet. The Memo program receives no lamports, so the sample skips the transfer minimum.

06

Calls and limits

Each poll is one getSignaturesForAddress call and each candidate adds one getTransaction call. Both cost 50 cells. The rates are per second, and limits are per account, so every key on the account shares one budget.

CallCellsFreeDevBusinessPro
getSignaturesForAddress500.24 req/s1.2 req/s100 req/s500 req/s
getTransaction500.24 req/s1.2 req/s5 req/s25 req/s

A poll every 5 seconds is 0.2 req/s, inside the Free rate. getTransaction runs only for rows whose memo matches an open code, so unrelated memos sent to your address cost nothing beyond the list call.

07

Where it ends

  • It links a wallet to a player and does nothing else with funds. The lamports stay in your receiving wallet. Keeping or returning them is your decision, and this file holds no key and signs nothing.
  • The check proves someone controlled the payer key when the transfer landed. It does not prove who they are. One wallet can link many players unless your database forbids it.
  • The fee payer stands in for the sender. A sponsored transaction needs the instruction check described above.
  • Address history reaches back 30 days at most. Store each link when it is made, because the list cannot show it again later.
  • Polling delays a link by up to one interval after the transfer confirms. For a push, Carbium's WebSocket has logsSubscribe with an address mention filter. You still read the transaction afterwards for the payer.
  • It delivers no items and changes nothing in the game. Which server API receives the command and sends the chat message is up to your plugin, and this file does not touch it. For a lookup of one known memo, see Memo payment lookup.
08

When it goes wrong

what goes wrongwhat to do
The player sent the transfer and the code never matches.The wallet app dropped or changed the memo, or the 10 minutes ran out. Print the row's memo from getSignaturesForAddress. A code is case sensitive and the whole memo must equal it, with no extra text.
The log shows memo matched, but only 0 lamports reached the address.The player attached the memo to a transaction that moved nothing to your address. Ask for a transfer of at least 1,000 lamports with the code in the memo.
getTransaction answers -32015.The call left out maxSupportedTransactionVersion or set it to 0, and the transaction is v1. Pass 1 as the file does.
The log shows no transaction to read yet for every candidate.The signature is older than the ledger floor, which happens when you scan old rows. Match against rows from the last minutes, because a code is only valid for 10 minutes.
A poll fails with 429.The poll runs more often than your plan's getSignaturesForAddress rate allows, so lengthen the interval. Free allows 0.24 req/s, so 5 seconds fits.
The file exits at start with Set CARBIUM_KEY to your Carbium API key.The variable did not reach the process. Add it to the supervisor's environment file and restart.
09

Questions

Why a memo and not a signed message?

A signed message needs a wallet connection inside the game, and a Minecraft client has none. A transfer works from any wallet app on the player's phone, and the chain keeps the proof.

Why fetch the transaction when the list already shows the memo?

The list row has no payer and no amounts. getTransaction gives the fee payer and the balance change, which tie the memo to a wallet and to a real transfer.

Who pays for the link?

The player pays the network fee and the small transfer. The lamports land in your receiving wallet.

Can the code sit inside a longer memo?

Not in this file, which compares the whole memo to the code. To allow a prefix, pull the code out with a regular expression in memos and keep the lookup in pending.

How soon does the link appear?

Within one poll interval of the transaction confirming, so within about 5 seconds with the value in the file.