Class: JsonRpcProvider
providers/json-rpc-provider.JsonRpcProvider
Client class to interact with the NEAR RPC API.
See
https://github.com/near/nearcore/tree/master/chain/jsonrpc
Hierarchy
Provider
↳
JsonRpcProvider
Constructors
constructor
new JsonRpcProvider(connectionInfo
)
Parameters
Name | Type | Description |
---|---|---|
connectionInfo | ConnectionInfo | Connection info |
Overrides
Provider.constructor
Defined in
providers/json-rpc-provider.ts:60
Methods
accessKeyChanges
accessKeyChanges(accountIdArray
, blockQuery
): Promise
<ChangeResult
>
Gets access key changes for a given array of accountIds See docs for more info
Parameters
Name | Type |
---|---|
accountIdArray | string [] |
blockQuery | BlockReference |
Returns
Promise
<ChangeResult
>
Overrides
Provider.accessKeyChanges
Defined in
providers/json-rpc-provider.ts:222
accountChanges
accountChanges(accountIdArray
, blockQuery
): Promise
<ChangeResult
>
Gets account changes for a given array of accountIds pass block_id OR finality as blockQuery, not both See docs for more info
Parameters
Name | Type |
---|---|
accountIdArray | string [] |
blockQuery | BlockReference |
Returns
Promise
<ChangeResult
>
Overrides
Provider.accountChanges
Defined in
providers/json-rpc-provider.ts:256
block
block(blockQuery
): Promise
<BlockResult
>
Query for block info from the RPC pass block_id OR finality as blockQuery, not both
See
https://docs.near.org/api/rpc/block-chunk
Parameters
Name | Type | Description |
---|---|---|
blockQuery | BlockId | BlockReference | BlockReference (passing a BlockId is deprecated) |
Returns
Promise
<BlockResult
>
Overrides
Provider.block
Defined in
providers/json-rpc-provider.ts:162
blockChanges
blockChanges(blockQuery
): Promise
<BlockChangeResult
>
Query changes in block from the RPC pass block_id OR finality as blockQuery, not both
See
https://docs.near.org/api/rpc/block-chunk
Parameters
Name | Type |
---|---|
blockQuery | BlockReference |
Returns
Promise
<BlockChangeResult
>
Overrides
Provider.blockChanges
Defined in
providers/json-rpc-provider.ts:173
chunk
chunk(chunkId
): Promise
<ChunkResult
>
Queries for details about a specific chunk appending details of receipts and transactions to the same chunk data provided by a block
See
https://docs.near.org/api/rpc/block-chunk
Parameters
Name | Type | Description |
---|---|---|
chunkId | ChunkId | Hash of a chunk ID or shard ID |
Returns
Promise
<ChunkResult
>
Overrides
Provider.chunk
Defined in
providers/json-rpc-provider.ts:185
contractCodeChanges
contractCodeChanges(accountIdArray
, blockQuery
): Promise
<ChangeResult
>
Gets contract code changes for a given array of accountIds pass block_id OR finality as blockQuery, not both Note: Change is returned in a base64 encoded WASM file See docs for more info
Parameters
Name | Type |
---|---|
accountIdArray | string [] |
blockQuery | BlockReference |
Returns
Promise
<ChangeResult
>
Overrides
Provider.contractCodeChanges
Defined in
providers/json-rpc-provider.ts:293
contractStateChanges
contractStateChanges(accountIdArray
, blockQuery
, keyPrefix?
): Promise
<ChangeResult
>
Gets contract state changes for a given array of accountIds pass block_id OR finality as blockQuery, not both Note: If you pass a keyPrefix it must be base64 encoded See docs for more info
Parameters
Name | Type | Default value |
---|---|---|
accountIdArray | string [] | undefined |
blockQuery | BlockReference | undefined |
keyPrefix | string | '' |
Returns
Promise
<ChangeResult
>
Overrides
Provider.contractStateChanges
Defined in
providers/json-rpc-provider.ts:274
experimental_protocolConfig
experimental_protocolConfig(blockReference
): Promise
<NearProtocolConfig
>
Gets the protocol config at a block from RPC
Parameters
Name | Type | Description |
---|---|---|
blockReference | BlockReference | { sync_checkpoint : "genesis" } | specifies the block to get the protocol config for |
Returns
Promise
<NearProtocolConfig
>
Overrides
Provider.experimental_protocolConfig
Defined in
providers/json-rpc-provider.ts:204
gasPrice
gasPrice(blockId
): Promise
<GasPrice
>
Returns gas price for a specific block_height or block_hash.
See
https://docs.near.org/api/rpc/gas
Parameters
Name | Type | Description |
---|---|---|
blockId | BlockId | Block hash or height, or null for latest. |
Returns
Promise
<GasPrice
>
Overrides
Provider.gasPrice
Defined in
providers/json-rpc-provider.ts:310
lightClientProof
lightClientProof(request
): Promise
<LightClientProof
>
Gets a light client execution proof for verifying execution outcomes
See
https://github.com/nearprotocol/NEPs/blob/master/specs/ChainSpec/LightClient.md#light-client-proof
Parameters
Name | Type |
---|---|
request | LightClientProofRequest |
Returns
Promise
<LightClientProof
>
Overrides
Provider.lightClientProof
Defined in
providers/json-rpc-provider.ts:213
query
query<T
>(...args
): Promise
<T
>
Query the RPC by passing an RpcQueryRequest
See
https://docs.near.org/api/rpc/contracts
Type parameters
Name | Type | Description |
---|---|---|
T | extends QueryResponseKind | the shape of the returned query response |
Parameters
Name | Type |
---|---|
...args | any [] |
Returns
Promise
<T
>
Overrides
Provider.query
Defined in
providers/json-rpc-provider.ts:140
sendJsonRpc
sendJsonRpc<T
>(method
, params
): Promise
<T
>
Directly call the RPC specifying the method and params
Type parameters
Name |
---|
T |
Parameters
Name | Type | Description |
---|---|---|
method | string | RPC method |
params | object | Parameters to the method |
Returns
Promise
<T
>
Defined in
providers/json-rpc-provider.ts:320
sendTransaction
sendTransaction(signedTransaction
): Promise
<FinalExecutionOutcome
>
Sends a signed transaction to the RPC and waits until transaction is fully complete
See
https://docs.near.org/docs/develop/front-end/rpc#send-transaction-await
Parameters
Name | Type | Description |
---|---|---|
signedTransaction | SignedTransaction | The signed transaction being sent |
Returns
Promise
<FinalExecutionOutcome
>
Overrides
Provider.sendTransaction
Defined in
providers/json-rpc-provider.ts:79
sendTransactionAsync
sendTransactionAsync(signedTransaction
): Promise
<FinalExecutionOutcome
>
Sends a signed transaction to the RPC and immediately returns transaction hash See docs for more info
Parameters
Name | Type | Description |
---|---|---|
signedTransaction | SignedTransaction | The signed transaction being sent |
Returns
Promise
<FinalExecutionOutcome
>
Overrides
Provider.sendTransactionAsync
Defined in
providers/json-rpc-provider.ts:90
singleAccessKeyChanges
singleAccessKeyChanges(accessKeyArray
, blockQuery
): Promise
<ChangeResult
>
Gets single access key changes for a given array of access keys pass block_id OR finality as blockQuery, not both See docs for more info
Parameters
Name | Type |
---|---|
accessKeyArray | AccessKeyWithPublicKey [] |
blockQuery | BlockReference |
Returns
Promise
<ChangeResult
>
Overrides
Provider.singleAccessKeyChanges
Defined in
providers/json-rpc-provider.ts:239
status
status(): Promise
<NodeStatusResult
>
Gets the RPC's status
See
https://docs.near.org/docs/develop/front-end/rpc#general-validator-status
Returns
Promise
<NodeStatusResult
>
Overrides
Provider.status
Defined in
providers/json-rpc-provider.ts:69
txStatus
txStatus(txHash
, accountId
): Promise
<FinalExecutionOutcome
>
Gets a transaction's status from the RPC
See
https://docs.near.org/docs/develop/front-end/rpc#transaction-status
Parameters
Name | Type | Description |
---|---|---|
txHash | string | Uint8Array | A transaction hash as either a Uint8Array or a base58 encoded string |
accountId | string | The NEAR account that signed the transaction |
Returns
Promise
<FinalExecutionOutcome
>
Overrides
Provider.txStatus
Defined in
providers/json-rpc-provider.ts:102
txStatusReceipts
txStatusReceipts(txHash
, accountId
): Promise
<FinalExecutionOutcome
>
Gets a transaction's status from the RPC with receipts See docs for more info
Parameters
Name | Type | Description |
---|---|---|
txHash | string | Uint8Array | The hash of the transaction |
accountId | string | The NEAR account that signed the transaction |
Returns
Promise
<FinalExecutionOutcome
>
Overrides
Provider.txStatusReceipts
Defined in
providers/json-rpc-provider.ts:125
txStatusString
Private
txStatusString(txHash
, accountId
): Promise
<FinalExecutionOutcome
>
Parameters
Name | Type |
---|---|
txHash | string |
accountId | string |
Returns
Promise
<FinalExecutionOutcome
>
Defined in
providers/json-rpc-provider.ts:114
txStatusUint8Array
Private
txStatusUint8Array(txHash
, accountId
): Promise
<FinalExecutionOutcome
>
Parameters
Name | Type |
---|---|
txHash | Uint8Array |
accountId | string |
Returns
Promise
<FinalExecutionOutcome
>
Defined in
providers/json-rpc-provider.ts:110
validators
validators(blockId
): Promise
<EpochValidatorInfo
>
Query validators of the epoch defined by the given block id.
See
https://docs.near.org/api/rpc/network#validation-status
Parameters
Name | Type | Description |
---|---|---|
blockId | BlockId | Block hash or height, or null for latest. |
Returns
Promise
<EpochValidatorInfo
>
Overrides
Provider.validators