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​(NearClient nearClient,
                                                          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,
                                                          NearException
        Sends a TransferAction transaction calling a contract to create_account and waits for result using NearClient.sendTransactionAwait(String)
        Parameters:
        nearClient - 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
        NearException - 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 NearClient.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
        NearException - any NEAR-RPC exception
      • createNamedAccountAsync

        public static EncodedHash createNamedAccountAsync​(NearClient nearClient,
                                                          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
        Sends a TransferAction transaction async using NearClient.sendTransactionAsync(String) with the needed actions to generate a named account and waits for result using NearClient.sendTransactionAwait(String)
        Parameters:
        nearClient - 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
        NearException - 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,
                                                          NearException
        Sends a TransferAction transaction async using NearClient.sendTransactionAsync(String) with the needed actions to generate a named account and waits for result using NearClient.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
        NearException - any NEAR-RPC exception
      • createSubAccount

        public static TransactionAwait createSubAccount​(NearClient nearClient,
                                                        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 NearClient.sendTransactionAwait(String)
        Parameters:
        nearClient - 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​(NearClient nearClient,
                                                        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 NearClient.sendTransactionAsync(String) with the needed actions to generate a sub account and waits for result using NearClient.sendTransactionAwait(String)
        Parameters:
        nearClient - 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 NearException
        Method to check that the human-readable account id follows the naming convention
        Parameters:
        accountId - human-readable account id
        Throws:
        NearException - thows if the name deviates from the regex pattern