🛠️KUtils

KUTHULU Utilities. This is a shared library of commonly used functions.

append

Joins five strings together.

let a = 'Hello';
let b = ' my';
let c = ' name';
let d = ' is';
let e = ' John';
let result = contract.append(a, b, c, d, e);

Input

Name
Type
Description

a, b, c, d, e

string

The strings to be concatenated.

Output

Name
Type
Description

return value

string

The concatenated string.

_toLower

Converts all uppercase characters in a string to lowercase.

let str = 'Hello World';
let result = contract._toLower(str);

Input

Name
Type
Description

str

string

The string to be converted.

Output

Name
Type
Description

return value

string

The converted string.

strlen

Returns the length of a given string.

let str = 'Hello World';
let result = contract.strlen(str);

Input

Name
Type
Description

str

string

The string to get the length.

Output

Name
Type
Description

return value

uint256

The length of the string.

stringsEqual

Compares two strings for equality.

let str1 = 'Hello';
let str2 = 'Hello';
let result = contract.stringsEqual(str1, str2);

Input

Name
Type
Description

a, b

string

The strings to be compared.

Output

Name
Type
Description

return value

bool

True if the strings are equal, false otherwise.

URI and String Validation

isValidURI

Checks if the given string is a valid URI according to RFC3986 URI Generic Syntax.

let str = 'https://example.com';
let result = contract.isValidURI(str);

Input

Name
Type
Description

str

string

The string to be checked.

Output

Name
Type
Description

return value

bool

True if the string is a valid URI, false otherwise.

isValidGroupString

Checks if the given string is a valid group string.

let str = 'HelloWorld';
let result = contract.isValidGroupString(str);

Input

Name
Type
Description

str

string

The string to be checked.

Output

Name
Type
Description

return value

bool

True if the string is a valid group string, false otherwise.

isValidString

Checks if the given string is a valid string.

let str = 'HelloWorld';
let result = contract.isValidString(str);

Input

Name
Type
Description

str

string

The string to be checked.

Output

Name
Type
Description

return value

bool

True if the string is valid, false otherwise.

Integer to String Conversion

toString

Converts a uint256 value to its string representation.

let value = 123456;
let result = contract.toString(value);

Input

Name
Type
Description

value

uint256

The value to be converted.

Output

Name
Type
Description

return value

string

The string representation of the input value.

addressToString

Converts an Ethereum address to its string representation.

let addr = '0x742d35Cc6634C0532925a3b844Bc454e4438f44e';
let result = contract.addressToString(addr);

Input

Name
Type
Description

addr

address

The address to be converted.

Output

Name
Type
Description

return value

string

The string representation of the input address.

Last updated