All Projects → willitscale → Solidity Util

willitscale / Solidity Util

Licence: apache-2.0
Solidity Standard Utilities

Programming Languages

solidity
1140 projects

Projects that are alternatives of or similar to Solidity Util

Css Flexbox Cheatsheet
VS Code extension that lets you open a CSS Flexbox cheatsheet directly in the editor.
Stars: ✭ 87 (-1.14%)
Mutual labels:  hacktoberfest
Openjdk Website
Website source
Stars: ✭ 86 (-2.27%)
Mutual labels:  hacktoberfest
Git Osp For Beginners
A GitHub Repository to encourage and involve beginners in Open Source Contributions
Stars: ✭ 88 (+0%)
Mutual labels:  hacktoberfest
Pastepwn
Python framework to scrape Pastebin pastes and analyze them
Stars: ✭ 87 (-1.14%)
Mutual labels:  hacktoberfest
Vue Finder
📁 A Vue.js component to display hierarchical data (like the MacOS X finder)
Stars: ✭ 87 (-1.14%)
Mutual labels:  hacktoberfest
Flexget
The official FlexGet repository
Stars: ✭ 1,279 (+1353.41%)
Mutual labels:  hacktoberfest
Dataengineeringproject
Example end to end data engineering project.
Stars: ✭ 82 (-6.82%)
Mutual labels:  hacktoberfest
Botbuilder Community Js
Part of the Bot Builder Community Project. Repository for extensions for the Bot Builder JavaScript SDK, including middleware, dialogs, recognizers and more.
Stars: ✭ 88 (+0%)
Mutual labels:  hacktoberfest
Awesome Thai Dev
A curated list of awesome technical libraries/articles/resources in Thai
Stars: ✭ 87 (-1.14%)
Mutual labels:  hacktoberfest
Policy Hub Cli
CLI for searching Rego policies
Stars: ✭ 88 (+0%)
Mutual labels:  hacktoberfest
Gomplate
A flexible commandline tool for template rendering. Supports lots of local and remote datasources.
Stars: ✭ 1,270 (+1343.18%)
Mutual labels:  hacktoberfest
Web App
Mifos X Web App is the revamped version of the Mifos X Community App built on top of the Fineract Platform leveraging the popular Angular framework.
Stars: ✭ 87 (-1.14%)
Mutual labels:  hacktoberfest
Policy sentry
IAM Least Privilege Policy Generator
Stars: ✭ 1,284 (+1359.09%)
Mutual labels:  hacktoberfest
Hasgo
Haskell-flavoured functions for Go 😃
Stars: ✭ 85 (-3.41%)
Mutual labels:  hacktoberfest
Geocube
Tool to convert geopandas vector data into rasterized xarray data.
Stars: ✭ 87 (-1.14%)
Mutual labels:  hacktoberfest
Generator Jhipster Quarkus
Quarkus blueprint for JHipster
Stars: ✭ 85 (-3.41%)
Mutual labels:  hacktoberfest
Dependency spy
Find known vulnerabilities in your dependencies
Stars: ✭ 87 (-1.14%)
Mutual labels:  hacktoberfest
Container Tabs Sidebar
Firefox addon aiming to utilize screen estate more efficiently by showing tabs in a sidebar grouped by privacy containers. Inspired by TreeStyleTab.
Stars: ✭ 87 (-1.14%)
Mutual labels:  hacktoberfest
Understat
An asynchronous Python package for https://understat.com/.
Stars: ✭ 88 (+0%)
Mutual labels:  hacktoberfest
Jetpack
Security, performance, marketing, and design tools — Jetpack is made by the WordPress experts to make WP sites safer and faster, and help you grow your traffic.
Stars: ✭ 1,283 (+1357.95%)
Mutual labels:  hacktoberfest

Solidity Standard Utilities

Solidity is still very primitive and doing basic operations can be quite tedious and off-putting to newer developers. I've put together a very basic library of functions to help improve this.

The easiest way to use this library is to install it with npm as

npm install willitscale/solidity-util

In a project based on Truffle framework you may then import and bind the libraries to the appropriate data types as seen below:

pragma solidity ^0.5.0;

import "solidity-util/lib/Strings.sol";
import "solidity-util/lib/Integers.sol";
import "solidity-util/lib/Addresses.sol";

contract MyContract {
    using Strings for string;
    using Integers for uint;
    using Addresses for address;
    using Addresses for address payable;
}

This will then allow the use of the functionality listed below.

Other frameworks may require slightly different approaches than the description above.

Addresses

The functionality of this library is to extend the existing functionality of an address:

isContract(address) : bool

Check to see if the subject address is a contract on the Ethereum network

    function isContract(address _addr) public {
        if (_addr.isContract()) {
            // Do contract specific stuff
        }
    }

Integers

The functionality of this library is based loosely around the Java implementation:

parseInt(string) : uint

Convert an ASCII string to its unsigned integer equivalent

    function parseInt() {
        if (321 == Integers.parseInt("321")) {
            // Matches the uint value
        }
    }

toString() : uint

Convert an unsigned integer to its ASCII string equivalent

    function toString(uint _value) returns (string) {
        return _value.toString();
    }

toBytes(uint) : bytes

Convert an unsigned integer to a bytes equivalent

    function toString(uint _value) returns (bytes) {
        return _value.toBytes();
    }

toByte(uint8) : byte

Convert an 8-bit unsigned integer to its byte equivalent

    function toByte(uint8 _value) {
        if (0x1 == Integer.toByte(_value)) {
            // Matching byte
        }
    }

Strings

Please be aware that some of these functions can be quite gas heavy so use appropriately!

The functionality of this library is based loosely around the Java implementation:

concat(string) : string

Concatenate two strings together.

    function concat() {
        string memory myVal = "firstname";
        myVal = myVal.concat(" ").concat("lastname");
    }

indexOf(string) : int

Find the position of a character.

    function indexOf() {
        string memory myVal = "haystack";
        uint positionOfFirstA = myVal.indexOf("a");
        uint positionOfSecondA = myVal._indexOf("a", positionOfFirstA+1);
    }

length() : uint

Get the length of a string.

    function length() {
        string memory myVal = "length";
        if (myVal.length() == 6) {
          // Length is 6!
        }
    }

substring(uint) : string

Get a partial section of the string.

    function substring() {
        string memory myVal = "sub string example";
        string memory firstWord = myVal.substring(3);
        string memory secondWord = myVal._substring(6,4);
    }

split(string) : string[]

Splits a string into an array of smaller strings based off a delimiter.

    function split() {
        string memory myVal = "my example split";
        string[] storage split = myVal.split(" ");
        if (3 == split.length) {
          if(split[1].compareTo("example")) {
            // Valid split length and second word
          }
        }
    }

compareTo(string) : bool

Compare two strings.

    function compareTo() {
        string memory myVal = "my example split";
        if(myVal.compareTo("my example split")) {
          // They match!
        }
    }

compareToIgnoreCase(string) : bool

Compare two strings discarding alphabetic case.

    function compareToIgnoreCase() {
        string memory myVal = "my example split";
        if(myVal.compareTo("mY Example Split")) {
          // They match regardless of case!
        }
    }

upper(string) : string

Converts a string to use upper alphabetic case.

    function upper() {
        string memory myVal = "lower";
        if(myVal.upper().compareTo("LOWER")) {
          // It's now upper!
        }
    }

lower(string) : string

Converts a string to use lower alphabetic case.

    function lower() {
        string memory myVal = "UPPER";
        if (myVal.lower().compareTo("upper")) {
          // It's now lower!
        }
    }

Feel free to contribute!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].