---
id: I0067
title: "Minecraft wallet link by memo"
url: https://carbium.sh/library/integrate/minecraft-wallet-link-by-memo
collection: Integrations
category: Game engines
revision: 1
updated: 2026-11-22
author: Carbium
code: MIT (LICENSE in the zip); text: all rights reserved, Carbium Corporation
---

# 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.

## The link flow

A Minecraft server knows a player by a UUID and has no wallet connection. This file ties the two together with one action from the player: a small transfer from their own wallet app with a one-time code in the memo. The game needs no wallet plugin and no sign-in page, and the server never sees a key.

1. The player types a command such as `/link`. Your plugin calls `issueCode` with the player's UUID and shows the code in chat, next to the address of your server's receiving wallet.
2. The player sends at least 1,000 lamports (0.000001 SOL) to that address from any wallet app, with the code as the memo.
3. The file polls the signature list of the receiving address. A row whose memo equals an open code is a candidate.
4. For a candidate it reads the transaction once, takes the fee payer and the lamports the receiving address gained, and stores the pair of player and wallet.

The game half (the command, the chat message, saving the pair) belongs to your plugin and the server API you build it on. This file covers the chain half, and `issueCode` and the `linked` map are the two places where the plugin connects. The map lives in memory, so write each pair to your own database when it appears.

> Many wallet apps show no memo field. A wallet that reads Solana Pay transfer request links fills the memo from the link's `memo` parameter, so show the player a link or QR in that form next to the code.

## 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](https://carbium.sh/library/howsolana/signature-history-pagination), which this file does not do.

Carbium answers the call from an [address index](https://carbium.sh/docs#migrate) that keeps up to 30 days. A code lives minutes, so the matcher never needs older rows. Both calls pass commitment `confirmed` explicitly.

## 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.

## 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.

## The matcher

Install with `npm install @solana/kit@8.6.0` 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` (run: `node main.ts <receiving-wallet-address>`)

```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: MIT

import { 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 program
const target = address(process.argv[2] ?? "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr");
const TTL_MS = 10 * 60_000;
const minPaid = serving ? 1_000n : 0n; // lamports; the Memo program receives none
const pending = new Map<string, { player: string; expires: number }>(); // open code -> player
const linked = new Map<string, string>(); // player -> wallet

function 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);
}
```

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.

## 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](https://carbium.sh/docs#limits) are per account, so every key on the account shares one budget.

| Call | Cells | Free | Dev | Business | Pro |
|---|---|---|---|---|---|
| getSignaturesForAddress | 50 | 0.24 req/s | 1.2 req/s | 100 req/s | 500 req/s |
| getTransaction | 50 | 0.24 req/s | 1.2 req/s | 5 req/s | 25 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.

## 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](https://carbium.sh/docs#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](https://carbium.sh/library/usecase/memo-payment-lookup).

## When it goes wrong

| What goes wrong | What 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. |

## 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.

## Related

- [Memo payment lookup](https://carbium.sh/library/usecase/memo-payment-lookup) (Use cases, UC0022)
- [Signature history pagination](https://carbium.sh/library/howsolana/signature-history-pagination) (How to use Solana, HS0034)
- [carbium.sh/docs#endpoints](https://carbium.sh/docs#endpoints)
- [carbium.sh/docs#rpc](https://carbium.sh/docs#rpc)
- [carbium.sh/docs#limits](https://carbium.sh/docs#limits)
- [carbium.sh/docs#migrate](https://carbium.sh/docs#migrate)
- [carbium.sh/docs#websocket](https://carbium.sh/docs#websocket)
