New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

gill

Package Overview
Dependencies
Maintainers
0
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gill - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

dist/chunk-2MNSKGHB.node.mjs

2

dist/core/explorer.d.ts

@@ -5,3 +5,3 @@ import { GetExplorerLinkArgs } from "../types";

*/
export declare function getExplorerLink(props: GetExplorerLinkArgs): URL;
export declare function getExplorerLink(props: GetExplorerLinkArgs): string;
//# sourceMappingURL=explorer.d.ts.map

@@ -0,1 +1,2 @@

export { debug, isDebugEnabled } from "./debug";
export * from "./const";

@@ -5,3 +6,6 @@ export * from "./rpc";

export * from "./transactions";
export * from "./base64-transactions";
export * from "./prepare-transaction";
export * from "./create-solana-client";
export * from "./accounts";
//# sourceMappingURL=index.d.ts.map

@@ -1,2 +0,3 @@

import { CreateSolanaClientArgs, CreateSolanaClientResult, SolanaClusterMoniker } from "../types/rpc";
import { LocalnetUrl, ModifiedClusterUrl, SolanaClusterMoniker } from "../types/rpc";
export declare function localnet(putativeString: string): LocalnetUrl;
/**

@@ -7,7 +8,3 @@ * Get a public Solana RPC endpoint for a cluster based on its moniker

*/
export declare function getPublicSolanaRpcUrl(cluster: SolanaClusterMoniker): string;
/**
* Create a Solana `rpc` and `rpcSubscriptions` client
*/
export declare function createSolanaClient({ urlOrMoniker, rpcConfig, rpcSubscriptionsConfig, }: CreateSolanaClientArgs): CreateSolanaClientResult;
export declare function getPublicSolanaRpcUrl(cluster: SolanaClusterMoniker | "mainnet-beta"): ModifiedClusterUrl;
//# sourceMappingURL=rpc.d.ts.map

@@ -1,12 +0,13 @@

import type { CreateTransactionInput } from "../types/transactions";
import { Simplify } from "../types";
import { ITransactionMessageWithFeePayer, TransactionMessageWithBlockhashLifetime, TransactionVersion } from "@solana/transaction-messages";
import { ITransactionMessageWithFeePayerSigner, TransactionSigner } from "@solana/signers";
import type { FullTransaction, CreateTransactionInput } from "../types/transactions";
import { Address } from "@solana/addresses";
/**
* Simple interface for creating a Solana transaction
*/
export declare function createTransaction({ version, feePayer, instructions, latestBlockhash, }: CreateTransactionInput): import("@solana/transaction-messages").ITransactionMessageWithFeePayer<string> & Omit<Readonly<{
instructions: readonly import("@solana/instructions").IInstruction<string, readonly import("@solana/instructions").IAccountMeta<string>[]>[];
version: "legacy";
}> | Readonly<{
instructions: readonly import("@solana/instructions").IInstruction<string, readonly (import("@solana/instructions").IAccountLookupMeta<string, string> | import("@solana/instructions").IAccountMeta<string>)[]>[];
version: 0;
}>, "feePayer">;
export declare function createTransaction<TVersion extends TransactionVersion, TFeePayer extends TransactionSigner>(props: CreateTransactionInput<TVersion, TFeePayer>): FullTransaction<TVersion, ITransactionMessageWithFeePayerSigner>;
export declare function createTransaction<TVersion extends TransactionVersion, TFeePayer extends Address>(props: CreateTransactionInput<TVersion, TFeePayer>): FullTransaction<TVersion, ITransactionMessageWithFeePayer>;
export declare function createTransaction<TVersion extends TransactionVersion, TFeePayer extends Address, TLifetimeConstraint extends TransactionMessageWithBlockhashLifetime["lifetimeConstraint"]>(props: CreateTransactionInput<TVersion, TFeePayer, TLifetimeConstraint>): Simplify<FullTransaction<TVersion, ITransactionMessageWithFeePayer, TransactionMessageWithBlockhashLifetime>>;
export declare function createTransaction<TVersion extends TransactionVersion, TFeePayer extends TransactionSigner, TLifetimeConstraint extends TransactionMessageWithBlockhashLifetime["lifetimeConstraint"]>(props: CreateTransactionInput<TVersion, TFeePayer, TLifetimeConstraint>): Simplify<FullTransaction<TVersion, ITransactionMessageWithFeePayerSigner, TransactionMessageWithBlockhashLifetime>>;
//# sourceMappingURL=transactions.d.ts.map

