caver.validator
The caver.validator
package provides validation functions that should be used when implementing applications on Klaytn.
NOTE caver.validator
is supported since caver-js v1.6.3.
validateSignedMessage
Validates a signed message by comparing the public key recovered from the signature with the account key of the Klaytn account.
Parameters
Name | Type | Description |
---|---|---|
message | string | The raw message string. If this message is hashed with the Klaytn-specific prefix, the third parameter should be passed as |
signatures | object | Array | An object in the format of |
address | string | The address of the account that signed the message. |
isHashed | boolean | (optional, default: |
Return Value
Promise
returning boolean
: The promise will be resolved with a boolean value of whether the signature on the message is valid or not.
Examples
validateTransaction
Validates a transaction. This function compares the public keys from the account key of the Klaytn account with the public keys recovered from signatures
. If the transaction is fee-delegated with the feePayerSignatures
variable inside, this function compares the public keys recovered from feePayerSignatures
with the public keys of the fee payer.
Parameters
Name | Type | Description |
---|---|---|
tx | object | An instance of Transaction to validate. |
Return Value
Promise
returning boolean
: The promise will be resolved with a boolean value of whether the transacion is valid or not.
Examples
validateSender
Validates the sender of the transaction. This function compares the public keys of the account key of the Klaytn account with the public keys recovered from signatures
.
Parameters
Name | Type | Description |
---|---|---|
tx | object | An instance of Transaction to validate. |
Return Value
Promise
returning boolean
: The promise will be resolved with a boolean value of whether the transaction is valid or not.
Examples
validateFeePayer
Validates a fee payer in the transaction. This function compares the public keys of the account key of the fee payer with the public keys recovered from feePayerSignatures
.
Parameters
Name | Type | Description |
---|---|---|
tx | object | An instance of Transaction to validate. |
Return Value
Promise
returning boolean
: The promise will be resolved with a boolean value of whether the transaction is valid or not.
Examples
Last updated