Class AccountService


  • public class AccountService
    extends java.lang.Object
    Account service provides methods to easily work with the creation of accounts
    Since:
    0.2.0
    Author:
    Alexandre Carvalho, Andre Bertolace
    • Constructor Detail

      • AccountService

        public AccountService()
    • Method Detail

      • createNamedAccount

        public static TransactionAwait createNamedAccount​(NearService nearService,
                                                          java.lang.String mainDomain,
                                                          java.lang.String newAccountId,
                                                          PublicKey newAccountPublicKey,
                                                          java.math.BigInteger amountToNewAccount,
                                                          java.lang.String creatorAccountId,
                                                          PublicKey creatorPublicKey,
                                                          PrivateKey creatorPrivateKey)
                                                   throws java.security.GeneralSecurityException,
                                                          NearServiceException
        Sends a TransferAction transaction calling a contract to create_account and waits for result using NearService.sendTransactionAwait(String)
        Parameters:
        nearService - the near service instance to use
        mainDomain - network main domain (eg. near, testnet, ...)
        newAccountId - human-readable id of new account
        newAccountPublicKey - public key of new account
        amountToNewAccount - the amount to transfer
        creatorAccountId - human-readable id of creatot account
        creatorPublicKey - signer/account creator public key
        creatorPrivateKey - signer/account creator privatekey
        Returns:
        TransactionAwait object with the result
        Throws:
        java.security.GeneralSecurityException - thrown if failed to sign the transaction
        NearServiceException - any NEAR-RPC exception
      • createNamedAccount

        public static TransactionAwait createNamedAccount​(Network network,
                                                          java.lang.String newAccountId,
                                                          PublicKey newAccountPublicKey,
                                                          java.math.BigInteger amountToNewAccount,
                                                          java.lang.String creatorAccountId,
                                                          PublicKey creatorPublicKey,
                                                          PrivateKey creatorPrivateKey)
                                                   throws java.security.GeneralSecurityException
        Sends a TransferAction transaction calling a contract to create_account and waits for result using NearService.sendTransactionAwait(String)
        Parameters:
        network - Near network of choice
        newAccountId - human-readable id of new account
        newAccountPublicKey - public key of new account
        amountToNewAccount - the amount to transfer
        creatorAccountId - human-readable id of creatot account
        creatorPublicKey - signer/account creator public key
        creatorPrivateKey - signer/account creator privatekey
        Returns:
        TransactionAwait object with the result
        Throws:
        java.security.GeneralSecurityException - thrown if failed to sign the transaction
        NearServiceException - any NEAR-RPC exception
      • createNamedAccountAsync

        public static EncodedHash createNamedAccountAsync​(NearService nearService,
                                                          java.lang.String mainDomain,
                                                          java.lang.String newAccountId,
                                                          PublicKey newAccountPublicKey,
                                                          java.math.BigInteger amountToNewAccount,
                                                          java.lang.String creatorAccountId,
                                                          PublicKey creatorPublicKey,
                                                          PrivateKey creatorPrivateKey)
                                                   throws java.security.GeneralSecurityException,
                                                          NearServiceException
        Sends a TransferAction transaction async using NearService.sendTransactionAsync(String) with the needed actions to generate a named account and waits for result using NearService.sendTransactionAwait(String)
        Parameters:
        nearService - the near service instance to use
        mainDomain - network main domain (eg. near, testnet, ...)
        newAccountId - human-readable id of new account
        newAccountPublicKey - public key of new account
        amountToNewAccount - the amount to transfer
        creatorAccountId - human-readable id of creatot account
        creatorPublicKey - signer/account creator public key
        creatorPrivateKey - signer/account creator privatekey
        Returns:
        transaction hash
        Throws:
        java.security.GeneralSecurityException - thrown if failed to sign the transaction
        NearServiceException - any NEAR-RPC exception
      • createNamedAccountAsync

        public static EncodedHash createNamedAccountAsync​(Network network,
                                                          java.lang.String newAccountId,
                                                          PublicKey newAccountPublicKey,
                                                          java.math.BigInteger amountToNewAccount,
                                                          java.lang.String creatorAccountId,
                                                          PublicKey creatorPublicKey,
                                                          PrivateKey creatorPrivateKey)
                                                   throws java.security.GeneralSecurityException,
                                                          NearServiceException
        Sends a TransferAction transaction async using NearService.sendTransactionAsync(String) with the needed actions to generate a named account and waits for result using NearService.sendTransactionAwait(String)
        Parameters:
        network - Near network of choice
        newAccountId - human-readable id of new account
        newAccountPublicKey - public key of new account
        amountToNewAccount - the amount to transfer
        creatorAccountId - human-readable id of creatot account
        creatorPublicKey - signer/account creator public key
        creatorPrivateKey - signer/account creator privatekey
        Returns:
        transaction hash
        Throws:
        java.security.GeneralSecurityException - thrown if failed to sign the transaction
        NearServiceException - any NEAR-RPC exception
      • createSubAccount

        public static TransactionAwait createSubAccount​(NearService nearService,
                                                        java.lang.String newAccountId,
                                                        java.math.BigInteger amountToNewAccount,
                                                        java.lang.String creatorAccountId,
                                                        PublicKey creatorPublicKey,
                                                        PrivateKey creatorPrivateKey)
                                                 throws java.security.GeneralSecurityException
        Sends a TransferAction transaction with the needed actions to generate a sub account and waits for result using NearService.sendTransactionAwait(String)
        Parameters:
        nearService - the near service instance to use
        newAccountId - human-readable id of new account
        amountToNewAccount - the amount to transfer
        creatorAccountId - human-readable id of creatot account
        creatorPublicKey - signer/account creator public key
        creatorPrivateKey - signer/account creator privatekey
        Returns:
        TransactionAwait object with the result
        Throws:
        java.security.GeneralSecurityException - thrown if failed to sign the transaction
      • createSubAccountAsync

        public static EncodedHash createSubAccountAsync​(NearService nearService,
                                                        java.lang.String newAccountId,
                                                        java.math.BigInteger amountToNewAccount,
                                                        java.lang.String creatorAccountId,
                                                        PublicKey creatorPublicKey,
                                                        PrivateKey creatorPrivateKey)
                                                 throws java.security.GeneralSecurityException
        Sends a TransferAction transaction async using NearService.sendTransactionAsync(String) with the needed actions to generate a sub account and waits for result using NearService.sendTransactionAwait(String)
        Parameters:
        nearService - the near service instance to use
        newAccountId - human-readable id of new account
        amountToNewAccount - the amount to transfer
        creatorAccountId - human-readable id of creatot account
        creatorPublicKey - signer/account creator public key
        creatorPrivateKey - signer/account creator privatekey
        Returns:
        transatcion hash
        Throws:
        java.security.GeneralSecurityException - thrown if failed to sign the transaction
      • checkAccountId

        public static void checkAccountId​(java.lang.String accountId)
                                   throws NearServiceException
        Method to check that the human-readable account id follows the naming convention
        Parameters:
        accountId - human-readable account id
        Throws:
        NearServiceException - thows if the name deviates from the regex pattern