1

I am looking at developing a dapp that rewards holders based on the length they keep their associated token account frozen for.

I have tried the below code in my nextjs/react app, however I can only get it to work when authority and the wallet connected matches the token update authority address.

const { sendTransaction } = useWallet();
const { connection } = useConnection();

const transaction = new Transaction().add(
    createFreezeAccountInstruction(
        account,
        mint,
        authority
    ),
);

await sendTransaction(transaction, connection).then(async (signature) => {
    console.log("signature", signature);
});

Is it possible for a token account owner to freeze their own account and if so what is the best approach to doing so with a dapp environment?

1
  • Do you want to freeze a token you do not own? If so you'll have to delegate authority first. Also, would you post the error logs
    – Jimii
    Commented Jun 8 at 6:23

1 Answer 1

0

There's no way to do this through the normal operation of SPL Token. The freeze authority is the only one that can freeze or thaw accounts normally.

To make this work, you can write your own on-chain program, and then give the freeze authority to a PDA of this program. The program can manage freeze and thaw requests from users, and store whatever additional information needed, ie. how long the token has been frozen

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.