Added credentials and mint tokens
This commit is contained in:
@@ -1,19 +1,28 @@
|
||||
import { Keypair, Connection, Commitment } from "@solana/web3.js";
|
||||
import { createMint } from '@solana/spl-token';
|
||||
import wallet from "../turbin3-wallet.json"
|
||||
import wallet from "/home/sortedcord/.config/solana/id.json";
|
||||
|
||||
// Import our keypair from the wallet file
|
||||
const keypair = Keypair.fromSecretKey(new Uint8Array(wallet));
|
||||
|
||||
//Create a Solana devnet connection
|
||||
const commitment: Commitment = "confirmed";
|
||||
const connection = new Connection("https://api.devnet.solana.com", commitment);
|
||||
const connection = new Connection("https://api.devnet.solana.com", commitment); // describes when a txn is to be done
|
||||
// avoid processed
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
// Start here
|
||||
// const mint = ???
|
||||
} catch(error) {
|
||||
const mint = await createMint(
|
||||
connection,
|
||||
keypair,
|
||||
keypair.publicKey,
|
||||
null,
|
||||
6
|
||||
);
|
||||
console.log(`successfully created a mint ${mint}`);
|
||||
|
||||
|
||||
} catch (error) {
|
||||
console.log(`Oops, something went wrong: ${error}`)
|
||||
}
|
||||
})()
|
||||
})();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Keypair, PublicKey, Connection, Commitment } from "@solana/web3.js";
|
||||
import { getOrCreateAssociatedTokenAccount, mintTo } from '@solana/spl-token';
|
||||
import wallet from "../turbin3-wallet.json"
|
||||
import wallet from "/home/sortedcord/.config/solana/id.json";
|
||||
|
||||
// Import our keypair from the wallet file
|
||||
const keypair = Keypair.fromSecretKey(new Uint8Array(wallet));
|
||||
@@ -9,21 +9,21 @@ const keypair = Keypair.fromSecretKey(new Uint8Array(wallet));
|
||||
const commitment: Commitment = "confirmed";
|
||||
const connection = new Connection("https://api.devnet.solana.com", commitment);
|
||||
|
||||
const token_decimals = 1_000_000n;
|
||||
const token_decimals = 500_000n;
|
||||
|
||||
// Mint address
|
||||
const mint = new PublicKey("<mint address>");
|
||||
const mint = new PublicKey("6cEVBKWwj1haj1gafHypmgxEKu5iKnML5QWck75Tcswk");
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
// Create an ATA
|
||||
// const ata = ???
|
||||
// console.log(`Your ata is: ${ata.address.toBase58()}`);
|
||||
const ata = await getOrCreateAssociatedTokenAccount(connection, keypair, mint, keypair.publicKey)
|
||||
console.log(`Your ata is: ${ata.address.toBase58()}`);
|
||||
|
||||
// Mint to ATA
|
||||
// const mintTx = ???
|
||||
// console.log(`Your mint txid: ${mintTx}`);
|
||||
} catch(error) {
|
||||
const mintTx = await mintTo(connection, keypair, mint, ata.address, keypair.publicKey, 67)
|
||||
console.log(`Your mint txid: ${mintTx}`);
|
||||
} catch (error) {
|
||||
console.log(`Oops, something went wrong: ${error}`)
|
||||
}
|
||||
})()
|
||||
|
||||
Reference in New Issue
Block a user