vkoukou
vkoukou

Reputation: 142

How to Query if an Account exists by name

I want to use Accounts in my CorDapp and I would like to check if an account already exists before creating a new one.

How can I query the Vault to see if an account with a specific name exists or not?

Upvotes: 0

Views: 111

Answers (1)

Adel Rustum
Adel Rustum

Reputation: 2548

int numberOfResults = getServiceHub().cordaService(KeyManagementBackedAccountService.class)
.accountInfo("USER_NAME").size();

Btw, this service KeyManagementBackedAccountService has a lot of useful functions; it comes with the Accounts library. I recommend exploring it.

Upvotes: 1

Related Questions