utils sub-class
The following readme describes all the functions and their parameters exposed by the utils
class of the KETH SDK.
add0x function
This function can be used to append 0x
towards the start of a string to convert it into a hex string accepted by the contracts. If the input string already contains the 0x
, the function will return the string as is.
Input Parameters
data: string which needs to be appended by 0x
Using add0x function
await sdk.utils.add0x(data);
Return Parameter
Returns hex string
remove0x function
This function removes 0x
from the beginning of a string. If the input string doesn't contain 0x
, it will return the string as is.
Input Parameters
data: string to remove 0x
from
Using remove0x function
await sdk.utils.remove0x(data);
Return Parameter
Returns string without 0x
in the beginning.