From 9d6ca22424ec9956ef0eda5838655a5a757b4168 Mon Sep 17 00:00:00 2001 From: Ricardo Guilherme Schmidt <3esmit@gmail.com> Date: Sun, 9 Apr 2017 20:29:15 +0000 Subject: [PATCH] added toBytes20 --- contracts/lib/StringLib.sol | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/contracts/lib/StringLib.sol b/contracts/lib/StringLib.sol index cf28d95..6f86bdd 100644 --- a/contracts/lib/StringLib.sol +++ b/contracts/lib/StringLib.sol @@ -14,6 +14,11 @@ library StringLib { result := mload(add(source, 32)) } } + function toBytes20(string memory source) constant returns (bytes20 result) { + assembly { + result := mload(add(source, 20)) + } + } function parseBytes20(string self) constant returns (bytes20 bs) { bytes memory h = bytes(self);