I am producing a game for a hackaton community to expose more people to Ethereum and blockchain. After hacking something my hackers will get many different seed phrases (similar to one generated by metamask). They will attempt to find the correct one however how can I set up to check if seed phrase is correct without going the "hardcoded" way?

For example, does metamask have an API to input your seed phrase and check if it's correct and allow you in? Maybe web3.js can do something?

If not, is it a good solution to transform the seed phrase into the private key and attempt to log in? How could this be done?

1 Answer 1


Ethers.js has a function that checks the validity of a seed phrase, HDNode.isValidMnemonic: https://docs.ethers.io/ethers.js/html/api-advanced.html#static-methods

For example:

import { utils } from 'ethers.js';

utils.HDNode.isValidMnemonic("action glow era all liquid critic achieve lawsuit era anger loud slight"); // returns true

If you're using Ethers.js v5 (beta) it's also possible to import the function directly from @ethersproject/hdnode, without having to include the other dependencies:

import { isValidMnemonic } from '@ethersproject/hdnode';


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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