Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

177
Vistas
Create random Wallet with connection to a specific provider via ethers.js

Problem

I am trying to create random wallets via the function Ethers.Wallet.createRandom with a connection to a specific network (like Ropsten for example). The docs specify that I can pass an optional options object.

What I tried

I tried passing a connection to the network like this:

const networkProvider = await new Ethers.getDefaultProvider(process.env.NETWORK);
const wallet = Ethers.Wallet.createRandom({ provider: networkProvider });

Unfortunately, that did not work.

Question

Is there an option to pass the network when creating the wallet or has this to be done later?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The returned Wallet object (docs) contains the private key and the address of the wallet. However, the address generating algorithm is universal across all networks. So if a private key 0x123 generates an address 0x456, you can always use the same 0x123 private key to sign transactions from 0x456 address on all networks - the mainnet, Ropsten, Rinkeby, etc.

The network on which you broadcast the transaction depends on what network is your provider connected to. So if your want to limit on what networks the app can send transactions, you need to validate the provider's getNetwork() returned value (docs).

Ad the options param: In the createRandom() source code, it only uses the param to affect the pseudo-randomness of how the private key is generated. But again, it's not related to the network(s) on which you're going to be using the wallet.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda