pragma solidity ^0.4.24; contract PrivateAPIContract { string public result; function TestURLBuilder(string apiKey, uint _time, string _ticker, uint _days) { // result = uintToString(12345678901234567890); result = string(abi.encodePacked("https://www.okex.com/v3/chainlink-midlayer/pc/public/implied-volatility?underlying=", _ticker, "&t=")); result = appendUintToString(result, _time); result = string(abi.encodePacked(result,"&days=")); result = appendUintToString(result, _days); result = string(abi.encodePacked(result,"&apiKey=", apiKey)); } function uintToString(uint v) constant returns (string str) { uint maxlength = 100; bytes memory reversed = new bytes(maxlength); uint i = 0; while (v != 0) { uint remainder = v % 10; v = v / 10; reversed[i++] = byte(48 + remainder); } bytes memory s = new bytes(i); for (uint j = 0; j < i; j++) { s[j] = reversed[i - 1 - j]; } str = string(s); } function appendUintToString(string inStr, uint v) constant returns (string str) { uint maxlength = 100; bytes memory reversed = new bytes(maxlength); uint i = 0; while (v != 0) { uint remainder = v % 10; v = v / 10; reversed[i++] = byte(48 + remainder); } bytes memory inStrb = bytes(inStr); bytes memory s = new bytes(inStrb.length + i); uint j; for (j = 0; j < inStrb.length; j++) { s[j] = inStrb[j]; } for (j = 0; j < i; j++) { s[j + inStrb.length] = reversed[i - 1 - j]; } str = string(s); } }
0.4.24