Skip to content

Commit

Permalink
fix and improve close-mint course (solana-foundation#536)
Browse files Browse the repository at this point in the history
* Update the Token Extensions Program link

* sync token-program.md from main

* change "mint" to "token mint account".
add a typescript code example for using an account on devnet while calling "initializeKeypair" in the section [2. Run validator node]
add a typescript code example for importing our new function in the section [3. Create a mint with close authority]
change "const mintInfo" to "let mintInfo" because "mintInfo" is used again in the "CLOSE MINT" code part.

---------

Co-authored-by: Jeff Wood <[email protected]>
  • Loading branch information
2 people authored and adpthegreat committed Oct 23, 2024
1 parent b4344da commit fb7fc6b
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions content/courses/token-extensions/close-mint.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,10 @@ await setAuthority(

## Lab

In this lab, we'll create a mint with the `close mint` extension. We will then
mint some of the tokens and see what happens when we try to close it with a
non-zero supply (hint, the close transaction will fail). Lastly, we will burn
the supply and close the account.
In this lab, we'll create a token mint account with the `close mint` extension.
We will then mint some of the tokens and see what happens when we try to close
it with a non-zero supply (hint, the close transaction will fail). Lastly, we
will burn the supply and close the account.

### 1. Getting Started

Expand Down Expand Up @@ -304,6 +304,14 @@ running `solana config get` in your terminal. And then go to
address. You can get your address from running `solana address` in your
terminal.

For example, assuming `keypairPath` is `/home/.config/solana/id.json`

```typescript
const payer = initializeKeypair(connection, {
keypairPath: "/home/.config/solana/id.json",
});
```

### 3. Create a mint with close authority

Let's create a closable mint by creating the function `createClosableMint` in a
Expand Down Expand Up @@ -399,7 +407,13 @@ export async function createClosableMint(
```

Now let's call this function in `src/index.ts`. First you'll need to import our
new function. Then paste the following under the right comment section:
new function by uncommenting the 3rd line.

```ts
import { createClosableMint } from "./create-mint";
```

Then paste the following under the right comment section:

```ts
// CREATE A MINT WITH CLOSE AUTHORITY
Expand Down Expand Up @@ -470,7 +484,7 @@ Underneath the minting functions, add the following code block:
/**
* Get mint information to verify supply
*/
const mintInfo = await getMint(
let mintInfo = await getMint(
connection,
mintKeypair.publicKey,
"finalized",
Expand Down Expand Up @@ -591,7 +605,7 @@ Putting this all together we get:

```ts
// CLOSE MINT
const mintInfo = await getMint(
mintInfo = await getMint(
connection,
mintKeypair.publicKey,
"finalized",
Expand Down

0 comments on commit fb7fc6b

Please sign in to comment.