All web object methods

All of the following methods are implemented by the account manager (web extension or mobile wallet), the sdk mostly provides ease of use and correct types.

MethodparametersreturnDescription

isKleverWebLoaded

()

boolean

Checks if an account manager is loaded on window.

isKleverWebActive

()

boolean

Checks if the loaded account manager is initialized.

broadcastTransactions

(transactions: ITransaction[])

Promise<IBroadcastResponse>

Broadcasts an array of transactions to the provided node.

signMessage

(message:string, privateKey:string)

Promise<string>

Uses the account manager's internal signature method to sign any message.

signTransaction

(transaction: ITransaction)

Promise<ITransaction>

Uses the account manager's internal signature method to sign a transaction.

validateSignature

( message: string, signature: string, publicKey: string )

Promise<boolean>

Checks if the signature, message and signer are compatible.

buildTransaction

( contracts: IContractRequest[], txData?: string[], options?: ITxOptionsRequest )

Promise<ITransaction>

Builds a simplified transaction into a transaction ready to be signed.

initialize

(timeout?: number)

Promise<void>

Initializes the account manager with the selected account in the wallet. Waits until the provider is injected on the window (default timeout: 5000ms).

getWalletAddress

()

string

Returns the selected account address.

getProvider

()

Gets the current provider object.

setProvider

(providers: IProvider)

void

Sets the provider object.

Optional Build Params Usage

To build a transaction you only need the contracts with the correct parameters, described in each contract page, however you can pass additional options such as metadata and custom nonce or permission ID for the transaction.

Metadata:

To send metadata, use the second parameter in buildTransaction, notice that it should be an array where each string corresponds to the metadata of the contract of the same index. E.g.:

buildTransaction([transferContract, assetTriggerContract], ["metadata0", "metadata1"])

"metadata0" will be added to the transferContract, "metadata1" will be added to the assetTriggerContract.

Nonce and Permission ID

To change the nonce or the permission ID, use the third parameter. E.g.:

buildTransaction([transferContract],, {
    nonce:0,
    permId:0
})

Last updated