# Global

##

### Methods

#### connectToDaemonRpc(uriOrConfig, username, password, rejectUnauthorized, pollInterval, proxyToWorker) → {MoneroDaemonRpc}

Create a client connected to monerod.

Examples:

`let daemon = await monerojs.connectToDaemonRpc("http://localhost:38081", "superuser", "abctesting123");
let daemon = await monerojs.connectToDaemonRpc({
uri: "http://localhost:38081",
username: "superuser",
password: "abctesting123"
});`

##### Parameters:

Name | Type | Description
--- | --- | ---
`uriOrConfig` | string | object | MoneroRpcConnection | uri of monerod or JS config object or MoneroRpcConnection ###### Properties
Name | Type | Description
--- | --- | ---
`uri` | string | uri of monerod
`username` | string | username to authenticate with monerod (optional)
`password` | string | password to authenticate with monerod (optional)
`rejectUnauthorized` | boolean | rejects self-signed certificates if true (default true)
`pollInterval` | number | poll interval to query for updates in ms (default 5000)
`proxyToWorker` | boolean | run the daemon client in a web worker if true (default true)
`username` | string | username to authenticate with monerod (optional)
`password` | string | password to authenticate with monerod (optional)
`rejectUnauthorized` | boolean | rejects self-signed certificates if true (default true)
`pollInterval` | number | poll interval to query for updates in ms (default 5000)
`proxyToWorker` | boolean | runs the daemon client in a web worker if true (default true)

Source:
  - index.js, line 135

##### Returns:

the daemon RPC client

Type
  MoneroDaemonRpc

#### connectToWalletRpc(uriOrConfig, username, password, rejectUnauthorized) → {MoneroWalletRpc}

Create a client connected to monero-wallet-rpc.

Examples:

`let walletRpc = await monerojs.connectToWalletRpc("http://localhost:38081", "superuser", "abctesting123");
let walletRpc = await monerojs.connectToWalletRpc({
uri: "http://localhost:38081",
username: "superuser",
password: "abctesting123",
rejectUnauthorized: false // e.g. local development
});
// connect to monero-wallet-rpc running as internal process
let walletRpc = await monerojs.connectToWalletRpc([
"/path/to/monero-wallet-rpc",
"--stagenet",
"--daemon-address", "http://localhost:38081",
"--daemon-login", "superuser:abctesting123",
"--rpc-bind-port", "38085",
"--rpc-login", "rpc_user:abc123",
"--wallet-dir", "/path/to/wallets", // defaults to monero-wallet-rpc directory
"--rpc-access-control-origins", "http://localhost:8080"
]);`

##### Parameters:

Name | Type | Description
--- | --- | ---
`uriOrConfig` | string | Array.<string> | object | MoneroRpcConnection | uri of monero-wallet-rpc or terminal parameters or JS config object or MoneroRpcConnection ###### Properties
Name | Type | Description
--- | --- | ---
`uri` | string | uri of monero-wallet-rpc
`username` | string | username to authenticate with monero-wallet-rpc (optional)
`password` | string | password to authenticate with monero-wallet-rpc (optional)
`rejectUnauthorized` | boolean | rejects self-signed certificates if true (default true)
`username` | string | username to authenticate with monero-wallet-rpc (optional)
`password` | string | password to authenticate with monero-wallet-rpc (optional)
`rejectUnauthorized` | boolean | rejects self-signed certificates if true (default true)

Source:
  - index.js, line 176

##### Returns:

the wallet RPC client

Type
  MoneroWalletRpc

#### createWalletFull(config) → {MoneroWalletFull}

Create a Monero wallet using fully client-side WebAssembly bindings to monero-project's wallet2 in C++.

Example:

`let wallet = await monerojs.createWalletFull({
path: "./test_wallets/wallet1", // leave blank for in-memory wallet
password: "supersecretpassword",
networkType: MoneroNetworkType.STAGENET,
mnemonic: "coexist igloo pamphlet lagoon...",
restoreHeight: 1543218,
server: new monerojs.MoneroRpcConnection("http://localhost:38081", "daemon_user", "daemon_password_123"),
});`

##### Parameters:

Name | Type | Description
--- | --- | ---
`config` | object | MoneroWalletConfig | MoneroWalletConfig or equivalent config object ###### Properties
Name | Type | Description
--- | --- | ---
`path` | string | path of the wallet to create (optional, in-memory wallet if not given)
`password` | string | password of the wallet to create
`networkType` | string | number | network type of the wallet to create (one of "mainnet", "testnet", "stagenet" or MoneroNetworkType.MAINNET|TESTNET|STAGENET)
`mnemonic` | string | mnemonic of the wallet to create (optional, random wallet created if neither mnemonic nor keys given)
`seedOffset` | string | the offset used to derive a new seed from the given mnemonic to recover a secret wallet from the mnemonic phrase
`primaryAddress` | string | primary address of the wallet to create (only provide if restoring from keys)
`privateViewKey` | string | private view key of the wallet to create (optional)
`privateSpendKey` | string | private spend key of the wallet to create (optional)
`restoreHeight` | number | block height to start scanning frsom (defaults to 0 unless generating random wallet)
`language` | string | language of the wallet's mnemonic phrase (defaults to "English" or auto-detected)
`accountLookahead` | number | number of accounts to scan (optional)
`subaddressLookahead` | number | number of subaddresses to scan per account (optional)
`serverUri` | string | uri of the wallet's daemon (optional)
`serverUsername` | string | username to authenticate with the daemon (optional)
`serverPassword` | string | password to authenticate with the daemon (optional)
`rejectUnauthorized` | boolean | reject self-signed server certificates if true (defaults to true)
`server` | MoneroRpcConnection | object | MoneroRpcConnection or equivalent JS object providing daemon configuration (optional)
`proxyToWorker` | boolean | proxies wallet operations to a web worker in order to not block the main thread (default true)
`fs` | fs | Node.js compatible file system to use (defaults to disk or in-memory FS if browser)

