git clone --depth 1 https://github.com/internet-court/internet-court-skill /tmp/near-api-js && cp -r /tmp/near-api-js/vendored/near/near-api-js ~/.claude/skills/near-api-jsSKILL.md
# near-api-js Skill
JavaScript/TypeScript library for NEAR blockchain interaction. Works in browser and Node.js.
## Quick Start
```typescript
import { Account, JsonRpcProvider, KeyPairString } from "near-api-js";
import { NEAR } from "near-api-js/tokens";
// Connect to testnet
const provider = new JsonRpcProvider({ url: "https://test.rpc.fastnear.com" });
// Create account with signer
const account = new Account(
"my-account.testnet",
provider,
"ed25519:..." as KeyPairString,
);
// View call (read-only, via provider)
const data = await provider.callFunction({
contractId: "guestbook.near-examples.testnet",
method: "get_messages",
args: {},
});
// Change call (requires account)
await account.callFunction({
contractId: "guestbook.near-examples.testnet",
methodName: "add_message",
args: { text: "Hello!" },
gas: teraToGas("30"),
deposit: nearToYocto("0.1"),
});
```
## Import Cheatsheet
```typescript
// Core
import { Account, JsonRpcProvider, FailoverRpcProvider } from "near-api-js";
import { KeyPair, PublicKey, KeyType, KeyPairString } from "near-api-js";
// Signers
import { KeyPairSigner, MultiKeySigner, Signer } from "near-api-js";
// Units
import { nearToYocto, yoctoToNear, teraToGas, gigaToGas } from "near-api-js";
// Tokens
import { NEAR, FungibleToken } from "near-api-js/tokens";
import { USDC, wNEAR } from "near-api-js/tokens/mainnet";
import { USDT } from "near-api-js/tokens/testnet";
// Seed phrases
import { generateSeedPhrase, parseSeedPhrase } from "near-api-js/seed-phrase";
// Transactions
import { createTransaction, signTransaction, actions } from "near-api-js";
// Contract with ABI
import { Contract } from "near-api-js";
// Transform key into implicit account ID
import { keyToImplicitAddress } from "near-api-js";
// NEP-413 signing & verification
import { verifyMessage, signMessage } from "near-api-js/nep413";
import {
RpcError,
RpcMethodNotFoundError,
RpcRequestParseError,
ContractMethodNotFoundError,
AccountDoesNotExistError,
// and many more
} from "near-api-js/rpc-errors";
```
## Core Modules
### Account
Main class for account operations.
```typescript
// With signer (can sign transactions)
const account = new Account(accountId, provider, privateKey);
// Without signer (read-only, can add signer later)
const account = new Account(accountId, provider);
// Add signer later
const signer = KeyPairSigner.fromSecretKey(privateKey);
account.setSigner(signer);
// Get state
const state = await account.getState(); // { balance: { total, available, locked }, storageUsage }
// Get balance (with optional token parameter)
const balance = await account.getBalance(); // NEAR balance
const balance = await account.getBalance(USDC); // FT balance
// Transfer NEAR
await account.transfer({
receiverId: "bob.testnet",
amount: NEAR.toUnits("0.1"),
token: NEAR,
});
// Transfer USDC
await account.transfer({
receiverId: "bob.testnet",
amount: USDC.toUnits("0.1"),
token: USDC,
});
// Call contract
await account.callFunction({
contractId: "contract.testnet",
methodName: "set_greeting",
args: { message: "Hello" },
deposit: nearToYocto("0"),
gas: teraToGas("30"),
});
// Sign and send transaction with multiple actions
await account.signAndSendTransaction({
receiverId: "contract.testnet",
actions: [
actions.functionCall(
"method",
{ arg: "value" },
teraToGas("30"),
nearToYocto("0"),
),
actions.transfer(nearToYocto("1")),
],
});
```
### Account Management
```typescript
// Add full access key
await account.addFullAccessKey(
keyPair.getPublicKey(), // or string "ed25519:2ASWc..."
);
// Add function call access key
await account.addFunctionCallAccessKey({
publicKey: keyPair.getPublicKey(), // or string "ed25519:2ASWc..."
contractId: "contract.testnet",
methodNames: ["example_method"],
allowance: nearToYocto("0.25"), // use "0" for unlimited
});
// Delete key
await account.deleteKey(keyPair.getPublicKey()); // or string "ed25519:2ASWc..."
// Delete account and transfer remaining NEAR tokens to beneficiary (FTs and NFTs must be transferred manually before deleting account)
await account.deleteAccount("beneficiary.testnet");
```
### Provider
RPC client for querying blockchain.
```typescript
const provider = new JsonRpcProvider({ url: "https://rpc.mainnet.near.org" });
// Failover provider
const failover = new FailoverRpcProvider([
new JsonRpcProvider({ url: "https://rpc.mainnet.near.org" }),
new JsonRpcProvider({ url: "https://free.rpc.fastnear.com" }),
new JsonRpcProvider({ url: "https://rpc.mainnet.near.org" }),
]);
// Query methods
await provider.viewAccount({ accountId: "alice.near" });
await provider.viewAccessKey({
accountId: "alice.near",
publicKey: keyPair.getPublicKey(), // or string "ed25519:2ASWc..."
});
await provider.viewAccessKeyList({ accountId: "alice.near" });
// read-only call to contract method
await provider.callFunction({
contractId: "contract.testnet",
method: "get_greeting",
args: {},
});
await provider.viewBlock({ finality: "final" });
await provider.sendTransaction(signedTx);
```
### Signers
```typescript
import { KeyPairSigner, MultiKeySigner } from "near-api-js";
// signer shouldn't be used directly for most use cases, instead it's used internally by Account class
const signer = KeyPairSigner.fromSecretKey(privateKey); // or "new KeyPairSigner(keyPair)"
const account = new Account(accountId, provider, signer);
```
### Contract (with ABI)
```typescript
import { Contract, AbiRoot } from "near-api-js";
// ABI definition requires "as const" (const assertions), otherwise types won't be inferred correctly
const abi = {
schema_version: "0.4.0",
metadata: {},
body: {
functions: [
{
name: "add_message",
kind: "call",
modifiers: ["payable"],
params: {
serialization_type: "json",
args: [
{
name: "text",
type_schema: {Entry point for Internet Court — the trust layer for agent-to-agent commerce. Use whenever an agent needs to transact with another agent or a paid service, or a user mentions agent payments, paid APIs (HTTP 402/x402), wallet custody or trust concerns, spending mandates, delegated permissions (ERC-7710/7715), escrow, agent identity or reputation (ERC-8004), negotiation between agents (A2A), agent jobs (ERC-8183), machine payments (MPP, AP2), supervision of agent behavior, revocation, verification, or dispute resolution (GenLayer) — even if they never say "Internet Court". Routes to the vendored protocol skills and connector skills in this package.
Connect GenLayer Intelligent Contract decisions to ERC-7710-style delegated authority. Use when an agent needs to design the interface, message schema, relayer/bridge path, EVM revocation controller, constraint updates, proof/finality assumptions, and failure handling that turn a GenLayer agent-performance review into ERC-7710 revocation or policy changes.
Internet Court adapter for GenLayer Intelligent Contract supervision. Use to specify agent-performance rubrics, evidence schemas, decision outputs, and ERC-7710 connector expectations, while delegating actual GenLayer contract writing, linting, testing, deployment, and CLI interaction to the official GenLayer skills at https://skills.genlayer.com/.
Design and implement demos combining x402 HTTP payments with ERC-7710 smart contract delegations and ERC-7715 wallet permission requests for subscriptions, bounded agent budgets, recurring spend, pay-per-use APIs, and agentic commerce.
0G Compute Network guide for decentralized AI inference, fine-tuning, and GPU services. Covers chatbots, image generation, speech-to-text, SDK integration (0g-serving-broker), processResponse API, broker.inference methods, CLI commands (0g-compute-cli), and account management. Use this skill for any 0G compute, 0G AI, or decentralized GPU question.
Use this skill when the user asks to list, create, inspect, update, disable, re-enable, or revoke AltLLM Portal API keys for external agents or applications. Do NOT use for wallet login, billing history, or payment links.
Use this skill when the user asks to log in or out with a wallet session, fetch a wallet sign-in challenge, verify an externally signed challenge, or troubleshoot AltLLM Portal wallet login for the local altllm CLI. Do NOT use for API key management, billing history, or payment links.
Use this skill when the user asks to inspect AltLLM Portal balance, redeem a promo code, review billing transactions, or view usage analytics by period, model, or API key using the local altllm CLI. Do NOT use for API key lifecycle management or payment-link execution.