Socket
Book a DemoInstallSign in
Socket

solidity-string-utils

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

solidity-string-utils

Simplify dumping data as string in solidity.

latest
npmnpm
Version
0.0.8-0
Version published
Maintainers
1
Created
Source

solidity string utilities.

Simplify dumping data as string in solidity.

Optimized for usability, and not for gas.

Mostly useful in testing by generating meaningful revert messages.

Currently supports toString() method for uint, address, bytes32, bool, int and string

Also provides concat() methods for those types, but only with 2 and 3 params. For longer params, use multiple concat calls or abi.encodePacked()

e.g.

import "solidity-string-utils/StringUtils.sol";

contract MyContract {

    using StringUtils for *;

    function someMethod() public {


        require(condition, "condition not met"
            .concat( " a=", a)
            .concat( " b=", b)
        );

        revert(string(abi.encodePacked(
                "asd",
                a.toString(),
                b.toString(),
                c.toString(),
                d.toString(),
                e.toString()
            )));
    }

}

FAQs

Package last updated on 12 Jul 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts