Version: 0.14.0

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:

const tlNetwork = new TLNetwork(...)
// Create user
tlNetwork.user.create().then(
newUser => console.log("New user:", newUser)
)

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:#

NameTypeDescription
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:#

NameTypeDescription
tlWalletDataTLWalletDataWallet data to encrypt and serialize.
password?string | (progress: number) => voidOptional password to encrypt wallet with. If not specified default password is used.
progressCallback?(progress: number) => voidOptional 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:#

NameTypeDescription
tlWalletDataTLWalletDatadata 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:#

NameTypeDescription
serializedEncryptedKeystorestringSerialized standard JSON keystore.
passwordstringPassword to decrypt serialized JSON keystore with.
progressCallback?(progress: number) => anyOptional 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:#

NameTypeDescription
privateKeystringPrivate 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:#

NameTypeDescription
seedstring12 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:#

NameTypeDescription
msgHashstringHash of message that should be signed.

Returns: Promise<Signature>