Introducing golem-js 3.5 release
Dear golem-js
developer community,
We are thrilled to announce the official release of golem-js
version 3.5! This exciting update brings powerful new features designed to enhance our ecosystem and empower developers like you to contribute and innovate. Here’s a peek at what’s new:
🆕 Introducing the Plugin System
We're excited to open up new avenues for developers who want to contribute to the Golem Network Ecosystem but may not have the resources to join as core-library (golem-js
) developers. With our new plugin system, if you have some experience with golem-js
, you can now develop impactful plugins and be an integral part of the Golem Network as a plugin developer.
Dive into our extensive Golem Network Plugins documentation stored in the golem-js
project repository to get started. Once your plugin is ready, share it with the community via NPM or any platform of your choice. Don't forget to inform us about your plugin—we're eager to showcase it in our list of community-maintained golem-js
plugins! 📢
Below is a quick example to get you inspired on how to build a plugin for golem-js
:
import { GolemNetwork, GolemPluginInitializer } from "@golem-sdk/golem-js";
/**
* Example plugin that tracks unique provider ID/name pairs on the market
*/
const providerTracker: GolemPluginInitializer = (glm) => {
const seenProviders: { id: string; name: string }[] = [];
glm.market.events.on("offerProposalReceived", (event) => {
const { id, name } = event.offerProposal.provider;
const providerInfo = { id, name };
if (!seenProviders.includes(providerInfo)) {
seenProviders.push(providerInfo);
console.log("Saw new provider %s named %s", id, name);
}
});
// Return a cleanup function that will be executed during the `disconnect`
return () => {
console.log("Provider tracker found a total of %d providers", seenProviders.length);
};
};
const glm = new GolemNetwork();
// Register the plugin that will be initialized during `connect` call
glm.use(providerTracker);
🧪 Experimental Feature: Volume Definitions
The upcoming yagna
0.17
release brings an innovative feature for defining volumes during the deployment of activities on the provider—a highly anticipated capability by developers of serious Golem-based applications.
This version of golem-js
introduces the API (check out the related PR) that you can leverage with the preview versions of 0.17
and fully utilize once 0.17
is released.
Check out the following example showcasing this new feature in action:
import { GolemNetwork } from "@golem-sdk/golem-js";
(async () => {
const glm = new GolemNetwork({
payment: {
network: "holesky",
},
});
try {
console.log("Connecting to Golem Network");
await glm.connect();
console.log("Acquiring resources from the market");
const rental = await glm.oneOf({
order: {
demand: {
workload: {
imageTag: "golem/node:latest",
minStorageGib: 1,
runtime: {
version: "0.5.2",
},
},
},
market: {
rentHours: 15 / 60,
pricing: {
avgGlmPerHour: 1,
model: "burn-rate",
},
},
},
volumes: {
data: {
path: "/custom-data",
sizeGib: 1,
},
files: {
path: "/custom-files",
sizeGib: 1,
},
},
});
console.log("Deploying workload to the rental");
const exe = await rental.getExeUnit();
console.log("Running command on the workload");
const result = await exe.run("df -h");
console.log(result.stdout?.toString());
console.log("Finalizing the rental and releasing resources to the market");
await rental.stopAndFinalize();
} finally {
await glm.disconnect();
}
})().catch(console.error);
Full Release Notes
For a comprehensive overview of all the improvements and fixes, make sure to read the full release notes. We encourage you to update golem-js
to the latest version and explore these new features. Your feedback is invaluable, so please report any issues you encounter.
Thank you for being a part of our dynamic community. Happy coding!
Have you tried out golem-js yet?
npx @golem-sdk/cli@latest new my-golem-app