Skip to content

Conversation

inspi-writer001
Copy link

Problem

Missing gillsdk examples

Summary of Changes

  • how to send sol with gill
  • calculate transaction cost
  • add memo to tx

example on sending SOL

import {
  createSolanaClient,
  createTransaction,
  getExplorerLink,
  lamports,
  LAMPORTS_PER_SOL,
} from "gill";
import {
  generateExtractableKeyPairSigner,
  generateKeyPair,
  generateKeyPairSigner,
} from "gill";
import { getTransferSolInstruction } from "gill/programs";

const { rpc, rpcSubscriptions, sendAndConfirmTransaction } = createSolanaClient(
  {
    urlOrMoniker: "devnet",
  }
);

const fromKeyPair = await generateExtractableKeyPairSigner(); // this has a .address which we're looking for
const fromKeyPair1 = await generateKeyPair(); // this gives you a .privatekey, .publickey - not a .address
const fromKeyPair2 = await generateKeyPairSigner(); // this has a .address

// console.log("extractable keypair signer: ", fromKeyPair);
// console.log("====================================================");
// console.log("keypair: ", fromKeyPair1);
// console.log("====================================================");
// console.log("keypair signer: ", fromKeyPair2);

let lamportsToAirdrop = BigInt(LAMPORTS_PER_SOL * 1.5);
let lamportsToSend = BigInt(LAMPORTS_PER_SOL * 0.5);

const airdropSignature = await rpc
  .requestAirdrop(
    fromKeyPair.address /* .address */,
    lamports(lamportsToAirdrop) // lamports() function helps assert that the input is a valid bigint and returs a Lamport type
  )
  .send();

console.log(
  "Explorer airdrop:",
  getExplorerLink({
    cluster: "http://localhost:8899",
    transaction: airdropSignature,
  })
);

let latestBlockhash = await rpc.getLatestBlockhash().send();

let transferInstruction = getTransferSolInstruction({
  amount: lamportsToSend,
  destination: fromKeyPair2.address,
  source: fromKeyPair,
});

let transferTransaction = createTransaction({
  feePayer: fromKeyPair,
  instructions: [transferInstruction],
  latestBlockhash: latestBlockhash.value,
  version: "legacy",
});

const transfer = await sendAndConfirmTransaction(transferTransaction);

console.log(
  "Explorer transfer:",
  getExplorerLink({
    cluster: "devnet",
    transaction: transfer,
  })
);

Copy link

vercel bot commented Sep 16, 2025

@inspi-writer001 is attempting to deploy a commit to the Solana Foundation Team on Vercel.

A member of the Team first needs to authorize it.

@inspi-writer001 inspi-writer001 marked this pull request as draft September 16, 2025 21:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant