@solana/web3.js 1.74.0 → 2.0.0-experimental.20762e0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/dist/index.browser.cjs +79 -0
  2. package/dist/index.browser.cjs.map +1 -0
  3. package/dist/index.browser.js +70 -0
  4. package/dist/index.browser.js.map +1 -0
  5. package/dist/index.development.js +539 -0
  6. package/dist/index.development.js.map +1 -0
  7. package/dist/index.native.js +68 -0
  8. package/dist/index.native.js.map +1 -0
  9. package/dist/index.node.cjs +79 -0
  10. package/dist/index.node.cjs.map +1 -0
  11. package/dist/index.node.js +70 -0
  12. package/dist/index.node.js.map +1 -0
  13. package/dist/index.production.min.js +13 -0
  14. package/dist/types/index.d.ts +4 -0
  15. package/dist/types/rpc-default-config.d.ts +3 -0
  16. package/dist/types/rpc-integer-overflow-error.d.ts +8 -0
  17. package/dist/types/rpc-transport.d.ts +4 -0
  18. package/dist/types/rpc.d.ts +5 -0
  19. package/package.json +86 -113
  20. package/README.md +0 -155
  21. package/lib/index.browser.cjs.js +0 -9485
  22. package/lib/index.browser.cjs.js.map +0 -1
  23. package/lib/index.browser.esm.js +0 -9379
  24. package/lib/index.browser.esm.js.map +0 -1
  25. package/lib/index.cjs.js +0 -12009
  26. package/lib/index.cjs.js.map +0 -1
  27. package/lib/index.d.ts +0 -3865
  28. package/lib/index.esm.js +0 -11896
  29. package/lib/index.esm.js.map +0 -1
  30. package/lib/index.iife.js +0 -24568
  31. package/lib/index.iife.js.map +0 -1
  32. package/lib/index.iife.min.js +0 -13
  33. package/lib/index.iife.min.js.map +0 -1
  34. package/lib/index.native.js +0 -9485
  35. package/lib/index.native.js.map +0 -1
  36. package/src/__forks__/browser/fetch-impl.ts +0 -4
  37. package/src/__forks__/browser/rpc-websocket-factory.ts +0 -1
  38. package/src/__forks__/react-native/fetch-impl.ts +0 -4
  39. package/src/__forks__/react-native/rpc-websocket-factory.ts +0 -1
  40. package/src/account-data.ts +0 -39
  41. package/src/account.ts +0 -55
  42. package/src/blockhash.ts +0 -4
  43. package/src/bpf-loader-deprecated.ts +0 -5
  44. package/src/bpf-loader.ts +0 -45
  45. package/src/connection.ts +0 -6678
  46. package/src/epoch-schedule.ts +0 -102
  47. package/src/errors.ts +0 -50
  48. package/src/fee-calculator.ts +0 -18
  49. package/src/fetch-impl.ts +0 -13
  50. package/src/index.ts +0 -24
  51. package/src/instruction.ts +0 -58
  52. package/src/keypair.ts +0 -93
  53. package/src/layout.ts +0 -188
  54. package/src/loader.ts +0 -236
  55. package/src/message/account-keys.ts +0 -79
  56. package/src/message/compiled-keys.ts +0 -165
  57. package/src/message/index.ts +0 -47
  58. package/src/message/legacy.ts +0 -326
  59. package/src/message/v0.ts +0 -496
  60. package/src/message/versioned.ts +0 -36
  61. package/src/nonce-account.ts +0 -82
  62. package/src/programs/address-lookup-table/index.ts +0 -435
  63. package/src/programs/address-lookup-table/state.ts +0 -84
  64. package/src/programs/compute-budget.ts +0 -281
  65. package/src/programs/ed25519.ts +0 -157
  66. package/src/programs/index.ts +0 -7
  67. package/src/programs/secp256k1.ts +0 -228
  68. package/src/programs/stake.ts +0 -935
  69. package/src/programs/system.ts +0 -1048
  70. package/src/programs/vote.ts +0 -541
  71. package/src/publickey.ts +0 -259
  72. package/src/rpc-websocket-factory.ts +0 -4
  73. package/src/rpc-websocket.ts +0 -79
  74. package/src/sysvar.ts +0 -37
  75. package/src/timing.ts +0 -23
  76. package/src/transaction/constants.ts +0 -12
  77. package/src/transaction/expiry-custom-errors.ts +0 -48
  78. package/src/transaction/index.ts +0 -5
  79. package/src/transaction/legacy.ts +0 -908
  80. package/src/transaction/message.ts +0 -140
  81. package/src/transaction/versioned.ts +0 -126
  82. package/src/utils/assert.ts +0 -8
  83. package/src/utils/bigint.ts +0 -43
  84. package/src/utils/borsh-schema.ts +0 -38
  85. package/src/utils/cluster.ts +0 -31
  86. package/src/utils/ed25519.ts +0 -46
  87. package/src/utils/index.ts +0 -5
  88. package/src/utils/makeWebsocketUrl.ts +0 -26
  89. package/src/utils/promise-timeout.ts +0 -14
  90. package/src/utils/secp256k1.ts +0 -18
  91. package/src/utils/send-and-confirm-raw-transaction.ts +0 -102
  92. package/src/utils/send-and-confirm-transaction.ts +0 -98
  93. package/src/utils/shortvec-encoding.ts +0 -28
  94. package/src/utils/sleep.ts +0 -4
  95. package/src/utils/to-buffer.ts +0 -11
  96. package/src/validator-info.ts +0 -104
  97. package/src/vote-account.ts +0 -236
