feat: add getEstimatedFee to Transaction (#23579)

This commit is contained in:
Marc Jaramillo
2022-03-11 09:05:22 -08:00
committed by GitHub
parent 4f18d73281
commit 2bff36dfba
2 changed files with 32 additions and 0 deletions

View File

@@ -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.