Class IconService


  • public class IconService
    extends java.lang.Object
    IconService which provides APIs of ICON network.
    • Constructor Detail

      • IconService

        public IconService​(Provider provider)
        Creates an IconService instance
        Parameters:
        provider - the worker that transports requests
    • Method Detail

      • setProvider

        public void setProvider​(Provider provider)
      • getTotalSupply

        public Request<java.math.BigInteger> getTotalSupply()
        Gets the total number of issued coins
        Returns:
        a BigInteger object of the total number of coins in loop
      • getBalance

        public Request<java.math.BigInteger> getBalance​(Address address)
        Gets the balance of an address
        Parameters:
        address - the address to check the balance
        Returns:
        a BigInteger object of the current balance for the given address in loop
      • getBlock

        public Request<Block> getBlock​(java.math.BigInteger height)
        Gets a block matching the block number
        Parameters:
        height - the block number
        Returns:
        a Block object
      • getBlock

        public Request<Block> getBlock​(Bytes hash)
        Gets a block matching the block hash
        Parameters:
        hash - the block hash
        Returns:
        a Block object
      • getLastBlock

        public Request<Block> getLastBlock()
        Gets the last block
        Returns:
        a Block object
      • getScoreApi

        public Request<java.util.List<ScoreApi>> getScoreApi​(Address scoreAddress)
        Gets information about the APIs in SCORE
        Parameters:
        scoreAddress - the address to get APIs
        Returns:
        a ScoreApi object
      • getTransaction

        public Request<ConfirmedTransaction> getTransaction​(Bytes hash)
        Gets a transaction matching the given transaction hash
        Parameters:
        hash - a transaction hash
        Returns:
        a ConfirmedTransaction object
      • getTransactionResult

        public Request<TransactionResult> getTransactionResult​(Bytes hash)
        Gets the result of a transaction specified by the transaction hash
        Parameters:
        hash - a transaction hash
        Returns:
        a TransactionResult object
      • call

        public <T> Request<T> call​(Call<T> call)
        Calls a SCORE read-only API
        Type Parameters:
        T - the response type
        Parameters:
        call - an instance of Call
        Returns:
        a Request object that can execute the request
      • sendTransaction

        public Request<Bytes> sendTransaction​(SignedTransaction signedTransaction)
        Sends a transaction that changes the states of the account
        Parameters:
        signedTransaction - a transaction that was signed with the sender's wallet
        Returns:
        a Request object that can execute the request (return type is txHash)
      • estimateStep

        public Request<java.math.BigInteger> estimateStep​(Transaction transaction)
        Gets an estimated step of how much step is necessary to allow the transaction to complete
        Parameters:
        transaction - a raw transaction without stepLimit and signature information
        Returns:
        a Request object that can execute the request (return type is BigInteger)
        Since:
        0.9.12
      • sendTransactionAndWait

        public Request<TransactionResult> sendTransactionAndWait​(SignedTransaction signedTransaction)
        Sends a transaction like sendTransaction, then waits for some time to get the result. The user may set a specific timeout in the HTTP header, but it cannot exceed the node's max timeout limit. If a timeout did not set by the user, the node uses its defaultWaitTimeout setting.
        Parameters:
        signedTransaction - a transaction that was signed with the sender's wallet
        Returns:
        a TransactionResult object
      • waitTransactionResult

        public Request<TransactionResult> waitTransactionResult​(Bytes hash)
        Gets the result of a transaction specified by the transaction hash like getTransactionResult, but waits for some time to get the transaction result instead of returning immediately if there is no finalized result. The user may set a specific timeout in the HTTP header, but it cannot exceed the node's max timeout limit. If a timeout did not set by the user, the node uses its defaultWaitTimeout setting.
        Parameters:
        hash - a transaction hash
        Returns:
        a TransactionResult object
      • getDataByHash

        public Request<Base64> getDataByHash​(Bytes hash)
        Retrieves data based on the hash algorithm (SHA3-256) Following data can be retrieved by a hash. - BlockHeader, Validators, Votes ...
        Parameters:
        hash - the hash value of the data to retrieve
        Returns:
        a Request object that can execute the request
      • getBlockHeaderByHeight

        public Request<Base64> getBlockHeaderByHeight​(java.math.BigInteger height)
        Gets block header for specified height
        Parameters:
        height - the height of the block
        Returns:
        a Request object that can execute the request
      • getVotesByHeight

        public Request<Base64> getVotesByHeight​(java.math.BigInteger height)
        Gets votes for the block specified by height
        Parameters:
        height - the height of the block
        Returns:
        a Request object that can execute the request
      • getProofForResult

        public Request<Base64[]> getProofForResult​(Bytes hash,
                                                   java.math.BigInteger index)
        Gets proof for the receipt
        Parameters:
        hash - the hash value of the block including the result
        index - index of the receipt in the block
        Returns:
        a Request object that can execute the request
      • monitorBlocks

        public Monitor<BlockNotification> monitorBlocks​(java.math.BigInteger height)
        Gets a monitor for block notification
        Parameters:
        height - the start height
        Returns:
        a Monitor object
      • monitorEvents

        public Monitor<EventNotification> monitorEvents​(java.math.BigInteger height,
                                                        java.lang.String event,
                                                        Address addr,
                                                        java.lang.String[] indexed,
                                                        java.lang.String[] data)
        Gets a monitor for event notification
        Parameters:
        height - the start height
        event - the event signature
        addr - the address of SCORE
        indexed - the array of arguments to match with indexed parameters of event
        data - the array of arguments to match with non-indexed parameters of event
        Returns:
        a Monitor object
      • addConverterFactory

        public void addConverterFactory​(RpcConverter.RpcConverterFactory factory)
        Adds Converter factory. It has a create function that creates the converter of the specific type.
        Parameters:
        factory - a converter factory