Interface NearService


  • public interface NearService
    RPC client for the Near network
    Since:
    0.0.1
    Author:
    Alexandre Carvalho, Andre Bertolace
    • Method Detail

      • getBlock

        Block getBlock​(Finality finality)
                throws NearServiceException
        Queries network and returns block for given height or hash.
        Parameters:
        finality - the finality param
        Returns:
        the data holding object
        Throws:
        NearServiceException - rpc call error exception
      • getBlock

        Block getBlock​(java.lang.String blockHash)
                throws NearServiceException
        Queries network and returns block for given height or hash.
        Parameters:
        blockHash - the block's hash
        Returns:
        the data holding object
        Throws:
        NearServiceException - rpc call error exception
      • getBlock

        Block getBlock​(long blockHeight)
                throws NearServiceException
        Queries network and returns block for given height or hash.
        Parameters:
        blockHeight - the block's height
        Returns:
        the data holding object
        Throws:
        NearServiceException - rpc call error exception
      • getChunkDetails

        Chunk getChunkDetails​(java.lang.String chunkId)
                       throws NearServiceException
        Returns details of a specific chunk. You can run a block details query to get a valid chunk hash.
        Parameters:
        chunkId - the id of the chunk
        Returns:
        the data holding object
        Throws:
        NearServiceException - rpc call error exception
      • getChunkDetails

        Chunk getChunkDetails​(java.lang.String blockId,
                              long shardId)
                       throws NearServiceException
        Returns details of a specific chunk. You can run a block details query to get a valid chunk hash.
        Parameters:
        blockId - the block hash
        shardId - the id of the shard
        Returns:
        the data holding object
        Throws:
        NearServiceException - rpc call error exception
      • getChunkDetails

        Chunk getChunkDetails​(long blockId,
                              long shardId)
                       throws NearServiceException
        Returns details of a specific chunk. You can run a block details query to get a valid chunk hash.
        Parameters:
        blockId - the block height
        shardId - the id of the shard
        Returns:
        the data holding object
        Throws:
        NearServiceException - rpc call error exception
      • getNodeStatus

        NodeStatus getNodeStatus()
                          throws NearServiceException
        Returns general status of a given node (sync status, near core node version, protocol version, etc.), and the current set of validators.
        Returns:
        the data holding object
        Throws:
        NearServiceException - rpc call error exception
      • getNetworkInfo

        NetworkInfo getNetworkInfo()
                            throws NearServiceException
        Returns the current state of node network connections (active peers, transmitted data, etc.)
        Returns:
        the data holding object
        Throws:
        NearServiceException - rpc call error exception
      • getNetworkValidationStatus

        ValidationStatus getNetworkValidationStatus​(java.lang.String blockHash)
                                             throws NearServiceException
        Queries active validators on the network returning details and the state of validation on the blockchain.
        Parameters:
        blockHash - the block's hash
        Returns:
        the data holding object
        Throws:
        NearServiceException - rpc call error exception
      • getNetworkValidationStatus

        ValidationStatus getNetworkValidationStatus​(long blockHeight)
                                             throws NearServiceException
        Queries active validators on the network returning details and the state of validation on the blockchain.
        Parameters:
        blockHeight - the block's height
        Returns:
        the data holding object
        Throws:
        NearServiceException - rpc call error exception
      • getGasPrice

        GasPrice getGasPrice​(java.lang.String blockHash)
                      throws NearServiceException
        Returns gas price for a specific block_height or block_hash. - Using [null] will return the most recent block's gas price.
        Parameters:
        blockHash - the block's hash
        Returns:
        the data holding object
        Throws:
        NearServiceException - rpc call error exception
      • getGasPrice

        GasPrice getGasPrice​(long blockHeight)
                      throws NearServiceException
        Returns gas price for a specific block_height or block_hash.
        Parameters:
        blockHeight - the block's height
        Returns:
        the data holding object
        Throws:
        NearServiceException - rpc call error exception
      • getProtocolConfig

        ProtocolConfig getProtocolConfig​(Finality finality)
                                  throws NearServiceException
        Returns most recent protocol configuration or a specific queried block. Useful for finding current storage and transaction costs.
        Parameters:
        finality - the finality param
        Returns:
        the data holding object
        Throws:
        NearServiceException - rpc call error exception
      • getProtocolConfig

        ProtocolConfig getProtocolConfig​(java.lang.String blockHash)
                                  throws NearServiceException
        Returns most recent protocol configuration or a specific queried block. Useful for finding current storage and transaction costs.
        Parameters:
        blockHash - the block's hash
        Returns:
        the data holding object
        Throws:
        NearServiceException - rpc call error exception
      • getProtocolConfig

        ProtocolConfig getProtocolConfig​(long blockHeight)
                                  throws NearServiceException
        Returns most recent protocol configuration or a specific queried block. Useful for finding current storage and transaction costs.
        Parameters:
        blockHeight - the block's height
        Returns:
        the data holding object
        Throws:
        NearServiceException - rpc call error exception
      • sendTransactionAsync

        java.lang.String sendTransactionAsync​(java.lang.String base64EncodedSignedTransaction)
                                       throws NearServiceException
        Sends a transaction and immediately returns transaction hash.
        Parameters:
        base64EncodedSignedTransaction - the base64 encoded signed transaction string
        Returns:
        the transaction hash
        Throws:
        NearServiceException - rpc call error exception
      • sendTransactionAwait

        TransactionAwait sendTransactionAwait​(java.lang.String base64EncodedSignedTransaction)
                                       throws NearServiceException
        Sends a transaction and waits until transaction is fully complete. (Has a 10-second timeout)
        Parameters:
        base64EncodedSignedTransaction - the base64 encoded signed transaction string
        Returns:
        the data holding object
        Throws:
        NearServiceException - rpc call error exception
      • getTransactionStatus

        TransactionStatus getTransactionStatus​(java.lang.String transactionHash,
                                               java.lang.String senderAccountId)
                                        throws NearServiceException
        Queries status of a transaction by hash and returns the final transaction result.
        Parameters:
        transactionHash - the transaction hash
        senderAccountId - the sender's account id
        Returns:
        the data holding object the final transaction result
        Throws:
        NearServiceException - rpc call error exception
      • getTransactionStatusWithReceipts

        TransactionStatus getTransactionStatusWithReceipts​(java.lang.String transactionHash,
                                                           java.lang.String senderAccountId)
                                                    throws NearServiceException
        Queries status of a transaction by hash, returning the final transaction result and details of all receipts.
        Parameters:
        transactionHash - the transaction hash
        senderAccountId - the sender's account id
        Returns:
        the data holding object the final transaction result and details of all receipts
        Throws:
        NearServiceException - rpc call error exception
      • getTransactionReceipt

        Receipt getTransactionReceipt​(java.lang.String receiptId)
                               throws NearServiceException
        Fetches a receipt by its ID (as is, without a status or execution outcome)
        Parameters:
        receiptId - the receipt ID to query for info
        Returns:
        the data holding object
        Throws:
        NearServiceException - rpc call error exception
      • viewAccessKey

        AccessKey viewAccessKey​(Finality finality,
                                java.lang.String accountId,
                                java.lang.String publicKey)
                         throws NearServiceException
        Returns information about a single access key for given account.

        If permission of the key is FunctionCall, it will return more details such as the allowance, receiver_id, and method_names.

        Parameters:
        finality - the finality param
        accountId - the account id
        publicKey - the associated public key
        Returns:
        the data holding object
        Throws:
        NearServiceException - rpc call error exception
      • viewAccessKey

        AccessKey viewAccessKey​(java.lang.String blockHash,
                                java.lang.String accountId,
                                java.lang.String publicKey)
                         throws NearServiceException
        Returns information about a single access key for given account.

        If permission of the key is FunctionCall, it will return more details such as the allowance, receiver_id, and method_names.

        Parameters:
        blockHash - the block's hash
        accountId - the account id
        publicKey - the associated public key
        Returns:
        the data holding object
        Throws:
        NearServiceException - rpc call error exception
      • viewAccessKey

        AccessKey viewAccessKey​(long blockHeight,
                                java.lang.String accountId,
                                java.lang.String publicKey)
                         throws NearServiceException
        Returns information about a single access key for given account.

        If permission of the key is FunctionCall, it will return more details such as the allowance, receiver_id, and method_names.

        Parameters:
        blockHeight - the block's height
        accountId - the account id
        publicKey - the associated public key
        Returns:
        the data holding object
        Throws:
        NearServiceException - rpc call error exception
      • viewAccessKeyList

        AccessKeyList viewAccessKeyList​(Finality finality,
                                        java.lang.String accountId)
                                 throws NearServiceException
        Returns all access keys for a given account.
        Parameters:
        finality - the finality param
        accountId - the account id
        Returns:
        the data holding object
        Throws:
        NearServiceException - rpc call error exception
      • viewAccessKeyList

        AccessKeyList viewAccessKeyList​(java.lang.String blockHash,
                                        java.lang.String accountId)
                                 throws NearServiceException
        Returns all access keys for a given account.
        Parameters:
        blockHash - the block's hash
        accountId - the account id
        Returns:
        the data holding object
        Throws:
        NearServiceException - rpc call error exception
      • viewAccessKeyList

        AccessKeyList viewAccessKeyList​(long blockHeight,
                                        java.lang.String accountId)
                                 throws NearServiceException
        Returns all access keys for a given account.
        Parameters:
        blockHeight - the block's height
        accountId - the account id
        Returns:
        the data holding object
        Throws:
        NearServiceException - rpc call error exception
      • viewSingleAccessKeyChanges

        AccessKeyChanges viewSingleAccessKeyChanges​(Finality finality,
                                                    Key[] keys)
                                             throws NearServiceException
        Returns individual access key changes in a specific block. You can query multiple keys by passing an array of objects containing the account_id and key.
        Parameters:
        finality - the finality param
        keys - the key data to query for changes
        Returns:
        the data holding object
        Throws:
        NearServiceException - rpc call error exception
      • viewSingleAccessKeyChanges

        AccessKeyChanges viewSingleAccessKeyChanges​(java.lang.String blockHash,
                                                    Key[] keys)
                                             throws NearServiceException
        Returns individual access key changes in a specific block. You can query multiple keys by passing an array of objects containing the account_id and key.
        Parameters:
        blockHash - the block's hash
        keys - the key data to query for changes
        Returns:
        the data holding object
        Throws:
        NearServiceException - rpc call error exception
      • viewSingleAccessKeyChanges

        AccessKeyChanges viewSingleAccessKeyChanges​(long blockHeight,
                                                    Key[] keys)
                                             throws NearServiceException
        Returns individual access key changes in a specific block. You can query multiple keys by passing an array of objects containing the account_id and key.
        Parameters:
        blockHeight - the block's height
        keys - the key data to query for changes
        Returns:
        the data holding object
        Throws:
        NearServiceException - rpc call error exception
      • viewAllAccessKeyChanges

        AccessKeyChanges viewAllAccessKeyChanges​(Finality finality,
                                                 java.lang.String[] accountIds)
                                          throws NearServiceException
        Returns changes to all access keys of a specific block. Multiple accounts can be queried by passing an array of account_ids.
        Parameters:
        finality - the finality param
        accountIds - the account ids
        Returns:
        the data holding object
        Throws:
        NearServiceException - rpc call error exception
      • viewAllAccessKeyChanges

        AccessKeyChanges viewAllAccessKeyChanges​(java.lang.String blockHash,
                                                 java.lang.String[] accountIds)
                                          throws NearServiceException
        Returns changes to all access keys of a specific block. Multiple accounts can be queried by passing an array of account_ids.
        Parameters:
        blockHash - the block's hash
        accountIds - the account ids
        Returns:
        the data holding object
        Throws:
        NearServiceException - rpc call error exception
      • viewAllAccessKeyChanges

        AccessKeyChanges viewAllAccessKeyChanges​(long blockHeight,
                                                 java.lang.String[] accountIds)
                                          throws NearServiceException
        Returns changes to all access keys of a specific block. Multiple accounts can be queried by passing an array of account_ids.
        Parameters:
        blockHeight - the block's height
        accountIds - the account ids
        Returns:
        the data holding object
        Throws:
        NearServiceException - rpc call error exception
      • viewAccount

        Account viewAccount​(Finality finality,
                            java.lang.String accountId)
                     throws NearServiceException
        Returns basic account information.
        Parameters:
        finality - the finality param
        accountId - the account id
        Returns:
        the data holding object
        Throws:
        NearServiceException - rpc call error exception
      • viewAccount

        Account viewAccount​(java.lang.String blockHash,
                            java.lang.String accountId)
                     throws NearServiceException
        Returns basic account information.
        Parameters:
        blockHash - the block's hash
        accountId - the account id
        Returns:
        the data holding object
        Throws:
        NearServiceException - rpc call error exception
      • viewAccount

        Account viewAccount​(long blockHeight,
                            java.lang.String accountId)
                     throws NearServiceException
        Returns basic account information.
        Parameters:
        blockHeight - the block's height
        accountId - the account id
        Returns:
        the data holding object
        Throws:
        NearServiceException - rpc call error exception
      • viewAccountChanges

        AccountChanges viewAccountChanges​(Finality finality,
                                          java.lang.String[] accountIds)
                                   throws NearServiceException
        Returns account changes from transactions in a given account.
        Parameters:
        finality - the finality param
        accountIds - the account ids
        Returns:
        the data holding object
        Throws:
        NearServiceException - rpc call error exception
      • viewAccountChanges

        AccountChanges viewAccountChanges​(java.lang.String blockHash,
                                          java.lang.String[] accountIds)
                                   throws NearServiceException
        Returns account changes from transactions in a given account.
        Parameters:
        blockHash - the block's hash
        accountIds - the account ids
        Returns:
        the data holding object
        Throws:
        NearServiceException - rpc call error exception
      • viewAccountChanges

        AccountChanges viewAccountChanges​(long blockHeight,
                                          java.lang.String[] accountIds)
                                   throws NearServiceException
        Returns account changes from transactions in a given account.
        Parameters:
        blockHeight - the block's height
        accountIds - the account ids
        Returns:
        the data holding object
        Throws:
        NearServiceException - rpc call error exception
      • viewContractCode

        ContractCode viewContractCode​(Finality finality,
                                      java.lang.String accountId)
                               throws NearServiceException
        Returns the contract code (Wasm binary) deployed to the account. Please note that the returned code will be encoded in base64.
        Parameters:
        finality - the finality param
        accountId - the account id
        Returns:
        the data holding object
        Throws:
        NearServiceException - rpc call error exception
      • viewContractCode

        ContractCode viewContractCode​(java.lang.String blockHash,
                                      java.lang.String accountId)
                               throws NearServiceException
        Returns the contract code (Wasm binary) deployed to the account. Please note that the returned code will be encoded in base64.
        Parameters:
        blockHash - the block's hash
        accountId - the account id
        Returns:
        the data holding object
        Throws:
        NearServiceException - rpc call error exception
      • viewContractCode

        ContractCode viewContractCode​(long blockHeight,
                                      java.lang.String accountId)
                               throws NearServiceException
        Returns the contract code (Wasm binary) deployed to the account. Please note that the returned code will be encoded in base64.
        Parameters:
        blockHeight - the block's height
        accountId - the account id
        Returns:
        the data holding object
        Throws:
        NearServiceException - rpc call error exception
      • viewContractState

        ContractState viewContractState​(Finality finality,
                                        java.lang.String accountId,
                                        java.lang.String prefixBase64)
                                 throws NearServiceException
        Returns the state (key value pairs) of a contract based on the key prefix (base64 encoded). Pass an empty string for prefix_base64 if you would like to return the entire state. Please note that the returned state will be base64 encoded as well.
        Parameters:
        finality - the finality param
        accountId - the account id
        prefixBase64 - the base64 encoded prefix
        Returns:
        the data holding object
        Throws:
        NearServiceException - rpc call error exception
      • viewContractState

        ContractState viewContractState​(java.lang.String blockHash,
                                        java.lang.String accountId,
                                        java.lang.String prefixBase64)
                                 throws NearServiceException
        Returns the state (key value pairs) of a contract based on the key prefix (base64 encoded). Pass an empty string for prefix_base64 if you would like to return the entire state. Please note that the returned state will be base64 encoded as well.
        Parameters:
        blockHash - the block's hash
        accountId - the account id
        prefixBase64 - the base64 encoded prefix
        Returns:
        the data holding object
        Throws:
        NearServiceException - rpc call error exception
      • viewContractState

        ContractState viewContractState​(long blockHeight,
                                        java.lang.String accountId,
                                        java.lang.String prefixBase64)
                                 throws NearServiceException
        Returns the state (key value pairs) of a contract based on the key prefix (base64 encoded). Pass an empty string for prefix_base64 if you would like to return the entire state. Please note that the returned state will be base64 encoded as well.
        Parameters:
        blockHeight - the block's height
        accountId - the account id
        prefixBase64 - the base64 encoded prefix
        Returns:
        the data holding object
        Throws:
        NearServiceException - rpc call error exception
      • viewContractStateChanges

        ContractStateChanges viewContractStateChanges​(Finality finality,
                                                      java.lang.String[] accountIds,
                                                      java.lang.String keyPrefixBase64)
                                               throws NearServiceException
        Returns the state change details of a contract based on the key prefix (encoded to base64). Pass an empty string for this param if you would like to return all state changes.
        Parameters:
        finality - the finality param
        accountIds - the account ids
        keyPrefixBase64 - the base64 encoded key prefix
        Returns:
        the data holding object
        Throws:
        NearServiceException - rpc call error exception
      • viewContractStateChanges

        ContractStateChanges viewContractStateChanges​(java.lang.String blockHash,
                                                      java.lang.String[] accountIds,
                                                      java.lang.String keyPrefixBase64)
                                               throws NearServiceException
        Returns the state change details of a contract based on the key prefix (encoded to base64). Pass an empty string for this param if you would like to return all state changes.
        Parameters:
        blockHash - the block's hash
        accountIds - the account ids
        keyPrefixBase64 - the base64 encoded key prefix
        Returns:
        the data holding object
        Throws:
        NearServiceException - rpc call error exception
      • viewContractStateChanges

        ContractStateChanges viewContractStateChanges​(long blockHeight,
                                                      java.lang.String[] accountIds,
                                                      java.lang.String keyPrefixBase64)
                                               throws NearServiceException
        Returns the state change details of a contract based on the key prefix (encoded to base64). Pass an empty string for this param if you would like to return all state changes.
        Parameters:
        blockHeight - the block's height
        accountIds - the account ids
        keyPrefixBase64 - the base64 encoded key prefix
        Returns:
        the data holding object
        Throws:
        NearServiceException - rpc call error exception
      • viewContractCodeChanges

        ContractCodeChanges viewContractCodeChanges​(Finality finality,
                                                    java.lang.String[] accountIds)
                                             throws NearServiceException
        Returns code changes made when deploying a contract. Change is returned is a base64 encoded WASM file.
        Parameters:
        finality - the finality param
        accountIds - the account ids
        Returns:
        the data holding object
        Throws:
        NearServiceException - rpc call error exception
      • viewContractCodeChanges

        ContractCodeChanges viewContractCodeChanges​(java.lang.String blockHash,
                                                    java.lang.String[] accountIds)
                                             throws NearServiceException
        Returns code changes made when deploying a contract. Change is returned is a base64 encoded WASM file.
        Parameters:
        blockHash - the block's hash
        accountIds - the account ids
        Returns:
        the data holding object
        Throws:
        NearServiceException - rpc call error exception
      • viewContractCodeChanges

        ContractCodeChanges viewContractCodeChanges​(long blockHeight,
                                                    java.lang.String[] accountIds)
                                             throws NearServiceException
        Returns code changes made when deploying a contract. Change is returned is a base64 encoded WASM file.
        Parameters:
        blockHeight - the block's height
        accountIds - the account ids
        Returns:
        the data holding object
        Throws:
        NearServiceException - rpc call error exception
      • callContractFunction

        ContractFunctionCallResult callContractFunction​(Finality finality,
                                                        java.lang.String accountId,
                                                        java.lang.String methodName,
                                                        java.lang.String argsBase64)
                                                 throws NearServiceException
        Allows you to call a contract method as a view function.
        Parameters:
        finality - the finality param
        accountId - the account id
        methodName - the name of the method to call the name of the method to call
        argsBase64 - the method's base64 encoded arguments
        Returns:
        the data holding object
        Throws:
        NearServiceException - rpc call error exception
      • callContractFunction

        ContractFunctionCallResult callContractFunction​(java.lang.String blockHash,
                                                        java.lang.String accountId,
                                                        java.lang.String methodName,
                                                        java.lang.String argsBase64)
                                                 throws NearServiceException
        Allows you to call a contract method as a view function.
        Parameters:
        blockHash - the block's hash
        accountId - the account id
        methodName - the name of the method to call
        argsBase64 - the method's base64 encoded arguments
        Returns:
        the data holding object
        Throws:
        NearServiceException - rpc call error exception
      • callContractFunction

        ContractFunctionCallResult callContractFunction​(long blockHeight,
                                                        java.lang.String accountId,
                                                        java.lang.String methodName,
                                                        java.lang.String argsBase64)
                                                 throws NearServiceException
        Allows you to call a contract method as a view function.
        Parameters:
        blockHeight - the block's height
        accountId - the account id
        methodName - the name of the method to call
        argsBase64 - the method's base64 encoded arguments
        Returns:
        the data holding object
        Throws:
        NearServiceException - rpc call error exception
      • usingNetwork

        static NearService usingNetwork​(Network network)
                                 throws java.net.MalformedURLException
        NearService builder
        Parameters:
        network - the rpc peer url to connect to
        Returns:
        the data holding object
        Throws:
        java.net.MalformedURLException - thrown when url is invalid or unparseable