New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

near-api-ts

Package Overview
Dependencies
Maintainers
4
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

near-api-ts

Typescript library for interactions with Near Protocol in the browser or Node.js

latest
Source
npmnpm
Version
0.9.0
Version published
Weekly downloads
11
-67.65%
Maintainers
4
Weekly downloads
 
Created
Source

NEAR API TS

TypeScript library for interactions with Near Protocol in the browser or Node.js

GitHub Repository

Installation

pnpm add near-api-ts

Node.js (esm, 25+) / Browser

import {
  createTestnetClient,
  createMemoryKeyService,
  createMemorySigner,
  transfer,
  near,
  isNatError,
} from 'near-api-ts';

// Read some data from the chain
const client = createTestnetClient();

const { accountInfo } = await client.getAccountInfo({
  accountId: 'testnet',
  atMomentOf: 'LatestFinalBlock',
});
console.log('Near:', accountInfo.balance.total.near);
console.log('YoctoNear:', accountInfo.balance.total.yoctoNear);

// Send some transaction
const keyService = createMemoryKeyService({
  keySource: { privateKey: 'ed25519:your-private-key' },
});

const signer = createMemorySigner({
  signerAccountId: 'your-account.testnet',
  client,
  keyService,
});

await signer.executeTransaction({
  intent: {
    action: transfer({ amount: { yoctoNear: '1' } }),
    receiverAccountId: 'some-receiver.testnet',
  },
});

// Handle transaction errors
try {
  const txResult = await signer.executeTransaction({
    intent: {
      action: transfer({ amount: near('10000000000') }),
      receiverAccountId: 'some-receiver.testnet',
    },
  });
} catch (e) {
  if (isNatError(e, 'MemorySigner.ExecuteTransaction.Rpc.Transaction.Signer.Balance.TooLow')) {
    console.log(e.context.transactionCost);
  }
}

// Use library functions in 'safe' mode
const maybeBlock = await client.safeGetBlock({
  blockReference: { blockHeight: 10000000000000 },
});
console.log(maybeBlock); // { ok: false, error: NatError: <{ kind: 'Client.GetBlock.Rpc.Block.NotFound', context: null }> }

Keywords

near

FAQs

Package last updated on 09 Apr 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts