An Unknown writer once said that;
"Procrastination is the grave in which opportunity is buried."
And I would agree that I have wasted a lot of opportunities both this year and in the past. Programming-related chances make up the majority of these, and I wish this would never happen.
If you're unfamiliar, I'm a front-end developer who uses the stacks ReactJS, NextJs, and EtherJs/Web3js. Even while it might seem like I've been working on web3-related apps for a while, I've just been concentrating on the EVM side of things, while sometimes document my journey on my hive blog.
I haven't been active here because programming every day to fulfill deadlines and updating my blog is exhausting. But a few days ago, I stumbled on an EVM bug, I fixed it, and decided to blog about it here.
The above paragraph seems to sound good because it feels like I am making progress in my programming journey. But for some reason, I feel like I'm falling behind in my development on the hive blockchain.
Gradually Becoming A Hive Dev
I, therefore, made the decision last week to begin studying how to build on the Hive network using https://developers.hive.io. I must admit that it has been enjoyable, and I keep kicking myself for not doing it sooner.
I've been using the Hive blockchain for six years, and for roughly five of those years, I've been an active user. This simply means I have a good idea of how much the Hive blockchain has evolved. This on other hand got me overwhelmed thinking working on a blockchain code will be tremendous. But I was wrong. Maybe because I already have programming skills.
The New Trend That Helps Everyone
For those who don't know, there has been a huge buzz on the net about how artificial intelligence is coming for our jobs. Yes, you read it right. AI is here to stay for sure. I watched a few youtube videos where ChatGPT seamlessly wrote codes. Those codes were compiled and ran fine as if they were written by humans.
Now back to whether AI is coming for our jobs, I don't think so. But I know for sure that AI is making work/jobs effective in specific ways. AI platforms like ChatGPT can be seen as an advanced google search/StackOverflow where solutions to problems can be gotten as responses after entering keywords in the chat.
AI should be seen as a tool that can help developers save time and focus on more complex and creative tasks, rather than a tool that is coming for everyone's job.
My experience with An AI
After watching videos and seeing how amazing ways AI could be utilized, I decided to test it with a coding exercise. Not just a random one but a Hive-related one. Below is the question I entered;
How to listen to hive blockchain data with javascript
It took about 5 seconds before it started printing out responses. And guess what? It printed out a sample code to stream transactions on the hive blockchain.
// Import the Hive JavaScript library
const hive = require("@hiveio/hive-js");
// Connect to the Hive blockchain
hive.api.setOptions({ url: "https://api.hive.blog" });
// Listen for new transactions on the Hive blockchain
hive.api.streamTransactions((err, result) => {
if (err) {
// Handle error
} else {
// Process the transaction data
console.log(result);
}
});
Immediately, I went wow!!! because this is exactly what I am currently learning on https://developers.hive.io/. Additionally, the AI didn't just print out the code but also explanations for the codes.
To listen to data on the Hive blockchain using JavaScript, you can use the Hive JavaScript library, which provides access to the Hive API. This library allows you to query the Hive blockchain and receive real-time data updates using WebSockets.
Here is an example of how you can use the Hive JavaScript library to listen to data on the Hive blockchain:
In this example, the
hive.api.streamTransactions
function is used to listen for new transactions on the Hive blockchain. Whenever a new transaction is processed, the provided callback function will be called with the transaction data as an argument. You can then use this data to perform any actions you need.
Note that this example uses the Hive JavaScript library to connect to the Hive blockchain and listen for new transactions. To use this library, you will need to install it using npm (
npm install @hiveio/hive-js
) and import it into your JavaScript code.
The explanation was a quick guide to understanding the codes. I didn't just end it there as I installed the needed NPM package and ran the code. And yes, I got an object response containing information relating to the latest block on Hive.
{
block_num: 70472252;
expiration: "2022-12-12T22:35:36";
extensions: [];
operations: [Array(2)];
ref_block_num: 21049;
ref_block_prefix: 1463341717;
signatures: [
"2034583cb988e237abb2518c9699b25b71d5b0efa57ee5d019…cacbf68e4d111daa83a524ada16b16e998fe7c32485719c0d",
];
transaction_id: "d17915381cbcc89f4a4e495bcc16226425841ecc";
transaction_num: 176;
}
ChatGPT is one of the best AI platforms I have ever come across and I am sure more will surface soonest. But for now, I will keep enjoying the beauty of ChatGPT.
What do you think about ChatGPT ?