NEAR Protocol JsonRpcProvider(url?: string) deprecated use `JsonRpcProvider(connectionInfo: ConnectionInfo)` instead

205 Views Asked by At

I'm initiating API/RPC connection to NEAR Protocol using JsonRpcProvider like that:

const provider = new nearAPI.providers.JsonRpcProvider(
  `https://rpc.${networkId}.near.org`
)

I'm getting this warning

JsonRpcProvider(url?: string) deprecated use `JsonRpcProvider(connectionInfo: ConnectionInfo)` instead index.js:18:18

I can't find any example of how to use it in JS. The only ConnectionInfo object I could found is https://near.github.io/near-api-js/interfaces/utils_web.connectioninfo.html

1

There are 1 best solutions below

0
MSaudi On

The way you can use it is like that:

let connInfo = { url: "https://rpc.${networkId}.near.org" }
// sets up a NEAR API/RPC provider to interact with the blockchain
const provider = new nearAPI.providers.JsonRpcProvider(connInfo)