
Product
Announcing Socket Fix 2.0
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
fast-near aims to provide the fastest RPC implementation for @NEARProtocol using high performance storage backends like:
It is optimized for view call performance and ease of deploy and scaling.
It currently doesn't sync with network on its own, data needs to be loaded either from NEAR Lake or from https://github.com/vgrichina/near-state-indexer.
nearcore
RPC performance isn't good enough for novel use cases like https://web4.near.page.
fast-near achieves better performance by using
fast-near is also a good fit if you want to run RPC node serving limited subset of accounts (e.g. supporting your app exclusively) on a smaller hardware. This works well if data is sourced from NEAR Lake.
FAST_NEAR_REDIS_URL=<redis_ip> FAST_NEAR_NODE_URL=<rpc_endpoint> npx fast-near
yarn
FAST_NEAR_REDIS_URL=<redis_ip> FAST_NEAR_NODE_URL=<rpc_endpoint> yarn start
docker build -t fastrpc .
docker run -d -e FAST_NEAR_REDIS_URL=<redis_ip> -e FAST_NEAR_NODE_URL=<rpc_endpoint> fastrpc
To load from NEAR Lake (use --help
to learn more about options):
node scripts/load-from-near-lake.js near-lake-data-mainnet --batch-size 50 --history-length 1 --dump-changes
To load from NEAR Lake (use --help
to learn more about options):
FAST_NEAR_STORAGE_TYPE=lmdb node scripts/load-from-near-lake.js near-lake-data-mainnet --batch-size 50 --history-length 1 --dump-changes
Run server:
FAST_NEAR_STORAGE_TYPE=lmdb yarn start
To load data for app1.near
, app2.near
and all subaccounts of superapp.near
:
node scripts/load-from-near-lake.js near-lake-data-mainnet --include app1.near --include app2.near --include '*.superapp.near' --dump-changes
To load data for all accounts except aurora
and sweat
subaccounts:
node scripts/load-from-near-lake.js near-lake-data-mainnet --exclude aurora.* --exclude sweat.* --dump-changes
Currently there are such options to dump data loaded from NEAR Lake:
--dump-changes
- dumps state changes into storage. Use FAST_NEAR_STORAGE_TYPE
to specify storage type. Defaults to redis
See https://github.com/vgrichina/near-state-indexer for Rust implementation running full nearcore node.
PORT
- port to listen on (default: 3000
)FAST_NEAR_STORAGE_TYPE
- storage type to use (default: redis
). Supported values: redis
, lmdb
.FAST_NEAR_ENABLE_CACHE
- enable client-side caching (default: true
).FAST_NEAR_LMDB_PATH
- path to LMDB database (default: ./lmdb-data
). This is only used if FAST_NEAR_STORAGE_TYPE
is set to lmdb
.FAST_NEAR_REDIS_URL
- Redis URL (default: redis://localhost:6379
)FAST_NEAR_NODE_URL
- NEAR RPC endpoint (default: https://rpc.mainnet.near.org
). This is only used as a fallback for JSON-RPC endpoint.FAST_NEAR_ARCHIVAL_NODE_URL
- NEAR RPC endpoint for archival node (default: https://rpc.mainnet.internal.near.org
). This is only used as a fallback for JSON-RPC endpoint for data unavailable in Redis or on non-archival RPC.FAST_NEAR_ALWAYS_PROXY
- Always proxy JSON-RPC requests to FAST_NEAR_NODE_URL
(default: false
).FAST_NEAR_START_BLOCK_HEIGHT
- Minimum block height expected to be present in Redis (default: 0
).FAST_NEAR_WORKER_COUNT
- Number of workers to use for execution of WASM code. (default: 4
).FAST_NEAR_CONTRACT_TIMEOUT_MS
- Timeout for contract execution in milliseconds (default: 1000
).You can post either JSON or binary body, it's passed raw as input to given method.
URL format:
https://rpc.web4.near.page/account/<contract_account_id>/view/<method_name>
http post https://rpc.web4.near.page/account/vlad.tkn.near/view/ft_balance_of account_id=vlad.near
Parameters are passed as part of URL query.
URL format:
https://rpc.web4.near.page/account/<contract_account_id>/view/<method_name>?<arg_name>=<string_arg_value>&<arg_name.json>=<json_arg_value>
curl 'https://rpc.web4.near.page/account/vlad.tkn.near/view/ft_balance_of?account_id=vlad.near'
https://rpc.web4.near.page/account/vlad.tkn.near/view/ft_balance_of?account_id=vlad.near
curl --globoff 'https://rpc.web4.near.page/account/lands.near/view/web4_get?request.json={"path":"/"}'
https://rpc.web4.near.page/account/lands.near/view/web4_get?request.json={"path":"/"}
curl 'https://rpc.web4.near.page/account/lands.near/view/getChunk?x.json=0&y.json=0'
https://rpc.web4.near.page/account/lands.near/view/getChunk?x.json=0&y.json=0
URL format:
https://rpc.web4.near.page/account/<account_id>
curl 'https://rpc.web4.near.page/account/vlad.near'
https://rpc.web4.near.page/account/vlad.near
URL format:
https://rpc.web4.near.page/account/<account_id>/key/<public_key>
curl 'https://rpc.web4.near.page/account/vlad.near/key/ed25519:JBHUrhF61wfScUxqGGRmfdJTQYg8MzRr5H8pqMMjqygr'
URL format:
https://rpc.web4.near.page/account/<account_id>/contract
curl 'https://rpc.web4.near.page/account/vlad.tkn.near/contract'
https://rpc.web4.near.page/account/vlad.tkn.near/contract
URL format:
https://rpc.web4.near.page/account/<account_id>/contract/methods
curl 'https://rpc.web4.near.page/account/lands.near/contract/methods'
https://rpc.web4.near.page/account/lands.near/contract/methods
Some of the planned and already implemented components. Is not exhaustive list.
FAQs
Fastest RPC for NEAR Protocol
We found that fast-near demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.