near-dapp
>
它会碰到什么
扫了多少5 个文本文件,16 KB
它会碰到什么不碰外部(只输出文字)
命中总数0 处
命中统计严重 0 · 高 0 · 中 0 · 低 0
这一栏是扫描器报的事实,不是结论。命中多不等于有毒(安全工具、规则库、示例脚本本来就会包含危险写法),命中少也不等于干净。它和你手上的凭据、文件、网络有什么关系,需要你自己看。
技能内容
NEAR dApp
Decision Router
Determine which path to follow:
Path A: New Project
User wants to create a new NEAR dApp from scratch.
- Read [references/create-near-app.md](references/create-near-app.md)
- Run scaffolding:
npx create-near-app@latest
Or with arguments:
npx create-near-app my-app --frontend vite-react --contract rs --install
Framework options: vite-react | next-app | next-page
Contract options: rs (Rust) | ts (TypeScript)
- If user needs wallet connection in the scaffolded app, also follow Path B.
Path B: Existing Project
User wants to add NEAR wallet connection to an existing React app.
- Read [references/near-connect-hooks.md](references/near-connect-hooks.md) — React hooks API and patterns
- If user needs low-level wallet API or non-React integration, also read [references/near-connect.md](references/near-connect.md)
Quick setup:
npm install near-connect-hooks @hot-labs/near-connect near-api-js
// 1. Wrap app root with NearProvider
import { NearProvider } from 'near-connect-hooks';
<NearProvider config={{ network: 'mainnet' }}>
<App />
</NearProvider>
// 2. Use hook in components
import { useNearWallet } from 'near-connect-hooks';
const { signedAccountId, signIn, signOut, viewFunction, callFunction } = useNearWallet();
Path C: Non-React or Vanilla JS
Use @hot-labs/near-connect directly without React hooks.
- Read [references/near-connect.md](references/near-connect.md)
npm install @hot-labs/near-connect
import { NearConnector } from "@hot-labs/near-connect";
const connector = new NearConnector({ network: "mainnet" });
connector.on("wallet:signIn", async (t) => {
const wallet = await connector.wallet();
const address = t.accounts[0].accountId;
});
await connector.connect();
Key Patterns
- Read contract state (no wallet):
viewFunction({ contractId, method, args }) - Write to contract (wallet required):
callFunction({ contractId, method, args, deposit }) - Transfer NEAR:
transfer({ receiverId, amount }) - NEAR ↔ yoctoNEAR: Use
nearToYocto()/yoctoToNear()fromnear-api-js - 1 NEAR =
"1000000000000000000000000"yoctoNEAR - Default gas:
"30000000000000"(30 TGas)
想直接用这个技能?
本站把开放许可(MIT / Apache 等)的技能按仓库打包整理到网盘,点一下转存到你自己的网盘,不用一个个从 GitHub 拉。许可未声明的技能只给原始仓库链接,不打包。