@@ -18,4 +18,5 @@ export * from "@solana/accounts";

export { createRpcMessage } from "@solana/rpc-spec-types";
export * from "./kit";
export * from "./types";
export * from "./core";
//# sourceMappingURL=index.d.ts.map

@@ -1,2 +0,2 @@

import type { SolanaUrlOrMoniker } from "./rpc";
import { SolanaClusterMoniker } from "./rpc";
type ExplorerLinkAccount = {

@@ -12,8 +12,8 @@ address: string;

/**
* @param cluster - Default: `mainnet-beta`
* @param cluster - Default: `mainnet`
*/
export type GetExplorerLinkArgs = {
cluster?: SolanaUrlOrMoniker;
cluster?: SolanaClusterMoniker | "mainnet-beta";
} & (ExplorerLinkAccount | ExplorerLinkTransaction | ExplorerLinkBlock);
export {};
//# sourceMappingURL=explorer.d.ts.map
export * from "./rpc";
export * from "./explorer";
export type Prettify<T> = {
export * from "./transactions";
export type Simplify<T> = {
[K in keyof T]: T[K];
} & {};
//# sourceMappingURL=index.d.ts.map

@@ -1,12 +0,15 @@

import type { createSolanaRpc } from "@solana/rpc";
import type { createSolanaRpcSubscriptions } from "@solana/rpc-subscriptions";
import type { createSolanaRpc, RpcTransportFromClusterUrl, SolanaRpcApiFromTransport, RpcFromTransport } from "@solana/rpc";
import type { createSolanaRpcSubscriptions, RpcSubscriptions, SolanaRpcSubscriptionsApi } from "@solana/rpc-subscriptions";
import type { DevnetUrl, MainnetUrl, TestnetUrl } from "@solana/rpc-types";
import type { SendAndConfirmTransactionWithBlockhashLifetimeFunction } from "../kit";
/** Solana cluster moniker */
export type SolanaClusterMoniker = "mainnet-beta" | "devnet" | "testnet" | "localnet";
type GenericUrl = string & {};
export type ModifiedClusterUrl = DevnetUrl | MainnetUrl | TestnetUrl | GenericUrl;
export type SolanaUrlOrMoniker = SolanaClusterMoniker | ModifiedClusterUrl;
export type CreateSolanaClientArgs = {
export type SolanaClusterMoniker = "mainnet" | "devnet" | "testnet" | "localnet";
export type LocalnetUrl = string & {
"~cluster": "localnet";
};
export type GenericUrl = string & {};
export type ModifiedClusterUrl = MainnetUrl | DevnetUrl | TestnetUrl | LocalnetUrl | GenericUrl;
export type CreateSolanaClientArgs<TClusterUrl extends ModifiedClusterUrl | SolanaClusterMoniker = GenericUrl> = {
/** Full RPC URL (for a private RPC endpoint) or the Solana moniker (for a public RPC endpoint) */
urlOrMoniker: URL | SolanaUrlOrMoniker;
urlOrMoniker: SolanaClusterMoniker | TClusterUrl | URL | ModifiedClusterUrl;
/** Configuration used to create the `rpc` client */

@@ -17,9 +20,14 @@ rpcConfig?: Parameters<typeof createSolanaRpc>[1];

};
export type CreateSolanaClientResult = {
/** Newly created Solana RPC client */
rpc: ReturnType<typeof createSolanaRpc>;
/** Newly created Solana RPC subscriptions client */
rpcSubscriptions: ReturnType<typeof createSolanaRpcSubscriptions>;
export type CreateSolanaClientResult<TClusterUrl extends ModifiedClusterUrl | string = string> = {
/** Used to make RPC calls to your RPC provider */
rpc: RpcFromTransport<SolanaRpcApiFromTransport<RpcTransportFromClusterUrl<TClusterUrl>>, RpcTransportFromClusterUrl<TClusterUrl>>;
/** Used to make RPC websocket calls to your RPC provider */
rpcSubscriptions: RpcSubscriptions<SolanaRpcSubscriptionsApi> & TClusterUrl;
/**
* Send and confirm a transaction to the network
*
* Default commitment level: `confirmed`
*/
sendAndConfirmTransaction: SendAndConfirmTransactionWithBlockhashLifetimeFunction;
};
export {};
//# sourceMappingURL=rpc.d.ts.map
import { Address } from "@solana/addresses";
import { IInstruction } from "@solana/instructions";
import { Blockhash } from "@solana/rpc-types";
import { TransactionSigner } from "@solana/signers";
import { TransactionVersion } from "@solana/transaction-messages";
export type CreateTransactionInput = {
import { ITransactionMessageWithFeePayerSigner, TransactionSigner } from "@solana/signers";
import { BaseTransactionMessage, ITransactionMessageWithFeePayer, TransactionMessageWithBlockhashLifetime, TransactionVersion } from "@solana/transaction-messages";
import { Simplify } from ".";
export type CreateTransactionInput<TVersion extends TransactionVersion, TFeePayer extends Address | TransactionSigner, TLifetimeConstraint extends TransactionMessageWithBlockhashLifetime["lifetimeConstraint"] | undefined = undefined> = {
/**

@@ -12,7 +12,7 @@ * Transaction version

* */
version: TransactionVersion;
version: TVersion;
/** List of instructions for this transaction */
instructions: IInstruction[];
/** Address or Signer that will pay transaction fees */
feePayer: Address | TransactionSigner;
feePayer: TFeePayer;
/**

@@ -22,7 +22,9 @@ * Latest blockhash (aka transaction lifetime) for this transaction to

* */
latestBlockhash?: Readonly<{
blockhash: Blockhash;
lastValidBlockHeight: bigint;
}>;
latestBlockhash?: TLifetimeConstraint;
/** Compute unit limit value to set on this transaction */
computeUnitLimit?: number | bigint;
/** Compute unit price (in micro-lamports) to set on this transaction */
computeUnitPrice?: number | bigint;
};
export type FullTransaction<TVersion extends TransactionVersion, TFeePayer extends ITransactionMessageWithFeePayer | ITransactionMessageWithFeePayerSigner, TBlockhashLifetime extends TransactionMessageWithBlockhashLifetime | undefined = undefined> = Simplify<BaseTransactionMessage<TVersion> & TFeePayer & (TBlockhashLifetime extends TransactionMessageWithBlockhashLifetime ? TransactionMessageWithBlockhashLifetime : {})>;
//# sourceMappingURL=transactions.d.ts.map
{
"name": "gill",
"version": "0.1.0",
"version": "0.2.0",
"description": "",
"exports": {
"./types": "./dist/index.d.ts",
".": {

@@ -27,2 +26,3 @@ "types": "./dist/index.d.ts",

},
"./react-native": "./dist/index.native.mjs",
"./node": {

@@ -33,3 +33,18 @@ "types": "./dist/node/index.d.ts",

},
"./react-native": "./dist/index.native.mjs"
"./programs": {
"types": "./dist/programs/index.d.ts",
"import": "./dist/programs/index.node.mjs",
"require": "./dist/programs/index.node.cjs"
},
"./programs/token": {
"types": "./dist/programs/token.d.ts",
"import": "./dist/programs/token.node.mjs",
"require": "./dist/programs/token.node.cjs"
},
"./programs/token22": {
"types": "./dist/programs/token22.d.ts",
"import": "./dist/programs/token22.node.mjs",
"require": "./dist/programs/token22.node.cjs"
},
"./types": "./dist/index.d.ts"
},

@@ -55,5 +70,5 @@ "browser": {

"author": "Solana Foundation DevRel <devrel@solana.org>",
"homepage": "https://github.com/nickfrosty/gill#readme",
"homepage": "https://github.com/solana-foundation/gill#readme",
"bugs": {
"url": "https://github.com/nickfrosty/gill/issues"
"url": "https://github.com/solana-foundation/gill/issues"
},

@@ -71,2 +86,7 @@ "browserslist": [

"dependencies": {
"@solana-program/compute-budget": "^0.6.1",
"@solana-program/memo": "^0.6.1",
"@solana-program/system": "^0.6.2",
"@solana-program/token": "^0.4.1",
"@solana-program/token-2022": "^0.3.4",
"@solana/accounts": "^2.0.0",

@@ -86,2 +106,3 @@ "@solana/addresses": "^2.0.0",

"@solana/signers": "^2.0.0",
"@solana/transaction-confirmation": "^2.0.0",
"@solana/transaction-messages": "^2.0.0",

@@ -91,2 +112,3 @@ "@solana/transactions": "^2.0.0"

"scripts": {
"clean": "rimraf dist build node_modules .turbo",
"compile:js": "tsup --config ./tsup.config.package.ts",

@@ -93,0 +115,0 @@ "compile:typedefs": "tsc -p ./tsconfig.declarations.json",

@@ -1,8 +0,30 @@

# gill
<h1 align="center">
gill
</h1>
Welcome to gill, a [Solana web3.js v2](https://github.com/solana-labs/solana-web3.js) compatible
helper library for building Solana apps in Node, web, and React Native.
<p align="center">
javascript/typescript client library for interacting with the Solana blockchain
</p>
## Get started
<p align="center">
<a href="https://github.com/solana-foundation/gill/actions/workflows/publish-packages.yml"><img src="https://img.shields.io/github/actions/workflow/status/solana-foundation/gill/publish-packages.yml?logo=GitHub" /></a>
<a href="https://www.npmjs.com/package/gill"><img src="https://img.shields.io/npm/v/gill?logo=npm&color=377CC0" /></a>
</p>
<p align="center">
<img width="600" alt="gill" src="https://raw.githubusercontent.com/solana-foundation/gill/refs/heads/master/media/cover.png" />
</p>
## Overview
Welcome to `gill`, a JavaScript/TypeScript client library for interacting with the
[Solana](http://solana.com/) blockchain. You can use it to build Solana apps in Node, web, React
Native, or just about any other JavaScript environment.
Gill is built on top of the modern javascript libraries for Solana built by Anza and used in
([@solana/web3.js v2](https://github.com/anza-xyz/solana-web3.js)). By utilizing the same types and
functions under the hood, `gill` is compatible with web3.js.
## Installation
Install `gill` with your package manager of choice:

@@ -25,13 +47,24 @@

- [Create a Solana RPC connection](#create-a-solana-rpc-connection)
- [Making Solana RPC calls](#making-solana-rpc-calls)
- [Create a transaction](#create-a-transaction)
- [Get a Solana Explorer link](#create-a-transaction)
- [Signing transactions](#signing-transactions)
- [Sending and confirming transaction](#sending-and-confirming-transactions)
- [Get a transaction signature](#get-the-signature-from-a-signed-transaction)
- [Get a Solana Explorer link](#get-a-solana-explorer-link-for-transactions-accounts-or-blocks)
- [Calculate minimum rent balance for an account](#calculate-minimum-rent-for-an-account)
You can also find some [Node specific helpers](#node-specific-imports):
You can also find some [NodeJS specific helpers](#node-specific-imports) like:
- [Loading a keypair from a file](#loading-a-keypair-from-a-file)
For troubleshooting and debugging your Solana transactions, see [Debug mode](#debug-mode) below.
> You can also consult the documentation for Anza's
> [JavaScript client](https://github.com/anza-xyz/solana-web3.js) library for more information and
> helpful resources.
### Create a Solana RPC connection
Create a Solana `rpc` and `rpcSubscriptions` client for any RPC URL or standard Solana network
moniker (i.e. `devnet`, `localnet`, etc).
moniker (i.e. `devnet`, `localnet`, `mainnet` etc).

@@ -41,9 +74,10 @@ ```typescript

const { rpc, rpcSubscriptions } = createSolanaClient({
urlOrMoniker: "mainnet-beta",
const { rpc, rpcSubscriptions, sendAndConfirmTransaction } = createSolanaClient({
urlOrMoniker: "mainnet",
});
```
> Using the Solana moniker will connect to the public RPC endpoints. These are subject to heavy rate
> limits and should not be used in production applications.
> Using the Solana moniker will connect to the public RPC endpoints. These are subject to rate
> limits and should not be used in production applications. Applications should find their own RPC
> provider and the URL provided from them.

@@ -55,3 +89,3 @@ To create an RPC client for your local test validator:

const { rpc, rpcSubscriptions } = createSolanaClient({
const { rpc, rpcSubscriptions, sendAndConfirmTransaction } = createSolanaClient({
urlOrMoniker: "localnet",

@@ -61,3 +95,3 @@ });

To create an RPC client for a paid RPC service:
To create an RPC client for an custom RPC provider or service:

@@ -67,3 +101,3 @@ ```typescript

const { rpc, rpcSubscriptions } = createSolanaClient({
const { rpc, rpcSubscriptions, sendAndConfirmTransaction } = createSolanaClient({
urlOrMoniker: "https://private-solana-rpc-provider.com",

@@ -73,2 +107,43 @@ });

### Making Solana RPC calls
After you have a Solana `rpc` connection, you can make all the
[JSON RPC method](https://solana.com/docs/rpc) calls directly off of it.
```typescript
import { createSolanaClient } from "gill";
const { rpc } = createSolanaClient({ urlOrMoniker: "devnet" });
// get slot
const slot = await rpc.getSlot().send();
// get the latest blockhash
const { value: latestBlockhash } = await rpc.getLatestBlockhash().send();
```
> The `rpc` client requires you to call `.send()` on the RPC method in order to actually send the
> request to your RPC provider and get a response.
You can also include custom configuration settings on your RPC calls, like using a JavaScript
[AbortController](https://developer.mozilla.org/en-US/docs/Web/API/AbortController), by passing it
into `send()`:
```typescript
import { createSolanaClient } from "gill";
const { rpc } = createSolanaClient({ urlOrMoniker: "devnet" });
// Create a new AbortController.
const abortController = new AbortController();
// Abort the request when the user navigates away from the current page.
function onUserNavigateAway() {
abortController.abort();
}
// The request will be aborted if and only if the user navigates away from the page.
const slot = await rpc.getSlot().send({ abortSignal: abortController.signal });
```
### Create a transaction

@@ -78,9 +153,14 @@

> Note: The `feePayer` can be either an `Address` or `TransactionSigner`.
```typescript
import { createTransaction } from "gill";
const transactions = createTransaction({
const transaction = createTransaction({
version,
feePayer,
instructions,
// the compute budget values are HIGHLY recommend to be set in order to maximize your transaction landing rate
// computeUnitLimit: number,
// computeUnitPrice: number,
});

@@ -96,3 +176,3 @@ ```

const transactions = createTransaction({
const transaction = createTransaction({
version,

@@ -102,7 +182,106 @@ feePayer,

latestBlockhash,
// the compute budget values are HIGHLY recommend to be set in order to maximize your transaction landing rate
// computeUnitLimit: number,
// computeUnitPrice: number,
});
```
The `feePayer` can be either an `Address` or `TransactionSigner`.
To create a transaction while setting the latest blockhash:
```typescript
import { createTransaction } from "gill";
const { value: latestBlockhash } = await rpc.getLatestBlockhash().send();
const transaction = createTransaction({
version,
feePayer,
instructions,
latestBlockhash,
// the compute budget values are HIGHLY recommend to be set in order to maximize your transaction landing rate
// computeUnitLimit: number,
// computeUnitPrice: number,
});
```
### Signing transactions
If your transaction already has the latest blockhash lifetime set via `createTransaction`:
```typescript
import {
signTransactionMessageWithSigners,
setTransactionMessageLifetimeUsingBlockhash,
} from "gill";
const signedTransaction = await signTransactionMessageWithSigners(transaction);
```
If your transaction does NOT have the latest blockhash lifetime set via `createTransaction`, you
must set the latest blockhash lifetime before (or during) the signing operation:
```typescript
import {
signTransactionMessageWithSigners,
setTransactionMessageLifetimeUsingBlockhash,
} from "gill";
const { value: latestBlockhash } = await rpc.getLatestBlockhash().send();
const signedTransaction = await signTransactionMessageWithSigners(
setTransactionMessageLifetimeUsingBlockhash(latestBlockhash, tx),
);
```
### Sending and confirming transactions
To send and confirm a transaction to the blockchain, you can use the `sendAndConfirmTransaction`
function initialized from `createSolanaClient`.
```typescript
import { createSolanaClient, createTransaction, signTransactionMessageWithSigners } from "gill";
const { rpc, rpcSubscriptions, sendAndConfirmTransaction } = createSolanaClient({
urlOrMoniker: "mainnet",
});
const transaction = createTransaction(...);
const signedTransaction = await signTransactionMessageWithSigners(transaction);
const signature: string = getSignatureFromTransaction(signedTransaction);
// default commitment level of `confirmed`
await sendAndConfirmTransaction(signedTransaction)
```
If you would like more fine grain control over the configuration of the `sendAndConfirmTransaction`
functionality, you can include configuration settings:
```typescript
await sendAndConfirmTransaction(signedTransaction, {
commitment: "confirmed",
skipPreflight: true,
maxRetries: 10n,
...
});
```
### Get the signature from a signed transaction
After you already have a partially or fully signed transaction, you can get the transaction
signature as follows:
```typescript
import { getSignatureFromTransaction } from "gill";
const signature: string = getSignatureFromTransaction(signedTransaction);
console.log(signature);
// Example output: 4nzNU7YxPtPsVzeg16oaZvLz4jMPtbAzavDfEFmemHNv93iYXKKYAaqBJzFCwEVxiULqTYYrbjPwQnA1d9ZCTELg
```
> Note: After a transaction has been signed by at least one Signer, it will have a transaction
> signature (aka transaction id). This is due to Solana transaction ids are the first item in the
> transaction's `signatures` array. Therefore, client applications can know the signature before it
> is even sent to the network for confirmation.
### Get a Solana Explorer link for transactions, accounts, or blocks

@@ -112,8 +291,12 @@

> When no `cluster` is provided, defaults to `mainnet-beta`.
> When no `cluster` is provided in the `getExplorerLink` function, it defaults to `mainnet`.
#### Get a Solana Explorer link for a transaction
To get an explorer link for a transaction's signature (aka transaction id):
```typescript
import { getExplorerLink } from "gill";
const link: URL = getExplorerLink({
const link: string = getExplorerLink({
transaction:

@@ -124,8 +307,26 @@ "4nzNU7YxPtPsVzeg16oaZvLz4jMPtbAzavDfEFmemHNv93iYXKKYAaqBJzFCwEVxiULqTYYrbjPwQnA1d9ZCTELg",

To get an explorer link for an account on devnet:
If you have a partially or fully signed transaction, you can get the Explorer link before even
sending the transaction to the network:
```typescript
import {
getExplorerLink,
getSignatureFromTransaction
signTransactionMessageWithSigners,
} from "gill";
const signedTransaction = await signTransactionMessageWithSigners(...);
const link: string = getExplorerLink({
transaction: getSignatureFromTransaction(signedTransaction),
});
```
#### Get a Solana Explorer link for an account
To get an explorer link for an account on Solana's devnet:
```typescript
import { getExplorerLink } from "gill";
const link: URL = getExplorerLink({
const link: string = getExplorerLink({
cluster: "devnet",

@@ -141,3 +342,3 @@ account: "nick6zJc6HpW3kfBm4xS2dmbuVRyb5F3AnUvj5ymzR5",

const link: URL = getExplorerLink({
const link: string = getExplorerLink({
cluster: "localnet",

@@ -148,2 +349,4 @@ account: "11111111111111111111111111111111",

#### Get a Solana Explorer link for a block
To get an explorer link for a block:

@@ -154,4 +357,4 @@

const link: URL = getExplorerLink({
cluster: "mainnet-beta",
const link: string = getExplorerLink({
cluster: "mainnet",
block: "242233124",

@@ -161,5 +364,32 @@ });

### Calculate minimum rent for an account
To calculate the minimum rent balance for an account (aka data storage deposit fee):
```typescript
import { getMinimumBalanceForRentExemption } from "gill";
// when not `space` argument is provided: defaults to `0`
const rent: bigint = getMinimumBalanceForRentExemption();
// Expected value: 890_880n
// same as
// getMinimumBalanceForRentExemption(0);
```
```typescript
import { getMinimumBalanceForRentExemption } from "gill";
const rent: bigint = getMinimumBalanceForRentExemption(50 /* 50 bytes */);
// Expected value: 1_238_880n
```
> Note: At this time, the minimum rent amount for an account is calculated based on static values in
> the Solana runtime. While you can use the `getMinimumBalanceForRentExemption` RPC call on your
> [connection](#create-a-solana-rpc-connection) to fetch this value, it will result in a network
> call and subject to latency.
## Node specific imports
The `gill` package has specific imports for use in NodeJS server backend and/or serverless
The `gill` package has specific imports for use in NodeJS server backends and/or serverless
environments which have access to Node specific APIs (like the file system via `node:fs`).

@@ -195,1 +425,119 @@

```
## Debug mode
Within `gill`, you can enable "debug mode" to automatically log additional information that will be
helpful in troubleshooting your transactions.
Debug mode is disabled by default to minimize additional logs for your application. But with its
flexible debug controller, you can enable it from the most common places your code will be run.
Including your code itself, NodeJS backends, serverless functions, and even the in web browser
console itself.
Some examples of the existing debug logs that `gill` has sprinkled in:
- log the Solana Explorer link for transactions as you are sending them
- log the base64 transaction string to troubleshoot via
[`mucho inspect`](https://github.com/solana-developers/mucho?tab=readme-ov-file#inspect) or Solana
Explorer's [Transaction Inspector](https://explorer.solana.com/tx/inspector)
### How to enable debug mode
To enable debug mode, set any of the following to `true` or `1`:
- `process.env.GILL_DEBUG`
- `global.__GILL_DEBUG__`
- `window.__GILL_DEBUG__` (i.e. in your web browser's console)
- or manually set any debug log level (see below)
To set a desired level of logs to be output in your application, set the value of one of the
following (default: `info`):
- `process.env.GILL_DEBUG_LEVEL`
- `global.__GILL_DEBUG_LEVEL__`
- `window.__GILL_DEBUG_LEVEL__` (i.e. in your web browser's console)
The log levels supported (in order of priority):
- `debug` (lowest)
- `info` (default)
- `warn`
- `error`
### Custom debug logs
Gill also exports the same debug functions it uses internally, allowing you to implement your own
debug logic related to your Solana transactions and use the same controller for it as `gill` does.
- `isDebugEnabled()` - check if debug mode is enabled or not
- `debug()` - print debug message if the set log level is reached
```typescript
import { debug, isDebugEnabled } from "gill";
if (isDebugEnabled()) {
// your custom logic
}
// log this message if the "info" or above log level is enabled
debug("custom message");
// log this message if the "debug" or above log level is enabled
debug("custom message", "debug");
// log this message if the "warn" or above log level is enabled
debug("custom message", "warn");
// log this message if the "warn" or above log level is enabled
debug("custom message", "warn");
```
## Program clients
With `gill` you can also import some of the most commonly used clients for popular programs. These
are also fully tree-shakable, so if you do not import them inside your project they will be removed
by your JavaScript bundler at build time (i.e. Webpack).
To import any of these program clients:
```typescript
import { ... } from "gill/programs";
import { ... } from "gill/programs/token";
import { ... } from "gill/programs/token22";
```
> Note: Some client re-exported client program clients have a naming collision. As a result, they
> may be re-exported under a subpath of `gill/programs`. For example, `gill/programs/token22` and
> `gill/programs/token`.
The program clients included inside `gill` are:
- [System program](https://github.com/solana-program/system) - re-exported from
`@solana-program/system`
- [Compute Budget program](https://github.com/solana-program/compute-budget) - re-exported from
`@solana-program/compute-budget`
- [Memo program](https://github.com/solana-program/memo) - re-exported from `@solana-program/memo`
- [Token program](https://github.com/solana-program/token) - re-exported from
`@solana-program/token`
- [Token Extension program (aka Token22)](https://github.com/solana-program/token-2022) -
re-exported from `@solana-program/token-2022`
If one of the existing clients are not being exported from `gill/programs` or a subpath therein, you
can of course manually add their compatible client to your repo.
### Other compatible program clients
From the [solana-program](https://github.com/solana-program/token) GitHub organization - formerly
known as the Solana Program Library (SPL)
- [Stake program](https://github.com/solana-program/stake) - re-exported from
`@solana-program/stake`
- [Address Lookup Table program](https://github.com/solana-program/address-lookup-table) -
re-exported from `@solana-program/address-lookup-table`
### Generate a program client from an IDL
If you want to easily interact with any custom program with this library, you can use
[Codama](https://github.com/codama-idl/codama) to generate a compatible JavaScript/TypeScript client
using its IDL. You can either store the generated client inside your repo or publish it as a NPM
package for others to easily consume.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc