Web3JS Online
Viem Online
Webhooks, Alerts, and a simple API.
The padLeft function is a utility method provided by the web3.utils module that adds a padding to the left of a string. The function takes three parameters: value, characterAmount, and sign.
The value parameter is the string or number that will be padded. If value is a integer or bigInt, it will be converted to a hex string before padding.
The characterAmount parameter is the number of characters that the resulting string should have.
The sign parameter is an optional string that specifies the character to be added to the left of the string. The default value of sign is '0'.
The function returns a string that has been padded to the left with the specified number of characters. If value is a string, the padding will be added to the left of the string. If value is a integer or bigInt, the hex string representation of the number will be padded to the left with the specified number of characters.
Here's an example usage of the padLeft function:
In this example, the padLeft function takes the string '0x123' as the value parameter, 10 as the characterAmount parameter, and the default value of sign is '0'. The function returns a string that has been padded to the left with 10 characters, resulting in the string '0x0000000123'.