Notice
Please strictly follow the steps below to perform recovery. Before proceeding, please read the step-by-step example and reference screenshot in the README.
Two wallets: Step 2 signs offline with your Beacon Chain wallet (no gas). Step 4 only generates a payload — broadcasting the recover tx requires the BNB Chain key for To BSC Address, which must hold BNB for gas.
// beaconChainAddress: string — the bnb1... Beacon Chain address
// messageToSign: string — the JSON message shown above
// Sign the message with the Beacon Chain wallet (e.g., Trust Wallet)
const bbcSigned = await window.TrustBinanceChain.bnbSign(
beaconChainAddress,
messageToSign
);
// Never print the full signature in production builds.
console.log("Signed; bbcSigned ready");
// Example bbcSigned shape (do not log this in production):
// {
// "signature": "0x...",
// "publicKey": "0x..."
// }Note: The signature returned by the wallet may not be 0x-prefixed. Make sure to prepend 0x if it's missing before using the signature in the next steps.
Security: window.TrustBinanceChain is a plain global — any browser extension can inject or override it (and provider.isTrust can be set by anyone). Before signing, make sure only the legitimate Trust Wallet extension is enabled and you're not on a shared/untrusted browser. Avoid signing with multiple wallet extensions installed simultaneously.
null
Note: Both the Owner Signature (from the wallet) and the Approval Signature (from the server) must be 0x-prefixed. If either is missing the prefix, prepend 0x before submitting.
recover function yourself with a BNB Chain wallet that holds BNB for gas — see the code example below.null
const SECURITY_RECOVER_GAS_LIMIT = 1000000;
const receipt = await contract.recover(
recoverPayload.tokenSymbol,
recoverPayload.amount,
recoverPayload.ownerPubKey,
recoverPayload.ownerSignature,
recoverPayload.approvalSignature,
recoverPayload.merkleProof,
{
gasLimit: SECURITY_RECOVER_GAS_LIMIT,
},
);
// 'receipt' is the tx receipt — safe to log; never print the payload's signatures.
console.log(receipt);