Storing `string` is expensive on smart-contracts and charge us expensive fees even if we want to store them in `Events`. Instead I want to store each string's decoded version in a smart-contract in order to save some memory and gas-fee charge. Overall, when I return string's decoded version, it also should be able to decoded into the original string.

As an example I want to pass my string as [compressing base64 input][1] format and its [code][2]. But when I stored compressed base64 string on a smart-contract, its returned version is not same as the one I passed.

Example `example.js`:

    var Base64String = require('./base64-string');

    var string = "QmWmyoMoctfbAaiEs2G46gpeUmhqFRDW6KWo64y5r581Vm";
    console.log("Size of sample is: " + string.length);
    var compressed = Base64String.compress(string);
    console.log("compressed:" + compressed)
    console.log("Size of compressed sample is: " + compressed.length);
    string = Base64String.decompress(compressed);
    console.log("Sample is: " + string);

Results node `example.js`: //as you can see 46 length string is compressed into 19 length.

    Size of sample is: 46
    compressed: ł斦쪃⡲ퟛƨ蒳憸幒桪ᔐ훨ꖨ릯鼵嗐
    Size of compressed sample is: 19
    Sample is: QmWmyoMoctfbAaiEs2G46gpeUmhqFRDW6KWo64y5r581VmAA


Passed base64 compressed string: //I want to store it on my smart-contract.



From the smart-contract its returned version seems not same as the string I passed. // `Contract.get()`


Overall: `"ł斦쪃⡲ퟛƨ蒳憸幒桪ᔐ훨ꖨ릯鼵嗐" != "ł斦쪃⡲<d7db>ƨ蒳憸幒桪ᔐ훨<a5a8>릯鼵嗐"`

Please note that I have tried this on remix-solidity.


    pragma solidity ^0.4.0;
    contract Contract {
        string str;

        function set(string val) public {
            str = val;

        function get() public constant returns (string) {
            return str;

**[Q]** How should I pass compressed base64 string into a smart-contract? or basically what should I do to store my string compressed version on a smart-contract that when I returned it, it should match with the string I passed?

Thank you for your valuable time and help.