-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #73 from Premian-Labs/feat/gas-api
Add simple GasAPI
- Loading branch information
Showing
4 changed files
with
34 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { JsonRpcProvider } from 'ethers' | ||
import { BaseAPI } from './baseAPI' | ||
|
||
/** | ||
* Represents a class for managing gas in transactions. | ||
* | ||
* @class GasAPI | ||
* @extends {BaseAPI} | ||
*/ | ||
export class GasAPI extends BaseAPI { | ||
/** | ||
* Returns a promise containing the gas price. | ||
* @returns {Promise<bigint>} Promise containing the gas price. | ||
*/ | ||
async getGasPrice(): Promise<bigint> { | ||
const price = await (this.premia.provider as JsonRpcProvider).send( | ||
'eth_gasPrice', | ||
[] | ||
) | ||
return BigInt(price) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters