Class: User
"User".User
The User class contains all user related functions, which also include wallet related methods. It is meant to be called via a TLNetwork instance like:
#
Hierarchy- User
#
Accessors#
address• get address(): string
Defined in src/User.ts:44
Checksummed Ethereum address of currently loaded wallet.
Returns: string
#
Methods#
createâ–¸ create(): Promise<TLWalletData>
Defined in src/User.ts:59
Creates a new random wallet based on the configured WalletType.
Returns: Promise<TLWalletData>
the wallet data that can be used with loadFrom
#
createLinkâ–¸ createLink(options
: { [key:string]: string; customBase?: string ; name?: string }): Promise<string>
Defined in src/User.ts:208
Returns a shareable link which can be send to other users. Contains username and address.
#
Parameters:Name | Type | Description |
---|---|---|
options | { [key:string]: string; customBase?: string ; name?: string } | any additional options that we should hang on the URL options.customBase - convention for a custom base for the URL options.name - convention for a name for the user options[key] - any other additional options that should be added to the URL |
Returns: Promise<string>
#
deployIdentityâ–¸ deployIdentity(): Promise<string>
Defined in src/User.ts:81
Deploys a new identity on the chain if the configured WalletType is WalletTypeIdentity and returns the transaction hash.
Returns: Promise<string>
#
encryptToSerializedKeystoreâ–¸ encryptToSerializedKeystore(tlWalletData
: TLWalletData, password?
: string | (progress: number) => void, progressCallback?
: (progress: number) => void): Promise<string>
Defined in src/User.ts:134
Encrypts and serializes the given wallet data.
#
Parameters:Name | Type | Description |
---|---|---|
tlWalletData | TLWalletData | Wallet data to encrypt and serialize. |
password? | string | (progress: number) => void | Optional password to encrypt wallet with. If not specified default password is used. |
progressCallback? | (progress: number) => void | Optional encryption progress callback. |
Returns: Promise<string>
#
exportPrivateKeyâ–¸ exportPrivateKey(): Promise<string>
Defined in src/User.ts:156
Returns the private key of loaded user.
Returns: Promise<string>
#
getAddressâ–¸ getAddress(): Promise<string>
Defined in src/User.ts:51
Async address
getter for loaded user.
Returns: Promise<string>
#
getBalanceâ–¸ getBalance(): Promise<Amount>
Defined in src/User.ts:103
Returns ETH balance of loaded user.
Returns: Promise<Amount>
#
getWalletDataâ–¸ getWalletData(): Promise<TLWalletData>
Defined in src/User.ts:74
Returns the wallet data. Can be used with loadFrom
Returns: Promise<TLWalletData>
#
isIdentityDeployedâ–¸ isIdentityDeployed(): Promise<boolean>
Defined in src/User.ts:88
Returns a boolean if a new identity already has been deployed for the loaded user.
Returns: Promise<boolean>
#
loadFromâ–¸ loadFrom(tlWalletData
: TLWalletData): Promise<void>
Defined in src/User.ts:67
Loads the given wallet data into the library
#
Parameters:Name | Type | Description |
---|---|---|
tlWalletData | TLWalletData | data of the wallet to load |
Returns: Promise<void>
#
recoverFromEncryptedKeystoreâ–¸ recoverFromEncryptedKeystore(serializedEncryptedKeystore
: string, password
: string, progressCallback?
: (progress: number) => any): Promise<TLWalletData>
Defined in src/User.ts:168
Recovers wallet data from a serialized encrypted JSON keystore string
(e.g. as returned by encryptToSerializedKeystore
).
#
Parameters:Name | Type | Description |
---|---|---|
serializedEncryptedKeystore | string | Serialized standard JSON keystore. |
password | string | Password to decrypt serialized JSON keystore with. |
progressCallback? | (progress: number) => any | Optional progress callback to call on encryption progress. |
Returns: Promise<TLWalletData>
the wallet data. Can be used with loadFrom
#
recoverFromPrivateKeyâ–¸ recoverFromPrivateKey(privateKey
: string): Promise<TLWalletData>
Defined in src/User.ts:194
Recovers wallet data from private key.
#
Parameters:Name | Type | Description |
---|---|---|
privateKey | string | Private key to recover wallet data from. |
Returns: Promise<TLWalletData>
wallet data. Can be used with loadFrom
#
recoverFromSeedâ–¸ recoverFromSeed(seed
: string): Promise<TLWalletData>
Defined in src/User.ts:185
Recovers wallet data from 12 word seed phrase.
#
Parameters:Name | Type | Description |
---|---|---|
seed | string | 12 word seed phrase string. |
Returns: Promise<TLWalletData>
the wallet data. Can be used with loadFrom
#
showSeedâ–¸ showSeed(): Promise<string>
Defined in src/User.ts:149
Returns the 12 word seed of loaded user.
Returns: Promise<string>
#
signMsgHashâ–¸ signMsgHash(msgHash
: string): Promise<Signature>
Defined in src/User.ts:96
Digitally signs a message hash with the currently loaded user/wallet.
#
Parameters:Name | Type | Description |
---|---|---|
msgHash | string | Hash of message that should be signed. |
Returns: Promise<Signature>