Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

179
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!