feat: add getEstimatedFee to Transaction (#23579)
This commit is contained in:
@@ -2,6 +2,7 @@ import nacl from 'tweetnacl';
|
||||
import bs58 from 'bs58';
|
||||
import {Buffer} from 'buffer';
|
||||
|
||||
import {Connection} from './connection';
|
||||
import {Message} from './message';
|
||||
import {PublicKey} from './publickey';
|
||||
import * as shortvec from './util/shortvec-encoding';
|
||||
@@ -405,6 +406,13 @@ export class Transaction {
|
||||
return this._compile().serialize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the estimated fee associated with a transaction
|
||||
*/
|
||||
async getEstimatedFee(connection: Connection): Promise<number> {
|
||||
return (await connection.getFeeForMessage(this.compileMessage())).value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify the public keys which will be used to sign the Transaction.
|
||||
* The first signer will be used as the transaction fee payer account.
|
||||
|
Reference in New Issue
Block a user