The Lisbon Solar Fund (LSF) is a demo asset whose token accounts start
frozen. An account can receive LSF only after the issuer approves it. Below,
the issuer approves two investors, then a holder sends LSF to an approved
investor and to an account nobody approved. Last, the issuer uses two more
controls: a pause and a clawback. Press Run to step through this tutorial’s
code on a local test network (Surfpool). Nothing is sent from your browser, and
you need no code or wallet.
Lisbon Solar Fund (LSF) · restricted assetLocal test network (Surfpool)
HolderJAg5yGYw5Be2J54jk9s7ZUxhtU2FXN8txfpjxPctaeqxNot approvedApproved · 1000 LSFSent 100 LSF · 900 LSF left900 LSF
Approved investorCpvfwkairbnMrGqdW9wxMSiFgsHxi7666Gu4j7vCdjDvNot approvedApproved · 0 LSFReceived 100 LSF50 LSF · 50 moved to the issuer
Unapproved accountFecRDHyzRTLH3dfdz6ni5pnGq5j883zcSBToSe3PPdbPNot openedNot openedFrozen · transfer blockedFrozen · 0 LSF
- Approve two investors Every new LSF token account opens frozen. The issuer opens and approves (thaws) two investor accounts: the first now holds 1000 LSF, the second 0 LSF.
- Send to an approved and an unapproved account The holder (the first investor) sends 100 LSF to the approved investor, and it confirms. Sending 1 LSF to an account nobody approved, still frozen, fails onchain with
Custom: 17(Account is frozen), and with preflight it is rejected before it lands. - Pause, resume, and claw back The issuer pauses the asset, which blocks every transfer (
Custom: 67), and resumes it. As permanent delegate it then moves 50 LSF out of the approved investor’s account without their signature.
# Step 1/3 · Approve two investors
await openAccount(issuer, mint, holder.address)
Opened JAg5yGYw5Be2J54jk9s7ZUxhtU2FXN8txfpjxPctaeqx state: Frozen
await approveHolder(issuer, mint, holder.address, 1_000_000_000n)
Approved JAg5yGYw5Be2J54jk9s7ZUxhtU2FXN8txfpjxPctaeqx state: Initialized balance: 1000 LSF
Signature: 2cTiGJS6oWQFZ8XG4gTXqHz6RiywDvCYRzbprNrPfop8AacwZQCWC4ExL4UNQxK3XYF3LfakaqHPWN9RJQUiQexW
await openAccount(issuer, mint, approved.address)
Opened CpvfwkairbnMrGqdW9wxMSiFgsHxi7666Gu4j7vCdjDv state: Frozen
await approveHolder(issuer, mint, approved.address, 0n)
Approved CpvfwkairbnMrGqdW9wxMSiFgsHxi7666Gu4j7vCdjDv state: Initialized balance: 0 LSF
Signature: 5bjv6TA5KoJ8v61sPZ4Vuf3U8qRoryzTcEGqDShtfGLjxq7zaMn3vxf69QJwbPAxrEFu1tyzPNjw5RLf9ebzRcFa
Opened and approved · 4 transactions
# Step 2/3 · Send to an approved and an unapproved account
await transfer(holder, mint, approved.address, 100_000_000n)
Transfer 100 LSF: confirmed
Signature: 3m3VeXJvsqmPunuwHRyf3qrXXYApTCv2WABEib1U9M7qrXSXgwJxDopg1L6cfvUQ9NL6aG8bJDj6csHVxDm69oTM
await openAccount(issuer, mint, unapproved.address)
Opened FecRDHyzRTLH3dfdz6ni5pnGq5j883zcSBToSe3PPdbP state: Frozen
await sendToUnapproved(holder, mint, unapproved.address)
Transfer 1 LSF: failed onchain
Failed signature: 57czSUTPw8a1c8yN7n4TMV3CsRGEQSqaa3s7Tuvv4sV3jN5HQaurXZZnCtkFnv4DumVSi7WFMpHVhDYcKdtaxseW
err:
{"InstructionError":[0,{"Custom":17}]}log: Program log: Error: Account is frozen
fee paid anyway: 5000 lamports
await sendToUnapprovedWithPreflight(holder, mint, unapproved.address)
Transfer 1 LSF: rejected: Custom program error: #17 (instruction #1)
accountFrozen: true (no fee: it never landed)
Approved investor: 100 LSF receivedUnapproved account: blocked, account is frozen (Custom: 17)
# Step 3/3 · Pause, resume, and claw back
await pause(issuer, mint)
Paused the asset. Signature: 34UgQ3NwajBVsXCGihEi9pTCpFc8CCkWDfgRzQD2KLyfGGwTpAux7hf7e8RTQfFBChZDsdxQwa4Ef5AVSCgWWy67
await transfer(holder, mint, approved.address, 1_000_000n)
Transfer 1 LSF: rejected: Custom program error: #67 (instruction #1)
await resume(issuer, mint)
Resumed the asset. Signature: 2k8BNXskFbwdVxvxihzs72mDDkGkm6GBmgtVXwJAD8X8QXCUcSSXYSENSWbi85uKmUSNEUBwNv63sem2f7vb9weA
await clawBack(issuer, mint, approved.address, 50_000_000n)
Permanent delegate moved 50 LSF from CpvfwkairbnMrGqdW9wxMSiFgsHxi7666Gu4j7vCdjDv to the issuer
Signature: 3ZXvUsuYkbBJMyCr4y1g8iKt8wmsJtt5xhybWW34W6vYShELvj2MMhwZ7UqeAxXVuAFK3Hs76Xb1QBhDJuNXwkmE
While paused: transfer blocked (Custom: 67)Resumed50 LSF moved by the permanent delegate
The approved investor received 100 LSF, and the network blocked the 1 LSF transfer to the unapproved account. The issuer then paused and resumed the asset, and moved 50 LSF out of the approved investor’s account.
Why the transfer failed
Every new LSF token account opens in theFrozen state. The issuer approves an
investor after a KYC check by thawing their account, which is what “Approve
two investors” did. Nobody approved the third account, so the
Token-2022 programProgramsPrograms are code deployed to the network that owns and updates accounts. Most apps call existing programs, such as the Token program, rather than writing their own.Learn more (Programs: Programs are code deployed to the network that owns and updates accounts. Most apps call existing programs, such as the Token program, rather than writing their own.)
refused to credit it. Here are the lines from step 2 (excerpt):
Failed transfer (excerpt of the output)
{"InstructionError":[0,{"Custom":17}]}means instruction 0 of the transaction failed with Token-2022 error 17,AccountFrozen. The program log says the same in words:Account is frozen.- Transactions are all-or-nothing. The failed transfer moved no tokens: the unapproved account still holds 0 LSF.
- This transfer was sent with
skipPreflight, so it landed onchain as a failed transaction and the sender still paid the 5000-lamport network fee. - Sent the normal way, with preflight, the RPC node simulates the transaction
first and rejects it before it lands. No fee is charged, and your code gets
the same error 17 back (
accountFrozen: true).
Transferring, minting, and burning is paused on this mint). After it resumes, the issuer, as permanent delegate,
moves 50 LSF out of an investor’s account without their signature, the control
for carrying out a court order or recovering lost tokens.
Next, you read the code that creates this asset.