0

I wonder something about the usage of the metamask wallet for Dapp. I have implemented an Authentication mechanism to my Dapp with Keycloak, and I ask for blockchain wallet addresses of the users in the registration.

However, I need to be sure that when the user uses my Dapp, he/she uses the address they provided in the registration; otherwise, I need to revoke their request.

I use metamask as a wallet provider; thank you.

1
  • Just ignore the requests that come from the account that is not in your database? Commented Oct 12, 2020 at 8:16

1 Answer 1

1

You can use the eth_accounts JSON-RPC call which returns the list of accounts owned by the client. Metamask API implements it with :

const accounts = await ethereum.request({ method: 'eth_accounts' });
const currentAccount = accounts[0];

The first item of the list should return the current used account.

Then just compare the returned value with the registered account.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.