Wallet
Defined in: classes/Wallet.ts:28
A Wallet manages a private key and can sign messages.
Example
import { Wallet } from 'essential-eth';
const wallet = new Wallet('0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef');console.log(wallet.address); // checksummed Ethereum address
const sig = await wallet.signMessage('hello');console.log(sig); // 0x... (65-byte hex signature)Constructors
Constructor
new Wallet(
privateKey):Wallet
Defined in: classes/Wallet.ts:36
Creates a new Wallet instance.
Parameters
privateKey
string
A 32-byte private key as a hex string (with or without 0x prefix)
Returns
Wallet
Accessors
address
Get Signature
get address():
string
Defined in: classes/Wallet.ts:51
The checksummed Ethereum address derived from the private key.
Returns
string
provider
Get Signature
get provider():
unknown
Defined in: classes/Wallet.ts:144
The currently connected provider, if any.
Returns
unknown
publicKey
Get Signature
get publicKey():
string
Defined in: classes/Wallet.ts:62
The uncompressed public key (with 04 prefix) as a hex string.
Returns
string
Methods
connect()
connect(
provider):Wallet
Defined in: classes/Wallet.ts:136
Returns a new Wallet connected to the specified provider. The provider is stored for future sendTransaction support.
Parameters
provider
unknown
A JSON-RPC provider instance
Returns
Wallet
This wallet instance with the provider attached
signMessage()
signMessage(
message):Promise<string>
Defined in: classes/Wallet.ts:75
Signs a message following EIP-191 (personal_sign) standard.
The message is prefixed with “\x19Ethereum Signed Message:\n” + message.length before being hashed with keccak256 and signed with secp256k1.
Parameters
message
The message to sign (string or Uint8Array)
string | Uint8Array<ArrayBufferLike>
Returns
Promise<string>
The signature as a hex string (r + s + v, 65 bytes / 130 hex chars + 0x prefix)
signTypedData()
signTypedData(
_domain,_types,_value):Promise<string>
Defined in: classes/Wallet.ts:122
Signs EIP-712 typed data. Not yet implemented.
Parameters
_domain
unknown
_types
unknown
_value
unknown
Returns
Promise<string>
Throws
Always throws “Not yet implemented”