hardlydifficult-ethereum-contracts
Version:
A collection of reusable contracts and Javascript helpers for Ethereum.
1,156 lines • 89.7 kB
JSON
{
"contractName": "Sqrt",
"abi": [],
"metadata": "{\"compiler\":{\"version\":\"0.5.17+commit.d19bba13\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"details\":\"Results may be off by 1.\",\"methods\":{},\"title\":\"Calculates the square root of a given value.\"},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"/home/circleci/repo/contracts/math/Sqrt.sol\":\"Sqrt\"},\"evmVersion\":\"istanbul\",\"libraries\":{},\"optimizer\":{\"enabled\":true,\"runs\":2000000},\"remappings\":[]},\"sources\":{\"/home/circleci/repo/contracts/math/Sqrt.sol\":{\"keccak256\":\"0xec541cc87ee76ff6c6f30adb84c51f085aeab720c3a199d97bb95186fe5dcefc\",\"urls\":[\"bzz-raw://47c4ab660a84cff2748e677649a293b1236ac52dc6f031a77922804171242d78\",\"dweb:/ipfs/QmQaesqchMSGP6YgbHenBoEoeKc8keEfgJRco6sKBZk5AH\"]}},\"version\":1}",
"bytecode": "0x60556023600b82828239805160001a607314601657fe5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea265627a7a723158202f5e6cec992dedbad0d934ebcd86a1c1c48e29daed6e67b441e9c0e3986fc9ea64736f6c63430005110032",
"deployedBytecode": "0x73000000000000000000000000000000000000000030146080604052600080fdfea265627a7a723158202f5e6cec992dedbad0d934ebcd86a1c1c48e29daed6e67b441e9c0e3986fc9ea64736f6c63430005110032",
"sourceMap": "122:548:5:-;;132:2:-1;166:7;155:9;146:7;137:37;255:7;249:14;246:1;241:23;235:4;232:33;222:2;;269:9;222:2;293:9;290:1;283:20;323:4;314:7;306:22;347:7;338;331:24",
"deployedSourceMap": "122:548:5:-;;;;;;;;",
"source": "pragma solidity ^0.5.0;\n\n\n/**\n * @title Calculates the square root of a given value.\n * @dev Results may be off by 1.\n */\nlibrary Sqrt\n{\n /// @notice The max possible value\n uint256 private constant MAX_UINT = 2**256 - 1;\n\n // Source: https://github.com/ethereum/dapp-bin/pull/50\n function sqrt(\n uint x\n ) internal pure\n returns (uint y)\n {\n if (x == 0)\n {\n return 0;\n }\n else if (x <= 3)\n {\n return 1;\n }\n else if (x == MAX_UINT)\n {\n // Without this we fail on x + 1 below\n return 2**128 - 1;\n }\n\n uint z = (x + 1) / 2;\n y = x;\n while (z < y)\n {\n y = z;\n z = (x / z + z) / 2;\n }\n }\n}",
"sourcePath": "/home/circleci/repo/contracts/math/Sqrt.sol",
"ast": {
"absolutePath": "/home/circleci/repo/contracts/math/Sqrt.sol",
"exportedSymbols": {
"Sqrt": [
1231
]
},
"id": 1232,
"nodeType": "SourceUnit",
"nodes": [
{
"id": 1157,
"literals": [
"solidity",
"^",
"0.5",
".0"
],
"nodeType": "PragmaDirective",
"src": "0:23:5"
},
{
"baseContracts": [],
"contractDependencies": [],
"contractKind": "library",
"documentation": "@title Calculates the square root of a given value.\n@dev Results may be off by 1.",
"fullyImplemented": true,
"id": 1231,
"linearizedBaseContracts": [
1231
],
"name": "Sqrt",
"nodeType": "ContractDefinition",
"nodes": [
{
"constant": true,
"id": 1164,
"name": "MAX_UINT",
"nodeType": "VariableDeclaration",
"scope": 1231,
"src": "176:46:5",
"stateVariable": true,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 1158,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "176:7:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": {
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_rational_115792089237316195423570985008687907853269984665640564039457584007913129639935_by_1",
"typeString": "int_const 1157...(70 digits omitted)...9935"
},
"id": 1163,
"isConstant": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_rational_115792089237316195423570985008687907853269984665640564039457584007913129639936_by_1",
"typeString": "int_const 1157...(70 digits omitted)...9936"
},
"id": 1161,
"isConstant": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"hexValue": "32",
"id": 1159,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "212:1:5",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_2_by_1",
"typeString": "int_const 2"
},
"value": "2"
},
"nodeType": "BinaryOperation",
"operator": "**",
"rightExpression": {
"argumentTypes": null,
"hexValue": "323536",
"id": 1160,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "215:3:5",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_256_by_1",
"typeString": "int_const 256"
},
"value": "256"
},
"src": "212:6:5",
"typeDescriptions": {
"typeIdentifier": "t_rational_115792089237316195423570985008687907853269984665640564039457584007913129639936_by_1",
"typeString": "int_const 1157...(70 digits omitted)...9936"
}
},
"nodeType": "BinaryOperation",
"operator": "-",
"rightExpression": {
"argumentTypes": null,
"hexValue": "31",
"id": 1162,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "221:1:5",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_1_by_1",
"typeString": "int_const 1"
},
"value": "1"
},
"src": "212:10:5",
"typeDescriptions": {
"typeIdentifier": "t_rational_115792089237316195423570985008687907853269984665640564039457584007913129639935_by_1",
"typeString": "int_const 1157...(70 digits omitted)...9935"
}
},
"visibility": "private"
},
{
"body": {
"id": 1229,
"nodeType": "Block",
"src": "352:316:5",
"statements": [
{
"condition": {
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"id": 1173,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"id": 1171,
"name": "x",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 1166,
"src": "362:1:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"nodeType": "BinaryOperation",
"operator": "==",
"rightExpression": {
"argumentTypes": null,
"hexValue": "30",
"id": 1172,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "367:1:5",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_0_by_1",
"typeString": "int_const 0"
},
"value": "0"
},
"src": "362:6:5",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
"falseBody": {
"condition": {
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"id": 1179,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"id": 1177,
"name": "x",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 1166,
"src": "411:1:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"nodeType": "BinaryOperation",
"operator": "<=",
"rightExpression": {
"argumentTypes": null,
"hexValue": "33",
"id": 1178,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "416:1:5",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_3_by_1",
"typeString": "int_const 3"
},
"value": "3"
},
"src": "411:6:5",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
"falseBody": {
"condition": {
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"id": 1185,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"id": 1183,
"name": "x",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 1166,
"src": "460:1:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"nodeType": "BinaryOperation",
"operator": "==",
"rightExpression": {
"argumentTypes": null,
"id": 1184,
"name": "MAX_UINT",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 1164,
"src": "465:8:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"src": "460:13:5",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
"falseBody": null,
"id": 1193,
"nodeType": "IfStatement",
"src": "456:100:5",
"trueBody": {
"id": 1192,
"nodeType": "Block",
"src": "479:77:5",
"statements": [
{
"expression": {
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_rational_340282366920938463463374607431768211455_by_1",
"typeString": "int_const 3402...(31 digits omitted)...1455"
},
"id": 1190,
"isConstant": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_rational_340282366920938463463374607431768211456_by_1",
"typeString": "int_const 3402...(31 digits omitted)...1456"
},
"id": 1188,
"isConstant": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"hexValue": "32",
"id": 1186,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "539:1:5",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_2_by_1",
"typeString": "int_const 2"
},
"value": "2"
},
"nodeType": "BinaryOperation",
"operator": "**",
"rightExpression": {
"argumentTypes": null,
"hexValue": "313238",
"id": 1187,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "542:3:5",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_128_by_1",
"typeString": "int_const 128"
},
"value": "128"
},
"src": "539:6:5",
"typeDescriptions": {
"typeIdentifier": "t_rational_340282366920938463463374607431768211456_by_1",
"typeString": "int_const 3402...(31 digits omitted)...1456"
}
},
"nodeType": "BinaryOperation",
"operator": "-",
"rightExpression": {
"argumentTypes": null,
"hexValue": "31",
"id": 1189,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "548:1:5",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_1_by_1",
"typeString": "int_const 1"
},
"value": "1"
},
"src": "539:10:5",
"typeDescriptions": {
"typeIdentifier": "t_rational_340282366920938463463374607431768211455_by_1",
"typeString": "int_const 3402...(31 digits omitted)...1455"
}
},
"functionReturnParameters": 1170,
"id": 1191,
"nodeType": "Return",
"src": "532:17:5"
}
]
}
},
"id": 1194,
"nodeType": "IfStatement",
"src": "407:149:5",
"trueBody": {
"id": 1182,
"nodeType": "Block",
"src": "423:23:5",
"statements": [
{
"expression": {
"argumentTypes": null,
"hexValue": "31",
"id": 1180,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "438:1:5",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_1_by_1",
"typeString": "int_const 1"
},
"value": "1"
},
"functionReturnParameters": 1170,
"id": 1181,
"nodeType": "Return",
"src": "431:8:5"
}
]
}
},
"id": 1195,
"nodeType": "IfStatement",
"src": "358:198:5",
"trueBody": {
"id": 1176,
"nodeType": "Block",
"src": "374:23:5",
"statements": [
{
"expression": {
"argumentTypes": null,
"hexValue": "30",
"id": 1174,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "389:1:5",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_0_by_1",
"typeString": "int_const 0"
},
"value": "0"
},
"functionReturnParameters": 1170,
"id": 1175,
"nodeType": "Return",
"src": "382:8:5"
}
]
}
},
{
"assignments": [
1197
],
"declarations": [
{
"constant": false,
"id": 1197,
"name": "z",
"nodeType": "VariableDeclaration",
"scope": 1229,
"src": "562:6:5",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 1196,
"name": "uint",
"nodeType": "ElementaryTypeName",
"src": "562:4:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": null,
"visibility": "internal"
}
],
"id": 1204,
"initialValue": {
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"id": 1203,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"components": [
{
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"id": 1200,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"id": 1198,
"name": "x",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 1166,
"src": "572:1:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"nodeType": "BinaryOperation",
"operator": "+",
"rightExpression": {
"argumentTypes": null,
"hexValue": "31",
"id": 1199,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "576:1:5",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_1_by_1",
"typeString": "int_const 1"
},
"value": "1"
},
"src": "572:5:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
}
],
"id": 1201,
"isConstant": false,
"isInlineArray": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"nodeType": "TupleExpression",
"src": "571:7:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"nodeType": "BinaryOperation",
"operator": "/",
"rightExpression": {
"argumentTypes": null,
"hexValue": "32",
"id": 1202,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "581:1:5",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_2_by_1",
"typeString": "int_const 2"
},
"value": "2"
},
"src": "571:11:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"nodeType": "VariableDeclarationStatement",
"src": "562:20:5"
},
{
"expression": {
"argumentTypes": null,
"id": 1207,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftHandSide": {
"argumentTypes": null,
"id": 1205,
"name": "y",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 1169,
"src": "588:1:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"nodeType": "Assignment",
"operator": "=",
"rightHandSide": {
"argumentTypes": null,
"id": 1206,
"name": "x",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 1166,
"src": "592:1:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"src": "588:5:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"id": 1208,
"nodeType": "ExpressionStatement",
"src": "588:5:5"
},
{
"body": {
"id": 1227,
"nodeType": "Block",
"src": "617:47:5",
"statements": [
{
"expression": {
"argumentTypes": null,
"id": 1214,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftHandSide": {
"argumentTypes": null,
"id": 1212,
"name": "y",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 1169,
"src": "625:1:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"nodeType": "Assignment",
"operator": "=",
"rightHandSide": {
"argumentTypes": null,
"id": 1213,
"name": "z",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 1197,
"src": "629:1:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"src": "625:5:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"id": 1215,
"nodeType": "ExpressionStatement",
"src": "625:5:5"
},
{
"expression": {
"argumentTypes": null,
"id": 1225,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftHandSide": {
"argumentTypes": null,
"id": 1216,
"name": "z",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 1197,
"src": "638:1:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"nodeType": "Assignment",
"operator": "=",
"rightHandSide": {
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"id": 1224,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"components": [
{
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"id": 1221,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"id": 1219,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"id": 1217,
"name": "x",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 1166,
"src": "643:1:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"nodeType": "BinaryOperation",
"operator": "/",
"rightExpression": {
"argumentTypes": null,
"id": 1218,
"name": "z",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 1197,
"src": "647:1:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"src": "643:5:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"nodeType": "BinaryOperation",
"operator": "+",
"rightExpression": {
"argumentTypes": null,
"id": 1220,
"name": "z",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 1197,
"src": "651:1:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"src": "643:9:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
}
],
"id": 1222,
"isConstant": false,
"isInlineArray": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"nodeType": "TupleExpression",
"src": "642:11:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"nodeType": "BinaryOperation",
"operator": "/",
"rightExpression": {
"argumentTypes": null,
"hexValue": "32",
"id": 1223,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "656:1:5",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_2_by_1",
"typeString": "int_const 2"
},
"value": "2"
},
"src": "642:15:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"src": "638:19:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"id": 1226,
"nodeType": "ExpressionStatement",
"src": "638:19:5"
}
]
},
"condition": {
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"id": 1211,
"isConstant": false,
"isLValue": false,
"isPure": false,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"id": 1209,
"name": "z",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 1197,
"src": "606:1:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"nodeType": "BinaryOperation",
"operator": "<",
"rightExpression": {
"argumentTypes": null,
"id": 1210,
"name": "y",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 1169,
"src": "610:1:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"src": "606:5:5",
"typeDescriptions": {
"typeIdentifier": "t_bool",
"typeString": "bool"
}
},
"id": 1228,
"nodeType": "WhileStatement",
"src": "599:65:5"
}
]
},
"documentation": null,
"id": 1230,
"implemented": true,
"kind": "function",
"modifiers": [],
"name": "sqrt",
"nodeType": "FunctionDefinition",
"parameters": {
"id": 1167,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 1166,
"name": "x",
"nodeType": "VariableDeclaration",
"scope": 1230,
"src": "304:6:5",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 1165,
"name": "uint",
"nodeType": "ElementaryTypeName",
"src": "304:4:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "298:16:5"
},
"returnParameters": {
"id": 1170,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 1169,
"name": "y",
"nodeType": "VariableDeclaration",
"scope": 1230,
"src": "342:6:5",
"stateVariable": false,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 1168,
"name": "uint",
"nodeType": "ElementaryTypeName",
"src": "342:4:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": null,
"visibility": "internal"
}
],
"src": "341:8:5"
},
"scope": 1231,
"src": "285:383:5",
"stateMutability": "pure",
"superFunction": null,
"visibility": "internal"
}
],
"scope": 1232,
"src": "122:548:5"
}
],
"src": "0:670:5"
},
"legacyAST": {
"absolutePath": "/home/circleci/repo/contracts/math/Sqrt.sol",
"exportedSymbols": {
"Sqrt": [
1231
]
},
"id": 1232,
"nodeType": "SourceUnit",
"nodes": [
{
"id": 1157,
"literals": [
"solidity",
"^",
"0.5",
".0"
],
"nodeType": "PragmaDirective",
"src": "0:23:5"
},
{
"baseContracts": [],
"contractDependencies": [],
"contractKind": "library",
"documentation": "@title Calculates the square root of a given value.\n@dev Results may be off by 1.",
"fullyImplemented": true,
"id": 1231,
"linearizedBaseContracts": [
1231
],
"name": "Sqrt",
"nodeType": "ContractDefinition",
"nodes": [
{
"constant": true,
"id": 1164,
"name": "MAX_UINT",
"nodeType": "VariableDeclaration",
"scope": 1231,
"src": "176:46:5",
"stateVariable": true,
"storageLocation": "default",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
},
"typeName": {
"id": 1158,
"name": "uint256",
"nodeType": "ElementaryTypeName",
"src": "176:7:5",
"typeDescriptions": {
"typeIdentifier": "t_uint256",
"typeString": "uint256"
}
},
"value": {
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_rational_115792089237316195423570985008687907853269984665640564039457584007913129639935_by_1",
"typeString": "int_const 1157...(70 digits omitted)...9935"
},
"id": 1163,
"isConstant": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"commonType": {
"typeIdentifier": "t_rational_115792089237316195423570985008687907853269984665640564039457584007913129639936_by_1",
"typeString": "int_const 1157...(70 digits omitted)...9936"
},
"id": 1161,
"isConstant": false,
"isLValue": false,
"isPure": true,
"lValueRequested": false,
"leftExpression": {
"argumentTypes": null,
"hexValue": "32",
"id": 1159,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "212:1:5",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_2_by_1",
"typeString": "int_const 2"
},
"value": "2"
},
"nodeType": "BinaryOperation",
"operator": "**",
"rightExpression": {
"argumentTypes": null,
"hexValue": "323536",
"id": 1160,
"isConstant": false,
"isLValue": false,
"isPure": true,
"kind": "number",
"lValueRequested": false,
"nodeType": "Literal",
"src": "215:3:5",
"subdenomination": null,
"typeDescriptions": {
"typeIdentifier": "t_rational_256_by_1",
"typeString": "int_const 256"
},
"value": "256"
},
"src": "212:6:5",
"typeDescriptions": {
"typeIdentifier": "t_rational_115792089237316195423570985008687907853269984665640564039457584007913129639