ethereumjs-monorepo

@ethereumjs/wallet / Wallet

Class: Wallet

Table of contents

Constructors

Methods

Constructors

constructor

new Wallet(privateKey?, publicKey?)

Parameters

Name Type Default value
privateKey? Uint8Array undefined
publicKey undefined | Uint8Array undefined

Defined in

wallet.ts:266

Methods

getAddress

getAddress(): Uint8Array

Returns the wallet’s address.

Returns

Uint8Array

Defined in

wallet.ts:548


getAddressString

getAddressString(): string

Returns the wallet’s address as a “0x” prefixed hex string

Returns

string

Defined in

wallet.ts:555


getChecksumAddressString

getChecksumAddressString(): string

Returns the wallet’s private key as a “0x” prefixed hex string checksummed according to EIP 55.

Returns

string

Defined in

wallet.ts:563


getPrivateKey

getPrivateKey(): Uint8Array

Returns the wallet’s private key.

Returns

Uint8Array

Defined in

wallet.ts:523


getPrivateKeyString

getPrivateKeyString(): string

Returns

string

Defined in

wallet.ts:527


getPublicKey

getPublicKey(): Uint8Array

Returns the wallet’s public key.

Returns

Uint8Array

Defined in

wallet.ts:534


getPublicKeyString

getPublicKeyString(): string

Returns the wallet’s public key as a “0x” prefixed hex string

Returns

string

Defined in

wallet.ts:541


getV3Filename

getV3Filename(timestamp?): string

Return the suggested filename for V3 keystores.

Parameters

Name Type
timestamp? number

Returns

string

Defined in

wallet.ts:633


toV3

toV3(password, opts?): Promise<V3Keystore>

Returns an Etherem Version 3 Keystore Format object representing the wallet

Parameters

Name Type Description
password string The password used to encrypt the Keystore.
opts? Partial<V3Params> The options for the keystore. See its spec for more info.

Returns

Promise<V3Keystore>

Defined in

wallet.ts:573


toV3String

toV3String(password, opts?): Promise<string>

Parameters

Name Type
password string
opts? Partial<V3Params>

Returns

Promise<string>

Defined in

wallet.ts:654


verifyPublicKey

verifyPublicKey(publicKey): boolean

Verify the publicKey, privateKey pair

Parameters

Name Type Description
publicKey Uint8Array the public key to verify against the private key of the wallet

Returns

boolean

Defined in

wallet.ts:663


fromEthSale

Static fromEthSale(input, password): Promise<Wallet>

Parameters

Name Type
input string | EthSaleKeystore
password string

Returns

Promise<Wallet>

Defined in

wallet.ts:465


fromExtendedPrivateKey

Static fromExtendedPrivateKey(extendedPrivateKey): Wallet

Create an instance based on a BIP32 extended private key (xprv)

Parameters

Name Type
extendedPrivateKey string

Returns

Wallet

Defined in

wallet.ts:357


fromExtendedPublicKey

Static fromExtendedPublicKey(extendedPublicKey): Wallet

Create an instance based on a BIP32 extended public key (xpub)

Parameters

Name Type
extendedPublicKey string

Returns

Wallet

Defined in

wallet.ts:338


fromPrivateKey

Static fromPrivateKey(privateKey): Wallet

Create an instance based on a raw private key

Parameters

Name Type
privateKey Uint8Array

Returns

Wallet

Defined in

wallet.ts:350


fromPublicKey

Static fromPublicKey(publicKey, nonStrict?): Wallet

Create an instance based on a public key (certain methods will not be available)

This method only accepts uncompressed Ethereum-style public keys, unless the nonStrict flag is set to true.

Parameters

Name Type Default value
publicKey Uint8Array undefined
nonStrict boolean false

Returns

Wallet

Defined in

wallet.ts:328


fromV1

Static fromV1(input, password): Promise<Wallet>

Import a wallet (Version 1 of the Ethereum wallet format).

Parameters

Name Type Description
input string | V1Keystore A JSON serialized string, or an object representing V1 Keystore.
password string The keystore password.

Returns

Promise<Wallet>

Defined in

wallet.ts:374


fromV3

Static fromV3(input, password, nonStrict?): Promise<Wallet>

Import a wallet (Version 3 of the Ethereum wallet format). Set nonStrict true to accept files with mixed-caps.

Parameters

Name Type Default value Description
input string | V3Keystore undefined A JSON serialized string, or an object representing V3 Keystore.
password string undefined The keystore password.
nonStrict boolean false -

Returns

Promise<Wallet>

Defined in

wallet.ts:407


generate

Static generate(icapDirect?): Wallet

Create an instance based on a new random key.

Parameters

Name Type Default value Description
icapDirect boolean false setting this to true will generate an address suitable for the ICAP Direct mode

Returns

Wallet

Defined in

wallet.ts:290


generateVanityAddress

Static generateVanityAddress(pattern): Wallet

Create an instance where the address is valid against the supplied pattern (this will be very slow)

Parameters

Name Type
pattern string | RegExp

Returns

Wallet

Defined in

wallet.ts:308