Skip to content

Commit

Permalink
fixed issue #497 - Code Snippet doesn't assign this object (#519)
Browse files Browse the repository at this point in the history
  • Loading branch information
tranminhquanq authored Apr 22, 2023
1 parent 01d4fc4 commit b2cc9f5
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const web3 = require("@solana/web3.js");
const { Token } = require("@solana/spl-token");
const splToken = require("@solana/spl-token");

(async () => {
// Connect to cluster
Expand All @@ -9,8 +9,8 @@ const { Token } = require("@solana/spl-token");
);

// Generate a new wallet keypair and airdrop SOL
var fromWallet = web3.Keypair.generate();
var fromAirdropSignature = await connection.requestAirdrop(
const fromWallet = web3.Keypair.generate();
const fromAirdropSignature = await connection.requestAirdrop(
fromWallet.publicKey,
web3.LAMPORTS_PER_SOL
);
Expand All @@ -21,7 +21,7 @@ const { Token } = require("@solana/spl-token");
const toWallet = web3.Keypair.generate();

// Create new token mint
const mint = await Token.createMint(
const mint = await splToken.createMint(
connection,
fromWallet,
fromWallet.publicKey,
Expand All @@ -45,12 +45,12 @@ const { Token } = require("@solana/spl-token");
fromTokenAccount.address,
fromWallet.publicKey,
[],
1000000000
1000000000 // it's 1 token, but in lamports
);

// Add token transfer instructions to transaction
const transaction = new web3.Transaction().add(
splToken.Token.createTransferInstruction(
splToken.createTransferInstruction(
splToken.TOKEN_PROGRAM_ID,
fromTokenAccount.address,
toTokenAccount.address,
Expand Down

1 comment on commit b2cc9f5

@vercel
Copy link

@vercel vercel bot commented on b2cc9f5 Apr 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.