> For the complete documentation index, see [llms.txt](https://obytejs.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://obytejs.com/0.1.3/utils/generate-wallet.md).

# Generate a random address

### Paper wallet

To generate a new random address you can use Obyte paper wallet offline here: <https://bonustrack.github.io/obyte-paperwallet/>

### Node.js

Open your terminal and run:

```
npm i byteball bitcore-mnemonic --save
```

Then run this script to generate a new wallet:

```javascript
const { toWif, getChash160 } = require('byteball/lib/utils');
const Mnemonic = require('bitcore-mnemonic');

const testnet = false; // Change to "true" to generate testnet wallet

const path = testnet ? "m/44'/1'/0'/0/0" : "m/44'/0'/0'/0/0";
let mnemonic = new Mnemonic();
while (!Mnemonic.isValid(mnemonic.toString())) {
  mnemonic = new Mnemonic();
}
const xPrivKey = mnemonic.toHDPrivateKey();
const { privateKey } = xPrivKey.derive(path);
const privKeyBuf = privateKey.bn.toBuffer({ size: 32 });
const wif = toWif(privKeyBuf, testnet);
const pubkey = privateKey.publicKey.toBuffer().toString('base64');
const definition = ['sig', { pubkey }];
const address = getChash160(definition);

console.log(
  'Seed:', mnemonic.phrase,
  '\nPath:', path,
  '\nWIF:', wif,
  '\nPublic key:', pubkey,
  '\nAddress:', address
);
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://obytejs.com/0.1.3/utils/generate-wallet.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
