@solana/web3.js 1.38.0 → 1.40.0

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