Class AccountsManager


  • public class AccountsManager
    extends BaseManager
    Controller class to manage the token functions
    • Field Detail

      • log

        private static final org.apache.logging.log4j.Logger log
      • faucetUrl

        private String faucetUrl
    • Constructor Detail

      • AccountsManager

        private AccountsManager​(io.keyko.common.web3.KeeperService keeperService,
                                MetadataApiService metadataApiService)
    • Method Detail

      • getInstance

        public static AccountsManager getInstance​(io.keyko.common.web3.KeeperService keeperService,
                                                  MetadataApiService metadataApiService)
        Given the KeeperService and MetadataApiService, returns a new instance of AccountsManager using them as attributes
        Parameters:
        keeperService - Keeper Dto
        metadataApiService - Provider Dto
        Returns:
        AccountsManager
      • getAccounts

        public List<Account> getAccounts()
                                  throws EthereumException
        Returns the list of ethereum accounts registered in the Keeper node If getBalance is true, get the ethereum and nevermined balance of each account
        Returns:
        List of accounts
        Throws:
        EthereumException - if the EVM throws an exception
      • getAccountBalance

        public Balance getAccountBalance​(String accountAddress)
                                  throws EthereumException
        Given an account returns a Balance object with the Ethereum and Ocean balance
        Parameters:
        accountAddress - account
        Returns:
        Balance
        Throws:
        EthereumException - if the EVM throws an exception
      • getEthAccountBalance

        public BigInteger getEthAccountBalance​(String accountAddress)
                                        throws EthereumException
        Given an account returns the Ethereum balance
        Parameters:
        accountAddress - account
        Returns:
        ethereum balance
        Throws:
        EthereumException - if the EVM throws an exception
      • getNeverminedAccountBalance

        public BigInteger getNeverminedAccountBalance​(String accountAddress)
                                               throws EthereumException
        Given an account returns the Ocean balance Contract: NeverminedToken Method: balanceOf
        Parameters:
        accountAddress - account
        Returns:
        nevermined balance
        Throws:
        EthereumException - if the EVM throws an exception
      • requestTokens

        public org.web3j.protocol.core.methods.response.TransactionReceipt requestTokens​(BigInteger amount)
                                                                                  throws EthereumException
        Requests Nevermined Tokens from the Dispenser Smart Contract
        Parameters:
        amount - amount of tokens requests
        Returns:
        TransactionReceipt
        Throws:
        EthereumException - if the EVM throws an exception
      • transfer

        public org.web3j.protocol.core.methods.response.TransactionReceipt transfer​(String receiverAccount,
                                                                                    BigInteger amount)
                                                                             throws EthereumException
        Transfer tokens from one account to the receiver address
        Parameters:
        receiverAccount - Address of the transfer receiver
        amount - Amount of tokens to transfer
        Returns:
        TransactionReceipt tx receipt
        Throws:
        EthereumException - if the EVM throws an exception
      • getFaucetUrl

        public String getFaucetUrl()