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?