@solana/web3.js 0.0.0-next

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