Transactions in the current epoch:
Transaction ID | Date | Block Number | Value (STEEM) | Status | Actions |
---|---|---|---|---|---|
Transaction ID: TX1234567890 | 2023-02-20 14:30:00 UTC | Block #120001 | 1.000 STEEM | Pending | View Transaction Cancel |
Transaction ID: TX2345678901 | 2023-02-20 14:35:00 UTC | Block #120001 | 0.500 STEEM | Pending | View Transaction Cancel |
I am building a Steem blockchain explorer, and I would like to make use of the steemd
library. This will allow me to interact with the Steem blockchain.
To start, you'll need to create an instance of the Steem
class, which is the entry point for most interactions with the Steem network.
Here's a basic example:
const Steem = require('steemd');
const steem = new Steem();
The above code creates an instance of the Steem
class, without specifying any parameters.
Next, you may want to use some of the various methods available on this instance. Here are some examples that we will go through:
- Getting the current epoch:
To get the current epoch (a 24-hour block interval), you can simply call the get_epoch()
method:
steem.get_epoch((err, result) => {
console.log(result);
});
The above code logs the current epoch to the console.
- Getting transactions in a given epoch:
To get all transactions within a certain epoch, use the get_transactions()
method. Here's how you can do it:
const startDate = '2023-02-19 00:00:00 UTC'; // Adjust date as needed
const endDate = '2023-02-20 23:59:59 UTC'; // Adjust date as needed
steem.get_transactions(startDate, endDate, (err, result) => {
console.log(result);
});
The above code logs all transactions within the specified epoch to the console.
For example:
const Steem = require('steemd');
const steem = new Steem();
// 1. Get current epoch
steem.get_epoch((err, result) => {
console.log("Current Epoch:", result);
});
// 2. Get transactions in a given epoch
const startDate = '2023-02-19 00:00:00 UTC'; // Adjust date as needed
const endDate = '2023-02-20 23:59:59 UTC'; // Adjust date as needed
steem.get_transactions(startDate, endDate, (err, result) => {
console.log("Transactions in epoch:", result);
});
You can replace the hardcoded dates with a dynamic way of calculating them. This will give you more flexibility when using this code.
Note: Make sure to install the steemd
library by running npm install steemd
or yarn add steemd
in your project directory before running the above code.