Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,24 @@ module.exports = {
env: {
browser: true,
amd: true,
node: true, // Add this line to specify the Node.js environment
node: true,
},
parser: '@typescript-eslint/parser', // Specify the TypeScript parser
parserOptions: {
ecmaVersion: 6,
sourceType: 'module', // Ensure this is set for ECMAScript modules
},
extends: 'eslint:recommended',
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
],
plugins: [
'@typescript-eslint', // Include the TypeScript plugin
],
rules: {
'no-console': 'off',
'@typescript-eslint/no-var-requires': 'off',
indent: ['error', 'tab'],
'linebreak-style': ['error', 'windows'],
quotes: ['error', 'single'],
Expand Down
88 changes: 44 additions & 44 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
]
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^7.3.1",
"@typescript-eslint/parser": "^7.3.1",
"@typescript-eslint/eslint-plugin": "^7.4.0",
"@typescript-eslint/parser": "^7.4.0",
"eslint": "^8.57.0",
"husky": "^8.0.3",
"lint-staged": "^15.2.2",
Expand All @@ -39,4 +39,4 @@
"tsconfig-paths": "^4.1.2",
"typescript": "^4.8.4"
}
}
}
7 changes: 7 additions & 0 deletions scripts/account.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { PublicKey } from '@solana/web3.js';
import { getAdminAccount } from '../lib/helpers';
require('dotenv').config();

const adminAccountPrivKey = process.env.ADMIN_PRIV_KEY;
const adminAccount = getAdminAccount(adminAccountPrivKey);
console.log(`Admin public key: ${new PublicKey(adminAccount.publicKey)}`);
142 changes: 74 additions & 68 deletions scripts/transferTokens.ts
Original file line number Diff line number Diff line change
@@ -1,68 +1,74 @@
//** NOTE: THIS SCRIPT HELPS TO TRANSFER SOLANA SPL TOKEN FROM ONE ACCOUNT TO ANOTHER */

const { Connection, PublicKey, Keypair } = require('@solana/web3.js');
const { getOrCreateAssociatedTokenAccount, transfer } = require('@solana/spl-token');
import {connection} from '../lib/vars';
import { getAdminAccount,loadPublicKeysFromFile } from '../lib/helpers';



// load the stored PublicKeys for ease of use
let localKeys = loadPublicKeysFromFile();

// ensure the desired script was already run
if (!localKeys?.tokenMint)
console.warn("No local keys were found. Please run '3.createTokenWithMetadata.ts'");


// Replace these with your actual values
const DESTINATION_WALLET = '4tEfs9QjdCiZBEuZfSbshnYQZzenDpYP4GzrSiKHjiqJ';
const MINT_ADDRESS = new PublicKey(localKeys.tokenMint); // Replace with your token's mint address
const TRANSFER_AMOUNT = 26666666.64; // Amount of tokens to transfer

// Initialize connection


// Sender's wallet keypair
const adminAccountPrivKey = process.env.ADMIN_PRIV_KEY;
const adminAccount =getAdminAccount(adminAccountPrivKey);


// Receiver's public key
const receiverPubkey = new PublicKey(DESTINATION_WALLET);

// Mint address
const mintAddress = new PublicKey(MINT_ADDRESS);

(async () => {
try {
// Get or create associated token accounts for sender and receiver
const senderTokenAccount = await getOrCreateAssociatedTokenAccount(
connection,
adminAccount,
mintAddress,
adminAccount.publicKey
);

const receiverTokenAccount = await getOrCreateAssociatedTokenAccount(
connection,
adminAccount,
mintAddress,
receiverPubkey
);

// Transfer tokens
const transferSignature = await transfer(
connection,
adminAccount,
senderTokenAccount.address,
receiverTokenAccount.address,
adminAccount.publicKey,
TRANSFER_AMOUNT * 1000000 // Adjust for token decimals
);

console.log(`Transfer successful. Signature: ${transferSignature}`);
} catch (error) {
console.error("Error transferring tokens:", error);
}
})();
//** NOTE: THIS SCRIPT HELPS TO TRANSFER SOLANA SPL TOKEN FROM ONE ACCOUNT TO ANOTHER */

const { PublicKey } = require('@solana/web3.js');
const {
getOrCreateAssociatedTokenAccount,
transfer,
} = require('@solana/spl-token');
import { connection } from '../lib/vars';
import {
getAdminAccount,
loadPublicKeysFromFile,
explorerURL,
} from '../lib/helpers';

// load the stored PublicKeys for ease of use
const localKeys = loadPublicKeysFromFile();

// ensure the desired script was already run
if (!localKeys?.tokenMint)
console.warn(
'No local keys were found. Please run \'3.createTokenWithMetadata.ts\'',
);

// Replace these with your actual values
const DESTINATION_WALLET = '4tEfs9QjdCiZBEuZfSbshnYQZzenDpYP4GzrSiKHjiqJ';
const MINT_ADDRESS = new PublicKey(localKeys.tokenMint); // Replace with your token's mint address
const TRANSFER_AMOUNT = 26666666640; // Amount of tokens to transfer

// Initialize connection

// Sender's wallet keypair
const adminAccountPrivKey = process.env.ADMIN_PRIV_KEY;
const adminAccount = getAdminAccount(adminAccountPrivKey);

// Receiver's public key
const receiverPubkey = new PublicKey(DESTINATION_WALLET);

// Mint address
const mintAddress = new PublicKey(MINT_ADDRESS);

(async () => {
try {
// Get or create associated token accounts for sender and receiver
const senderTokenAccount = await getOrCreateAssociatedTokenAccount(
connection,
adminAccount,
mintAddress,
adminAccount.publicKey,
);

const receiverTokenAccount = await getOrCreateAssociatedTokenAccount(
connection,
adminAccount,
mintAddress,
receiverPubkey,
);

// Transfer tokens
const transferSignature = await transfer(
connection,
adminAccount,
senderTokenAccount.address,
receiverTokenAccount.address,
adminAccount.publicKey,
TRANSFER_AMOUNT, // Adjust for token decimals
);

console.log(
`Transfer successful. Signature: ${explorerURL({ txSignature: transferSignature })}`,
);
} catch (error) {
console.error('Error transferring tokens:', error);
}
})();