Logo

dev-resources.site

for different kinds of informations.

Easy Solana Token Airdrops: A TypeScript Guide

Published at
8/10/2024
Categories
typescript
solana
airdrop
web3
Author
sumana10
Categories
4 categories in total
typescript
open
solana
open
airdrop
open
web3
open
Author
8 person written this
sumana10
open
Easy Solana Token Airdrops: A TypeScript Guide

Introduction:

This TypeScript tutorial simplifies Solana token distribution. Learn to effortlessly airdrop Solana tokens programmatically, making token distribution on the Solana blockchain a breeze.

Starting a Test Validator

solana-test-validator
Enter fullscreen mode Exit fullscreen mode

Step 1: Setting Up Your TypeScript Project
Initialize a TypeScript project:

npm init -y
npm install --save-dev typescript
npx tsc --init
Enter fullscreen mode Exit fullscreen mode

Step 2: Installing Solana Web3.js Library
Install the library:

npm install --save @solana/web3.js
Enter fullscreen mode Exit fullscreen mode

Step 3: Crafting the Airdrop Functionality
Create index.ts:

import { PublicKey, Connection, LAMPORTS_PER_SOL } from "@solana/web3.js";

export const airdrop = async (address: PublicKey | string, amount: number) => {
    const publicKey = new PublicKey(address);
    const connection = new Connection("http://127.0.0.1:8899", "confirmed");
    const signature = await connection.requestAirdrop(publicKey, amount * LAMPORTS_PER_SOL);
    await connection.confirmTransaction(signature);
}

airdrop("<public key>", 1);
Enter fullscreen mode Exit fullscreen mode

Step 4: Building and Executing Your Project
Build:

npm run build
Enter fullscreen mode Exit fullscreen mode

Run:

node dist/index.js
Enter fullscreen mode Exit fullscreen mode

Conclusion:
You've learned to airdrop Solana tokens programmatically👩🏼‍💻! Explore further and leverage Solana's capabilities for innovative blockchain applications.

airdrop Article's
30 articles in total
Favicon
Monthly Airdrops Alert
Favicon
In-Depth Analysis of the Mint Roadmap: Paving the Way for a New Chapter
Favicon
Mint 101: Exploring the Three Core User Groups and Ways to Claim the $MINT Airdrop
Favicon
GAEA Achieves Major Milestones: Completion of Seed Round and 200,000+ Registered Users
Favicon
Reddio Semi-Retrodrop and Earn Staking Points
Favicon
Join Reddio Semi-Retrodrop and Earn Staking Points
Favicon
Discover CriptoAddicts' Telegram Bot: Earn Free Crypto with No Investment!
Favicon
🌟 How to Claim Free Blum Points: Your Ultimate Guide! 🌟
Favicon
Mint Expedition Season 3 Kicks Off: Time to Reach the Mountain Peak
Favicon
$ETHFI Airdrop Update — Ether.Fi Official (Sep 28, 2024)
Favicon
The Airdrop is live
Favicon
Airdrop Farming for New Projects: Tips and Tools
Favicon
Turn Your Internet into Passive Income with Grass
Favicon
Easy Solana Token Airdrops: A TypeScript Guide
Favicon
How to Airdrop SOL Using Solana CLI: Step-by-Step Guide
Favicon
Power Up Your Earnings with These Telegram Projects
Favicon
LayerZero (ZRO) Airdrop Claim Promo by GetBlock: Private RPCs for Degens
Favicon
GetBlock Offers Custom zkSync Nodes for Airdrop Management
Favicon
Blast Airdrop: Claim Tokens Faster with GetBlock RPC Nodes
Favicon
Бесплатная раздача токенов DICK и TON
Favicon
Cash Gift $750
Favicon
Is Ponce Ton more promising than Pepecoin?
Favicon
PulseChain Airdrop is live
Favicon
MantaNetwork Airdrop
Favicon
Top Airdrops and Crypto Activities November List
Favicon
🤑SupraOracles Airdrop: Earn Up to $500k SUPRA Tokens | Join Now!
Favicon
Gold Tether AIRDROP
Favicon
Apa itu airdrop crypto?
Favicon
Upcomings DAO #Whitelist and #Airdrop Live
Favicon
Automating and airdrop on xrpl

Featured ones: