Is there any way to close the associated account using JS libs?
Asked
Active
Viewed 1,421 times
0
-
Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Oct 15 '21 at 20:18
1 Answers
0
Absolutely! You can use the normal closeAccount()
function that exists on the Token
object, if you have one: https://github.com/solana-labs/solana-program-library/blob/e8b7009cc4d8cdd87232ccfc9ce93ab203ada496/token/js/client/token.js#L1109
And here's a test example using that function: https://github.com/solana-labs/solana-program-library/blob/e8b7009cc4d8cdd87232ccfc9ce93ab203ada496/token/js/cli/token-test.js#L480
If you don't, then you'll have to roughly copy the implementation of the first link, creating a closeAccount
instruction using createCloseAccountInstruction
and signing it with the owner: https://github.com/solana-labs/solana-program-library/blob/e8b7009cc4d8cdd87232ccfc9ce93ab203ada496/token/js/client/token.js#L1850

Jon C
- 7,019
- 10
- 17