Skip to main content
One of near-kit’s superpowers is that it abstracts the “Signer.” Whether a transaction is signed by a generic private key, a secure server-side keystore, or a user’s browser wallet, the code to build and send that transaction is identical. This allows you to write “Universal Business Logic”—functions that define what to do, without caring where they are running.

1. The Business Logic

First, write your logic as a standalone function. It should accept a Near instance and a signerId.

2. Injecting the Near Instance

Now, let’s see how to initialize the Near object for different environments.
For simple scripts, passing a raw private key is the easiest method.

Summary

Your business logic (buyItem) never needs to know which one is happening.