Skip to content
This repository has been archived by the owner on Jun 17, 2021. It is now read-only.

Latest commit

 

History

History
287 lines (168 loc) · 7.18 KB

_account_.md

File metadata and controls

287 lines (168 loc) · 7.18 KB

ethereumjs-util"account"

Module: "account"

Index

Classes

Interfaces

Variables

Functions

Variables

Const publicToAddress

publicToAddress: pubToAddress = pubToAddress

Defined in account.ts:258

Functions

Const generateAddress

generateAddress(from: Buffer, nonce: Buffer): Buffer

Defined in account.ts:180

Generates an address of a newly created contract.

Parameters:

Name Type Description
from Buffer The address which is creating this new address
nonce Buffer The nonce of the from account

Returns: Buffer


Const generateAddress2

generateAddress2(from: Buffer, salt: Buffer, initCode: Buffer): Buffer

Defined in account.ts:201

Generates an address for a contract created using CREATE2.

Parameters:

Name Type Description
from Buffer The address which is creating this new address
salt Buffer A salt
initCode Buffer The init code of the contract being created

Returns: Buffer


Const importPublic

importPublic(publicKey: Buffer): Buffer

Defined in account.ts:281

Converts a public key to the Ethereum format.

Parameters:

Name Type
publicKey Buffer

Returns: Buffer


Const isValidAddress

isValidAddress(hexAddress: string): boolean

Defined in account.ts:128

Checks if the address is a valid. Accepts checksummed addresses too.

Parameters:

Name Type
hexAddress string

Returns: boolean


Const isValidChecksumAddress

isValidChecksumAddress(hexAddress: string, eip1191ChainId?: undefined | number): boolean

Defined in account.ts:168

Checks if the address is a valid checksummed address.

See toChecksumAddress' documentation for details about the eip1191ChainId parameter.

Parameters:

Name Type
hexAddress string
eip1191ChainId? undefined | number

Returns: boolean


Const isValidPrivate

isValidPrivate(privateKey: Buffer): boolean

Defined in account.ts:219

Checks if the private key satisfies the rules of the curve secp256k1.

Parameters:

Name Type
privateKey Buffer

Returns: boolean


Const isValidPublic

isValidPublic(publicKey: Buffer, sanitize: boolean): boolean

Defined in account.ts:229

Checks if the public key satisfies the rules of the curve secp256k1 and the requirements of Ethereum.

Parameters:

Name Type Default Description
publicKey Buffer - The two points of an uncompressed key, unless sanitize is enabled
sanitize boolean false Accept public keys in other formats

Returns: boolean


Const isZeroAddress

isZeroAddress(hexAddress: string): boolean

Defined in account.ts:301

Checks if a given address is the zero address.

Parameters:

Name Type
hexAddress string

Returns: boolean


Const privateToAddress

privateToAddress(privateKey: Buffer): Buffer

Defined in account.ts:264

Returns the ethereum address of a given private key.

Parameters:

Name Type Description
privateKey Buffer A private key must be 256 bits wide

Returns: Buffer


Const privateToPublic

privateToPublic(privateKey: Buffer): Buffer

Defined in account.ts:272

Returns the ethereum public key of a given private key.

Parameters:

Name Type Description
privateKey Buffer A private key must be 256 bits wide

Returns: Buffer


Const pubToAddress

pubToAddress(pubKey: Buffer, sanitize: boolean): Buffer

Defined in account.ts:249

Returns the ethereum address of a given public key. Accepts "Ethereum public keys" and SEC1 encoded keys.

Parameters:

Name Type Default Description
pubKey Buffer - The two points of an uncompressed key, unless sanitize is enabled
sanitize boolean false Accept public keys in other formats

Returns: Buffer


Const toChecksumAddress

toChecksumAddress(hexAddress: string, eip1191ChainId?: undefined | number): string

Defined in account.ts:143

Returns a checksummed address.

If a eip1191ChainId is provided, the chainId will be included in the checksum calculation. This has the effect of checksummed addresses for one chain having invalid checksums for others. For more details see EIP-1191.

WARNING: Checksums with and without the chainId will differ. As of 2019-06-26, the most commonly used variation in Ethereum was without the chainId. This may change in the future.

Parameters:

Name Type
hexAddress string
eip1191ChainId? undefined | number

Returns: string


Const zeroAddress

zeroAddress(): string

Defined in account.ts:292

Returns the zero address.

Returns: string