Source:
  - index.js, line 216

##### Returns:

the created wallet

Type
  MoneroWalletFull

#### createWalletKeys(config) → {MoneroWalletKeys}

Create a wallet using WebAssembly bindings to monero-project.

Example:

`let wallet = await monerojs.createWalletKeys({
password: "abc123",
networkType: MoneroNetworkType.STAGENET,
mnemonic: "coexist igloo pamphlet lagoon..."
});`

##### Parameters:

Name | Type | Description
--- | --- | ---
`config` | MoneroWalletConfig | object | MoneroWalletConfig or equivalent config object ###### Properties
Name | Type | Description
--- | --- | ---
`networkType` | string | number | network type of the wallet to create (one of "mainnet", "testnet", "stagenet" or MoneroNetworkType.MAINNET|TESTNET|STAGENET)
`mnemonic` | string | mnemonic of the wallet to create (optional, random wallet created if neither mnemonic nor keys given)
`seedOffset` | string | the offset used to derive a new seed from the given mnemonic to recover a secret wallet from the mnemonic phrase
`primaryAddress` | string | primary address of the wallet to create (only provide if restoring from keys)
`privateViewKey` | string | private view key of the wallet to create (optional)
`privateSpendKey` | string | private spend key of the wallet to create (optional)
`language` | string | language of the wallet's mnemonic phrase (defaults to "English" or auto-detected)

Source:
  - index.js, line 286

##### Returns:

the created wallet

Type
  MoneroWalletKeys

#### getVersion() → {string}

Get the version of the monero-javascript library.

Source:
  - index.js, line 102

##### Returns:

the version of this monero-javascript library

Type
  string

#### openWalletFull(configOrPath, password, networkType, daemonUriOrConnection, proxyToWorker, fs) → {MoneroWalletFull}

Open an existing Monero wallet using fully client-side WebAssembly bindings to monero-project's wallet2 in C++.

Examples:

`let wallet1 = await monerojs.openWalletFull(
"./wallets/wallet1",
"supersecretpassword",
MoneroNetworkType.STAGENET,
"http://localhost:38081" // daemon uri
);
let wallet2 = await monerojs.openWalletFull({
path: "./wallets/wallet2",
password: "supersecretpassword",
networkType: MoneroNetworkType.STAGENET,
serverUri: "http://localhost:38081", // daemon configuration
serverUsername: "superuser",
serverPassword: "abctesting123"
});`

##### Parameters:

Name | Type | Description
--- | --- | ---
`configOrPath` | MoneroWalletConfig | object | string | MoneroWalletConfig or equivalent config object or a path to a wallet to open ###### Properties
Name | Type | Description
--- | --- | ---
`path` | string | path of the wallet to open (optional if 'keysData' provided)
`password` | string | password of the wallet to open
`networkType` | string | number | network type of the wallet to open (one of "mainnet", "testnet", "stagenet" or MoneroNetworkType.MAINNET|TESTNET|STAGENET)
`keysData` | Uint8Array | wallet keys data to open (optional if path provided)
`cacheData` | Uint8Array | wallet cache data to open (optional)
`serverUri` | string | uri of the wallet's daemon (optional)
`serverUsername` | string | username to authenticate with the daemon (optional)
`serverPassword` | string | password to authenticate with the daemon (optional)
`rejectUnauthorized` | boolean | reject self-signed server certificates if true (defaults to true)
`server` | MoneroRpcConnection | object | MoneroRpcConnection or equivalent JS object configuring the daemon connection (optional)
`proxyToWorker` | boolean | proxies wallet operations to a web worker in order to not block the main thread (default true)
`fs` | fs | Node.js compatible file system to use (defaults to disk or in-memory FS if browser)
`password` | string | password of the wallet to open
`networkType` | string | number | network type of the wallet to open
`daemonUriOrConnection` | string | MoneroRpcConnection | daemon URI or MoneroRpcConnection
`proxyToWorker` | boolean | proxies wallet operations to a web worker in order to not block the main thread (default true)
`fs` | fs | Node.js compatible file system to use (defaults to disk or in-memory FS if browser)

Source:
  - index.js, line 261

##### Returns:

the opened wallet

Type
  MoneroWalletFull