Instantiating the RPC API. This is going to expose the NEAR Json RPC Provider service.
// web3Api.tsimport naxios from'@wpdas/naxios'constnaxiosInstance=newnaxios({ contractId:"hello.near-examples.near", network:'mainnet',// or testnet, localnet})/** * NEAR RPC API */exportconstrpcApi=naxiosInstance.rpcApi()
API Reference
All details about it and how to query data using it can be found on the original RPC API Docs website.
Here is a simple example of using this feature to view account details:
import { rpcApi } from './web3Api'
// Viewing account using Near RPC API
// https://docs.near.org/api/rpc/contracts#view-account
rpcApi
.query({
request_type: 'view_account',
finality: 'final',
account_id: 'wendersonpires.near',
})
.then((data) => console.log('Account Data:', data))