Skip to content

Instantly share code, notes, and snippets.

@vasa-develop
Last active July 26, 2018 09:08
Show Gist options
  • Save vasa-develop/4b8dc1ebd075fe7382954728c254ba91 to your computer and use it in GitHub Desktop.
Save vasa-develop/4b8dc1ebd075fe7382954728c254ba91 to your computer and use it in GitHub Desktop.
var hexStringFromSolidity = "<PASTE THE SOLIDTY BYTE OUTPUT HERE>"
var convert = function hexToStr(hex) {
var str = '';
for (var i = 0; i < hex.length; i += 2) {
var v = parseInt(hex.substr(i, 2), 16);
if (v) str += String.fromCharCode(v);
}
params = [];
res = "";
for (var i=0; i<= str.length; i++){
if(str.charCodeAt(i) > 31){
res = res + str[i];
}
else{
params.push(res);
res = "";
}
}
params.pop();
return params;
}
var stringArray = convert(hexStringFromSolidity);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment