UNPKG

@volare.finance/utils.js

Version:
50 lines 2.27 kB
"use strict"; /** * @file provider.ts * @author astra <astra@volare.finance> * @date 2022 */ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const dotenv_1 = require("dotenv"); const src_1 = require("../src"); (0, dotenv_1.config)({ path: '.env', encoding: 'utf8', }); const ENDPOINT = String(process.env.ENDPOINT); const txHash = '0x16e7d077c07ea37868c4673f62163305e65cfa2e7711ee9f422024be1061a910'; const address = '0x1436ea4bb8548447016bd3e838920b2260a2b41d'; (() => tslib_1.__awaiter(void 0, void 0, void 0, function* () { src_1.Provider.Init(ENDPOINT); console.log('IsInited', src_1.Provider.IsInited()); console.log('ChainId', yield src_1.Provider.ChainId()); const txCount = yield src_1.Provider.GetTransactionCount(address); console.log('txCount', txCount); const tx = yield src_1.Provider.GetTransaction(txHash); console.log('tx', tx); const txReceipt = yield src_1.Provider.GetTransactionReceipt(txHash); console.log('txReceipt', txReceipt); const reason = yield src_1.Provider.GetTransactionFailedReason(tx); console.log('reason', reason); const gasPrice = yield src_1.Provider.GetGasPrice(); console.log('gasPrice', gasPrice.toString()); const gasLimit = yield src_1.Provider.EstimateGas({ to: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', value: 1 }); console.log('gasLimit', gasLimit.toString()); // ---------------- const provider = new src_1.Provider(ENDPOINT); console.log('ChainId', yield provider.chainId()); const txCount1 = yield provider.getTransactionCount(address); console.log('txCount', txCount1); const tx1 = yield provider.getTransaction(txHash); console.log('tx', tx1); const txReceipt1 = yield provider.getTransactionReceipt(txHash); console.log('txReceipt', txReceipt1); const reason1 = yield provider.getTransactionFailedReason(tx); console.log('reason', reason1); const gasPrice1 = yield provider.getGasPrice(); console.log('gasPrice', gasPrice1.toString()); const gasLimit1 = yield provider.estimateGas({ to: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', value: 1 }); console.log('gasLimit', gasLimit1.toString()); }))(); //# sourceMappingURL=provider.js.map