package/lib/index.d.ts DELETED
@@ -1,3865 +0,0 @@
1
- /// <reference types="node" />
2
- declare module "@solana/web3.js" {
3
- import { Buffer } from 'buffer';
4
- import { Agent } from 'http';
5
- import { Agent as Agent$1 } from 'https';
6
- import * as nodeFetch from 'node-fetch';
7
-
8
- export class Struct {
9
- constructor(properties: any);
10
- encode(): Buffer;
11
- static decode(data: Buffer): any;
12
- static decodeUnchecked(data: Buffer): any;
13
- }
14
- export class Enum extends Struct {
15
- enum: string;
16
- constructor(properties: any);
17
- }
18
- export const SOLANA_SCHEMA: Map<Function, any>;
19
-
20
- /**
21
- * Maximum length of derived pubkey seed
22
- */
23
- export const MAX_SEED_LENGTH = 32;
24
- /**
25
- * Size of public key in bytes
26
- */
27
- export const PUBLIC_KEY_LENGTH = 32;
28
- /**
29
- * Value to be converted into public key
30
- */
31
- type PublicKeyInitData = number | string | Uint8Array | Array<number> | PublicKeyData;
32
- /**
33
- * JSON object representation of PublicKey class
34
- */
35
- type PublicKeyData = {};
36
- /**
37
- * A public key
38
- */
39
- export class PublicKey extends Struct {
40
- /**
41
- * Create a new PublicKey object
42
- * @param value ed25519 public key as buffer or base-58 encoded string
43
- */
44
- constructor(value: PublicKeyInitData);
45
- /**
46
- * Returns a unique PublicKey for tests and benchmarks using a counter
47
- */
48
- static unique(): PublicKey;
49
- /**
50
- * Default public key value. The base58-encoded string representation is all ones (as seen below)
51
- * The underlying BN number is 32 bytes that are all zeros
52
- */
53
- static default: PublicKey;
54
- /**
55
- * Checks if two publicKeys are equal
56
- */
57
- equals(publicKey: PublicKey): boolean;
58
- /**
59
- * Return the base-58 representation of the public key
60
- */
61
- toBase58(): string;
62
- toJSON(): string;
63
- /**
64
- * Return the byte array representation of the public key in big endian
65
- */
66
- toBytes(): Uint8Array;
67
- /**
68
- * Return the Buffer representation of the public key in big endian
69
- */
70
- toBuffer(): Buffer;
71
- get [Symbol.toStringTag](): string;
72
- /**
73
- * Return the base-58 representation of the public key
74
- */
75
- toString(): string;
76
- /**
77
- * Derive a public key from another key, a seed, and a program ID.
78
- * The program ID will also serve as the owner of the public key, giving
79
- * it permission to write data to the account.
80
- */
81
- static createWithSeed(fromPublicKey: PublicKey, seed: string, programId: PublicKey): Promise<PublicKey>;
82
- /**
83
- * Derive a program address from seeds and a program ID.
84
- */
85
- static createProgramAddressSync(seeds: Array<Buffer | Uint8Array>, programId: PublicKey): PublicKey;
86
- /**
87
- * Async version of createProgramAddressSync
88
- * For backwards compatibility
89
- *
90
- * @deprecated Use {@link createProgramAddressSync} instead
91
- */
92
- static createProgramAddress(seeds: Array<Buffer | Uint8Array>, programId: PublicKey): Promise<PublicKey>;
93
- /**
94
- * Find a valid program address
95
- *
96
- * Valid program addresses must fall off the ed25519 curve. This function
97
- * iterates a nonce until it finds one that when combined with the seeds
98
- * results in a valid program address.
99
- */
100
- static findProgramAddressSync(seeds: Array<Buffer | Uint8Array>, programId: PublicKey): [PublicKey, number];
101
- /**
102
- * Async version of findProgramAddressSync
103
- * For backwards compatibility
104
- *
105
- * @deprecated Use {@link findProgramAddressSync} instead
106
- */
107
- static findProgramAddress(seeds: Array<Buffer | Uint8Array>, programId: PublicKey): Promise<[PublicKey, number]>;
108
- /**
109
- * Check that a pubkey is on the ed25519 curve.
110
- */
111
- static isOnCurve(pubkeyData: PublicKeyInitData): boolean;
112
- }
113
-
114
- /**
115
- * An account key pair (public and secret keys).
116
- *
117
- * @deprecated since v1.10.0, please use {@link Keypair} instead.
118
- */
119
- export class Account {
120
- /**
121
- * Create a new Account object
122
- *
123
- * If the secretKey parameter is not provided a new key pair is randomly
124
- * created for the account
125
- *
126
- * @param secretKey Secret key for the account
127
- */
128
- constructor(secretKey?: Uint8Array | Array<number>);
129
- /**
130
- * The public key for this account
131
- */
132
- get publicKey(): PublicKey;
133
- /**
134
- * The **unencrypted** secret key for this account. The first 32 bytes
135
- * is the private scalar and the last 32 bytes is the public key.
136
- * Read more: https://blog.mozilla.org/warner/2011/11/29/ed25519-keys/
137
- */
138
- get secretKey(): Buffer;
139
- }
140
-
141
- /**
142
- * Blockhash as Base58 string.
143
- */
144
- type Blockhash = string;
145
-
146
- export const BPF_LOADER_DEPRECATED_PROGRAM_ID: PublicKey;
147
-
148
- /**
149
- * Epoch schedule
150
- * (see https://docs.solana.com/terminology#epoch)
151
- * Can be retrieved with the {@link Connection.getEpochSchedule} method
152
- */
153
- export class EpochSchedule {
154
- /** The maximum number of slots in each epoch */
155
- slotsPerEpoch: number;
156
- /** The number of slots before beginning of an epoch to calculate a leader schedule for that epoch */
157
- leaderScheduleSlotOffset: number;
158
- /** Indicates whether epochs start short and grow */
159
- warmup: boolean;
160
- /** The first epoch with `slotsPerEpoch` slots */
161
- firstNormalEpoch: number;
162
- /** The first slot of `firstNormalEpoch` */
163
- firstNormalSlot: number;
164
- constructor(slotsPerEpoch: number, leaderScheduleSlotOffset: number, warmup: boolean, firstNormalEpoch: number, firstNormalSlot: number);
165
- getEpoch(slot: number): number;
166
- getEpochAndSlotIndex(slot: number): [number, number];
167
- getFirstSlotInEpoch(epoch: number): number;
168
- getLastSlotInEpoch(epoch: number): number;
169
- getSlotsInEpoch(epoch: number): number;
170
- }
171
-
172
- export function export_default(input: nodeFetch.RequestInfo, init?: nodeFetch.RequestInit): Promise<nodeFetch.Response>;
173
-
174
- /**
175
- * Calculator for transaction fees.
176
- *
177
- * @deprecated Deprecated since Solana v1.8.0.
178
- */
179
- interface FeeCalculator {
180
- /** Cost in lamports to validate a signature. */
181
- lamportsPerSignature: number;
182
- }
183
-
184
- export const NONCE_ACCOUNT_LENGTH: number;
185
- /**
186
- * A durable nonce is a 32 byte value encoded as a base58 string.
187
- */
188
- type DurableNonce = string;
189
- /**
190
- * NonceAccount class
191
- */
192
- export class NonceAccount {
193
- authorizedPubkey: PublicKey;
194
- nonce: DurableNonce;
195
- feeCalculator: FeeCalculator;
196
- /**
197
- * Deserialize NonceAccount from the account data.
198
- *
199
- * @param buffer account data
200
- * @return NonceAccount
201
- */
202
- static fromAccountData(buffer: Buffer | Uint8Array | Array<number>): NonceAccount;
203
- }
204
-
205
- /**
206
- * A 64 byte secret key, the first 32 bytes of which is the
207
- * private scalar and the last 32 bytes is the public key.
208
- * Read more: https://blog.mozilla.org/warner/2011/11/29/ed25519-keys/
209
- */
210
- type Ed25519SecretKey = Uint8Array;
211
- /**
212
- * Ed25519 Keypair
213
- */
214
- interface Ed25519Keypair {
215
- publicKey: Uint8Array;
216
- secretKey: Ed25519SecretKey;
217
- }
218
-
219
- /**
220
- * Keypair signer interface
221
- */
222
- interface Signer {
223
- publicKey: PublicKey;
224
- secretKey: Uint8Array;
225
- }
226
- /**
227
- * An account keypair used for signing transactions.
228
- */
229
- export class Keypair {
230
- private _keypair;
231
- /**
232
- * Create a new keypair instance.
233
- * Generate random keypair if no {@link Ed25519Keypair} is provided.
234
- *
235
- * @param keypair ed25519 keypair
236
- */
237
- constructor(keypair?: Ed25519Keypair);
238
- /**
239
- * Generate a new random keypair
240
- */
241
- static generate(): Keypair;
242
- /**
243
- * Create a keypair from a raw secret key byte array.
244
- *
245
- * This method should only be used to recreate a keypair from a previously
246
- * generated secret key. Generating keypairs from a random seed should be done
247
- * with the {@link Keypair.fromSeed} method.
248
- *
249
- * @throws error if the provided secret key is invalid and validation is not skipped.
250
- *
251
- * @param secretKey secret key byte array
252
- * @param options: skip secret key validation
253
- */
254
- static fromSecretKey(secretKey: Uint8Array, options?: {
255
- skipValidation?: boolean;
256
- }): Keypair;
257
- /**
258
- * Generate a keypair from a 32 byte seed.
259
- *
260
- * @param seed seed byte array
261
- */
262
- static fromSeed(seed: Uint8Array): Keypair;
263
- /**
264
- * The public key for this keypair
265
- */
266
- get publicKey(): PublicKey;
267
- /**
268
- * The raw secret key for this keypair
269
- */
270
- get secretKey(): Uint8Array;
271
- }
272
-
273
- /**
274
- * Maximum over-the-wire size of a Transaction
275
- *
276
- * 1280 is IPv6 minimum MTU
277
- * 40 bytes is the size of the IPv6 header
278
- * 8 bytes is the size of the fragment header
279
- */
280
- export const PACKET_DATA_SIZE: number;
281
- export const VERSION_PREFIX_MASK = 127;
282
- export const SIGNATURE_LENGTH_IN_BYTES = 64;
283
-
284
- export class TransactionExpiredBlockheightExceededError extends Error {
285
- signature: string;
286
- constructor(signature: string);
287
- }
288
- export class TransactionExpiredTimeoutError extends Error {
289
- signature: string;
290
- constructor(signature: string, timeoutSeconds: number);
291
- }
292
- export class TransactionExpiredNonceInvalidError extends Error {
293
- signature: string;
294
- constructor(signature: string);
295
- }
296
-
297
- type AccountKeysFromLookups = LoadedAddresses;
298
- export class MessageAccountKeys {
299
- staticAccountKeys: Array<PublicKey>;
300
- accountKeysFromLookups?: AccountKeysFromLookups;
301
- constructor(staticAccountKeys: Array<PublicKey>, accountKeysFromLookups?: AccountKeysFromLookups);
302
- keySegments(): Array<Array<PublicKey>>;
303
- get(index: number): PublicKey | undefined;
304
- get length(): number;
305
- compileInstructions(instructions: Array<TransactionInstruction>): Array<MessageCompiledInstruction>;
306
- }
307
-
308
- /**
309
- * An instruction to execute by a program
310
- *
311
- * @property {number} programIdIndex
312
- * @property {number[]} accounts
313
- * @property {string} data
314
- */
315
- type CompiledInstruction = {
316
- /** Index into the transaction keys array indicating the program account that executes this instruction */
317
- programIdIndex: number;
318
- /** Ordered indices into the transaction keys array indicating which accounts to pass to the program */
319
- accounts: number[];
320
- /** The program input data encoded as base 58 */
321
- data: string;
322
- };
323
- /**
324
- * Message constructor arguments
325
- */
326
- type MessageArgs = {
327
- /** The message header, identifying signed and read-only `accountKeys` */
328
- header: MessageHeader;
329
- /** All the account keys used by this transaction */
330
- accountKeys: string[] | PublicKey[];
331
- /** The hash of a recent ledger block */
332
- recentBlockhash: Blockhash;
333
- /** Instructions that will be executed in sequence and committed in one atomic transaction if all succeed. */
334
- instructions: CompiledInstruction[];
335
- };
336
- type CompileLegacyArgs = {
337
- payerKey: PublicKey;
338
- instructions: Array<TransactionInstruction>;
339
- recentBlockhash: Blockhash;
340
- };
341
- /**
342
- * List of instructions to be processed atomically
343
- */
344
- export class Message {
345
- header: MessageHeader;
346
- accountKeys: PublicKey[];
347
- recentBlockhash: Blockhash;
348
- instructions: CompiledInstruction[];
349
- private indexToProgramIds;
350
- constructor(args: MessageArgs);
351
- get version(): 'legacy';
352
- get staticAccountKeys(): Array<PublicKey>;
353
- get compiledInstructions(): Array<MessageCompiledInstruction>;
354
- get addressTableLookups(): Array<MessageAddressTableLookup>;
355
- getAccountKeys(): MessageAccountKeys;
356
- static compile(args: CompileLegacyArgs): Message;
357
- isAccountSigner(index: number): boolean;
358
- isAccountWritable(index: number): boolean;
359
- isProgramId(index: number): boolean;
360
- programIds(): PublicKey[];
361
- nonProgramIds(): PublicKey[];
362
- serialize(): Buffer;
363
- /**
364
- * Decode a compiled message into a Message object.
365
- */
366
- static from(buffer: Buffer | Uint8Array | Array<number>): Message;
367
- }
368
-
369
- type AddressLookupTableState = {
370
- deactivationSlot: bigint;
371
- lastExtendedSlot: number;
372
- lastExtendedSlotStartIndex: number;
373
- authority?: PublicKey;
374
- addresses: Array<PublicKey>;
375
- };
376
- type AddressLookupTableAccountArgs = {
377
- key: PublicKey;
378
- state: AddressLookupTableState;
379
- };
380
- export class AddressLookupTableAccount {
381
- key: PublicKey;
382
- state: AddressLookupTableState;
383
- constructor(args: AddressLookupTableAccountArgs);
384
- isActive(): boolean;
385
- static deserialize(accountData: Uint8Array): AddressLookupTableState;
386
- }
387
-
388
- type CreateLookupTableParams = {
389
- /** Account used to derive and control the new address lookup table. */
390
- authority: PublicKey;
391
- /** Account that will fund the new address lookup table. */
392
- payer: PublicKey;
393
- /** A recent slot must be used in the derivation path for each initialized table. */
394
- recentSlot: bigint | number;
395
- };
396
- type FreezeLookupTableParams = {
397
- /** Address lookup table account to freeze. */
398
- lookupTable: PublicKey;
399
- /** Account which is the current authority. */
400
- authority: PublicKey;
401
- };
402
- type ExtendLookupTableParams = {
403
- /** Address lookup table account to extend. */
404
- lookupTable: PublicKey;
405
- /** Account which is the current authority. */
406
- authority: PublicKey;
407
- /** Account that will fund the table reallocation.
408
- * Not required if the reallocation has already been funded. */
409
- payer?: PublicKey;
410
- /** List of Public Keys to be added to the lookup table. */
411
- addresses: Array<PublicKey>;
412
- };
413
- type DeactivateLookupTableParams = {
414
- /** Address lookup table account to deactivate. */
415
- lookupTable: PublicKey;
416
- /** Account which is the current authority. */
417
- authority: PublicKey;
418
- };
419
- type CloseLookupTableParams = {
420
- /** Address lookup table account to close. */
421
- lookupTable: PublicKey;
422
- /** Account which is the current authority. */
423
- authority: PublicKey;
424
- /** Recipient of closed account lamports. */
425
- recipient: PublicKey;
426
- };
427
- /**
428
- * An enumeration of valid LookupTableInstructionType's
429
- */
430
- type LookupTableInstructionType = 'CreateLookupTable' | 'ExtendLookupTable' | 'CloseLookupTable' | 'FreezeLookupTable' | 'DeactivateLookupTable';
431
- export class AddressLookupTableInstruction {
432
- static decodeInstructionType(instruction: TransactionInstruction): LookupTableInstructionType;
433
- static decodeCreateLookupTable(instruction: TransactionInstruction): CreateLookupTableParams;
434
- static decodeExtendLookupTable(instruction: TransactionInstruction): ExtendLookupTableParams;
435
- static decodeCloseLookupTable(instruction: TransactionInstruction): CloseLookupTableParams;
436
- static decodeFreezeLookupTable(instruction: TransactionInstruction): FreezeLookupTableParams;
437
- static decodeDeactivateLookupTable(instruction: TransactionInstruction): DeactivateLookupTableParams;
438
- }
439
- export class AddressLookupTableProgram {
440
- static programId: PublicKey;
441
- static createLookupTable(params: CreateLookupTableParams): [TransactionInstruction, PublicKey];
442
- static freezeLookupTable(params: FreezeLookupTableParams): TransactionInstruction;
443
- static extendLookupTable(params: ExtendLookupTableParams): TransactionInstruction;
444
- static deactivateLookupTable(params: DeactivateLookupTableParams): TransactionInstruction;
445
- static closeLookupTable(params: CloseLookupTableParams): TransactionInstruction;
446
- }
447
-
448
- /**
449
- * Compute Budget Instruction class
450
- */
451
- export class ComputeBudgetInstruction {
452
- /**
453
- * Decode a compute budget instruction and retrieve the instruction type.
454
- */
455
- static decodeInstructionType(instruction: TransactionInstruction): ComputeBudgetInstructionType;
456
- /**
457
- * Decode request units compute budget instruction and retrieve the instruction params.
458
- */
459
- static decodeRequestUnits(instruction: TransactionInstruction): RequestUnitsParams;
460
- /**
461
- * Decode request heap frame compute budget instruction and retrieve the instruction params.
462
- */
463
- static decodeRequestHeapFrame(instruction: TransactionInstruction): RequestHeapFrameParams;
464
- /**
465
- * Decode set compute unit limit compute budget instruction and retrieve the instruction params.
466
- */
467
- static decodeSetComputeUnitLimit(instruction: TransactionInstruction): SetComputeUnitLimitParams;
468
- /**
469
- * Decode set compute unit price compute budget instruction and retrieve the instruction params.
470
- */
471
- static decodeSetComputeUnitPrice(instruction: TransactionInstruction): SetComputeUnitPriceParams;
472
- }
473
- /**
474
- * An enumeration of valid ComputeBudgetInstructionType's
475
- */
476
- type ComputeBudgetInstructionType = 'RequestUnits' | 'RequestHeapFrame' | 'SetComputeUnitLimit' | 'SetComputeUnitPrice';
477
- /**
478
- * Request units instruction params
479
- */
480
- interface RequestUnitsParams {
481
- /** Units to request for transaction-wide compute */
482
- units: number;
483
- /** Prioritization fee lamports */
484
- additionalFee: number;
485
- }
486
- /**
487
- * Request heap frame instruction params
488
- */
489
- type RequestHeapFrameParams = {
490
- /** Requested transaction-wide program heap size in bytes. Must be multiple of 1024. Applies to each program, including CPIs. */
491
- bytes: number;
492
- };
493
- /**
494
- * Set compute unit limit instruction params
495
- */
496
- interface SetComputeUnitLimitParams {
497
- /** Transaction-wide compute unit limit */
498
- units: number;
499
- }
500
- /**
501
- * Set compute unit price instruction params
502
- */
503
- interface SetComputeUnitPriceParams {
504
- /** Transaction compute unit price used for prioritization fees */
505
- microLamports: number | bigint;
506
- }
507
- /**
508
- * Factory class for transaction instructions to interact with the Compute Budget program
509
- */
510
- export class ComputeBudgetProgram {
511
- /**
512
- * Public key that identifies the Compute Budget program
513
- */
514
- static programId: PublicKey;
515
- /**
516
- * @deprecated Instead, call {@link setComputeUnitLimit} and/or {@link setComputeUnitPrice}
517
- */
518
- static requestUnits(params: RequestUnitsParams): TransactionInstruction;
519
- static requestHeapFrame(params: RequestHeapFrameParams): TransactionInstruction;
520
- static setComputeUnitLimit(params: SetComputeUnitLimitParams): TransactionInstruction;
521
- static setComputeUnitPrice(params: SetComputeUnitPriceParams): TransactionInstruction;
522
- }
523
-
524
- /**
525
- * Params for creating an ed25519 instruction using a public key
526
- */
527
- type CreateEd25519InstructionWithPublicKeyParams = {
528
- publicKey: Uint8Array;
529
- message: Uint8Array;
530
- signature: Uint8Array;
531
- instructionIndex?: number;
532
- };
533
- /**
534
- * Params for creating an ed25519 instruction using a private key
535
- */
536
- type CreateEd25519InstructionWithPrivateKeyParams = {
537
- privateKey: Uint8Array;
538
- message: Uint8Array;
539
- instructionIndex?: number;
540
- };
541
- export class Ed25519Program {
542
- /**
543
- * Public key that identifies the ed25519 program
544
- */
545
- static programId: PublicKey;
546
- /**
547
- * Create an ed25519 instruction with a public key and signature. The
548
- * public key must be a buffer that is 32 bytes long, and the signature
549
- * must be a buffer of 64 bytes.
550
- */
551
- static createInstructionWithPublicKey(params: CreateEd25519InstructionWithPublicKeyParams): TransactionInstruction;
552
- /**
553
- * Create an ed25519 instruction with a private key. The private key
554
- * must be a buffer that is 64 bytes long.
555
- */
556
- static createInstructionWithPrivateKey(params: CreateEd25519InstructionWithPrivateKeyParams): TransactionInstruction;
557
- }
558
-
559
- /**
560
- * Params for creating an secp256k1 instruction using a public key
561
- */
562
- type CreateSecp256k1InstructionWithPublicKeyParams = {
563
- publicKey: Buffer | Uint8Array | Array<number>;
564
- message: Buffer | Uint8Array | Array<number>;
565
- signature: Buffer | Uint8Array | Array<number>;
566
- recoveryId: number;
567
- instructionIndex?: number;
568
- };
569
- /**
570
- * Params for creating an secp256k1 instruction using an Ethereum address
571
- */
572
- type CreateSecp256k1InstructionWithEthAddressParams = {
573
- ethAddress: Buffer | Uint8Array | Array<number> | string;
574
- message: Buffer | Uint8Array | Array<number>;
575
- signature: Buffer | Uint8Array | Array<number>;
576
- recoveryId: number;
577
- instructionIndex?: number;
578
- };
579
- /**
580
- * Params for creating an secp256k1 instruction using a private key
581
- */
582
- type CreateSecp256k1InstructionWithPrivateKeyParams = {
583
- privateKey: Buffer | Uint8Array | Array<number>;
584
- message: Buffer | Uint8Array | Array<number>;
585
- instructionIndex?: number;
586
- };
587
- export class Secp256k1Program {
588
- /**
589
- * Public key that identifies the secp256k1 program
590
- */
591
- static programId: PublicKey;
592
- /**
593
- * Construct an Ethereum address from a secp256k1 public key buffer.
594
- * @param {Buffer} publicKey a 64 byte secp256k1 public key buffer
595
- */
596
- static publicKeyToEthAddress(publicKey: Buffer | Uint8Array | Array<number>): Buffer;
597
- /**
598
- * Create an secp256k1 instruction with a public key. The public key
599
- * must be a buffer that is 64 bytes long.
600
- */
601
- static createInstructionWithPublicKey(params: CreateSecp256k1InstructionWithPublicKeyParams): TransactionInstruction;
602
- /**
603
- * Create an secp256k1 instruction with an Ethereum address. The address
604
- * must be a hex string or a buffer that is 20 bytes long.
605
- */
606
- static createInstructionWithEthAddress(params: CreateSecp256k1InstructionWithEthAddressParams): TransactionInstruction;
607
- /**
608
- * Create an secp256k1 instruction with a private key. The private key
609
- * must be a buffer that is 32 bytes long.
610
- */
611
- static createInstructionWithPrivateKey(params: CreateSecp256k1InstructionWithPrivateKeyParams): TransactionInstruction;
612
- }
613
-
614
- /**
615
- * Address of the stake config account which configures the rate
616
- * of stake warmup and cooldown as well as the slashing penalty.
617
- */
618
- export const STAKE_CONFIG_ID: PublicKey;
619
- /**
620
- * Stake account authority info
621
- */
622
- export class Authorized {
623
- /** stake authority */
624
- staker: PublicKey;
625
- /** withdraw authority */
626
- withdrawer: PublicKey;
627
- /**
628
- * Create a new Authorized object
629
- * @param staker the stake authority
630
- * @param withdrawer the withdraw authority
631
- */
632
- constructor(staker: PublicKey, withdrawer: PublicKey);
633
- }
634
- /**
635
- * Stake account lockup info
636
- */
637
- export class Lockup {
638
- /** Unix timestamp of lockup expiration */
639
- unixTimestamp: number;
640
- /** Epoch of lockup expiration */
641
- epoch: number;
642
- /** Lockup custodian authority */
643
- custodian: PublicKey;
644
- /**
645
- * Create a new Lockup object
646
- */
647
- constructor(unixTimestamp: number, epoch: number, custodian: PublicKey);
648
- /**
649
- * Default, inactive Lockup value
650
- */
651
- static default: Lockup;
652
- }
653
- /**
654
- * Create stake account transaction params
655
- */
656
- type CreateStakeAccountParams = {
657
- /** Address of the account which will fund creation */
658
- fromPubkey: PublicKey;
659
- /** Address of the new stake account */
660
- stakePubkey: PublicKey;
661
- /** Authorities of the new stake account */
662
- authorized: Authorized;
663
- /** Lockup of the new stake account */
664
- lockup?: Lockup;
665
- /** Funding amount */
666
- lamports: number;
667
- };
668
- /**
669
- * Create stake account with seed transaction params
670
- */
671
- type CreateStakeAccountWithSeedParams = {
672
- fromPubkey: PublicKey;
673
- stakePubkey: PublicKey;
674
- basePubkey: PublicKey;
675
- seed: string;
676
- authorized: Authorized;
677
- lockup?: Lockup;
678
- lamports: number;
679
- };
680
- /**
681
- * Initialize stake instruction params
682
- */
683
- type InitializeStakeParams = {
684
- stakePubkey: PublicKey;
685
- authorized: Authorized;
686
- lockup?: Lockup;
687
- };
688
- /**
689
- * Delegate stake instruction params
690
- */
691
- type DelegateStakeParams = {
692
- stakePubkey: PublicKey;
693
- authorizedPubkey: PublicKey;
694
- votePubkey: PublicKey;
695
- };
696
- /**
697
- * Authorize stake instruction params
698
- */
699
- type AuthorizeStakeParams = {
700
- stakePubkey: PublicKey;
701
- authorizedPubkey: PublicKey;
702
- newAuthorizedPubkey: PublicKey;
703
- stakeAuthorizationType: StakeAuthorizationType;
704
- custodianPubkey?: PublicKey;
705
- };
706
- /**
707
- * Authorize stake instruction params using a derived key
708
- */
709
- type AuthorizeWithSeedStakeParams = {
710
- stakePubkey: PublicKey;
711
- authorityBase: PublicKey;
712
- authoritySeed: string;
713
- authorityOwner: PublicKey;
714
- newAuthorizedPubkey: PublicKey;
715
- stakeAuthorizationType: StakeAuthorizationType;
716
- custodianPubkey?: PublicKey;
717
- };
718
- /**
719
- * Split stake instruction params
720
- */
721
- type SplitStakeParams = {
722
- stakePubkey: PublicKey;
723
- authorizedPubkey: PublicKey;
724
- splitStakePubkey: PublicKey;
725
- lamports: number;
726
- };
727
- /**
728
- * Split with seed transaction params
729
- */
730
- type SplitStakeWithSeedParams = {
731
- stakePubkey: PublicKey;
732
- authorizedPubkey: PublicKey;
733
- splitStakePubkey: PublicKey;
734
- basePubkey: PublicKey;
735
- seed: string;
736
- lamports: number;
737
- };
738
- /**
739
- * Withdraw stake instruction params
740
- */
741
- type WithdrawStakeParams = {
742
- stakePubkey: PublicKey;
743
- authorizedPubkey: PublicKey;
744
- toPubkey: PublicKey;
745
- lamports: number;
746
- custodianPubkey?: PublicKey;
747
- };
748
- /**
749
- * Deactivate stake instruction params
750
- */
751
- type DeactivateStakeParams = {
752
- stakePubkey: PublicKey;
753
- authorizedPubkey: PublicKey;
754
- };
755
- /**
756
- * Merge stake instruction params
757
- */
758
- type MergeStakeParams = {
759
- stakePubkey: PublicKey;
760
- sourceStakePubKey: PublicKey;
761
- authorizedPubkey: PublicKey;
762
- };
763
- /**
764
- * Stake Instruction class
765
- */
766
- export class StakeInstruction {
767
- /**
768
- * Decode a stake instruction and retrieve the instruction type.
769
- */
770
- static decodeInstructionType(instruction: TransactionInstruction): StakeInstructionType;
771
- /**
772
- * Decode a initialize stake instruction and retrieve the instruction params.
773
- */
774
- static decodeInitialize(instruction: TransactionInstruction): InitializeStakeParams;
775
- /**
776
- * Decode a delegate stake instruction and retrieve the instruction params.
777
- */
778
- static decodeDelegate(instruction: TransactionInstruction): DelegateStakeParams;
779
- /**
780
- * Decode an authorize stake instruction and retrieve the instruction params.
781
- */
782
- static decodeAuthorize(instruction: TransactionInstruction): AuthorizeStakeParams;
783
- /**
784
- * Decode an authorize-with-seed stake instruction and retrieve the instruction params.
785
- */
786
- static decodeAuthorizeWithSeed(instruction: TransactionInstruction): AuthorizeWithSeedStakeParams;
787
- /**
788
- * Decode a split stake instruction and retrieve the instruction params.
789
- */
790
- static decodeSplit(instruction: TransactionInstruction): SplitStakeParams;
791
- /**
792
- * Decode a merge stake instruction and retrieve the instruction params.
793
- */
794
- static decodeMerge(instruction: TransactionInstruction): MergeStakeParams;
795
- /**
796
- * Decode a withdraw stake instruction and retrieve the instruction params.
797
- */
798
- static decodeWithdraw(instruction: TransactionInstruction): WithdrawStakeParams;
799
- /**
800
- * Decode a deactivate stake instruction and retrieve the instruction params.
801
- */
802
- static decodeDeactivate(instruction: TransactionInstruction): DeactivateStakeParams;
803
- }
804
- /**
805
- * An enumeration of valid StakeInstructionType's
806
- */
807
- type StakeInstructionType = 'Authorize' | 'AuthorizeWithSeed' | 'Deactivate' | 'Delegate' | 'Initialize' | 'Merge' | 'Split' | 'Withdraw';
808
- /**
809
- * Stake authorization type
810
- */
811
- type StakeAuthorizationType = {
812
- /** The Stake Authorization index (from solana-stake-program) */
813
- index: number;
814
- };
815
- /**
816
- * An enumeration of valid StakeAuthorizationLayout's
817
- */
818
- export const StakeAuthorizationLayout: Readonly<{
819
- Staker: {
820
- index: number;
821
- };
822
- Withdrawer: {
823
- index: number;
824
- };
825
- }>;
826
- /**
827
- * Factory class for transactions to interact with the Stake program
828
- */
829
- export class StakeProgram {
830
- /**
831
- * Public key that identifies the Stake program
832
- */
833
- static programId: PublicKey;
834
- /**
835
- * Max space of a Stake account
836
- *
837
- * This is generated from the solana-stake-program StakeState struct as
838
- * `StakeState::size_of()`:
839
- * https://docs.rs/solana-stake-program/latest/solana_stake_program/stake_state/enum.StakeState.html
840
- */
841
- static space: number;
842
- /**
843
- * Generate an Initialize instruction to add to a Stake Create transaction
844
- */
845
- static initialize(params: InitializeStakeParams): TransactionInstruction;
846
- /**
847
- * Generate a Transaction that creates a new Stake account at
848
- * an address generated with `from`, a seed, and the Stake programId
849
- */
850
- static createAccountWithSeed(params: CreateStakeAccountWithSeedParams): Transaction;
851
- /**
852
- * Generate a Transaction that creates a new Stake account
853
- */
854
- static createAccount(params: CreateStakeAccountParams): Transaction;
855
- /**
856
- * Generate a Transaction that delegates Stake tokens to a validator
857
- * Vote PublicKey. This transaction can also be used to redelegate Stake
858
- * to a new validator Vote PublicKey.
859
- */
860
- static delegate(params: DelegateStakeParams): Transaction;
861
- /**
862
- * Generate a Transaction that authorizes a new PublicKey as Staker
863
- * or Withdrawer on the Stake account.
864
- */
865
- static authorize(params: AuthorizeStakeParams): Transaction;
866
- /**
867
- * Generate a Transaction that authorizes a new PublicKey as Staker
868
- * or Withdrawer on the Stake account.
869
- */
870
- static authorizeWithSeed(params: AuthorizeWithSeedStakeParams): Transaction;
871
- /**
872
- * Generate a Transaction that splits Stake tokens into another stake account
873
- */
874
- static split(params: SplitStakeParams): Transaction;
875
- /**
876
- * Generate a Transaction that splits Stake tokens into another account
877
- * derived from a base public key and seed
878
- */
879
- static splitWithSeed(params: SplitStakeWithSeedParams): Transaction;
880
- /**
881
- * Generate a Transaction that merges Stake accounts.
882
- */
883
- static merge(params: MergeStakeParams): Transaction;
884
- /**
885
- * Generate a Transaction that withdraws deactivated Stake tokens.
886
- */
887
- static withdraw(params: WithdrawStakeParams): Transaction;
888
- /**
889
- * Generate a Transaction that deactivates Stake tokens.
890
- */
891
- static deactivate(params: DeactivateStakeParams): Transaction;
892
- }
893
-
894
- /**
895
- * Create account system transaction params
896
- */
897
- type CreateAccountParams = {
898
- /** The account that will transfer lamports to the created account */
899
- fromPubkey: PublicKey;
900
- /** Public key of the created account */
901
- newAccountPubkey: PublicKey;
902
- /** Amount of lamports to transfer to the created account */
903
- lamports: number;
904
- /** Amount of space in bytes to allocate to the created account */
905
- space: number;
906
- /** Public key of the program to assign as the owner of the created account */
907
- programId: PublicKey;
908
- };
909
- /**
910
- * Transfer system transaction params
911
- */
912
- type TransferParams = {
913
- /** Account that will transfer lamports */
914
- fromPubkey: PublicKey;
915
- /** Account that will receive transferred lamports */
916
- toPubkey: PublicKey;
917
- /** Amount of lamports to transfer */
918
- lamports: number | bigint;
919
- };
920
- /**
921
- * Assign system transaction params
922
- */
923
- type AssignParams = {
924
- /** Public key of the account which will be assigned a new owner */
925
- accountPubkey: PublicKey;
926
- /** Public key of the program to assign as the owner */
927
- programId: PublicKey;
928
- };
929
- /**
930
- * Create account with seed system transaction params
931
- */
932
- type CreateAccountWithSeedParams = {
933
- /** The account that will transfer lamports to the created account */
934
- fromPubkey: PublicKey;
935
- /** Public key of the created account. Must be pre-calculated with PublicKey.createWithSeed() */
936
- newAccountPubkey: PublicKey;
937
- /** Base public key to use to derive the address of the created account. Must be the same as the base key used to create `newAccountPubkey` */
938
- basePubkey: PublicKey;
939
- /** Seed to use to derive the address of the created account. Must be the same as the seed used to create `newAccountPubkey` */
940
- seed: string;
941
- /** Amount of lamports to transfer to the created account */
942
- lamports: number;
943
- /** Amount of space in bytes to allocate to the created account */
944
- space: number;
945
- /** Public key of the program to assign as the owner of the created account */
946
- programId: PublicKey;
947
- };
948
- /**
949
- * Create nonce account system transaction params
950
- */
951
- type CreateNonceAccountParams = {
952
- /** The account that will transfer lamports to the created nonce account */
953
- fromPubkey: PublicKey;
954
- /** Public key of the created nonce account */
955
- noncePubkey: PublicKey;
956
- /** Public key to set as authority of the created nonce account */
957
- authorizedPubkey: PublicKey;
958
- /** Amount of lamports to transfer to the created nonce account */
959
- lamports: number;
960
- };
961
- /**
962
- * Create nonce account with seed system transaction params
963
- */
964
- type CreateNonceAccountWithSeedParams = {
965
- /** The account that will transfer lamports to the created nonce account */
966
- fromPubkey: PublicKey;
967
- /** Public key of the created nonce account */
968
- noncePubkey: PublicKey;
969
- /** Public key to set as authority of the created nonce account */
970
- authorizedPubkey: PublicKey;
971
- /** Amount of lamports to transfer to the created nonce account */
972
- lamports: number;
973
- /** Base public key to use to derive the address of the nonce account */
974
- basePubkey: PublicKey;
975
- /** Seed to use to derive the address of the nonce account */
976
- seed: string;
977
- };
978
- /**
979
- * Initialize nonce account system instruction params
980
- */
981
- type InitializeNonceParams = {
982
- /** Nonce account which will be initialized */
983
- noncePubkey: PublicKey;
984
- /** Public key to set as authority of the initialized nonce account */
985
- authorizedPubkey: PublicKey;
986
- };
987
- /**
988
- * Advance nonce account system instruction params
989
- */
990
- type AdvanceNonceParams = {
991
- /** Nonce account */
992
- noncePubkey: PublicKey;
993
- /** Public key of the nonce authority */
994
- authorizedPubkey: PublicKey;
995
- };
996
- /**
997
- * Withdraw nonce account system transaction params
998
- */
999
- type WithdrawNonceParams = {
1000
- /** Nonce account */
1001
- noncePubkey: PublicKey;
1002
- /** Public key of the nonce authority */
1003
- authorizedPubkey: PublicKey;
1004
- /** Public key of the account which will receive the withdrawn nonce account balance */
1005
- toPubkey: PublicKey;
1006
- /** Amount of lamports to withdraw from the nonce account */
1007
- lamports: number;
1008
- };
1009
- /**
1010
- * Authorize nonce account system transaction params
1011
- */
1012
- type AuthorizeNonceParams = {
1013
- /** Nonce account */
1014
- noncePubkey: PublicKey;
1015
- /** Public key of the current nonce authority */
1016
- authorizedPubkey: PublicKey;
1017
- /** Public key to set as the new nonce authority */
1018
- newAuthorizedPubkey: PublicKey;
1019
- };
1020
- /**
1021
- * Allocate account system transaction params
1022
- */
1023
- type AllocateParams = {
1024
- /** Account to allocate */
1025
- accountPubkey: PublicKey;
1026
- /** Amount of space in bytes to allocate */
1027
- space: number;
1028
- };
1029
- /**
1030
- * Allocate account with seed system transaction params
1031
- */
1032
- type AllocateWithSeedParams = {
1033
- /** Account to allocate */
1034
- accountPubkey: PublicKey;
1035
- /** Base public key to use to derive the address of the allocated account */
1036
- basePubkey: PublicKey;
1037
- /** Seed to use to derive the address of the allocated account */
1038
- seed: string;
1039
- /** Amount of space in bytes to allocate */
1040
- space: number;
1041
- /** Public key of the program to assign as the owner of the allocated account */
1042
- programId: PublicKey;
1043
- };
1044
- /**
1045
- * Assign account with seed system transaction params
1046
- */
1047
- type AssignWithSeedParams = {
1048
- /** Public key of the account which will be assigned a new owner */
1049
- accountPubkey: PublicKey;
1050
- /** Base public key to use to derive the address of the assigned account */
1051
- basePubkey: PublicKey;
1052
- /** Seed to use to derive the address of the assigned account */
1053
- seed: string;
1054
- /** Public key of the program to assign as the owner */
1055
- programId: PublicKey;
1056
- };
1057
- /**
1058
- * Transfer with seed system transaction params
1059
- */
1060
- type TransferWithSeedParams = {
1061
- /** Account that will transfer lamports */
1062
- fromPubkey: PublicKey;
1063
- /** Base public key to use to derive the funding account address */
1064
- basePubkey: PublicKey;
1065
- /** Account that will receive transferred lamports */
1066
- toPubkey: PublicKey;
1067
- /** Amount of lamports to transfer */
1068
- lamports: number | bigint;
1069
- /** Seed to use to derive the funding account address */
1070
- seed: string;
1071
- /** Program id to use to derive the funding account address */
1072
- programId: PublicKey;
1073
- };
1074
- /** Decoded transfer system transaction instruction */
1075
- type DecodedTransferInstruction = {
1076
- /** Account that will transfer lamports */
1077
- fromPubkey: PublicKey;
1078
- /** Account that will receive transferred lamports */
1079
- toPubkey: PublicKey;
1080
- /** Amount of lamports to transfer */
1081
- lamports: bigint;
1082
- };
1083
- /** Decoded transferWithSeed system transaction instruction */
1084
- type DecodedTransferWithSeedInstruction = {
1085
- /** Account that will transfer lamports */
1086
- fromPubkey: PublicKey;
1087
- /** Base public key to use to derive the funding account address */
1088
- basePubkey: PublicKey;
1089
- /** Account that will receive transferred lamports */
1090
- toPubkey: PublicKey;
1091
- /** Amount of lamports to transfer */
1092
- lamports: bigint;
1093
- /** Seed to use to derive the funding account address */
1094
- seed: string;
1095
- /** Program id to use to derive the funding account address */
1096
- programId: PublicKey;
1097
- };
1098
- /**
1099
- * System Instruction class
1100
- */
1101
- export class SystemInstruction {
1102
- /**
1103
- * Decode a system instruction and retrieve the instruction type.
1104
- */
1105
- static decodeInstructionType(instruction: TransactionInstruction): SystemInstructionType;
1106
- /**
1107
- * Decode a create account system instruction and retrieve the instruction params.
1108
- */
1109
- static decodeCreateAccount(instruction: TransactionInstruction): CreateAccountParams;
1110
- /**
1111
- * Decode a transfer system instruction and retrieve the instruction params.
1112
- */
1113
- static decodeTransfer(instruction: TransactionInstruction): DecodedTransferInstruction;
1114
- /**
1115
- * Decode a transfer with seed system instruction and retrieve the instruction params.
1116
- */
1117
- static decodeTransferWithSeed(instruction: TransactionInstruction): DecodedTransferWithSeedInstruction;
1118
- /**
1119
- * Decode an allocate system instruction and retrieve the instruction params.
1120
- */
1121
- static decodeAllocate(instruction: TransactionInstruction): AllocateParams;
1122
- /**
1123
- * Decode an allocate with seed system instruction and retrieve the instruction params.
1124
- */
1125
- static decodeAllocateWithSeed(instruction: TransactionInstruction): AllocateWithSeedParams;
1126
- /**
1127
- * Decode an assign system instruction and retrieve the instruction params.
1128
- */
1129
- static decodeAssign(instruction: TransactionInstruction): AssignParams;
1130
- /**
1131
- * Decode an assign with seed system instruction and retrieve the instruction params.
1132
- */
1133
- static decodeAssignWithSeed(instruction: TransactionInstruction): AssignWithSeedParams;
1134
- /**
1135
- * Decode a create account with seed system instruction and retrieve the instruction params.
1136
- */
1137
- static decodeCreateWithSeed(instruction: TransactionInstruction): CreateAccountWithSeedParams;
1138
- /**
1139
- * Decode a nonce initialize system instruction and retrieve the instruction params.
1140
- */
1141
- static decodeNonceInitialize(instruction: TransactionInstruction): InitializeNonceParams;
1142
- /**
1143
- * Decode a nonce advance system instruction and retrieve the instruction params.
1144
- */
1145
- static decodeNonceAdvance(instruction: TransactionInstruction): AdvanceNonceParams;
1146
- /**
1147
- * Decode a nonce withdraw system instruction and retrieve the instruction params.
1148
- */
1149
- static decodeNonceWithdraw(instruction: TransactionInstruction): WithdrawNonceParams;
1150
- /**
1151
- * Decode a nonce authorize system instruction and retrieve the instruction params.
1152
- */
1153
- static decodeNonceAuthorize(instruction: TransactionInstruction): AuthorizeNonceParams;
1154
- }
1155
- /**
1156
- * An enumeration of valid SystemInstructionType's
1157
- */
1158
- type SystemInstructionType = 'AdvanceNonceAccount' | 'Allocate' | 'AllocateWithSeed' | 'Assign' | 'AssignWithSeed' | 'AuthorizeNonceAccount' | 'Create' | 'CreateWithSeed' | 'InitializeNonceAccount' | 'Transfer' | 'TransferWithSeed' | 'WithdrawNonceAccount' | 'UpgradeNonceAccount';
1159
- /**
1160
- * Factory class for transactions to interact with the System program
1161
- */
1162
- export class SystemProgram {
1163
- /**
1164
- * Public key that identifies the System program
1165
- */
1166
- static programId: PublicKey;
1167
- /**
1168
- * Generate a transaction instruction that creates a new account
1169
- */
1170
- static createAccount(params: CreateAccountParams): TransactionInstruction;
1171
- /**
1172
- * Generate a transaction instruction that transfers lamports from one account to another
1173
- */
1174
- static transfer(params: TransferParams | TransferWithSeedParams): TransactionInstruction;
1175
- /**
1176
- * Generate a transaction instruction that assigns an account to a program
1177
- */
1178
- static assign(params: AssignParams | AssignWithSeedParams): TransactionInstruction;
1179
- /**
1180
- * Generate a transaction instruction that creates a new account at
1181
- * an address generated with `from`, a seed, and programId
1182
- */
1183
- static createAccountWithSeed(params: CreateAccountWithSeedParams): TransactionInstruction;
1184
- /**
1185
- * Generate a transaction that creates a new Nonce account
1186
- */
1187
- static createNonceAccount(params: CreateNonceAccountParams | CreateNonceAccountWithSeedParams): Transaction;
1188
- /**
1189
- * Generate an instruction to initialize a Nonce account
1190
- */
1191
- static nonceInitialize(params: InitializeNonceParams): TransactionInstruction;
1192
- /**
1193
- * Generate an instruction to advance the nonce in a Nonce account
1194
- */
1195
- static nonceAdvance(params: AdvanceNonceParams): TransactionInstruction;
1196
- /**
1197
- * Generate a transaction instruction that withdraws lamports from a Nonce account
1198
- */
1199
- static nonceWithdraw(params: WithdrawNonceParams): TransactionInstruction;
1200
- /**
1201
- * Generate a transaction instruction that authorizes a new PublicKey as the authority
1202
- * on a Nonce account.
1203
- */
1204
- static nonceAuthorize(params: AuthorizeNonceParams): TransactionInstruction;
1205
- /**
1206
- * Generate a transaction instruction that allocates space in an account without funding
1207
- */
1208
- static allocate(params: AllocateParams | AllocateWithSeedParams): TransactionInstruction;
1209
- }
1210
-
1211
- /**
1212
- * Vote account info
1213
- */
1214
- export class VoteInit {
1215
- nodePubkey: PublicKey;
1216
- authorizedVoter: PublicKey;
1217
- authorizedWithdrawer: PublicKey;
1218
- commission: number; /** [0, 100] */
1219
- constructor(nodePubkey: PublicKey, authorizedVoter: PublicKey, authorizedWithdrawer: PublicKey, commission: number);
1220
- }
1221
- /**
1222
- * Create vote account transaction params
1223
- */
1224
- type CreateVoteAccountParams = {
1225
- fromPubkey: PublicKey;
1226
- votePubkey: PublicKey;
1227
- voteInit: VoteInit;
1228
- lamports: number;
1229
- };
1230
- /**
1231
- * InitializeAccount instruction params
1232
- */
1233
- type InitializeAccountParams = {
1234
- votePubkey: PublicKey;
1235
- nodePubkey: PublicKey;
1236
- voteInit: VoteInit;
1237
- };
1238
- /**
1239
- * Authorize instruction params
1240
- */
1241
- type AuthorizeVoteParams = {
1242
- votePubkey: PublicKey;
1243
- /** Current vote or withdraw authority, depending on `voteAuthorizationType` */
1244
- authorizedPubkey: PublicKey;
1245
- newAuthorizedPubkey: PublicKey;
1246
- voteAuthorizationType: VoteAuthorizationType;
1247
- };
1248
- /**
1249
- * AuthorizeWithSeed instruction params
1250
- */
1251
- type AuthorizeVoteWithSeedParams = {
1252
- currentAuthorityDerivedKeyBasePubkey: PublicKey;
1253
- currentAuthorityDerivedKeyOwnerPubkey: PublicKey;
1254
- currentAuthorityDerivedKeySeed: string;
1255
- newAuthorizedPubkey: PublicKey;
1256
- voteAuthorizationType: VoteAuthorizationType;
1257
- votePubkey: PublicKey;
1258
- };
1259
- /**
1260
- * Withdraw from vote account transaction params
1261
- */
1262
- type WithdrawFromVoteAccountParams = {
1263
- votePubkey: PublicKey;
1264
- authorizedWithdrawerPubkey: PublicKey;
1265
- lamports: number;
1266
- toPubkey: PublicKey;
1267
- };
1268
- /**
1269
- * Vote Instruction class
1270
- */
1271
- export class VoteInstruction {
1272
- /**
1273
- * Decode a vote instruction and retrieve the instruction type.
1274
- */
1275
- static decodeInstructionType(instruction: TransactionInstruction): VoteInstructionType;
1276
- /**
1277
- * Decode an initialize vote instruction and retrieve the instruction params.
1278
- */
1279
- static decodeInitializeAccount(instruction: TransactionInstruction): InitializeAccountParams;
1280
- /**
1281
- * Decode an authorize instruction and retrieve the instruction params.
1282
- */
1283
- static decodeAuthorize(instruction: TransactionInstruction): AuthorizeVoteParams;
1284
- /**
1285
- * Decode an authorize instruction and retrieve the instruction params.
1286
- */
1287
- static decodeAuthorizeWithSeed(instruction: TransactionInstruction): AuthorizeVoteWithSeedParams;
1288
- /**
1289
- * Decode a withdraw instruction and retrieve the instruction params.
1290
- */
1291
- static decodeWithdraw(instruction: TransactionInstruction): WithdrawFromVoteAccountParams;
1292
- }
1293
- /**
1294
- * An enumeration of valid VoteInstructionType's
1295
- */
1296
- type VoteInstructionType = 'Authorize' | 'AuthorizeWithSeed' | 'InitializeAccount' | 'Withdraw';
1297
- /**
1298
- * VoteAuthorize type
1299
- */
1300
- type VoteAuthorizationType = {
1301
- /** The VoteAuthorize index (from solana-vote-program) */
1302
- index: number;
1303
- };
1304
- /**
1305
- * An enumeration of valid VoteAuthorization layouts.
1306
- */
1307
- export const VoteAuthorizationLayout: Readonly<{
1308
- Voter: {
1309
- index: number;
1310
- };
1311
- Withdrawer: {
1312
- index: number;
1313
- };
1314
- }>;
1315
- /**
1316
- * Factory class for transactions to interact with the Vote program
1317
- */
1318
- export class VoteProgram {
1319
- /**
1320
- * Public key that identifies the Vote program
1321
- */
1322
- static programId: PublicKey;
1323
- /**
1324
- * Max space of a Vote account
1325
- *
1326
- * This is generated from the solana-vote-program VoteState struct as
1327
- * `VoteState::size_of()`:
1328
- * https://docs.rs/solana-vote-program/1.9.5/solana_vote_program/vote_state/struct.VoteState.html#method.size_of
1329
- */
1330
- static space: number;
1331
- /**
1332
- * Generate an Initialize instruction.
1333
- */
1334
- static initializeAccount(params: InitializeAccountParams): TransactionInstruction;
1335
- /**
1336
- * Generate a transaction that creates a new Vote account.
1337
- */
1338
- static createAccount(params: CreateVoteAccountParams): Transaction;
1339
- /**
1340
- * Generate a transaction that authorizes a new Voter or Withdrawer on the Vote account.
1341
- */
1342
- static authorize(params: AuthorizeVoteParams): Transaction;
1343
- /**
1344
- * Generate a transaction that authorizes a new Voter or Withdrawer on the Vote account
1345
- * where the current Voter or Withdrawer authority is a derived key.
1346
- */
1347
- static authorizeWithSeed(params: AuthorizeVoteWithSeedParams): Transaction;
1348
- /**
1349
- * Generate a transaction to withdraw from a Vote account.
1350
- */
1351
- static withdraw(params: WithdrawFromVoteAccountParams): Transaction;
1352
- /**
1353
- * Generate a transaction to withdraw safely from a Vote account.
1354
- *
1355
- * This function was created as a safeguard for vote accounts running validators, `safeWithdraw`
1356
- * checks that the withdraw amount will not exceed the specified balance while leaving enough left
1357
- * to cover rent. If you wish to close the vote account by withdrawing the full amount, call the
1358
- * `withdraw` method directly.
1359
- */
1360
- static safeWithdraw(params: WithdrawFromVoteAccountParams, currentVoteAccountBalance: number, rentExemptMinimum: number): Transaction;
1361
- }
1362
-
1363
- /**
1364
- * Message constructor arguments
1365
- */
1366
- type MessageV0Args = {
1367
- /** The message header, identifying signed and read-only `accountKeys` */
1368
- header: MessageHeader;
1369
- /** The static account keys used by this transaction */
1370
- staticAccountKeys: PublicKey[];
1371
- /** The hash of a recent ledger block */
1372
- recentBlockhash: Blockhash;
1373
- /** Instructions that will be executed in sequence and committed in one atomic transaction if all succeed. */
1374
- compiledInstructions: MessageCompiledInstruction[];
1375
- /** Instructions that will be executed in sequence and committed in one atomic transaction if all succeed. */
1376
- addressTableLookups: MessageAddressTableLookup[];
1377
- };
1378
- type CompileV0Args = {
1379
- payerKey: PublicKey;
1380
- instructions: Array<TransactionInstruction>;
1381
- recentBlockhash: Blockhash;
1382
- addressLookupTableAccounts?: Array<AddressLookupTableAccount>;
1383
- };
1384
- type GetAccountKeysArgs = {
1385
- accountKeysFromLookups?: AccountKeysFromLookups | null;
1386
- } | {
1387
- addressLookupTableAccounts?: AddressLookupTableAccount[] | null;
1388
- };
1389
- export class MessageV0 {
1390
- header: MessageHeader;
1391
- staticAccountKeys: Array<PublicKey>;
1392
- recentBlockhash: Blockhash;
1393
- compiledInstructions: Array<MessageCompiledInstruction>;
1394
- addressTableLookups: Array<MessageAddressTableLookup>;
1395
- constructor(args: MessageV0Args);
1396
- get version(): 0;
1397
- get numAccountKeysFromLookups(): number;
1398
- getAccountKeys(args?: GetAccountKeysArgs): MessageAccountKeys;
1399
- isAccountSigner(index: number): boolean;
1400
- isAccountWritable(index: number): boolean;
1401
- resolveAddressTableLookups(addressLookupTableAccounts: AddressLookupTableAccount[]): AccountKeysFromLookups;
1402
- static compile(args: CompileV0Args): MessageV0;
1403
- serialize(): Uint8Array;
1404
- private serializeInstructions;
1405
- private serializeAddressTableLookups;
1406
- static deserialize(serializedMessage: Uint8Array): MessageV0;
1407
- }
1408
-
1409
- type VersionedMessage = Message | MessageV0;
1410
- export const VersionedMessage: {
1411
- deserializeMessageVersion(serializedMessage: Uint8Array): 'legacy' | number;
1412
- deserialize: (serializedMessage: Uint8Array) => VersionedMessage;
1413
- };
1414
-
1415
- /**
1416
- * The message header, identifying signed and read-only account
1417
- */
1418
- type MessageHeader = {
1419
- /**
1420
- * The number of signatures required for this message to be considered valid. The
1421
- * signatures must match the first `numRequiredSignatures` of `accountKeys`.
1422
- */
1423
- numRequiredSignatures: number;
1424
- /** The last `numReadonlySignedAccounts` of the signed keys are read-only accounts */
1425
- numReadonlySignedAccounts: number;
1426
- /** The last `numReadonlySignedAccounts` of the unsigned keys are read-only accounts */
1427
- numReadonlyUnsignedAccounts: number;
1428
- };
1429
- /**
1430
- * An address table lookup used to load additional accounts
1431
- */
1432
- type MessageAddressTableLookup = {
1433
- accountKey: PublicKey;
1434
- writableIndexes: Array<number>;
1435
- readonlyIndexes: Array<number>;
1436
- };
1437
- /**
1438
- * An instruction to execute by a program
1439
- *
1440
- * @property {number} programIdIndex
1441
- * @property {number[]} accountKeyIndexes
1442
- * @property {Uint8Array} data
1443
- */
1444
- type MessageCompiledInstruction = {
1445
- /** Index into the transaction keys array indicating the program account that executes this instruction */
1446
- programIdIndex: number;
1447
- /** Ordered indices into the transaction keys array indicating which accounts to pass to the program */
1448
- accountKeyIndexes: number[];
1449
- /** The program input data */
1450
- data: Uint8Array;
1451
- };
1452
-
1453
- /**
1454
- * Transaction signature as base-58 encoded string
1455
- */
1456
- type TransactionSignature = string;
1457
- export const enum TransactionStatus {
1458
- BLOCKHEIGHT_EXCEEDED = 0,
1459
- PROCESSED = 1,
1460
- TIMED_OUT = 2,
1461
- NONCE_INVALID = 3
1462
- }
1463
- /**
1464
- * Account metadata used to define instructions
1465
- */
1466
- type AccountMeta = {
1467
- /** An account's public key */
1468
- pubkey: PublicKey;
1469
- /** True if an instruction requires a transaction signature matching `pubkey` */
1470
- isSigner: boolean;
1471
- /** True if the `pubkey` can be loaded as a read-write account. */
1472
- isWritable: boolean;
1473
- };
1474
- /**
1475
- * List of TransactionInstruction object fields that may be initialized at construction
1476
- */
1477
- type TransactionInstructionCtorFields = {
1478
- keys: Array<AccountMeta>;
1479
- programId: PublicKey;
1480
- data?: Buffer;
1481
- };
1482
- /**
1483
- * Configuration object for Transaction.serialize()
1484
- */
1485
- type SerializeConfig = {
1486
- /** Require all transaction signatures be present (default: true) */
1487
- requireAllSignatures?: boolean;
1488
- /** Verify provided signatures (default: true) */
1489
- verifySignatures?: boolean;
1490
- };
1491
- /**
1492
- * Transaction Instruction class
1493
- */
1494
- export class TransactionInstruction {
1495
- /**
1496
- * Public keys to include in this transaction
1497
- * Boolean represents whether this pubkey needs to sign the transaction
1498
- */
1499
- keys: Array<AccountMeta>;
1500
- /**
1501
- * Program Id to execute
1502
- */
1503
- programId: PublicKey;
1504
- /**
1505
- * Program input
1506
- */
1507
- data: Buffer;
1508
- constructor(opts: TransactionInstructionCtorFields);
1509
- }
1510
- /**
1511
- * Pair of signature and corresponding public key
1512
- */
1513
- type SignaturePubkeyPair = {
1514
- signature: Buffer | null;
1515
- publicKey: PublicKey;
1516
- };
1517
- /**
1518
- * List of Transaction object fields that may be initialized at construction
1519
- */
1520
- type TransactionCtorFields_DEPRECATED = {
1521
- /** Optional nonce information used for offline nonce'd transactions */
1522
- nonceInfo?: NonceInformation | null;
1523
- /** The transaction fee payer */
1524
- feePayer?: PublicKey | null;
1525
- /** One or more signatures */
1526
- signatures?: Array<SignaturePubkeyPair>;
1527
- /** A recent blockhash */
1528
- recentBlockhash?: Blockhash;
1529
- };
1530
- type TransactionCtorFields = TransactionCtorFields_DEPRECATED;
1531
- /**
1532
- * Blockhash-based transactions have a lifetime that are defined by
1533
- * the blockhash they include. Any transaction whose blockhash is
1534
- * too old will be rejected.
1535
- */
1536
- type TransactionBlockhashCtor = {
1537
- /** The transaction fee payer */
1538
- feePayer?: PublicKey | null;
1539
- /** One or more signatures */
1540
- signatures?: Array<SignaturePubkeyPair>;
1541
- /** A recent blockhash */
1542
- blockhash: Blockhash;
1543
- /** the last block chain can advance to before tx is exportd expired */
1544
- lastValidBlockHeight: number;
1545
- };
1546
- /**
1547
- * Use these options to construct a durable nonce transaction.
1548
- */
1549
- type TransactionNonceCtor = {
1550
- /** The transaction fee payer */
1551
- feePayer?: PublicKey | null;
1552
- minContextSlot: number;
1553
- nonceInfo: NonceInformation;
1554
- /** One or more signatures */
1555
- signatures?: Array<SignaturePubkeyPair>;
1556
- };
1557
- /**
1558
- * Nonce information to be used to build an offline Transaction.
1559
- */
1560
- type NonceInformation = {
1561
- /** The current blockhash stored in the nonce */
1562
- nonce: Blockhash;
1563
- /** AdvanceNonceAccount Instruction */
1564
- nonceInstruction: TransactionInstruction;
1565
- };
1566
- /**
1567
- * Transaction class
1568
- */
1569
- export class Transaction {
1570
- /**
1571
- * Signatures for the transaction. Typically created by invoking the
1572
- * `sign()` method
1573
- */
1574
- signatures: Array<SignaturePubkeyPair>;
1575
- /**
1576
- * The first (payer) Transaction signature
1577
- */
1578
- get signature(): Buffer | null;
1579
- /**
1580
- * The transaction fee payer
1581
- */
1582
- feePayer?: PublicKey;
1583
- /**
1584
- * The instructions to atomically execute
1585
- */
1586
- instructions: Array<TransactionInstruction>;
1587
- /**
1588
- * A recent transaction id. Must be populated by the caller
1589
- */
1590
- recentBlockhash?: Blockhash;
1591
- /**
1592
- * the last block chain can advance to before tx is exportd expired
1593
- * */
1594
- lastValidBlockHeight?: number;
1595
- /**
1596
- * Optional Nonce information. If populated, transaction will use a durable
1597
- * Nonce hash instead of a recentBlockhash. Must be populated by the caller
1598
- */
1599
- nonceInfo?: NonceInformation;
1600
- /**
1601
- * If this is a nonce transaction this represents the minimum slot from which
1602
- * to evaluate if the nonce has advanced when attempting to confirm the
1603
- * transaction. This protects against a case where the transaction confirmation
1604
- * logic loads the nonce account from an old slot and assumes the mismatch in
1605
- * nonce value implies that the nonce has been advanced.
1606
- */
1607
- minNonceContextSlot?: number;
1608
- constructor(opts?: TransactionBlockhashCtor);
1609
- constructor(opts?: TransactionNonceCtor);
1610
- /**
1611
- * @deprecated `TransactionCtorFields` has been deprecated and will be removed in a future version.
1612
- * Please supply a `TransactionBlockhashCtor` instead.
1613
- */
1614
- constructor(opts?: TransactionCtorFields_DEPRECATED);
1615
- /**
1616
- * Add one or more instructions to this Transaction
1617
- */
1618
- add(...items: Array<Transaction | TransactionInstruction | TransactionInstructionCtorFields>): Transaction;
1619
- /**
1620
- * Compile transaction data
1621
- */
1622
- compileMessage(): Message;
1623
- /**
1624
- * Get a buffer of the Transaction data that need to be covered by signatures
1625
- */
1626
- serializeMessage(): Buffer;
1627
- /**
1628
- * Get the estimated fee associated with a transaction
1629
- */
1630
- getEstimatedFee(connection: Connection): Promise<number | null>;
1631
- /**
1632
- * Specify the public keys which will be used to sign the Transaction.
1633
- * The first signer will be used as the transaction fee payer account.
1634
- *
1635
- * Signatures can be added with either `partialSign` or `addSignature`
1636
- *
1637
- * @deprecated Deprecated since v0.84.0. Only the fee payer needs to be
1638
- * specified and it can be set in the Transaction constructor or with the
1639
- * `feePayer` property.
1640
- */
1641
- setSigners(...signers: Array<PublicKey>): void;
1642
- /**
1643
- * Sign the Transaction with the specified signers. Multiple signatures may
1644
- * be applied to a Transaction. The first signature is considered "primary"
1645
- * and is used identify and confirm transactions.
1646
- *
1647
- * If the Transaction `feePayer` is not set, the first signer will be used
1648
- * as the transaction fee payer account.
1649
- *
1650
- * Transaction fields should not be modified after the first call to `sign`,
1651
- * as doing so may invalidate the signature and cause the Transaction to be
1652
- * rejected.
1653
- *
1654
- * The Transaction must be assigned a valid `recentBlockhash` before invoking this method
1655
- */
1656
- sign(...signers: Array<Signer>): void;
1657
- /**
1658
- * Partially sign a transaction with the specified accounts. All accounts must
1659
- * correspond to either the fee payer or a signer account in the transaction
1660
- * instructions.
1661
- *
1662
- * All the caveats from the `sign` method apply to `partialSign`
1663
- */
1664
- partialSign(...signers: Array<Signer>): void;
1665
- /**
1666
- * Add an externally created signature to a transaction. The public key
1667
- * must correspond to either the fee payer or a signer account in the transaction
1668
- * instructions.
1669
- */
1670
- addSignature(pubkey: PublicKey, signature: Buffer): void;
1671
- /**
1672
- * Verify signatures of a Transaction
1673
- * Optional parameter specifies if we're expecting a fully signed Transaction or a partially signed one.
1674
- * If no boolean is provided, we expect a fully signed Transaction by default.
1675
- */
1676
- verifySignatures(requireAllSignatures?: boolean): boolean;
1677
- /**
1678
- * Serialize the Transaction in the wire format.
1679
- */
1680
- serialize(config?: SerializeConfig): Buffer;
1681
- /**
1682
- * Parse a wire transaction into a Transaction object.
1683
- */
1684
- static from(buffer: Buffer | Uint8Array | Array<number>): Transaction;
1685
- /**
1686
- * Populate Transaction object from message and signatures
1687
- */
1688
- static populate(message: Message, signatures?: Array<string>): Transaction;
1689
- }
1690
-
1691
- type TransactionMessageArgs = {
1692
- payerKey: PublicKey;
1693
- instructions: Array<TransactionInstruction>;
1694
- recentBlockhash: Blockhash;
1695
- };
1696
- type DecompileArgs = {
1697
- accountKeysFromLookups: AccountKeysFromLookups;
1698
- } | {
1699
- addressLookupTableAccounts: AddressLookupTableAccount[];
1700
- };
1701
- export class TransactionMessage {
1702
- payerKey: PublicKey;
1703
- instructions: Array<TransactionInstruction>;
1704
- recentBlockhash: Blockhash;
1705
- constructor(args: TransactionMessageArgs);
1706
- static decompile(message: VersionedMessage, args?: DecompileArgs): TransactionMessage;
1707
- compileToLegacyMessage(): Message;
1708
- compileToV0Message(addressLookupTableAccounts?: AddressLookupTableAccount[]): MessageV0;
1709
- }
1710
-
1711
- type TransactionVersion = 'legacy' | 0;
1712
- /**
1713
- * Versioned transaction class
1714
- */
1715
- export class VersionedTransaction {
1716
- signatures: Array<Uint8Array>;
1717
- message: VersionedMessage;
1718
- get version(): TransactionVersion;
1719
- constructor(message: VersionedMessage, signatures?: Array<Uint8Array>);
1720
- serialize(): Uint8Array;
1721
- static deserialize(serializedTransaction: Uint8Array): VersionedTransaction;
1722
- sign(signers: Array<Signer>): void;
1723
- addSignature(publicKey: PublicKey, signature: Uint8Array): void;
1724
- }
1725
-
1726
- type ClientSubscriptionId = number;
1727
- type TokenAccountsFilter = {
1728
- mint: PublicKey;
1729
- } | {
1730
- programId: PublicKey;
1731
- };
1732
- /**
1733
- * Extra contextual information for RPC responses
1734
- */
1735
- type Context = {
1736
- slot: number;
1737
- };
1738
- /**
1739
- * Options for sending transactions
1740
- */
1741
- type SendOptions = {
1742
- /** disable transaction verification step */
1743
- skipPreflight?: boolean;
1744
- /** preflight commitment level */
1745
- preflightCommitment?: Commitment;
1746
- /** Maximum number of times for the RPC node to retry sending the transaction to the leader. */
1747
- maxRetries?: number;
1748
- /** The minimum slot that the request can be evaluated at */
1749
- minContextSlot?: number;
1750
- };
1751
- /**
1752
- * Options for confirming transactions
1753
- */
1754
- type ConfirmOptions = {
1755
- /** disable transaction verification step */
1756
- skipPreflight?: boolean;
1757
- /** desired commitment level */
1758
- commitment?: Commitment;
1759
- /** preflight commitment level */
1760
- preflightCommitment?: Commitment;
1761
- /** Maximum number of times for the RPC node to retry sending the transaction to the leader. */
1762
- maxRetries?: number;
1763
- /** The minimum slot that the request can be evaluated at */
1764
- minContextSlot?: number;
1765
- };
1766
- /**
1767
- * Options for getConfirmedSignaturesForAddress2
1768
- */
1769
- type ConfirmedSignaturesForAddress2Options = {
1770
- /**
1771
- * Start searching backwards from this transaction signature.
1772
- * @remark If not provided the search starts from the highest max confirmed block.
1773
- */
1774
- before?: TransactionSignature;
1775
- /** Search until this transaction signature is reached, if found before `limit`. */
1776
- until?: TransactionSignature;
1777
- /** Maximum transaction signatures to return (between 1 and 1,000, default: 1,000). */
1778
- limit?: number;
1779
- };
1780
- /**
1781
- * Options for getSignaturesForAddress
1782
- */
1783
- type SignaturesForAddressOptions = {
1784
- /**
1785
- * Start searching backwards from this transaction signature.
1786
- * @remark If not provided the search starts from the highest max confirmed block.
1787
- */
1788
- before?: TransactionSignature;
1789
- /** Search until this transaction signature is reached, if found before `limit`. */
1790
- until?: TransactionSignature;
1791
- /** Maximum transaction signatures to return (between 1 and 1,000, default: 1,000). */
1792
- limit?: number;
1793
- /** The minimum slot that the request can be evaluated at */
1794
- minContextSlot?: number;
1795
- };
1796
- /**
1797
- * RPC Response with extra contextual information
1798
- */
1799
- type RpcResponseAndContext<T> = {
1800
- /** response context */
1801
- context: Context;
1802
- /** response value */
1803
- value: T;
1804
- };
1805
- type BlockhashWithExpiryBlockHeight = Readonly<{
1806
- blockhash: Blockhash;
1807
- lastValidBlockHeight: number;
1808
- }>;
1809
- /**
1810
- * A strategy for confirming transactions that uses the last valid
1811
- * block height for a given blockhash to check for transaction expiration.
1812
- */
1813
- type BlockheightBasedTransactionConfirmationStrategy = BaseTransactionConfirmationStrategy & BlockhashWithExpiryBlockHeight;
1814
- /**
1815
- * A strategy for confirming durable nonce transactions.
1816
- */
1817
- type DurableNonceTransactionConfirmationStrategy = BaseTransactionConfirmationStrategy & {
1818
- /**
1819
- * The lowest slot at which to fetch the nonce value from the
1820
- * nonce account. This should be no lower than the slot at
1821
- * which the last-known value of the nonce was fetched.
1822
- */
1823
- minContextSlot: number;
1824
- /**
1825
- * The account where the current value of the nonce is stored.
1826
- */
1827
- nonceAccountPubkey: PublicKey;
1828
- /**
1829
- * The nonce value that was used to sign the transaction
1830
- * for which confirmation is being sought.
1831
- */
1832
- nonceValue: DurableNonce;
1833
- };
1834
- /**
1835
- * Properties shared by all transaction confirmation strategies
1836
- */
1837
- type BaseTransactionConfirmationStrategy = Readonly<{
1838
- /** A signal that, when aborted, cancels any outstanding transaction confirmation operations */
1839
- abortSignal?: AbortSignal;
1840
- signature: TransactionSignature;
1841
- }>;
1842
- /**
1843
- * This type represents all transaction confirmation strategies
1844
- */
1845
- type TransactionConfirmationStrategy = BlockheightBasedTransactionConfirmationStrategy | DurableNonceTransactionConfirmationStrategy;
1846
- /**
1847
- * The level of commitment desired when querying state
1848
- * <pre>
1849
- * 'processed': Query the most recent block which has reached 1 confirmation by the connected node
1850
- * 'confirmed': Query the most recent block which has reached 1 confirmation by the cluster
1851
- * 'finalized': Query the most recent block which has been finalized by the cluster
1852
- * </pre>
1853
- */
1854
- type Commitment = 'processed' | 'confirmed' | 'finalized' | 'recent' | 'single' | 'singleGossip' | 'root' | 'max';
1855
- /**
1856
- * A subset of Commitment levels, which are at least optimistically confirmed
1857
- * <pre>
1858
- * 'confirmed': Query the most recent block which has reached 1 confirmation by the cluster
1859
- * 'finalized': Query the most recent block which has been finalized by the cluster
1860
- * </pre>
1861
- */
1862
- type Finality = 'confirmed' | 'finalized';
1863
- /**
1864
- * Filter for largest accounts query
1865
- * <pre>
1866
- * 'circulating': Return the largest accounts that are part of the circulating supply
1867
- * 'nonCirculating': Return the largest accounts that are not part of the circulating supply
1868
- * </pre>
1869
- */
1870
- type LargestAccountsFilter = 'circulating' | 'nonCirculating';
1871
- /**
1872
- * Configuration object for changing `getAccountInfo` query behavior
1873
- */
1874
- type GetAccountInfoConfig = {
1875
- /** The level of commitment desired */
1876
- commitment?: Commitment;
1877
- /** The minimum slot that the request can be evaluated at */
1878
- minContextSlot?: number;
1879
- /** Optional data slice to limit the returned account data */
1880
- dataSlice?: DataSlice;
1881
- };
1882
- /**
1883
- * Configuration object for changing `getBalance` query behavior
1884
- */
1885
- type GetBalanceConfig = {
1886
- /** The level of commitment desired */
1887
- commitment?: Commitment;
1888
- /** The minimum slot that the request can be evaluated at */
1889
- minContextSlot?: number;
1890
- };
1891
- /**
1892
- * Configuration object for changing `getBlock` query behavior
1893
- */
1894
- type GetBlockConfig = {
1895
- /** The level of finality desired */
1896
- commitment?: Finality;
1897
- /**
1898
- * Whether to populate the rewards array. If parameter not provided, the default includes rewards.
1899
- */
1900
- rewards?: boolean;
1901
- /**
1902
- * Level of transaction detail to return, either "full", "accounts", "signatures", or "none". If
1903
- * parameter not provided, the default detail level is "full". If "accounts" are requested,
1904
- * transaction details only include signatures and an annotated list of accounts in each
1905
- * transaction. Transaction metadata is limited to only: fee, err, pre_balances, post_balances,
1906
- * pre_token_balances, and post_token_balances.
1907
- */
1908
- transactionDetails?: 'accounts' | 'full' | 'none' | 'signatures';
1909
- };
1910
- /**
1911
- * Configuration object for changing `getBlock` query behavior
1912
- */
1913
- type GetVersionedBlockConfig = {
1914
- /** The level of finality desired */
1915
- commitment?: Finality;
1916
- /** The max transaction version to return in responses. If the requested transaction is a higher version, an error will be returned */
1917
- maxSupportedTransactionVersion?: number;
1918
- /**
1919
- * Whether to populate the rewards array. If parameter not provided, the default includes rewards.
1920
- */
1921
- rewards?: boolean;
1922
- /**
1923
- * Level of transaction detail to return, either "full", "accounts", "signatures", or "none". If
1924
- * parameter not provided, the default detail level is "full". If "accounts" are requested,
1925
- * transaction details only include signatures and an annotated list of accounts in each
1926
- * transaction. Transaction metadata is limited to only: fee, err, pre_balances, post_balances,
1927
- * pre_token_balances, and post_token_balances.
1928
- */
1929
- transactionDetails?: 'accounts' | 'full' | 'none' | 'signatures';
1930
- };
1931
- /**
1932
- * Configuration object for changing `getStakeMinimumDelegation` query behavior
1933
- */
1934
- type GetStakeMinimumDelegationConfig = {
1935
- /** The level of commitment desired */
1936
- commitment?: Commitment;
1937
- };
1938
- /**
1939
- * Configuration object for changing `getBlockHeight` query behavior
1940
- */
1941
- type GetBlockHeightConfig = {
1942
- /** The level of commitment desired */
1943
- commitment?: Commitment;
1944
- /** The minimum slot that the request can be evaluated at */
1945
- minContextSlot?: number;
1946
- };
1947
- /**
1948
- * Configuration object for changing `getEpochInfo` query behavior
1949
- */
1950
- type GetEpochInfoConfig = {
1951
- /** The level of commitment desired */
1952
- commitment?: Commitment;
1953
- /** The minimum slot that the request can be evaluated at */
1954
- minContextSlot?: number;
1955
- };
1956
- /**
1957
- * Configuration object for changing `getInflationReward` query behavior
1958
- */
1959
- type GetInflationRewardConfig = {
1960
- /** The level of commitment desired */
1961
- commitment?: Commitment;
1962
- /** An epoch for which the reward occurs. If omitted, the previous epoch will be used */
1963
- epoch?: number;
1964
- /** The minimum slot that the request can be evaluated at */
1965
- minContextSlot?: number;
1966
- };
1967
- /**
1968
- * Configuration object for changing `getLatestBlockhash` query behavior
1969
- */
1970
- type GetLatestBlockhashConfig = {
1971
- /** The level of commitment desired */
1972
- commitment?: Commitment;
1973
- /** The minimum slot that the request can be evaluated at */
1974
- minContextSlot?: number;
1975
- };
1976
- /**
1977
- * Configuration object for changing `getSlot` query behavior
1978
- */
1979
- type GetSlotConfig = {
1980
- /** The level of commitment desired */
1981
- commitment?: Commitment;
1982
- /** The minimum slot that the request can be evaluated at */
1983
- minContextSlot?: number;
1984
- };
1985
- /**
1986
- * Configuration object for changing `getSlotLeader` query behavior
1987
- */
1988
- type GetSlotLeaderConfig = {
1989
- /** The level of commitment desired */
1990
- commitment?: Commitment;
1991
- /** The minimum slot that the request can be evaluated at */
1992
- minContextSlot?: number;
1993
- };
1994
- /**
1995
- * Configuration object for changing `getTransaction` query behavior
1996
- */
1997
- type GetTransactionConfig = {
1998
- /** The level of finality desired */
1999
- commitment?: Finality;
2000
- };
2001
- /**
2002
- * Configuration object for changing `getTransaction` query behavior
2003
- */
2004
- type GetVersionedTransactionConfig = {
2005
- /** The level of finality desired */
2006
- commitment?: Finality;
2007
- /** The max transaction version to return in responses. If the requested transaction is a higher version, an error will be returned */
2008
- maxSupportedTransactionVersion?: number;
2009
- };
2010
- /**
2011
- * Configuration object for changing `getLargestAccounts` query behavior
2012
- */
2013
- type GetLargestAccountsConfig = {
2014
- /** The level of commitment desired */
2015
- commitment?: Commitment;
2016
- /** Filter largest accounts by whether they are part of the circulating supply */
2017
- filter?: LargestAccountsFilter;
2018
- };
2019
- /**
2020
- * Configuration object for changing `getSupply` request behavior
2021
- */
2022
- type GetSupplyConfig = {
2023
- /** The level of commitment desired */
2024
- commitment?: Commitment;
2025
- /** Exclude non circulating accounts list from response */
2026
- excludeNonCirculatingAccountsList?: boolean;
2027
- };
2028
- /**
2029
- * Configuration object for changing query behavior
2030
- */
2031
- type SignatureStatusConfig = {
2032
- /** enable searching status history, not needed for recent transactions */
2033
- searchTransactionHistory: boolean;
2034
- };
2035
- /**
2036
- * Information describing a cluster node
2037
- */
2038
- type ContactInfo = {
2039
- /** Identity public key of the node */
2040
- pubkey: string;
2041
- /** Gossip network address for the node */
2042
- gossip: string | null;
2043
- /** TPU network address for the node (null if not available) */
2044
- tpu: string | null;
2045
- /** JSON RPC network address for the node (null if not available) */
2046
- rpc: string | null;
2047
- /** Software version of the node (null if not available) */
2048
- version: string | null;
2049
- };
2050
- /**
2051
- * Information describing a vote account
2052
- */
2053
- type VoteAccountInfo = {
2054
- /** Public key of the vote account */
2055
- votePubkey: string;
2056
- /** Identity public key of the node voting with this account */
2057
- nodePubkey: string;
2058
- /** The stake, in lamports, delegated to this vote account and activated */
2059
- activatedStake: number;
2060
- /** Whether the vote account is staked for this epoch */
2061
- epochVoteAccount: boolean;
2062
- /** Recent epoch voting credit history for this voter */
2063
- epochCredits: Array<[number, number, number]>;
2064
- /** A percentage (0-100) of rewards payout owed to the voter */
2065
- commission: number;
2066
- /** Most recent slot voted on by this vote account */
2067
- lastVote: number;
2068
- };
2069
- /**
2070
- * A collection of cluster vote accounts
2071
- */
2072
- type VoteAccountStatus = {
2073
- /** Active vote accounts */
2074
- current: Array<VoteAccountInfo>;
2075
- /** Inactive vote accounts */
2076
- delinquent: Array<VoteAccountInfo>;
2077
- };
2078
- /**
2079
- * Network Inflation
2080
- * (see https://docs.solana.com/implemented-proposals/ed_overview)
2081
- */
2082
- type InflationGovernor = {
2083
- foundation: number;
2084
- foundationTerm: number;
2085
- initial: number;
2086
- taper: number;
2087
- terminal: number;
2088
- };
2089
- /**
2090
- * The inflation reward for an epoch
2091
- */
2092
- type InflationReward = {
2093
- /** epoch for which the reward occurs */
2094
- epoch: number;
2095
- /** the slot in which the rewards are effective */
2096
- effectiveSlot: number;
2097
- /** reward amount in lamports */
2098
- amount: number;
2099
- /** post balance of the account in lamports */
2100
- postBalance: number;
2101
- /** vote account commission when the reward was credited */
2102
- commission?: number | null;
2103
- };
2104
- type InflationRate = {
2105
- /** total inflation */
2106
- total: number;
2107
- /** inflation allocated to validators */
2108
- validator: number;
2109
- /** inflation allocated to the foundation */
2110
- foundation: number;
2111
- /** epoch for which these values are valid */
2112
- epoch: number;
2113
- };
2114
- /**
2115
- * Information about the current epoch
2116
- */
2117
- type EpochInfo = {
2118
- epoch: number;
2119
- slotIndex: number;
2120
- slotsInEpoch: number;
2121
- absoluteSlot: number;
2122
- blockHeight?: number;
2123
- transactionCount?: number;
2124
- };
2125
- /**
2126
- * Leader schedule
2127
- * (see https://docs.solana.com/terminology#leader-schedule)
2128
- */
2129
- type LeaderSchedule = {
2130
- [address: string]: number[];
2131
- };
2132
- /**
2133
- * Version info for a node
2134
- */
2135
- type Version = {
2136
- /** Version of solana-core */
2137
- 'solana-core': string;
2138
- 'feature-set'?: number;
2139
- };
2140
- type SimulatedTransactionAccountInfo = {
2141
- /** `true` if this account's data contains a loaded program */
2142
- executable: boolean;
2143
- /** Identifier of the program that owns the account */
2144
- owner: string;
2145
- /** Number of lamports assigned to the account */
2146
- lamports: number;
2147
- /** Optional data assigned to the account */
2148
- data: string[];
2149
- /** Optional rent epoch info for account */
2150
- rentEpoch?: number;
2151
- };
2152
- type TransactionReturnDataEncoding = 'base64';
2153
- type TransactionReturnData = {
2154
- programId: string;
2155
- data: [string, TransactionReturnDataEncoding];
2156
- };
2157
- type SimulateTransactionConfig = {
2158
- /** Optional parameter used to enable signature verification before simulation */
2159
- sigVerify?: boolean;
2160
- /** Optional parameter used to replace the simulated transaction's recent blockhash with the latest blockhash */
2161
- replaceRecentBlockhash?: boolean;
2162
- /** Optional parameter used to set the commitment level when selecting the latest block */
2163
- commitment?: Commitment;
2164
- /** Optional parameter used to specify a list of account addresses to return post simulation state for */
2165
- accounts?: {
2166
- encoding: 'base64';
2167
- addresses: string[];
2168
- };
2169
- /** Optional parameter used to specify the minimum block slot that can be used for simulation */
2170
- minContextSlot?: number;
2171
- };
2172
- type SimulatedTransactionResponse = {
2173
- err: TransactionError | string | null;
2174
- logs: Array<string> | null;
2175
- accounts?: (SimulatedTransactionAccountInfo | null)[] | null;
2176
- unitsConsumed?: number;
2177
- returnData?: TransactionReturnData | null;
2178
- };
2179
- type ParsedInnerInstruction = {
2180
- index: number;
2181
- instructions: (ParsedInstruction | PartiallyDecodedInstruction)[];
2182
- };
2183
- type TokenBalance = {
2184
- accountIndex: number;
2185
- mint: string;
2186
- owner?: string;
2187
- uiTokenAmount: TokenAmount;
2188
- };
2189
- /**
2190
- * Metadata for a parsed confirmed transaction on the ledger
2191
- *
2192
- * @deprecated Deprecated since Solana v1.8.0. Please use {@link ParsedTransactionMeta} instead.
2193
- */
2194
- type ParsedConfirmedTransactionMeta = ParsedTransactionMeta;
2195
- /**
2196
- * Collection of addresses loaded by a transaction using address table lookups
2197
- */
2198
- type LoadedAddresses = {
2199
- writable: Array<PublicKey>;
2200
- readonly: Array<PublicKey>;
2201
- };
2202
- /**
2203
- * Metadata for a parsed transaction on the ledger
2204
- */
2205
- type ParsedTransactionMeta = {
2206
- /** The fee charged for processing the transaction */
2207
- fee: number;
2208
- /** An array of cross program invoked parsed instructions */
2209
- innerInstructions?: ParsedInnerInstruction[] | null;
2210
- /** The balances of the transaction accounts before processing */
2211
- preBalances: Array<number>;
2212
- /** The balances of the transaction accounts after processing */
2213
- postBalances: Array<number>;
2214
- /** An array of program log messages emitted during a transaction */
2215
- logMessages?: Array<string> | null;
2216
- /** The token balances of the transaction accounts before processing */
2217
- preTokenBalances?: Array<TokenBalance> | null;
2218
- /** The token balances of the transaction accounts after processing */
2219
- postTokenBalances?: Array<TokenBalance> | null;
2220
- /** The error result of transaction processing */
2221
- err: TransactionError | null;
2222
- /** The collection of addresses loaded using address lookup tables */
2223
- loadedAddresses?: LoadedAddresses;
2224
- /** The compute units consumed after processing the transaction */
2225
- computeUnitsConsumed?: number;
2226
- };
2227
- type CompiledInnerInstruction = {
2228
- index: number;
2229
- instructions: CompiledInstruction[];
2230
- };
2231
- /**
2232
- * Metadata for a confirmed transaction on the ledger
2233
- */
2234
- type ConfirmedTransactionMeta = {
2235
- /** The fee charged for processing the transaction */
2236
- fee: number;
2237
- /** An array of cross program invoked instructions */
2238
- innerInstructions?: CompiledInnerInstruction[] | null;
2239
- /** The balances of the transaction accounts before processing */
2240
- preBalances: Array<number>;
2241
- /** The balances of the transaction accounts after processing */
2242
- postBalances: Array<number>;
2243
- /** An array of program log messages emitted during a transaction */
2244
- logMessages?: Array<string> | null;
2245
- /** The token balances of the transaction accounts before processing */
2246
- preTokenBalances?: Array<TokenBalance> | null;
2247
- /** The token balances of the transaction accounts after processing */
2248
- postTokenBalances?: Array<TokenBalance> | null;
2249
- /** The error result of transaction processing */
2250
- err: TransactionError | null;
2251
- /** The collection of addresses loaded using address lookup tables */
2252
- loadedAddresses?: LoadedAddresses;
2253
- /** The compute units consumed after processing the transaction */
2254
- computeUnitsConsumed?: number;
2255
- };
2256
- /**
2257
- * A processed transaction from the RPC API
2258
- */
2259
- type TransactionResponse = {
2260
- /** The slot during which the transaction was processed */
2261
- slot: number;
2262
- /** The transaction */
2263
- transaction: {
2264
- /** The transaction message */
2265
- message: Message;
2266
- /** The transaction signatures */
2267
- signatures: string[];
2268
- };
2269
- /** Metadata produced from the transaction */
2270
- meta: ConfirmedTransactionMeta | null;
2271
- /** The unix timestamp of when the transaction was processed */
2272
- blockTime?: number | null;
2273
- };
2274
- /**
2275
- * A processed transaction from the RPC API
2276
- */
2277
- type VersionedTransactionResponse = {
2278
- /** The slot during which the transaction was processed */
2279
- slot: number;
2280
- /** The transaction */
2281
- transaction: {
2282
- /** The transaction message */
2283
- message: VersionedMessage;
2284
- /** The transaction signatures */
2285
- signatures: string[];
2286
- };
2287
- /** Metadata produced from the transaction */
2288
- meta: ConfirmedTransactionMeta | null;
2289
- /** The unix timestamp of when the transaction was processed */
2290
- blockTime?: number | null;
2291
- /** The transaction version */
2292
- version?: TransactionVersion;
2293
- };
2294
- /**
2295
- * A confirmed transaction on the ledger
2296
- *
2297
- * @deprecated Deprecated since Solana v1.8.0.
2298
- */
2299
- type ConfirmedTransaction = {
2300
- /** The slot during which the transaction was processed */
2301
- slot: number;
2302
- /** The details of the transaction */
2303
- transaction: Transaction;
2304
- /** Metadata produced from the transaction */
2305
- meta: ConfirmedTransactionMeta | null;
2306
- /** The unix timestamp of when the transaction was processed */
2307
- blockTime?: number | null;
2308
- };
2309
- /**
2310
- * A partially decoded transaction instruction
2311
- */
2312
- type PartiallyDecodedInstruction = {
2313
- /** Program id called by this instruction */
2314
- programId: PublicKey;
2315
- /** Public keys of accounts passed to this instruction */
2316
- accounts: Array<PublicKey>;
2317
- /** Raw base-58 instruction data */
2318
- data: string;
2319
- };
2320
- /**
2321
- * A parsed transaction message account
2322
- */
2323
- type ParsedMessageAccount = {
2324
- /** Public key of the account */
2325
- pubkey: PublicKey;
2326
- /** Indicates if the account signed the transaction */
2327
- signer: boolean;
2328
- /** Indicates if the account is writable for this transaction */
2329
- writable: boolean;
2330
- /** Indicates if the account key came from the transaction or a lookup table */
2331
- source?: 'transaction' | 'lookupTable';
2332
- };
2333
- /**
2334
- * A parsed transaction instruction
2335
- */
2336
- type ParsedInstruction = {
2337
- /** Name of the program for this instruction */
2338
- program: string;
2339
- /** ID of the program for this instruction */
2340
- programId: PublicKey;
2341
- /** Parsed instruction info */
2342
- parsed: any;
2343
- };
2344
- /**
2345
- * A parsed address table lookup
2346
- */
2347
- type ParsedAddressTableLookup = {
2348
- /** Address lookup table account key */
2349
- accountKey: PublicKey;
2350
- /** Parsed instruction info */
2351
- writableIndexes: number[];
2352
- /** Parsed instruction info */
2353
- readonlyIndexes: number[];
2354
- };
2355
- /**
2356
- * A parsed transaction message
2357
- */
2358
- type ParsedMessage = {
2359
- /** Accounts used in the instructions */
2360
- accountKeys: ParsedMessageAccount[];
2361
- /** The atomically executed instructions for the transaction */
2362
- instructions: (ParsedInstruction | PartiallyDecodedInstruction)[];
2363
- /** Recent blockhash */
2364
- recentBlockhash: string;
2365
- /** Address table lookups used to load additional accounts */
2366
- addressTableLookups?: ParsedAddressTableLookup[] | null;
2367
- };
2368
- /**
2369
- * A parsed transaction
2370
- */
2371
- type ParsedTransaction = {
2372
- /** Signatures for the transaction */
2373
- signatures: Array<string>;
2374
- /** Message of the transaction */
2375
- message: ParsedMessage;
2376
- };
2377
- /**
2378
- * A parsed and confirmed transaction on the ledger
2379
- *
2380
- * @deprecated Deprecated since Solana v1.8.0. Please use {@link ParsedTransactionWithMeta} instead.
2381
- */
2382
- type ParsedConfirmedTransaction = ParsedTransactionWithMeta;
2383
- /**
2384
- * A parsed transaction on the ledger with meta
2385
- */
2386
- type ParsedTransactionWithMeta = {
2387
- /** The slot during which the transaction was processed */
2388
- slot: number;
2389
- /** The details of the transaction */
2390
- transaction: ParsedTransaction;
2391
- /** Metadata produced from the transaction */
2392
- meta: ParsedTransactionMeta | null;
2393
- /** The unix timestamp of when the transaction was processed */
2394
- blockTime?: number | null;
2395
- /** The version of the transaction message */
2396
- version?: TransactionVersion;
2397
- };
2398
- /**
2399
- * A processed block fetched from the RPC API
2400
- */
2401
- type BlockResponse = {
2402
- /** Blockhash of this block */
2403
- blockhash: Blockhash;
2404
- /** Blockhash of this block's parent */
2405
- previousBlockhash: Blockhash;
2406
- /** Slot index of this block's parent */
2407
- parentSlot: number;
2408
- /** Vector of transactions with status meta and original message */
2409
- transactions: Array<{
2410
- /** The transaction */
2411
- transaction: {
2412
- /** The transaction message */
2413
- message: Message;
2414
- /** The transaction signatures */
2415
- signatures: string[];
2416
- };
2417
- /** Metadata produced from the transaction */
2418
- meta: ConfirmedTransactionMeta | null;
2419
- /** The transaction version */
2420
- version?: TransactionVersion;
2421
- }>;
2422
- /** Vector of block rewards */
2423
- rewards?: Array<{
2424
- /** Public key of reward recipient */
2425
- pubkey: string;
2426
- /** Reward value in lamports */
2427
- lamports: number;
2428
- /** Account balance after reward is applied */
2429
- postBalance: number | null;
2430
- /** Type of reward received */
2431
- rewardType: string | null;
2432
- /** Vote account commission when the reward was credited, only present for voting and staking rewards */
2433
- commission?: number | null;
2434
- }>;
2435
- /** The unix timestamp of when the block was processed */
2436
- blockTime: number | null;
2437
- };
2438
- /**
2439
- * A processed block fetched from the RPC API where the `transactionDetails` mode is `accounts`
2440
- */
2441
- type AccountsModeBlockResponse = VersionedAccountsModeBlockResponse;
2442
- /**
2443
- * A processed block fetched from the RPC API where the `transactionDetails` mode is `none`
2444
- */
2445
- type NoneModeBlockResponse = VersionedNoneModeBlockResponse;
2446
- /**
2447
- * A block with parsed transactions
2448
- */
2449
- type ParsedBlockResponse = {
2450
- /** Blockhash of this block */
2451
- blockhash: Blockhash;
2452
- /** Blockhash of this block's parent */
2453
- previousBlockhash: Blockhash;
2454
- /** Slot index of this block's parent */
2455
- parentSlot: number;
2456
- /** Vector of transactions with status meta and original message */
2457
- transactions: Array<{
2458
- /** The details of the transaction */
2459
- transaction: ParsedTransaction;
2460
- /** Metadata produced from the transaction */
2461
- meta: ParsedTransactionMeta | null;
2462
- /** The transaction version */
2463
- version?: TransactionVersion;
2464
- }>;
2465
- /** Vector of block rewards */
2466
- rewards?: Array<{
2467
- /** Public key of reward recipient */
2468
- pubkey: string;
2469
- /** Reward value in lamports */
2470
- lamports: number;
2471
- /** Account balance after reward is applied */
2472
- postBalance: number | null;
2473
- /** Type of reward received */
2474
- rewardType: string | null;
2475
- /** Vote account commission when the reward was credited, only present for voting and staking rewards */
2476
- commission?: number | null;
2477
- }>;
2478
- /** The unix timestamp of when the block was processed */
2479
- blockTime: number | null;
2480
- /** The number of blocks beneath this block */
2481
- blockHeight: number | null;
2482
- };
2483
- /**
2484
- * A block with parsed transactions where the `transactionDetails` mode is `accounts`
2485
- */
2486
- type ParsedAccountsModeBlockResponse = Omit<ParsedBlockResponse, 'transactions'> & {
2487
- transactions: Array<Omit<ParsedBlockResponse['transactions'][number], 'transaction'> & {
2488
- transaction: Pick<ParsedBlockResponse['transactions'][number]['transaction'], 'signatures'> & {
2489
- accountKeys: ParsedMessageAccount[];
2490
- };
2491
- }>;
2492
- };
2493
- /**
2494
- * A block with parsed transactions where the `transactionDetails` mode is `none`
2495
- */
2496
- type ParsedNoneModeBlockResponse = Omit<ParsedBlockResponse, 'transactions'>;
2497
- /**
2498
- * A processed block fetched from the RPC API
2499
- */
2500
- type VersionedBlockResponse = {
2501
- /** Blockhash of this block */
2502
- blockhash: Blockhash;
2503
- /** Blockhash of this block's parent */
2504
- previousBlockhash: Blockhash;
2505
- /** Slot index of this block's parent */
2506
- parentSlot: number;
2507
- /** Vector of transactions with status meta and original message */
2508
- transactions: Array<{
2509
- /** The transaction */
2510
- transaction: {
2511
- /** The transaction message */
2512
- message: VersionedMessage;
2513
- /** The transaction signatures */
2514
- signatures: string[];
2515
- };
2516
- /** Metadata produced from the transaction */
2517
- meta: ConfirmedTransactionMeta | null;
2518
- /** The transaction version */
2519
- version?: TransactionVersion;
2520
- }>;
2521
- /** Vector of block rewards */
2522
- rewards?: Array<{
2523
- /** Public key of reward recipient */
2524
- pubkey: string;
2525
- /** Reward value in lamports */
2526
- lamports: number;
2527
- /** Account balance after reward is applied */
2528
- postBalance: number | null;
2529
- /** Type of reward received */
2530
- rewardType: string | null;
2531
- /** Vote account commission when the reward was credited, only present for voting and staking rewards */
2532
- commission?: number | null;
2533
- }>;
2534
- /** The unix timestamp of when the block was processed */
2535
- blockTime: number | null;
2536
- };
2537
- /**
2538
- * A processed block fetched from the RPC API where the `transactionDetails` mode is `accounts`
2539
- */
2540
- type VersionedAccountsModeBlockResponse = Omit<VersionedBlockResponse, 'transactions'> & {
2541
- transactions: Array<Omit<VersionedBlockResponse['transactions'][number], 'transaction'> & {
2542
- transaction: Pick<VersionedBlockResponse['transactions'][number]['transaction'], 'signatures'> & {
2543
- accountKeys: ParsedMessageAccount[];
2544
- };
2545
- }>;
2546
- };
2547
- /**
2548
- * A processed block fetched from the RPC API where the `transactionDetails` mode is `none`
2549
- */
2550
- type VersionedNoneModeBlockResponse = Omit<VersionedBlockResponse, 'transactions'>;
2551
- /**
2552
- * A confirmed block on the ledger
2553
- *
2554
- * @deprecated Deprecated since Solana v1.8.0.
2555
- */
2556
- type ConfirmedBlock = {
2557
- /** Blockhash of this block */
2558
- blockhash: Blockhash;
2559
- /** Blockhash of this block's parent */
2560
- previousBlockhash: Blockhash;
2561
- /** Slot index of this block's parent */
2562
- parentSlot: number;
2563
- /** Vector of transactions and status metas */
2564
- transactions: Array<{
2565
- transaction: Transaction;
2566
- meta: ConfirmedTransactionMeta | null;
2567
- }>;
2568
- /** Vector of block rewards */
2569
- rewards?: Array<{
2570
- pubkey: string;
2571
- lamports: number;
2572
- postBalance: number | null;
2573
- rewardType: string | null;
2574
- commission?: number | null;
2575
- }>;
2576
- /** The unix timestamp of when the block was processed */
2577
- blockTime: number | null;
2578
- };
2579
- /**
2580
- * A Block on the ledger with signatures only
2581
- */
2582
- type BlockSignatures = {
2583
- /** Blockhash of this block */
2584
- blockhash: Blockhash;
2585
- /** Blockhash of this block's parent */
2586
- previousBlockhash: Blockhash;
2587
- /** Slot index of this block's parent */
2588
- parentSlot: number;
2589
- /** Vector of signatures */
2590
- signatures: Array<string>;
2591
- /** The unix timestamp of when the block was processed */
2592
- blockTime: number | null;
2593
- };
2594
- /**
2595
- * recent block production information
2596
- */
2597
- type BlockProduction = Readonly<{
2598
- /** a dictionary of validator identities, as base-58 encoded strings. Value is a two element array containing the number of leader slots and the number of blocks produced */
2599
- byIdentity: Readonly<Record<string, ReadonlyArray<number>>>;
2600
- /** Block production slot range */
2601
- range: Readonly<{
2602
- /** first slot of the block production information (inclusive) */
2603
- firstSlot: number;
2604
- /** last slot of block production information (inclusive) */
2605
- lastSlot: number;
2606
- }>;
2607
- }>;
2608
- type GetBlockProductionConfig = {
2609
- /** Optional commitment level */
2610
- commitment?: Commitment;
2611
- /** Slot range to return block production for. If parameter not provided, defaults to current epoch. */
2612
- range?: {
2613
- /** first slot to return block production information for (inclusive) */
2614
- firstSlot: number;
2615
- /** last slot to return block production information for (inclusive). If parameter not provided, defaults to the highest slot */
2616
- lastSlot?: number;
2617
- };
2618
- /** Only return results for this validator identity (base-58 encoded) */
2619
- identity?: string;
2620
- };
2621
- /**
2622
- * A performance sample
2623
- */
2624
- type PerfSample = {
2625
- /** Slot number of sample */
2626
- slot: number;
2627
- /** Number of transactions in a sample window */
2628
- numTransactions: number;
2629
- /** Number of slots in a sample window */
2630
- numSlots: number;
2631
- /** Sample window in seconds */
2632
- samplePeriodSecs: number;
2633
- };
2634
- /**
2635
- * Supply
2636
- */
2637
- type Supply = {
2638
- /** Total supply in lamports */
2639
- total: number;
2640
- /** Circulating supply in lamports */
2641
- circulating: number;
2642
- /** Non-circulating supply in lamports */
2643
- nonCirculating: number;
2644
- /** List of non-circulating account addresses */
2645
- nonCirculatingAccounts: Array<PublicKey>;
2646
- };
2647
- /**
2648
- * Token amount object which returns a token amount in different formats
2649
- * for various client use cases.
2650
- */
2651
- type TokenAmount = {
2652
- /** Raw amount of tokens as string ignoring decimals */
2653
- amount: string;
2654
- /** Number of decimals configured for token's mint */
2655
- decimals: number;
2656
- /** Token amount as float, accounts for decimals */
2657
- uiAmount: number | null;
2658
- /** Token amount as string, accounts for decimals */
2659
- uiAmountString?: string;
2660
- };
2661
- /**
2662
- * Token address and balance.
2663
- */
2664
- type TokenAccountBalancePair = {
2665
- /** Address of the token account */
2666
- address: PublicKey;
2667
- /** Raw amount of tokens as string ignoring decimals */
2668
- amount: string;
2669
- /** Number of decimals configured for token's mint */
2670
- decimals: number;
2671
- /** Token amount as float, accounts for decimals */
2672
- uiAmount: number | null;
2673
- /** Token amount as string, accounts for decimals */
2674
- uiAmountString?: string;
2675
- };
2676
- /**
2677
- * Pair of an account address and its balance
2678
- */
2679
- type AccountBalancePair = {
2680
- address: PublicKey;
2681
- lamports: number;
2682
- };
2683
- /**
2684
- * Slot updates which can be used for tracking the live progress of a cluster.
2685
- * - `"firstShredReceived"`: connected node received the first shred of a block.
2686
- * Indicates that a new block that is being produced.
2687
- * - `"completed"`: connected node has received all shreds of a block. Indicates
2688
- * a block was recently produced.
2689
- * - `"optimisticConfirmation"`: block was optimistically confirmed by the
2690
- * cluster. It is not guaranteed that an optimistic confirmation notification
2691
- * will be sent for every finalized blocks.
2692
- * - `"root"`: the connected node rooted this block.
2693
- * - `"createdBank"`: the connected node has started validating this block.
2694
- * - `"frozen"`: the connected node has validated this block.
2695
- * - `"dead"`: the connected node failed to validate this block.
2696
- */
2697
- type SlotUpdate = {
2698
- type: 'firstShredReceived';
2699
- slot: number;
2700
- timestamp: number;
2701
- } | {
2702
- type: 'completed';
2703
- slot: number;
2704
- timestamp: number;
2705
- } | {
2706
- type: 'createdBank';
2707
- slot: number;
2708
- timestamp: number;
2709
- parent: number;
2710
- } | {
2711
- type: 'frozen';
2712
- slot: number;
2713
- timestamp: number;
2714
- stats: {
2715
- numTransactionEntries: number;
2716
- numSuccessfulTransactions: number;
2717
- numFailedTransactions: number;
2718
- maxTransactionsPerEntry: number;
2719
- };
2720
- } | {
2721
- type: 'dead';
2722
- slot: number;
2723
- timestamp: number;
2724
- err: string;
2725
- } | {
2726
- type: 'optimisticConfirmation';
2727
- slot: number;
2728
- timestamp: number;
2729
- } | {
2730
- type: 'root';
2731
- slot: number;
2732
- timestamp: number;
2733
- };
2734
- /**
2735
- * Information about the latest slot being processed by a node
2736
- */
2737
- type SlotInfo = {
2738
- /** Currently processing slot */
2739
- slot: number;
2740
- /** Parent of the current slot */
2741
- parent: number;
2742
- /** The root block of the current slot's fork */
2743
- root: number;
2744
- };
2745
- /**
2746
- * Parsed account data
2747
- */
2748
- type ParsedAccountData = {
2749
- /** Name of the program that owns this account */
2750
- program: string;
2751
- /** Parsed account data */
2752
- parsed: any;
2753
- /** Space used by account data */
2754
- space: number;
2755
- };
2756
- /**
2757
- * Stake Activation data
2758
- */
2759
- type StakeActivationData = {
2760
- /** the stake account's activation state */
2761
- state: 'active' | 'inactive' | 'activating' | 'deactivating';
2762
- /** stake active during the epoch */
2763
- active: number;
2764
- /** stake inactive during the epoch */
2765
- inactive: number;
2766
- };
2767
- /**
2768
- * Data slice argument for getProgramAccounts
2769
- */
2770
- type DataSlice = {
2771
- /** offset of data slice */
2772
- offset: number;
2773
- /** length of data slice */
2774
- length: number;
2775
- };
2776
- /**
2777
- * Memory comparison filter for getProgramAccounts
2778
- */
2779
- type MemcmpFilter = {
2780
- memcmp: {
2781
- /** offset into program account data to start comparison */
2782
- offset: number;
2783
- /** data to match, as base-58 encoded string and limited to less than 129 bytes */
2784
- bytes: string;
2785
- };
2786
- };
2787
- /**
2788
- * Data size comparison filter for getProgramAccounts
2789
- */
2790
- type DataSizeFilter = {
2791
- /** Size of data for program account data length comparison */
2792
- dataSize: number;
2793
- };
2794
- /**
2795
- * A filter object for getProgramAccounts
2796
- */
2797
- type GetProgramAccountsFilter = MemcmpFilter | DataSizeFilter;
2798
- /**
2799
- * Configuration object for getProgramAccounts requests
2800
- */
2801
- type GetProgramAccountsConfig = {
2802
- /** Optional commitment level */
2803
- commitment?: Commitment;
2804
- /** Optional encoding for account data (default base64)
2805
- * To use "jsonParsed" encoding, please refer to `getParsedProgramAccounts` in connection.ts
2806
- * */
2807
- encoding?: 'base64';
2808
- /** Optional data slice to limit the returned account data */
2809
- dataSlice?: DataSlice;
2810
- /** Optional array of filters to apply to accounts */
2811
- filters?: GetProgramAccountsFilter[];
2812
- /** The minimum slot that the request can be evaluated at */
2813
- minContextSlot?: number;
2814
- };
2815
- /**
2816
- * Configuration object for getParsedProgramAccounts
2817
- */
2818
- type GetParsedProgramAccountsConfig = {
2819
- /** Optional commitment level */
2820
- commitment?: Commitment;
2821
- /** Optional array of filters to apply to accounts */
2822
- filters?: GetProgramAccountsFilter[];
2823
- /** The minimum slot that the request can be evaluated at */
2824
- minContextSlot?: number;
2825
- };
2826
- /**
2827
- * Configuration object for getMultipleAccounts
2828
- */
2829
- type GetMultipleAccountsConfig = {
2830
- /** Optional commitment level */
2831
- commitment?: Commitment;
2832
- /** The minimum slot that the request can be evaluated at */
2833
- minContextSlot?: number;
2834
- /** Optional data slice to limit the returned account data */
2835
- dataSlice?: DataSlice;
2836
- };
2837
- /**
2838
- * Configuration object for `getStakeActivation`
2839
- */
2840
- type GetStakeActivationConfig = {
2841
- /** Optional commitment level */
2842
- commitment?: Commitment;
2843
- /** Epoch for which to calculate activation details. If parameter not provided, defaults to current epoch */
2844
- epoch?: number;
2845
- /** The minimum slot that the request can be evaluated at */
2846
- minContextSlot?: number;
2847
- };
2848
- /**
2849
- * Configuration object for `getStakeActivation`
2850
- */
2851
- type GetTokenAccountsByOwnerConfig = {
2852
- /** Optional commitment level */
2853
- commitment?: Commitment;
2854
- /** The minimum slot that the request can be evaluated at */
2855
- minContextSlot?: number;
2856
- };
2857
- /**
2858
- * Configuration object for `getStakeActivation`
2859
- */
2860
- type GetTransactionCountConfig = {
2861
- /** Optional commitment level */
2862
- commitment?: Commitment;
2863
- /** The minimum slot that the request can be evaluated at */
2864
- minContextSlot?: number;
2865
- };
2866
- /**
2867
- * Configuration object for `getNonce`
2868
- */
2869
- type GetNonceConfig = {
2870
- /** Optional commitment level */
2871
- commitment?: Commitment;
2872
- /** The minimum slot that the request can be evaluated at */
2873
- minContextSlot?: number;
2874
- };
2875
- /**
2876
- * Configuration object for `getNonceAndContext`
2877
- */
2878
- type GetNonceAndContextConfig = {
2879
- /** Optional commitment level */
2880
- commitment?: Commitment;
2881
- /** The minimum slot that the request can be evaluated at */
2882
- minContextSlot?: number;
2883
- };
2884
- /**
2885
- * Information describing an account
2886
- */
2887
- type AccountInfo<T> = {
2888
- /** `true` if this account's data contains a loaded program */
2889
- executable: boolean;
2890
- /** Identifier of the program that owns the account */
2891
- owner: PublicKey;
2892
- /** Number of lamports assigned to the account */
2893
- lamports: number;
2894
- /** Optional data assigned to the account */
2895
- data: T;
2896
- /** Optional rent epoch info for account */
2897
- rentEpoch?: number;
2898
- };
2899
- /**
2900
- * Account information identified by pubkey
2901
- */
2902
- type KeyedAccountInfo = {
2903
- accountId: PublicKey;
2904
- accountInfo: AccountInfo<Buffer>;
2905
- };
2906
- /**
2907
- * Callback function for account change notifications
2908
- */
2909
- type AccountChangeCallback = (accountInfo: AccountInfo<Buffer>, context: Context) => void;
2910
- /**
2911
- * Callback function for program account change notifications
2912
- */
2913
- type ProgramAccountChangeCallback = (keyedAccountInfo: KeyedAccountInfo, context: Context) => void;
2914
- /**
2915
- * Callback function for slot change notifications
2916
- */
2917
- type SlotChangeCallback = (slotInfo: SlotInfo) => void;
2918
- /**
2919
- * Callback function for slot update notifications
2920
- */
2921
- type SlotUpdateCallback = (slotUpdate: SlotUpdate) => void;
2922
- /**
2923
- * Callback function for signature status notifications
2924
- */
2925
- type SignatureResultCallback = (signatureResult: SignatureResult, context: Context) => void;
2926
- /**
2927
- * Signature status notification with transaction result
2928
- */
2929
- type SignatureStatusNotification = {
2930
- type: 'status';
2931
- result: SignatureResult;
2932
- };
2933
- /**
2934
- * Signature received notification
2935
- */
2936
- type SignatureReceivedNotification = {
2937
- type: 'received';
2938
- };
2939
- /**
2940
- * Callback function for signature notifications
2941
- */
2942
- type SignatureSubscriptionCallback = (notification: SignatureStatusNotification | SignatureReceivedNotification, context: Context) => void;
2943
- /**
2944
- * Signature subscription options
2945
- */
2946
- type SignatureSubscriptionOptions = {
2947
- commitment?: Commitment;
2948
- enableReceivedNotification?: boolean;
2949
- };
2950
- /**
2951
- * Callback function for root change notifications
2952
- */
2953
- type RootChangeCallback = (root: number) => void;
2954
- /**
2955
- * Logs result.
2956
- */
2957
- type Logs = {
2958
- err: TransactionError | null;
2959
- logs: string[];
2960
- signature: string;
2961
- };
2962
- /**
2963
- * Filter for log subscriptions.
2964
- */
2965
- type LogsFilter = PublicKey | 'all' | 'allWithVotes';
2966
- /**
2967
- * Callback function for log notifications.
2968
- */
2969
- type LogsCallback = (logs: Logs, ctx: Context) => void;
2970
- /**
2971
- * Signature result
2972
- */
2973
- type SignatureResult = {
2974
- err: TransactionError | null;
2975
- };
2976
- /**
2977
- * Transaction error
2978
- */
2979
- type TransactionError = {} | string;
2980
- /**
2981
- * Transaction confirmation status
2982
- * <pre>
2983
- * 'processed': Transaction landed in a block which has reached 1 confirmation by the connected node
2984
- * 'confirmed': Transaction landed in a block which has reached 1 confirmation by the cluster
2985
- * 'finalized': Transaction landed in a block which has been finalized by the cluster
2986
- * </pre>
2987
- */
2988
- type TransactionConfirmationStatus = 'processed' | 'confirmed' | 'finalized';
2989
- /**
2990
- * Signature status
2991
- */
2992
- type SignatureStatus = {
2993
- /** when the transaction was processed */
2994
- slot: number;
2995
- /** the number of blocks that have been confirmed and voted on in the fork containing `slot` */
2996
- confirmations: number | null;
2997
- /** transaction error, if any */
2998
- err: TransactionError | null;
2999
- /** cluster confirmation status, if data available. Possible responses: `processed`, `confirmed`, `finalized` */
3000
- confirmationStatus?: TransactionConfirmationStatus;
3001
- };
3002
- /**
3003
- * A confirmed signature with its status
3004
- */
3005
- type ConfirmedSignatureInfo = {
3006
- /** the transaction signature */
3007
- signature: string;
3008
- /** when the transaction was processed */
3009
- slot: number;
3010
- /** error, if any */
3011
- err: TransactionError | null;
3012
- /** memo associated with the transaction, if any */
3013
- memo: string | null;
3014
- /** The unix timestamp of when the transaction was processed */
3015
- blockTime?: number | null;
3016
- /** Cluster confirmation status, if available. Possible values: `processed`, `confirmed`, `finalized` */
3017
- confirmationStatus?: TransactionConfirmationStatus;
3018
- };
3019
- /**
3020
- * An object defining headers to be passed to the RPC server
3021
- */
3022
- type HttpHeaders = {
3023
- [header: string]: string;
3024
- } & {
3025
- 'solana-client'?: never;
3026
- };
3027
- /**
3028
- * The type of the JavaScript `fetch()` API
3029
- */
3030
- type FetchFn = typeof export_default;
3031
- /**
3032
- * A callback used to augment the outgoing HTTP request
3033
- */
3034
- type FetchMiddleware = (info: Parameters<FetchFn>[0], init: Parameters<FetchFn>[1], fetch: (...a: Parameters<FetchFn>) => void) => void;
3035
- /**
3036
- * Configuration for instantiating a Connection
3037
- */
3038
- type ConnectionConfig = {
3039
- /**
3040
- * An `http.Agent` that will be used to manage socket connections (eg. to implement connection
3041
- * persistence). Set this to `false` to create a connection that uses no agent. This applies to
3042
- * Node environments only.
3043
- */
3044
- httpAgent?: Agent | Agent$1 | false;
3045
- /** Optional commitment level */
3046
- commitment?: Commitment;
3047
- /** Optional endpoint URL to the fullnode JSON RPC PubSub WebSocket Endpoint */
3048
- wsEndpoint?: string;
3049
- /** Optional HTTP headers object */
3050
- httpHeaders?: HttpHeaders;
3051
- /** Optional custom fetch function */
3052
- fetch?: FetchFn;
3053
- /** Optional fetch middleware callback */
3054
- fetchMiddleware?: FetchMiddleware;
3055
- /** Optional Disable retrying calls when server responds with HTTP 429 (Too Many Requests) */
3056
- disableRetryOnRateLimit?: boolean;
3057
- /** time to allow for the server to initially process a transaction (in milliseconds) */
3058
- confirmTransactionInitialTimeout?: number;
3059
- };
3060
- /**
3061
- * A connection to a fullnode JSON RPC endpoint
3062
- */
3063
- export class Connection {
3064
- /**
3065
- * Establish a JSON RPC connection
3066
- *
3067
- * @param endpoint URL to the fullnode JSON RPC endpoint
3068
- * @param commitmentOrConfig optional default commitment level or optional ConnectionConfig configuration object
3069
- */
3070
- constructor(endpoint: string, commitmentOrConfig?: Commitment | ConnectionConfig);
3071
- /**
3072
- * The default commitment used for requests
3073
- */
3074
- get commitment(): Commitment | undefined;
3075
- /**
3076
- * The RPC endpoint
3077
- */
3078
- get rpcEndpoint(): string;
3079
- /**
3080
- * Fetch the balance for the specified public key, return with context
3081
- */
3082
- getBalanceAndContext(publicKey: PublicKey, commitmentOrConfig?: Commitment | GetBalanceConfig): Promise<RpcResponseAndContext<number>>;
3083
- /**
3084
- * Fetch the balance for the specified public key
3085
- */
3086
- getBalance(publicKey: PublicKey, commitmentOrConfig?: Commitment | GetBalanceConfig): Promise<number>;
3087
- /**
3088
- * Fetch the estimated production time of a block
3089
- */
3090
- getBlockTime(slot: number): Promise<number | null>;
3091
- /**
3092
- * Fetch the lowest slot that the node has information about in its ledger.
3093
- * This value may increase over time if the node is configured to purge older ledger data
3094
- */
3095
- getMinimumLedgerSlot(): Promise<number>;
3096
- /**
3097
- * Fetch the slot of the lowest confirmed block that has not been purged from the ledger
3098
- */
3099
- getFirstAvailableBlock(): Promise<number>;
3100
- /**
3101
- * Fetch information about the current supply
3102
- */
3103
- getSupply(config?: GetSupplyConfig | Commitment): Promise<RpcResponseAndContext<Supply>>;
3104
- /**
3105
- * Fetch the current supply of a token mint
3106
- */
3107
- getTokenSupply(tokenMintAddress: PublicKey, commitment?: Commitment): Promise<RpcResponseAndContext<TokenAmount>>;
3108
- /**
3109
- * Fetch the current balance of a token account
3110
- */
3111
- getTokenAccountBalance(tokenAddress: PublicKey, commitment?: Commitment): Promise<RpcResponseAndContext<TokenAmount>>;
3112
- /**
3113
- * Fetch all the token accounts owned by the specified account
3114
- *
3115
- * @return {Promise<RpcResponseAndContext<Array<{pubkey: PublicKey, account: AccountInfo<Buffer>}>>>}
3116
- */
3117
- getTokenAccountsByOwner(ownerAddress: PublicKey, filter: TokenAccountsFilter, commitmentOrConfig?: Commitment | GetTokenAccountsByOwnerConfig): Promise<RpcResponseAndContext<Array<{
3118
- pubkey: PublicKey;
3119
- account: AccountInfo<Buffer>;
3120
- }>>>;
3121
- /**
3122
- * Fetch parsed token accounts owned by the specified account
3123
- *
3124
- * @return {Promise<RpcResponseAndContext<Array<{pubkey: PublicKey, account: AccountInfo<ParsedAccountData>}>>>}
3125
- */
3126
- getParsedTokenAccountsByOwner(ownerAddress: PublicKey, filter: TokenAccountsFilter, commitment?: Commitment): Promise<RpcResponseAndContext<Array<{
3127
- pubkey: PublicKey;
3128
- account: AccountInfo<ParsedAccountData>;
3129
- }>>>;
3130
- /**
3131
- * Fetch the 20 largest accounts with their current balances
3132
- */
3133
- getLargestAccounts(config?: GetLargestAccountsConfig): Promise<RpcResponseAndContext<Array<AccountBalancePair>>>;
3134
- /**
3135
- * Fetch the 20 largest token accounts with their current balances
3136
- * for a given mint.
3137
- */
3138
- getTokenLargestAccounts(mintAddress: PublicKey, commitment?: Commitment): Promise<RpcResponseAndContext<Array<TokenAccountBalancePair>>>;
3139
- /**
3140
- * Fetch all the account info for the specified public key, return with context
3141
- */
3142
- getAccountInfoAndContext(publicKey: PublicKey, commitmentOrConfig?: Commitment | GetAccountInfoConfig): Promise<RpcResponseAndContext<AccountInfo<Buffer> | null>>;
3143
- /**
3144
- * Fetch parsed account info for the specified public key
3145
- */
3146
- getParsedAccountInfo(publicKey: PublicKey, commitmentOrConfig?: Commitment | GetAccountInfoConfig): Promise<RpcResponseAndContext<AccountInfo<Buffer | ParsedAccountData> | null>>;
3147
- /**
3148
- * Fetch all the account info for the specified public key
3149
- */
3150
- getAccountInfo(publicKey: PublicKey, commitmentOrConfig?: Commitment | GetAccountInfoConfig): Promise<AccountInfo<Buffer> | null>;
3151
- /**
3152
- * Fetch all the account info for multiple accounts specified by an array of public keys, return with context
3153
- */
3154
- getMultipleParsedAccounts(publicKeys: PublicKey[], rawConfig?: GetMultipleAccountsConfig): Promise<RpcResponseAndContext<(AccountInfo<Buffer | ParsedAccountData> | null)[]>>;
3155
- /**
3156
- * Fetch all the account info for multiple accounts specified by an array of public keys, return with context
3157
- */
3158
- getMultipleAccountsInfoAndContext(publicKeys: PublicKey[], commitmentOrConfig?: Commitment | GetMultipleAccountsConfig): Promise<RpcResponseAndContext<(AccountInfo<Buffer> | null)[]>>;
3159
- /**
3160
- * Fetch all the account info for multiple accounts specified by an array of public keys
3161
- */
3162
- getMultipleAccountsInfo(publicKeys: PublicKey[], commitmentOrConfig?: Commitment | GetMultipleAccountsConfig): Promise<(AccountInfo<Buffer> | null)[]>;
3163
- /**
3164
- * Returns epoch activation information for a stake account that has been delegated
3165
- */
3166
- getStakeActivation(publicKey: PublicKey, commitmentOrConfig?: Commitment | GetStakeActivationConfig, epoch?: number): Promise<StakeActivationData>;
3167
- /**
3168
- * Fetch all the accounts owned by the specified program id
3169
- *
3170
- * @return {Promise<Array<{pubkey: PublicKey, account: AccountInfo<Buffer>}>>}
3171
- */
3172
- getProgramAccounts(programId: PublicKey, configOrCommitment?: GetProgramAccountsConfig | Commitment): Promise<Array<{
3173
- pubkey: PublicKey;
3174
- account: AccountInfo<Buffer>;
3175
- }>>;
3176
- /**
3177
- * Fetch and parse all the accounts owned by the specified program id
3178
- *
3179
- * @return {Promise<Array<{pubkey: PublicKey, account: AccountInfo<Buffer | ParsedAccountData>}>>}
3180
- */
3181
- getParsedProgramAccounts(programId: PublicKey, configOrCommitment?: GetParsedProgramAccountsConfig | Commitment): Promise<Array<{
3182
- pubkey: PublicKey;
3183
- account: AccountInfo<Buffer | ParsedAccountData>;
3184
- }>>;
3185
- confirmTransaction(strategy: TransactionConfirmationStrategy, commitment?: Commitment): Promise<RpcResponseAndContext<SignatureResult>>;
3186
- /** @deprecated Instead, call `confirmTransaction` and pass in {@link TransactionConfirmationStrategy} */
3187
- confirmTransaction(strategy: TransactionSignature, commitment?: Commitment): Promise<RpcResponseAndContext<SignatureResult>>;
3188
- private getCancellationPromise;
3189
- private getTransactionConfirmationPromise;
3190
- private confirmTransactionUsingBlockHeightExceedanceStrategy;
3191
- private confirmTransactionUsingDurableNonceStrategy;
3192
- private confirmTransactionUsingLegacyTimeoutStrategy;
3193
- /**
3194
- * Return the list of nodes that are currently participating in the cluster
3195
- */
3196
- getClusterNodes(): Promise<Array<ContactInfo>>;
3197
- /**
3198
- * Return the list of nodes that are currently participating in the cluster
3199
- */
3200
- getVoteAccounts(commitment?: Commitment): Promise<VoteAccountStatus>;
3201
- /**
3202
- * Fetch the current slot that the node is processing
3203
- */
3204
- getSlot(commitmentOrConfig?: Commitment | GetSlotConfig): Promise<number>;
3205
- /**
3206
- * Fetch the current slot leader of the cluster
3207
- */
3208
- getSlotLeader(commitmentOrConfig?: Commitment | GetSlotLeaderConfig): Promise<string>;
3209
- /**
3210
- * Fetch `limit` number of slot leaders starting from `startSlot`
3211
- *
3212
- * @param startSlot fetch slot leaders starting from this slot
3213
- * @param limit number of slot leaders to return
3214
- */
3215
- getSlotLeaders(startSlot: number, limit: number): Promise<Array<PublicKey>>;
3216
- /**
3217
- * Fetch the current status of a signature
3218
- */
3219
- getSignatureStatus(signature: TransactionSignature, config?: SignatureStatusConfig): Promise<RpcResponseAndContext<SignatureStatus | null>>;
3220
- /**
3221
- * Fetch the current statuses of a batch of signatures
3222
- */
3223
- getSignatureStatuses(signatures: Array<TransactionSignature>, config?: SignatureStatusConfig): Promise<RpcResponseAndContext<Array<SignatureStatus | null>>>;
3224
- /**
3225
- * Fetch the current transaction count of the cluster
3226
- */
3227
- getTransactionCount(commitmentOrConfig?: Commitment | GetTransactionCountConfig): Promise<number>;
3228
- /**
3229
- * Fetch the current total currency supply of the cluster in lamports
3230
- *
3231
- * @deprecated Deprecated since v1.2.8. Please use {@link getSupply} instead.
3232
- */
3233
- getTotalSupply(commitment?: Commitment): Promise<number>;
3234
- /**
3235
- * Fetch the cluster InflationGovernor parameters
3236
- */
3237
- getInflationGovernor(commitment?: Commitment): Promise<InflationGovernor>;
3238
- /**
3239
- * Fetch the inflation reward for a list of addresses for an epoch
3240
- */
3241
- getInflationReward(addresses: PublicKey[], epoch?: number, commitmentOrConfig?: Commitment | GetInflationRewardConfig): Promise<(InflationReward | null)[]>;
3242
- /**
3243
- * Fetch the specific inflation values for the current epoch
3244
- */
3245
- getInflationRate(): Promise<InflationRate>;
3246
- /**
3247
- * Fetch the Epoch Info parameters
3248
- */
3249
- getEpochInfo(commitmentOrConfig?: Commitment | GetEpochInfoConfig): Promise<EpochInfo>;
3250
- /**
3251
- * Fetch the Epoch Schedule parameters
3252
- */
3253
- getEpochSchedule(): Promise<EpochSchedule>;
3254
- /**
3255
- * Fetch the leader schedule for the current epoch
3256
- * @return {Promise<RpcResponseAndContext<LeaderSchedule>>}
3257
- */
3258
- getLeaderSchedule(): Promise<LeaderSchedule>;
3259
- /**
3260
- * Fetch the minimum balance needed to exempt an account of `dataLength`
3261
- * size from rent
3262
- */
3263
- getMinimumBalanceForRentExemption(dataLength: number, commitment?: Commitment): Promise<number>;
3264
- /**
3265
- * Fetch a recent blockhash from the cluster, return with context
3266
- * @return {Promise<RpcResponseAndContext<{blockhash: Blockhash, feeCalculator: FeeCalculator}>>}
3267
- *
3268
- * @deprecated Deprecated since Solana v1.8.0. Please use {@link getLatestBlockhash} instead.
3269
- */
3270
- getRecentBlockhashAndContext(commitment?: Commitment): Promise<RpcResponseAndContext<{
3271
- blockhash: Blockhash;
3272
- feeCalculator: FeeCalculator;
3273
- }>>;
3274
- /**
3275
- * Fetch recent performance samples
3276
- * @return {Promise<Array<PerfSample>>}
3277
- */
3278
- getRecentPerformanceSamples(limit?: number): Promise<Array<PerfSample>>;
3279
- /**
3280
- * Fetch the fee calculator for a recent blockhash from the cluster, return with context
3281
- *
3282
- * @deprecated Deprecated since Solana v1.8.0. Please use {@link getFeeForMessage} instead.
3283
- */
3284
- getFeeCalculatorForBlockhash(blockhash: Blockhash, commitment?: Commitment): Promise<RpcResponseAndContext<FeeCalculator | null>>;
3285
- /**
3286
- * Fetch the fee for a message from the cluster, return with context
3287
- */
3288
- getFeeForMessage(message: VersionedMessage, commitment?: Commitment): Promise<RpcResponseAndContext<number | null>>;
3289
- /**
3290
- * Fetch a recent blockhash from the cluster
3291
- * @return {Promise<{blockhash: Blockhash, feeCalculator: FeeCalculator}>}
3292
- *
3293
- * @deprecated Deprecated since Solana v1.8.0. Please use {@link getLatestBlockhash} instead.
3294
- */
3295
- getRecentBlockhash(commitment?: Commitment): Promise<{
3296
- blockhash: Blockhash;
3297
- feeCalculator: FeeCalculator;
3298
- }>;
3299
- /**
3300
- * Fetch the latest blockhash from the cluster
3301
- * @return {Promise<BlockhashWithExpiryBlockHeight>}
3302
- */
3303
- getLatestBlockhash(commitmentOrConfig?: Commitment | GetLatestBlockhashConfig): Promise<BlockhashWithExpiryBlockHeight>;
3304
- /**
3305
- * Fetch the latest blockhash from the cluster
3306
- * @return {Promise<BlockhashWithExpiryBlockHeight>}
3307
- */
3308
- getLatestBlockhashAndContext(commitmentOrConfig?: Commitment | GetLatestBlockhashConfig): Promise<RpcResponseAndContext<BlockhashWithExpiryBlockHeight>>;
3309
- /**
3310
- * Fetch the node version
3311
- */
3312
- getVersion(): Promise<Version>;
3313
- /**
3314
- * Fetch the genesis hash
3315
- */
3316
- getGenesisHash(): Promise<string>;
3317
- /**
3318
- * Fetch a processed block from the cluster.
3319
- *
3320
- * @deprecated Instead, call `getBlock` using a `GetVersionedBlockConfig` by
3321
- * setting the `maxSupportedTransactionVersion` property.
3322
- */
3323
- getBlock(slot: number, rawConfig?: GetBlockConfig): Promise<BlockResponse | null>;
3324
- /**
3325
- * @deprecated Instead, call `getBlock` using a `GetVersionedBlockConfig` by
3326
- * setting the `maxSupportedTransactionVersion` property.
3327
- */
3328
- getBlock(slot: number, rawConfig: GetBlockConfig & {
3329
- transactionDetails: 'accounts';
3330
- }): Promise<AccountsModeBlockResponse | null>;
3331
- /**
3332
- * @deprecated Instead, call `getBlock` using a `GetVersionedBlockConfig` by
3333
- * setting the `maxSupportedTransactionVersion` property.
3334
- */
3335
- getBlock(slot: number, rawConfig: GetBlockConfig & {
3336
- transactionDetails: 'none';
3337
- }): Promise<NoneModeBlockResponse | null>;
3338
- /**
3339
- * Fetch a processed block from the cluster.
3340
- */
3341
- getBlock(slot: number, rawConfig?: GetVersionedBlockConfig): Promise<VersionedBlockResponse | null>;
3342
- getBlock(slot: number, rawConfig: GetVersionedBlockConfig & {
3343
- transactionDetails: 'accounts';
3344
- }): Promise<VersionedAccountsModeBlockResponse | null>;
3345
- getBlock(slot: number, rawConfig: GetVersionedBlockConfig & {
3346
- transactionDetails: 'none';
3347
- }): Promise<VersionedNoneModeBlockResponse | null>;
3348
- /**
3349
- * Fetch parsed transaction details for a confirmed or finalized block
3350
- */
3351
- getParsedBlock(slot: number, rawConfig?: GetVersionedBlockConfig): Promise<ParsedAccountsModeBlockResponse>;
3352
- getParsedBlock(slot: number, rawConfig: GetVersionedBlockConfig & {
3353
- transactionDetails: 'accounts';
3354
- }): Promise<ParsedAccountsModeBlockResponse>;
3355
- getParsedBlock(slot: number, rawConfig: GetVersionedBlockConfig & {
3356
- transactionDetails: 'none';
3357
- }): Promise<ParsedNoneModeBlockResponse>;
3358
- getBlockHeight: (commitmentOrConfig?: Commitment | GetBlockHeightConfig) => Promise<number>;
3359
- getBlockProduction(configOrCommitment?: GetBlockProductionConfig | Commitment): Promise<RpcResponseAndContext<BlockProduction>>;
3360
- /**
3361
- * Fetch a confirmed or finalized transaction from the cluster.
3362
- *
3363
- * @deprecated Instead, call `getTransaction` using a
3364
- * `GetVersionedTransactionConfig` by setting the
3365
- * `maxSupportedTransactionVersion` property.
3366
- */
3367
- getTransaction(signature: string, rawConfig?: GetTransactionConfig): Promise<TransactionResponse | null>;
3368
- /**
3369
- * Fetch a confirmed or finalized transaction from the cluster.
3370
- */
3371
- getTransaction(signature: string, rawConfig: GetVersionedTransactionConfig): Promise<VersionedTransactionResponse | null>;
3372
- /**
3373
- * Fetch parsed transaction details for a confirmed or finalized transaction
3374
- */
3375
- getParsedTransaction(signature: TransactionSignature, commitmentOrConfig?: GetVersionedTransactionConfig | Finality): Promise<ParsedTransactionWithMeta | null>;
3376
- /**
3377
- * Fetch parsed transaction details for a batch of confirmed transactions
3378
- */
3379
- getParsedTransactions(signatures: TransactionSignature[], commitmentOrConfig?: GetVersionedTransactionConfig | Finality): Promise<(ParsedTransactionWithMeta | null)[]>;
3380
- /**
3381
- * Fetch transaction details for a batch of confirmed transactions.
3382
- * Similar to {@link getParsedTransactions} but returns a {@link TransactionResponse}.
3383
- *
3384
- * @deprecated Instead, call `getTransactions` using a
3385
- * `GetVersionedTransactionConfig` by setting the
3386
- * `maxSupportedTransactionVersion` property.
3387
- */
3388
- getTransactions(signatures: TransactionSignature[], commitmentOrConfig?: GetTransactionConfig | Finality): Promise<(TransactionResponse | null)[]>;
3389
- /**
3390
- * Fetch transaction details for a batch of confirmed transactions.
3391
- * Similar to {@link getParsedTransactions} but returns a {@link
3392
- * VersionedTransactionResponse}.
3393
- */
3394
- getTransactions(signatures: TransactionSignature[], commitmentOrConfig: GetVersionedTransactionConfig | Finality): Promise<(VersionedTransactionResponse | null)[]>;
3395
- /**
3396
- * Fetch a list of Transactions and transaction statuses from the cluster
3397
- * for a confirmed block.
3398
- *
3399
- * @deprecated Deprecated since v1.13.0. Please use {@link getBlock} instead.
3400
- */
3401
- getConfirmedBlock(slot: number, commitment?: Finality): Promise<ConfirmedBlock>;
3402
- /**
3403
- * Fetch confirmed blocks between two slots
3404
- */
3405
- getBlocks(startSlot: number, endSlot?: number, commitment?: Finality): Promise<Array<number>>;
3406
- /**
3407
- * Fetch a list of Signatures from the cluster for a block, excluding rewards
3408
- */
3409
- getBlockSignatures(slot: number, commitment?: Finality): Promise<BlockSignatures>;
3410
- /**
3411
- * Fetch a list of Signatures from the cluster for a confirmed block, excluding rewards
3412
- *
3413
- * @deprecated Deprecated since Solana v1.8.0. Please use {@link getBlockSignatures} instead.
3414
- */
3415
- getConfirmedBlockSignatures(slot: number, commitment?: Finality): Promise<BlockSignatures>;
3416
- /**
3417
- * Fetch a transaction details for a confirmed transaction
3418
- *
3419
- * @deprecated Deprecated since Solana v1.8.0. Please use {@link getTransaction} instead.
3420
- */
3421
- getConfirmedTransaction(signature: TransactionSignature, commitment?: Finality): Promise<ConfirmedTransaction | null>;
3422
- /**
3423
- * Fetch parsed transaction details for a confirmed transaction
3424
- *
3425
- * @deprecated Deprecated since Solana v1.8.0. Please use {@link getParsedTransaction} instead.
3426
- */
3427
- getParsedConfirmedTransaction(signature: TransactionSignature, commitment?: Finality): Promise<ParsedConfirmedTransaction | null>;
3428
- /**
3429
- * Fetch parsed transaction details for a batch of confirmed transactions
3430
- *
3431
- * @deprecated Deprecated since Solana v1.8.0. Please use {@link getParsedTransactions} instead.
3432
- */
3433
- getParsedConfirmedTransactions(signatures: TransactionSignature[], commitment?: Finality): Promise<(ParsedConfirmedTransaction | null)[]>;
3434
- /**
3435
- * Fetch a list of all the confirmed signatures for transactions involving an address
3436
- * within a specified slot range. Max range allowed is 10,000 slots.
3437
- *
3438
- * @deprecated Deprecated since v1.3. Please use {@link getConfirmedSignaturesForAddress2} instead.
3439
- *
3440
- * @param address queried address
3441
- * @param startSlot start slot, inclusive
3442
- * @param endSlot end slot, inclusive
3443
- */
3444
- getConfirmedSignaturesForAddress(address: PublicKey, startSlot: number, endSlot: number): Promise<Array<TransactionSignature>>;
3445
- /**
3446
- * Returns confirmed signatures for transactions involving an
3447
- * address backwards in time from the provided signature or most recent confirmed block
3448
- *
3449
- *
3450
- * @param address queried address
3451
- * @param options
3452
- */
3453
- getConfirmedSignaturesForAddress2(address: PublicKey, options?: ConfirmedSignaturesForAddress2Options, commitment?: Finality): Promise<Array<ConfirmedSignatureInfo>>;
3454
- /**
3455
- * Returns confirmed signatures for transactions involving an
3456
- * address backwards in time from the provided signature or most recent confirmed block
3457
- *
3458
- *
3459
- * @param address queried address
3460
- * @param options
3461
- */
3462
- getSignaturesForAddress(address: PublicKey, options?: SignaturesForAddressOptions, commitment?: Finality): Promise<Array<ConfirmedSignatureInfo>>;
3463
- getAddressLookupTable(accountKey: PublicKey, config?: GetAccountInfoConfig): Promise<RpcResponseAndContext<AddressLookupTableAccount | null>>;
3464
- /**
3465
- * Fetch the contents of a Nonce account from the cluster, return with context
3466
- */
3467
- getNonceAndContext(nonceAccount: PublicKey, commitmentOrConfig?: Commitment | GetNonceAndContextConfig): Promise<RpcResponseAndContext<NonceAccount | null>>;
3468
- /**
3469
- * Fetch the contents of a Nonce account from the cluster
3470
- */
3471
- getNonce(nonceAccount: PublicKey, commitmentOrConfig?: Commitment | GetNonceConfig): Promise<NonceAccount | null>;
3472
- /**
3473
- * Request an allocation of lamports to the specified address
3474
- *
3475
- * ```typescript
3476
- * import { Connection, PublicKey, LAMPORTS_PER_SOL } from "@solana/web3.js";
3477
- *
3478
- * (async () => {
3479
- * const connection = new Connection("https://api.testnet.solana.com", "confirmed");
3480
- * const myAddress = new PublicKey("2nr1bHFT86W9tGnyvmYW4vcHKsQB3sVQfnddasz4kExM");
3481
- * const signature = await connection.requestAirdrop(myAddress, LAMPORTS_PER_SOL);
3482
- * await connection.confirmTransaction(signature);
3483
- * })();
3484
- * ```
3485
- */
3486
- requestAirdrop(to: PublicKey, lamports: number): Promise<TransactionSignature>;
3487
- /**
3488
- * get the stake minimum delegation
3489
- */
3490
- getStakeMinimumDelegation(config?: GetStakeMinimumDelegationConfig): Promise<RpcResponseAndContext<number>>;
3491
- /**
3492
- * Simulate a transaction
3493
- *
3494
- * @deprecated Instead, call {@link simulateTransaction} with {@link
3495
- * VersionedTransaction} and {@link SimulateTransactionConfig} parameters
3496
- */
3497
- simulateTransaction(transactionOrMessage: Transaction | Message, signers?: Array<Signer>, includeAccounts?: boolean | Array<PublicKey>): Promise<RpcResponseAndContext<SimulatedTransactionResponse>>;
3498
- /**
3499
- * Simulate a transaction
3500
- */
3501
- simulateTransaction(transaction: VersionedTransaction, config?: SimulateTransactionConfig): Promise<RpcResponseAndContext<SimulatedTransactionResponse>>;
3502
- /**
3503
- * Sign and send a transaction
3504
- *
3505
- * @deprecated Instead, call {@link sendTransaction} with a {@link
3506
- * VersionedTransaction}
3507
- */
3508
- sendTransaction(transaction: Transaction, signers: Array<Signer>, options?: SendOptions): Promise<TransactionSignature>;
3509
- /**
3510
- * Send a signed transaction
3511
- */
3512
- sendTransaction(transaction: VersionedTransaction, options?: SendOptions): Promise<TransactionSignature>;
3513
- /**
3514
- * Send a transaction that has already been signed and serialized into the
3515
- * wire format
3516
- */
3517
- sendRawTransaction(rawTransaction: Buffer | Uint8Array | Array<number>, options?: SendOptions): Promise<TransactionSignature>;
3518
- /**
3519
- * Send a transaction that has already been signed, serialized into the
3520
- * wire format, and encoded as a base64 string
3521
- */
3522
- sendEncodedTransaction(encodedTransaction: string, options?: SendOptions): Promise<TransactionSignature>;
3523
- /**
3524
- * Register a callback to be invoked whenever the specified account changes
3525
- *
3526
- * @param publicKey Public key of the account to monitor
3527
- * @param callback Function to invoke whenever the account is changed
3528
- * @param commitment Specify the commitment level account changes must reach before notification
3529
- * @return subscription id
3530
- */
3531
- onAccountChange(publicKey: PublicKey, callback: AccountChangeCallback, commitment?: Commitment): ClientSubscriptionId;
3532
- /**
3533
- * Deregister an account notification callback
3534
- *
3535
- * @param id client subscription id to deregister
3536
- */
3537
- removeAccountChangeListener(clientSubscriptionId: ClientSubscriptionId): Promise<void>;
3538
- /**
3539
- * Register a callback to be invoked whenever accounts owned by the
3540
- * specified program change
3541
- *
3542
- * @param programId Public key of the program to monitor
3543
- * @param callback Function to invoke whenever the account is changed
3544
- * @param commitment Specify the commitment level account changes must reach before notification
3545
- * @param filters The program account filters to pass into the RPC method
3546
- * @return subscription id
3547
- */
3548
- onProgramAccountChange(programId: PublicKey, callback: ProgramAccountChangeCallback, commitment?: Commitment, filters?: GetProgramAccountsFilter[]): ClientSubscriptionId;
3549
- /**
3550
- * Deregister an account notification callback
3551
- *
3552
- * @param id client subscription id to deregister
3553
- */
3554
- removeProgramAccountChangeListener(clientSubscriptionId: ClientSubscriptionId): Promise<void>;
3555
- /**
3556
- * Registers a callback to be invoked whenever logs are emitted.
3557
- */
3558
- onLogs(filter: LogsFilter, callback: LogsCallback, commitment?: Commitment): ClientSubscriptionId;
3559
- /**
3560
- * Deregister a logs callback.
3561
- *
3562
- * @param id client subscription id to deregister.
3563
- */
3564
- removeOnLogsListener(clientSubscriptionId: ClientSubscriptionId): Promise<void>;
3565
- /**
3566
- * Register a callback to be invoked upon slot changes
3567
- *
3568
- * @param callback Function to invoke whenever the slot changes
3569
- * @return subscription id
3570
- */
3571
- onSlotChange(callback: SlotChangeCallback): ClientSubscriptionId;
3572
- /**
3573
- * Deregister a slot notification callback
3574
- *
3575
- * @param id client subscription id to deregister
3576
- */
3577
- removeSlotChangeListener(clientSubscriptionId: ClientSubscriptionId): Promise<void>;
3578
- /**
3579
- * Register a callback to be invoked upon slot updates. {@link SlotUpdate}'s
3580
- * may be useful to track live progress of a cluster.
3581
- *
3582
- * @param callback Function to invoke whenever the slot updates
3583
- * @return subscription id
3584
- */
3585
- onSlotUpdate(callback: SlotUpdateCallback): ClientSubscriptionId;
3586
- /**
3587
- * Deregister a slot update notification callback
3588
- *
3589
- * @param id client subscription id to deregister
3590
- */
3591
- removeSlotUpdateListener(clientSubscriptionId: ClientSubscriptionId): Promise<void>;
3592
- _buildArgs(args: Array<any>, override?: Commitment, encoding?: 'jsonParsed' | 'base64', extra?: any): Array<any>;
3593
- /**
3594
- * Register a callback to be invoked upon signature updates
3595
- *
3596
- * @param signature Transaction signature string in base 58
3597
- * @param callback Function to invoke on signature notifications
3598
- * @param commitment Specify the commitment level signature must reach before notification
3599
- * @return subscription id
3600
- */
3601
- onSignature(signature: TransactionSignature, callback: SignatureResultCallback, commitment?: Commitment): ClientSubscriptionId;
3602
- /**
3603
- * Register a callback to be invoked when a transaction is
3604
- * received and/or processed.
3605
- *
3606
- * @param signature Transaction signature string in base 58
3607
- * @param callback Function to invoke on signature notifications
3608
- * @param options Enable received notifications and set the commitment
3609
- * level that signature must reach before notification
3610
- * @return subscription id
3611
- */
3612
- onSignatureWithOptions(signature: TransactionSignature, callback: SignatureSubscriptionCallback, options?: SignatureSubscriptionOptions): ClientSubscriptionId;
3613
- /**
3614
- * Deregister a signature notification callback
3615
- *
3616
- * @param id client subscription id to deregister
3617
- */
3618
- removeSignatureListener(clientSubscriptionId: ClientSubscriptionId): Promise<void>;
3619
- /**
3620
- * Register a callback to be invoked upon root changes
3621
- *
3622
- * @param callback Function to invoke whenever the root changes
3623
- * @return subscription id
3624
- */
3625
- onRootChange(callback: RootChangeCallback): ClientSubscriptionId;
3626
- /**
3627
- * Deregister a root notification callback
3628
- *
3629
- * @param id client subscription id to deregister
3630
- */
3631
- removeRootChangeListener(clientSubscriptionId: ClientSubscriptionId): Promise<void>;
3632
- }
3633
-
3634
- export const BPF_LOADER_PROGRAM_ID: PublicKey;
3635
- /**
3636
- * Factory class for transactions to interact with a program loader
3637
- */
3638
- export class BpfLoader {
3639
- /**
3640
- * Minimum number of signatures required to load a program not including
3641
- * retries
3642
- *
3643
- * Can be used to calculate transaction fees
3644
- */
3645
- static getMinNumSignatures(dataLength: number): number;
3646
- /**
3647
- * Load a SBF program
3648
- *
3649
- * @param connection The connection to use
3650
- * @param payer Account that will pay program loading fees
3651
- * @param program Account to load the program into
3652
- * @param elf The entire ELF containing the SBF program
3653
- * @param loaderProgramId The program id of the BPF loader to use
3654
- * @return true if program was loaded successfully, false if program was already loaded
3655
- */
3656
- static load(connection: Connection, payer: Signer, program: Signer, elf: Buffer | Uint8Array | Array<number>, loaderProgramId: PublicKey): Promise<boolean>;
3657
- }
3658
-
3659
- export class SendTransactionError extends Error {
3660
- logs: string[] | undefined;
3661
- constructor(message: string, logs?: string[]);
3662
- }
3663
- export const SolanaJSONRPCErrorCode: {
3664
- readonly JSON_RPC_SERVER_ERROR_BLOCK_CLEANED_UP: -32001;
3665
- readonly JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE: -32002;
3666
- readonly JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE: -32003;
3667
- readonly JSON_RPC_SERVER_ERROR_BLOCK_NOT_AVAILABLE: -32004;
3668
- readonly JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY: -32005;
3669
- readonly JSON_RPC_SERVER_ERROR_TRANSACTION_PRECOMPILE_VERIFICATION_FAILURE: -32006;
3670
- readonly JSON_RPC_SERVER_ERROR_SLOT_SKIPPED: -32007;
3671
- readonly JSON_RPC_SERVER_ERROR_NO_SNAPSHOT: -32008;
3672
- readonly JSON_RPC_SERVER_ERROR_LONG_TERM_STORAGE_SLOT_SKIPPED: -32009;
3673
- readonly JSON_RPC_SERVER_ERROR_KEY_EXCLUDED_FROM_SECONDARY_INDEX: -32010;
3674
- readonly JSON_RPC_SERVER_ERROR_TRANSACTION_HISTORY_NOT_AVAILABLE: -32011;
3675
- readonly JSON_RPC_SCAN_ERROR: -32012;
3676
- readonly JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_LEN_MISMATCH: -32013;
3677
- readonly JSON_RPC_SERVER_ERROR_BLOCK_STATUS_NOT_AVAILABLE_YET: -32014;
3678
- readonly JSON_RPC_SERVER_ERROR_UNSUPPORTED_TRANSACTION_VERSION: -32015;
3679
- readonly JSON_RPC_SERVER_ERROR_MIN_CONTEXT_SLOT_NOT_REACHED: -32016;
3680
- };
3681
- type SolanaJSONRPCErrorCodeEnum = typeof SolanaJSONRPCErrorCode[keyof typeof SolanaJSONRPCErrorCode];
3682
- export class SolanaJSONRPCError extends Error {
3683
- code: SolanaJSONRPCErrorCodeEnum | unknown;
3684
- data?: any;
3685
- constructor({ code, message, data, }: Readonly<{
3686
- code: unknown;
3687
- message: string;
3688
- data?: any;
3689
- }>, customMessage?: string);
3690
- }
3691
-
3692
- /**
3693
- * Program loader interface
3694
- */
3695
- export class Loader {
3696
- /**
3697
- * Amount of program data placed in each load Transaction
3698
- */
3699
- static chunkSize: number;
3700
- /**
3701
- * Minimum number of signatures required to load a program not including
3702
- * retries
3703
- *
3704
- * Can be used to calculate transaction fees
3705
- */
3706
- static getMinNumSignatures(dataLength: number): number;
3707
- /**
3708
- * Loads a generic program
3709
- *
3710
- * @param connection The connection to use
3711
- * @param payer System account that pays to load the program
3712
- * @param program Account to load the program into
3713
- * @param programId Public key that identifies the loader
3714
- * @param data Program octets
3715
- * @return true if program was loaded successfully, false if program was already loaded
3716
- */
3717
- static load(connection: Connection, payer: Signer, program: Signer, programId: PublicKey, data: Buffer | Uint8Array | Array<number>): Promise<boolean>;
3718
- }
3719
-
3720
- export const VALIDATOR_INFO_KEY: PublicKey;
3721
- /**
3722
- * Info used to identity validators.
3723
- */
3724
- type Info = {
3725
- /** validator name */
3726
- name: string;
3727
- /** optional, validator website */
3728
- website?: string;
3729
- /** optional, extra information the validator chose to share */
3730
- details?: string;
3731
- /** optional, used to identify validators on keybase.io */
3732
- keybaseUsername?: string;
3733
- };
3734
- /**
3735
- * ValidatorInfo class
3736
- */
3737
- export class ValidatorInfo {
3738
- /**
3739
- * validator public key
3740
- */
3741
- key: PublicKey;
3742
- /**
3743
- * validator information
3744
- */
3745
- info: Info;
3746
- /**
3747
- * Construct a valid ValidatorInfo
3748
- *
3749
- * @param key validator public key
3750
- * @param info validator information
3751
- */
3752
- constructor(key: PublicKey, info: Info);
3753
- /**
3754
- * Deserialize ValidatorInfo from the config account data. Exactly two config
3755
- * keys are required in the data.
3756
- *
3757
- * @param buffer config account data
3758
- * @return null if info was not found
3759
- */
3760
- static fromConfigData(buffer: Buffer | Uint8Array | Array<number>): ValidatorInfo | null;
3761
- }
3762
-
3763
- export const VOTE_PROGRAM_ID: PublicKey;
3764
- type Lockout = {
3765
- slot: number;
3766
- confirmationCount: number;
3767
- };
3768
- /**
3769
- * History of how many credits earned by the end of each epoch
3770
- */
3771
- type EpochCredits = Readonly<{
3772
- epoch: number;
3773
- credits: number;
3774
- prevCredits: number;
3775
- }>;
3776
- type AuthorizedVoter = Readonly<{
3777
- epoch: number;
3778
- authorizedVoter: PublicKey;
3779
- }>;
3780
- type PriorVoter = Readonly<{
3781
- authorizedPubkey: PublicKey;
3782
- epochOfLastAuthorizedSwitch: number;
3783
- targetEpoch: number;
3784
- }>;
3785
- type BlockTimestamp = Readonly<{
3786
- slot: number;
3787
- timestamp: number;
3788
- }>;
3789
- /**
3790
- * VoteAccount class
3791
- */
3792
- export class VoteAccount {
3793
- nodePubkey: PublicKey;
3794
- authorizedWithdrawer: PublicKey;
3795
- commission: number;
3796
- rootSlot: number | null;
3797
- votes: Lockout[];
3798
- authorizedVoters: AuthorizedVoter[];
3799
- priorVoters: PriorVoter[];
3800
- epochCredits: EpochCredits[];
3801
- lastTimestamp: BlockTimestamp;
3802
- /**
3803
- * Deserialize VoteAccount from the account data.
3804
- *
3805
- * @param buffer account data
3806
- * @return VoteAccount
3807
- */
3808
- static fromAccountData(buffer: Buffer | Uint8Array | Array<number>): VoteAccount;
3809
- }
3810
-
3811
- export const SYSVAR_CLOCK_PUBKEY: PublicKey;
3812
- export const SYSVAR_EPOCH_SCHEDULE_PUBKEY: PublicKey;
3813
- export const SYSVAR_INSTRUCTIONS_PUBKEY: PublicKey;
3814
- export const SYSVAR_RECENT_BLOCKHASHES_PUBKEY: PublicKey;
3815
- export const SYSVAR_RENT_PUBKEY: PublicKey;
3816
- export const SYSVAR_REWARDS_PUBKEY: PublicKey;
3817
- export const SYSVAR_SLOT_HASHES_PUBKEY: PublicKey;
3818
- export const SYSVAR_SLOT_HISTORY_PUBKEY: PublicKey;
3819
- export const SYSVAR_STAKE_HISTORY_PUBKEY: PublicKey;
3820
-
3821
- type Cluster = 'devnet' | 'testnet' | 'mainnet-beta';
3822
- /**
3823
- * Retrieves the RPC API URL for the specified cluster
3824
- */
3825
- export function clusterApiUrl(cluster?: Cluster, tls?: boolean): string;
3826
-
3827
- /**
3828
- * Send and confirm a raw transaction
3829
- *
3830
- * If `commitment` option is not specified, defaults to 'max' commitment.
3831
- *
3832
- * @param {Connection} connection
3833
- * @param {Buffer} rawTransaction
3834
- * @param {TransactionConfirmationStrategy} confirmationStrategy
3835
- * @param {ConfirmOptions} [options]
3836
- * @returns {Promise<TransactionSignature>}
3837
- */
3838
- export function sendAndConfirmRawTransaction(connection: Connection, rawTransaction: Buffer, confirmationStrategy: TransactionConfirmationStrategy, options?: ConfirmOptions): Promise<TransactionSignature>;
3839
- /**
3840
- * @deprecated Calling `sendAndConfirmRawTransaction()` without a `confirmationStrategy`
3841
- * is no longer supported and will be removed in a future version.
3842
- */
3843
- export function sendAndConfirmRawTransaction(connection: Connection, rawTransaction: Buffer, options?: ConfirmOptions): Promise<TransactionSignature>;
3844
-
3845
- /**
3846
- * Sign, send and confirm a transaction.
3847
- *
3848
- * If `commitment` option is not specified, defaults to 'max' commitment.
3849
- *
3850
- * @param {Connection} connection
3851
- * @param {Transaction} transaction
3852
- * @param {Array<Signer>} signers
3853
- * @param {ConfirmOptions} [options]
3854
- * @returns {Promise<TransactionSignature>}
3855
- */
3856
- export function sendAndConfirmTransaction(connection: Connection, transaction: Transaction, signers: Array<Signer>, options?: ConfirmOptions & Readonly<{
3857
- abortSignal?: AbortSignal;
3858
- }>): Promise<TransactionSignature>;
3859
-
3860
- /**
3861
- * There are 1-billion lamports in one SOL
3862
- */
3863
- export const LAMPORTS_PER_SOL = 1000000000;
3864
-
3865
- }