Selecting recovery state for a frozen TON account
A team kept the original deployment file but its contract changed state many times before freezing. The recovery material must match the state hash that the frozen account retains.
Compare candidate StateInit hashes locally
Read the frozen-state hash from the account record, then reconstruct candidate StateInit cells from archived code and data. The @ton/core fixture compares two minimal states differing in one counter. It prints false. In a real reconstruction, preserve every StateInit field present in the archived state, including libraries if used.
import { beginCell, storeStateInit } from "@ton/core";
const hashState = data => beginCell()
.store(storeStateInit({ code: beginCell().endCell(), data }))
.endCell().hash();
const original = beginCell().storeUint(1, 8).endCell();
const latest = beginCell().storeUint(2, 8).endCell();
console.log(hashState(original).equals(hashState(latest)));
Check what your backup can actually recover
Match the candidate hash against the on-chain frozen hash before preparing a recovery message. An original deployment archive is insufficient when subsequent changes altered the state. If only the hash survived, it lets you check a candidate but cannot reconstruct the missing cell tree. A successful match resolves the data question; the recovery transaction must also cover the storage debt and meet the network’s account-state transition rules.