-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7498287
commit 2658159
Showing
1 changed file
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { | ||
address, | ||
lamports, | ||
airdropFactory, | ||
createSolanaClient, | ||
SolanaClusterMoniker, | ||
} from "gill"; | ||
|
||
/** | ||
* Load a keypair signer from the local filesystem | ||
* | ||
* This defaults to the file path used by the Solana CLI: `~/.config/solana/id.json` | ||
*/ | ||
const wallet = address("nick6zJc6HpW3kfBm4xS2dmbuVRyb5F3AnUvj5ymzR5"); | ||
console.log("wallet:", wallet); | ||
|
||
/** | ||
* Declare what Solana network cluster we want our code to interact with | ||
*/ | ||
const cluster: SolanaClusterMoniker = "devnet"; | ||
|
||
/** | ||
* Create a client connection to the Solana blockchain | ||
* | ||
* Note: `urlOrMoniker` can be either a Solana network moniker or a full URL of your RPC provider | ||
*/ | ||
const { rpc, rpcSubscriptions } = createSolanaClient({ | ||
urlOrMoniker: cluster, | ||
}); | ||
|
||
/** | ||
* Get the current lamport balance of the `wallet` | ||
*/ | ||
const { value: initialBalance } = await rpc.getBalance(wallet).send(); | ||
console.log("Initial balance:", initialBalance); | ||
|
||
/** | ||
* Request an airdrop of testing tokens to the `wallet` address | ||
* | ||
* Note: devnet and testnet are subject to rate limits. | ||
* it is strongly recommended to use `localnet` and the local test validator | ||
*/ | ||
await airdropFactory({ rpc, rpcSubscriptions })({ | ||
commitment: "confirmed", | ||
lamports: lamports(100n), | ||
recipientAddress: wallet, | ||
}); | ||
|
||
/** | ||
* Get the current new lamport balance of the `wallet` | ||
*/ | ||
const { value: newBalance } = await rpc.getBalance(wallet).send(); | ||
console.log("New balance:", newBalance); |