DEV Community

Hauwa Ibrahim
Hauwa Ibrahim

Posted on

From CLI Commands to My First Solana Transfer Tool

By this point in the #100DaysOfSolana course, I had already explored a few different aspects of Solana, not just the CLI. But when I first started experimenting, I was mainly running one‑off CLI commands on devnet:

solana transfer <recipient> <amount>
Enter fullscreen mode Exit fullscreen mode

It worked, but it felt awkward. Each time I wanted to send SOL I had to type in the recipient and the amount again, with no balance checks or helpful feedback — just bare commands.

On Day 17, the course pushed me to go further: instead of repeating raw CLI commands, I built my own Node.js script. Now I can run:

node transfer.mjs <recipient> 0.05
Enter fullscreen mode Exit fullscreen mode

The recipient and amount are passed in as arguments, and the script handles the rest — checking balances, sending the transaction, and even giving me a link to Solana Explorer. That was the moment things started to click. I wasn’t just typing commands anymore, I was building a tool I could reuse.

The Struggle

At first, I thought it would be straightforward. But I quickly ran into issues:

  • Node v12 didn’t support modern syntax like ?? and ?..
  • Even after upgrading, I hit the dreaded error:
  Transfer failed: No random values implementation could be found.
Enter fullscreen mode Exit fullscreen mode
  • Debugging felt endless. I was learning Web3 concepts while also fighting with Web2 runtime quirks.

The Breakthrough

The breakthrough came when I realized the Solana kit I was using expected browser‑like APIs. Node didn’t expose them globally. So I patched my environment:

import { webcrypto } from "node:crypto";
globalThis.crypto = webcrypto;

// Polyfill CustomEvent for Node.js < 18.7
if (typeof CustomEvent === "undefined") {
  globalThis.CustomEvent = class CustomEvent extends Event {
    constructor(type, options = {}) {
      super(type, options);
      this.detail = options.detail ?? null;
    }
  };
}
Enter fullscreen mode Exit fullscreen mode

Suddenly, the randomness error disappeared. My script connected, checked balances, built transactions, and confirmed them with a link to Solana Explorer.


The Result

Now I have a reusable CLI transfer tool that:

  • Accepts recipient + amount as arguments
  • Checks my balance before sending
  • Reports the result with a signature and Explorer link
  • Shows my updated balance after the transfer

What started as a one‑off CLI experiment became a proper utility — something I can reuse, extend, and share.


My Takeaway

Web3 isn’t magic. It’s just APIs, runtimes, and debugging like any other stack. The difference is that every bug you fix teaches you something deeper about how blockchains work.

If you’re a web or mobile developer curious about Solana, start small. Wrap a CLI command in code. Debug the errors. Before you know it, you’ll have built your own tool — and you’ll understand Solana a lot better.

I went from typing raw commands to building my first Solana transfer tool. And the best part? It feels like the beginning of something bigger.

Top comments (0)