{"_id":"@skalenetwork/filestorage","_rev":"43-55ae8995c7d942e126b8b1d9a20a5cc5","name":"@skalenetwork/filestorage","dist-tags":{"latest":"1.0.1","develop":"1.1.0-develop.8","beta":"1.1.0-beta.3"},"versions":{"0.4.0-develop.1":{"name":"@skalenetwork/filestorage","version":"0.4.0-develop.1","keywords":["SKALE","blockchain","ethereum"],"author":{"name":"SKALE Labs and contributors"},"license":"AGPL-3.0","_id":"@skalenetwork/filestorage@0.4.0-develop.1","maintainers":[{"name":"theskyunicorn","email":"christine@skalelabs.com"},{"name":"skalelabsdev","email":"dev@skalelabs.com"},{"name":"cstrange","email":"chadwick@skalelabs.com"},{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},{"name":"dmitrytk","email":"dmitry.tkachuk@skalelabs.com"}],"homepage":"https://github.com/skalenetwork/filestorage#readme","bugs":{"url":"https://github.com/skalenetwork/filestorage/issues"},"dist":{"shasum":"4baf26513aad4ebfe802bdfbb8a40b97765df85f","tarball":"https://registry.npmjs.org/@skalenetwork/filestorage/-/filestorage-0.4.0-develop.1.tgz","fileCount":5,"integrity":"sha512-RiZVuDqvAdY5HKNslKRhziTCxQyPiaVvPf9qHHAgIc3AzRhi9VlUna8XdyS8RjFo1gFBR0LKJ09xwry8sxKLag==","signatures":[{"sig":"MEYCIQDwGdWJv4DAyI5SqJ0iOQ3Jt6Id+bJcXwmWWT5fUR8KmQIhANETZ7B9u2OXjgxvf/eLZkW5wIq+q9ziFFyFXBF4EjNh","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":49373,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfbaNwCRA9TVsSAnZWagAA4fEP/2G6+k0XcKt/YrRltjFa\nWsYAPZsjhxCRrAEeQko965foLNfAPZtKjHeiizlWfxhlkRvMmyChOGD4uiP8\nyisP6rn5i97h+XXhPFPT4IUVFcQP9xjfs2WRMa7PPZ0D40caRCeDhSUzXqCL\n3BQXoBfgb8y4zG5cG49TI19irx9QZqmQ9mApBXiWio8lH1bMnZdMasLwbv3D\niPy/k2/vJn6/+SoDrBFjStxlQ/EJg4RgBG4C7DGZWeEh6Ou9FLQRbSoT+5+h\n7vrrcwaBmPec8q8XoNLNWGu+h+bfqJ53/TiQX8XhmrCgGHjzTPQuyZJoRb8O\nEwq9FQLfdzZka4pNXjQwl/NzlwN5j5RVHIjN2o36LLuC8d5oorKFou8z1Tuz\nVqsWiLFjRssTq5PRKfEqIS+5Kc7Uh1PGy8CtAW0k2eYXa8kPBXLh0OePjLtV\nWk364zfAIB81KmwmwQLr9A8NbQGXifEPoCduhNL8MDXEmGfS72pBFErje5eJ\nrw/NJZF/BNOOfxeBuo1Dh7ZVgWppUGj0nofaMsZ7MJP0GeUSGoXl3CAoh1lS\nSxBLRl19Y8tm2/1YnJHGpg73gzsS7rjtT7Soq//7vIAlBaennHLS0ZHg1jES\n/7yNcoHcsP3qISJDTYUIOZFuRpWUZuWsdAOCrjyx+2QVP8pYULShfZMbyCd1\n6dvF\r\n=e52E\r\n-----END PGP SIGNATURE-----\r\n"},"main":"artifacts.json","gitHead":"72c71013aee586c3eeb8891381eb5718f0d2cfc4","scripts":{"lint":"npx ethlint -d contracts","build":"rm -r ./build; truffle build","slither":"slither . --filter-path strings --filter-path Migrations","version":"node -e \"console.log(require('./package.json').version);\"","lint-fix":"npm run lint -- --fix","generate-config":"node -e 'require(\"./test/utils/helper.js\").generateTestConfig()'"},"_npmUser":{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},"repository":{"url":"git+https://github.com/skalenetwork/filestorage.git","type":"git"},"_npmVersion":"6.14.6","description":"SKALE Filestorage contracts","directories":{},"_nodeVersion":"10.22.1","dependencies":{},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"chai":"^4.2.0","web3":"^1.2.1","dotenv":"^8.2.0","codecov":"^3.3.0","truffle":"^5.0.27","randomstring":"^1.1.5","chai-as-promised":"^7.1.1","solidity-coverage":"^0.6.7","@truffle/hdwallet-provider":"^1.0.18"},"_npmOperationalInternal":{"tmp":"tmp/filestorage_0.4.0-develop.1_1601020784292_0.6441902942964415","host":"s3://npm-registry-packages"}},"1.0.0-develop.0":{"name":"@skalenetwork/filestorage","version":"1.0.0-develop.0","keywords":["SKALE","blockchain","ethereum"],"author":{"name":"SKALE Labs and contributors"},"license":"AGPL-3.0","_id":"@skalenetwork/filestorage@1.0.0-develop.0","maintainers":[{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},{"name":"dmitrytk","email":"dmitry.tkachuk@skalelabs.com"},{"name":"cstrange","email":"chadwick@skalelabs.com"},{"name":"skalelabsdev","email":"dev@skalelabs.com"},{"name":"theskyunicorn","email":"christine@skalelabs.com"}],"homepage":"https://github.com/skalenetwork/filestorage#readme","bugs":{"url":"https://github.com/skalenetwork/filestorage/issues"},"dist":{"shasum":"ed6d2c2b8eaa064927e377f60af86d39890ca869","tarball":"https://registry.npmjs.org/@skalenetwork/filestorage/-/filestorage-1.0.0-develop.0.tgz","fileCount":5,"integrity":"sha512-2BLEu/Q+kK8ir/YzS1WdyrtDm6iRpUqODz1f2yh+NfVVN7Q6xg7eDoLD05iMvWsdUm87ZZGE3vJZ2CZBjuG9cw==","signatures":[{"sig":"MEYCIQD0VL5WgmrQX/jFTv5ynTOJMI+vBp8tXwonZScpwrAc7wIhAOS1aTMagNYDG/ULjGe/My8gdz8sVjq2ZftvQeJyzcSs","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":49477,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgYwMSCRA9TVsSAnZWagAAfDMP/ishvEKSypAuL/qe3tts\n2nh6o7N66hsEWgcI4gPObRjNMttEOiTlzfP/8bQW8OovNUli7siW/XJZwnBf\nSqRcFl1SizT3XpUEc5GX1jAkf4jJxSuPb5Vl/EdDpaAzckLVdFO6cuA3PdNj\naN1JHQxKAZvkcUVFDe/VUdeJ/Ju+nip/HMoHmYPzrrEd8CJr4VJezSiPneGf\nkzQtJA3M4R3gJUIkuvR6sfHzoMKs9DPmq1E3K6cbG90KuVPlRhUeAU7K9eEk\n1BWOBNyRS1Vs8hoK+aAsnFDq2Yse18gMO6g8Q9ebXKYlGyEiCpAFMRGYmqTX\nZjtuUrMXfu+keNT+gAPGgbFZF7zjwCSQ9mE4+z+xmw/EvOkP3U04tPyj53j6\nwcmpR6s8othMC6ez3NulkW1GTo6vU8Q8Uzsm/sr8aH32nuI1fLBfzaisRu8y\n9vUTBkVXYToHCPQEux+UtVhRhAFkrsPS2JMYia+a9YEUjq9fxYNEcxV+M51L\nLrYgRmeduKOS/T+bCVj7MPhQelX5AJK7De60AqQVirn6nuzVHROmyWxc1mSA\nLSTo6wco+O3rp0Xe8JCkIzvlhCb6EGAWWfBpYN5NdSxupA/41BEP4akwate9\n2i7J6QZKpGJUmaK0TjbPFfsdtMnXNYACd2Q1y7y3yFHTIV2Oc9zmEFsAgKA8\nngqW\r\n=CYyp\r\n-----END PGP SIGNATURE-----\r\n"},"main":"artifacts.json","readme":"# SKALE Filestorage\n\n[![Build Status](https://travis-ci.com/skalenetwork/filestorage.svg?token=HYnwEPctUzUdXVcsecA6&branch=develop)](https://travis-ci.com/skalenetwork/filestorage)\n[![codecov](https://codecov.io/gh/skalenetwork/filestorage/branch/develop/graph/badge.svg?token=2wkF3kZTXh)](https://codecov.io/gh/skalenetwork/filestorage)\n[![Discord](https://img.shields.io/discord/534485763354787851.svg)](https://discord.gg/vvUtWJB)\n\nFilestorage - smart contract, that controls decentralized file storage on SKALE chains.\n\n## Description\n\nFilestorage is a cost-effective storage layer within Ethereum capable of handling files up to 100MB. Filestorage uses UNIX-based filesystem of SKALE chains. Filestorage smart contract is a set of functions to interact with files on EVM. This contract may be predeployed on SKALE chains. It contains functions to work with Filestorage precompiled smart contracts. \n\nSmart contract language - Solidity 0.5.3\n\n## API Reference\n\n### File interaction methods\n\nTo begin the uploading process, the file should be broken into chunks of 1MB (&lt; 1MB for the last chunk) which are uploaded as separate transactions to FileStorage.sol. \nThe pipeline of the uploading file is:\n\n1.  creating empty file of fixed size on EVM by calling `startUpload`,\n2.  uploading data chunk by chunk with `uploadChunk`,\n3.  checking the file validity and finishing process with `finishUpload`.\n\n#### startUpload\n\n```solidity\nfunction startUpload(string memory filePath, uint256 fileSize)\n```\n\nCreates empty file on EVM with specific name and size. Owner of the file - message sender. \n\n-   Function is called by file owner\n-   Maximum amount of directories and files in one directory is **8196**\n-   Maximum filesize is **100,000,000** bytes\n-   Owner should have enough free space\n\n**Parameters:**\n\n| Parameter          | Description                           |\n| ------------------ | ------------------------------------- |\n| `string` filePath  | Path to the file in account directory |\n| `uint256` fileSize | Uploaded file size in bytes           |\n\n#### uploadChunk\n\n```solidity\nfunction uploadChunk(string memory filePath, uint position, bytes memory data)\n```\n\nUploads 1MB chunk of data from specific position in specific file by file owner.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n| `uint` position   | Uploaded chunk position               |\n| `bytes` data      | Uploaded chunk data                   |\n\n#### finishUpload\n\n```solidity\nfunction finishUpload(string memory filePath)\n```\n\nFinishes uploading of the file. Checks whether all chunks are uploaded correctly.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### deleteFile\n\n```solidity\nfunction deleteFile(string memory filePath)\n```\n\nDeletes file from Filestorage.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### readChunk\n\n```solidity\nfunction readChunk(string memory storagePath, uint position, uint length)\n        public\n        view\n        returns (bytes32[MAX_BLOCK_COUNT] memory out)\n```\n\nReads chunk from file from specific position with specific length. Returns `bytes32` array of fixed size with requested data.\n\n-   Maximum length of the chunk to read is 1Mb\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n| `uint` position      | First byte to read from              |\n| `uint` length        | Uploaded chunk length                |\n\n**Returns:**\n\n| Parameter       | Description                                       |\n| --------------- | ------------------------------------------------- |\n| `bytes32[]` out | Requested chunk data split across `bytes32` array |\n\n#### getFileSize\n\n```solidity\nfunction getFileSize(string memory storagePath) \n        public \n        view \n        returns (uint fileSize)\n```\n\nGets size of the requested file in bytes.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description            |\n| --------------- | ---------------------- |\n| `uint` fileSize | Size of requested file |\n\n#### getFileStatus\n\n```solidity\nfunction getFileStatus(string memory storagePath) \n        public \n        view \n        returns (int)\n```\n\nReturns status of the requested file:\n\n-   0 - file does not exist\n-   1 - file is created but has not finished uploading\n-   2 - file is fully uploaded\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter         | Description              |\n| ----------------- | ------------------------ |\n| `uint` fileStatus | Status of requested file |\n\n### Directory interaction methods\n\nFilestorage is represented with UNIX-based filesystem that consisted of files and directories. Directories are stored in `Directory` structure that contains information about its content in `ContentInfo` structure. Maximum amount of content in separate directory is **8196**.\n\n#### createDirectory\n\n```solidity\nfunction createDirectory(string memory directoryPath)\n```\n\nCreates directory in Filestorage. Owner of the directory - message sender. \n\n-   Function is called by directory owner\n-   Maximum amount of directories and files in one directory is **8196**\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### deleteDirectory\n\n```solidity\nfunction deleteDirectory(string memory directoryPath)\n```\n\nDeletes directory from Filestorage.\n\n-   Function is called by directory owner\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### listDirectory\n\n```solidity\nfunction listDirectory(string memory storagePath) \n        public \n        view \n        returns (ContentInfo[])\n```\n\nList information about content of the specific directory.\n\n**Parameters:**\n\n| Parameter            | Description                               |\n| -------------------- | ----------------------------------------- |\n| `string` storagePath | Full path of the directory in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description                          |\n| --------------- | ------------------------------------ |\n| `ContentInfo[]` | Array of content stored in directory |\n\nObject `ContentInfo` can be file or directory and contains:\n\n| Field                    | Description                                                                      |\n| ------------------------ | -------------------------------------------------------------------------------- |\n| `string` name            | Content name                                                                     |\n| `bool` isFile            | Whether content is file                                                          |\n| `uint` size              | File size, in bytes                                                              |\n| `int` status             | File uploading status                                                            |\n| `bool[]` isChunkUploaded | Array with statuses of each chunk (`true` - chunk uploaded, `false` - otherwise) |\n\n## Build\n\nCreate an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nPRIVATEKEY='Private key for test account'\n```\n\nCompile `FileStorage.sol`:\n\n```bash\ntruffle compile\n```\n\n## Test\n\nTests run only on SKALE chains. Create an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nSCHAIN_OWNER_PK='Private key of SKALE endpoint owner (or account with money)'\nPRIVATEKEY='Private key for test account'\n```\n\nRun tests:\n\n```bash\ntruffle test --network skaled\n```\n","gitHead":"eb1f6574f88fecfe362ce99cdcb11f131a2dfef7","scripts":{"lint":"npx ethlint -d contracts","test":"truffle test test/unit/* --network skaled","build":"rm -r ./build; truffle build","slither":"slither . --filter-path strings --filter-path Migrations","version":"node -e \"console.log(require('./package.json').version);\"","lint-fix":"npm run lint -- --fix","generate-config":"node -e 'require(\"./test/utils/helper.js\").generateTestConfig()'"},"_npmUser":{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},"repository":{"url":"git+https://github.com/skalenetwork/filestorage.git","type":"git"},"_npmVersion":"6.14.11","description":"SKALE Filestorage contracts","directories":{},"_nodeVersion":"10.24.0","dependencies":{"@openzeppelin/upgrades-core":"^1.5.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"chai":"^4.2.0","web3":"^1.2.1","dotenv":"^8.2.0","codecov":"^3.3.0","truffle":"^5.0.27","randomstring":"^1.1.5","chai-as-promised":"^7.1.1","solidity-coverage":"^0.6.7","@truffle/hdwallet-provider":"^1.0.18"},"_npmOperationalInternal":{"tmp":"tmp/filestorage_1.0.0-develop.0_1617101586100_0.45301121627041363","host":"s3://npm-registry-packages"}},"1.0.0-develop.1":{"name":"@skalenetwork/filestorage","version":"1.0.0-develop.1","keywords":["SKALE","blockchain","ethereum"],"author":{"name":"SKALE Labs and contributors"},"license":"AGPL-3.0","_id":"@skalenetwork/filestorage@1.0.0-develop.1","maintainers":[{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},{"name":"dmitrytk","email":"dmitry.tkachuk@skalelabs.com"},{"name":"cstrange","email":"chadwick@skalelabs.com"},{"name":"skalelabsdev","email":"dev@skalelabs.com"},{"name":"theskyunicorn","email":"christine@skalelabs.com"}],"homepage":"https://github.com/skalenetwork/filestorage#readme","bugs":{"url":"https://github.com/skalenetwork/filestorage/issues"},"dist":{"shasum":"feb659f7e4e92047c5baa892e17a81fb95663311","tarball":"https://registry.npmjs.org/@skalenetwork/filestorage/-/filestorage-1.0.0-develop.1.tgz","fileCount":5,"integrity":"sha512-ZjMRBJ+oHCBK22+cRh39OoKYW0woYypGfJEQzTd7527Xhj3af2aT93Pc9xnN3CVcm3YTOHbBe+o3qncd0od+PA==","signatures":[{"sig":"MEQCIGjOJ6hzTvNQ9nxwXFMhWUwR9XyJkKuYeEyhBB/uNYdrAiBwId8NnlkWOqgofP/fh8JeL4sap4ztmW829mmwNGTnzQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":49477,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgY6e4CRA9TVsSAnZWagAA9B8P/iDUCNVE1LWaZyVWQU1I\nekGVFbKq8Xe7xVbBp708K16yABQbtC0e+/rNiANIMMAjIkfPnqRZS9ZzQMrX\nF/sjuVutdkNqAFGQFV9hDJjEaobPfr/cE0HOSWA2C9my6sYoyZ0T9czN3F/y\ngecuSxTEj8S8JDBPimTOaf7GPRNHfmMxQ04r/oRHBcaTBYpzRVV/ExSVP51c\nG7UDtfl1OnrvfX0PRelewJ91zWhl5B3skFNom+9Vn7Bpu4BAElX6LZp+JXLB\nMUP4Ds+fuZ/lVjgyF5yeL5fTJsIqDHaO0ElxAtwOcU7gcz3q1NYy1NP1LW0R\nHWslRKYvqNtG+JrWUFqeLvjsg5Xnl9FzEhcJX0KgbC7SMd8nORpK72rtbj6w\nAJF8J05cJ/L42Rt2Qw98A0xivjyBF7keWofxXBSCMZ38FwAizpoSUMWqblfv\nVlmJfZovSpGfKTbIaUQi+PYYm3ir87Sc4yt1/GdM13s0KkzIWyy3k8Q1lKuc\nudndoNLFIc5JczJoGofcATYKWyZJ8oUCf7xQkgfXzPtL1Lg3ATmC6FhmwtJx\nemNrj/oBJ6iE+nMJZOW0PKhwosZ/R2KZKfvzXbhfT9pYdkqyZgHb0HJ9Cpcs\nB4m/JjqBvbnyMBILvetZ+XuCAgOuvEEHEjDrv1gejWQ5LmIbQ7wO+9w/yvOj\nZr9l\r\n=1mJW\r\n-----END PGP SIGNATURE-----\r\n"},"main":"artifacts.json","readme":"# SKALE Filestorage\n\n[![Build Status](https://travis-ci.com/skalenetwork/filestorage.svg?token=HYnwEPctUzUdXVcsecA6&branch=develop)](https://travis-ci.com/skalenetwork/filestorage)\n[![codecov](https://codecov.io/gh/skalenetwork/filestorage/branch/develop/graph/badge.svg?token=2wkF3kZTXh)](https://codecov.io/gh/skalenetwork/filestorage)\n[![Discord](https://img.shields.io/discord/534485763354787851.svg)](https://discord.gg/vvUtWJB)\n\nFilestorage - smart contract, that controls decentralized file storage on SKALE chains.\n\n## Description\n\nFilestorage is a cost-effective storage layer within Ethereum capable of handling files up to 100MB. Filestorage uses UNIX-based filesystem of SKALE chains. Filestorage smart contract is a set of functions to interact with files on EVM. This contract may be predeployed on SKALE chains. It contains functions to work with Filestorage precompiled smart contracts. \n\nSmart contract language - Solidity 0.5.3\n\n## API Reference\n\n### File interaction methods\n\nTo begin the uploading process, the file should be broken into chunks of 1MB (&lt; 1MB for the last chunk) which are uploaded as separate transactions to FileStorage.sol. \nThe pipeline of the uploading file is:\n\n1.  creating empty file of fixed size on EVM by calling `startUpload`,\n2.  uploading data chunk by chunk with `uploadChunk`,\n3.  checking the file validity and finishing process with `finishUpload`.\n\n#### startUpload\n\n```solidity\nfunction startUpload(string memory filePath, uint256 fileSize)\n```\n\nCreates empty file on EVM with specific name and size. Owner of the file - message sender. \n\n-   Function is called by file owner\n-   Maximum amount of directories and files in one directory is **8196**\n-   Maximum filesize is **100,000,000** bytes\n-   Owner should have enough free space\n\n**Parameters:**\n\n| Parameter          | Description                           |\n| ------------------ | ------------------------------------- |\n| `string` filePath  | Path to the file in account directory |\n| `uint256` fileSize | Uploaded file size in bytes           |\n\n#### uploadChunk\n\n```solidity\nfunction uploadChunk(string memory filePath, uint position, bytes memory data)\n```\n\nUploads 1MB chunk of data from specific position in specific file by file owner.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n| `uint` position   | Uploaded chunk position               |\n| `bytes` data      | Uploaded chunk data                   |\n\n#### finishUpload\n\n```solidity\nfunction finishUpload(string memory filePath)\n```\n\nFinishes uploading of the file. Checks whether all chunks are uploaded correctly.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### deleteFile\n\n```solidity\nfunction deleteFile(string memory filePath)\n```\n\nDeletes file from Filestorage.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### readChunk\n\n```solidity\nfunction readChunk(string memory storagePath, uint position, uint length)\n        public\n        view\n        returns (bytes32[MAX_BLOCK_COUNT] memory out)\n```\n\nReads chunk from file from specific position with specific length. Returns `bytes32` array of fixed size with requested data.\n\n-   Maximum length of the chunk to read is 1Mb\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n| `uint` position      | First byte to read from              |\n| `uint` length        | Uploaded chunk length                |\n\n**Returns:**\n\n| Parameter       | Description                                       |\n| --------------- | ------------------------------------------------- |\n| `bytes32[]` out | Requested chunk data split across `bytes32` array |\n\n#### getFileSize\n\n```solidity\nfunction getFileSize(string memory storagePath) \n        public \n        view \n        returns (uint fileSize)\n```\n\nGets size of the requested file in bytes.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description            |\n| --------------- | ---------------------- |\n| `uint` fileSize | Size of requested file |\n\n#### getFileStatus\n\n```solidity\nfunction getFileStatus(string memory storagePath) \n        public \n        view \n        returns (int)\n```\n\nReturns status of the requested file:\n\n-   0 - file does not exist\n-   1 - file is created but has not finished uploading\n-   2 - file is fully uploaded\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter         | Description              |\n| ----------------- | ------------------------ |\n| `uint` fileStatus | Status of requested file |\n\n### Directory interaction methods\n\nFilestorage is represented with UNIX-based filesystem that consisted of files and directories. Directories are stored in `Directory` structure that contains information about its content in `ContentInfo` structure. Maximum amount of content in separate directory is **8196**.\n\n#### createDirectory\n\n```solidity\nfunction createDirectory(string memory directoryPath)\n```\n\nCreates directory in Filestorage. Owner of the directory - message sender. \n\n-   Function is called by directory owner\n-   Maximum amount of directories and files in one directory is **8196**\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### deleteDirectory\n\n```solidity\nfunction deleteDirectory(string memory directoryPath)\n```\n\nDeletes directory from Filestorage.\n\n-   Function is called by directory owner\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### listDirectory\n\n```solidity\nfunction listDirectory(string memory storagePath) \n        public \n        view \n        returns (ContentInfo[])\n```\n\nList information about content of the specific directory.\n\n**Parameters:**\n\n| Parameter            | Description                               |\n| -------------------- | ----------------------------------------- |\n| `string` storagePath | Full path of the directory in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description                          |\n| --------------- | ------------------------------------ |\n| `ContentInfo[]` | Array of content stored in directory |\n\nObject `ContentInfo` can be file or directory and contains:\n\n| Field                    | Description                                                                      |\n| ------------------------ | -------------------------------------------------------------------------------- |\n| `string` name            | Content name                                                                     |\n| `bool` isFile            | Whether content is file                                                          |\n| `uint` size              | File size, in bytes                                                              |\n| `int` status             | File uploading status                                                            |\n| `bool[]` isChunkUploaded | Array with statuses of each chunk (`true` - chunk uploaded, `false` - otherwise) |\n\n## Build\n\nCreate an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nPRIVATEKEY='Private key for test account'\n```\n\nCompile `FileStorage.sol`:\n\n```bash\ntruffle compile\n```\n\n## Test\n\nTests run only on SKALE chains. Create an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nSCHAIN_OWNER_PK='Private key of SKALE endpoint owner (or account with money)'\nPRIVATEKEY='Private key for test account'\n```\n\nRun tests:\n\n```bash\ntruffle test --network skaled\n```\n","gitHead":"1d1dfc48ca6719b0b7b5646a9ae591c99b148513","scripts":{"lint":"npx ethlint -d contracts","test":"truffle test test/unit/* --network skaled","build":"rm -r ./build; truffle build","slither":"slither . --filter-path strings --filter-path Migrations","version":"node -e \"console.log(require('./package.json').version);\"","lint-fix":"npm run lint -- --fix","generate-config":"node -e 'require(\"./test/utils/helper.js\").generateTestConfig()'"},"_npmUser":{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},"repository":{"url":"git+https://github.com/skalenetwork/filestorage.git","type":"git"},"_npmVersion":"6.14.11","description":"SKALE Filestorage contracts","directories":{},"_nodeVersion":"10.24.0","dependencies":{"@openzeppelin/upgrades-core":"^1.5.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"chai":"^4.2.0","web3":"^1.2.1","dotenv":"^8.2.0","codecov":"^3.3.0","truffle":"^5.0.27","randomstring":"^1.1.5","chai-as-promised":"^7.1.1","solidity-coverage":"^0.6.7","@truffle/hdwallet-provider":"^1.0.18"},"_npmOperationalInternal":{"tmp":"tmp/filestorage_1.0.0-develop.1_1617143735552_0.2911896396816138","host":"s3://npm-registry-packages"}},"1.0.0-develop.2":{"name":"@skalenetwork/filestorage","version":"1.0.0-develop.2","keywords":["SKALE","blockchain","ethereum"],"author":{"name":"SKALE Labs and contributors"},"license":"AGPL-3.0","_id":"@skalenetwork/filestorage@1.0.0-develop.2","maintainers":[{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},{"name":"dmitrytk","email":"dmitry.tkachuk@skalelabs.com"},{"name":"cstrange","email":"chadwick@skalelabs.com"},{"name":"skalelabsdev","email":"dev@skalelabs.com"},{"name":"theskyunicorn","email":"christine@skalelabs.com"},{"name":"stebaev","email":"dimastebaev@gmail.com"},{"name":"l_sergiy","email":"sergiy@skalelabs.com"}],"homepage":"https://github.com/skalenetwork/filestorage#readme","bugs":{"url":"https://github.com/skalenetwork/filestorage/issues"},"dist":{"shasum":"03735ee1f03b3814ec2d1ffa35d480ff5dbd17ee","tarball":"https://registry.npmjs.org/@skalenetwork/filestorage/-/filestorage-1.0.0-develop.2.tgz","fileCount":5,"integrity":"sha512-3llZ0Gtj5DgMY/rFYjuevdSkcZh7lYPgd9AGGDE5y65Kab5PR6J9TPMrIs2vyAIwuJacmLgRMnKbc1KP0pBLUg==","signatures":[{"sig":"MEUCIQC5MzUl5qA/0Bu7fi5klBWwxwOBhl0DJbbw8wwp8NHPLAIgJoLAluNSknFmRtA7G7eefadJ7vu4Kh2p59jjIXbXrTw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":98851,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhLMmpCRA9TVsSAnZWagAA2q8P/14KfylhRyM/eFVeinlN\ntlZjJ9b3RAQxN2vwN6PCoo6yc6zLB6GtVPvjQiA9xvNFYnHoYc7W3Qvc6+B/\nrDPE183BceisZLXNwRqGyCAniKbERJFV5ENa7dL0SVEAhL8tpfS5WkbWwG5k\nSi64ZoFW1AYLqydTfwLuoZXoM+I3ZcW/OWFfTGG0Jpxk4BIKpogiN0V4N6am\nhYG4Jjaps91G3psy742pakABiBZthsh2uRSUM5NExfsX7vf55Nede4BMa42J\ngnd4DWWNSRSnxPeowvtLhuAkiLyYCAraFX73X+9TC3AoshqRRgts9zoGzKGF\nuBrXPAhSYpfinsyEfG+U7LxS+mOzS/NKibRtVjbtI+43pNPhdOWqC6/2wz+r\nYdzr/4a3DfYwQXW43Yhuh/BwZ4hvc9xakYHEXVwuVJJZexYBLif5r1pEd3k1\neF2CGQ6Gq2rOP29aw9Powx0zEcReKRu1SBzywInEs8cZBC+U0l4OUUKttKcw\nnMWqjx9BAcZ7cfJyQV9aTOxdzrmfHVqQjbB16PSfni7hMlGneII227IAsi1I\nlG8zVgOl69ij+SSf66pEwXdMEKKQopsxKTY3aaDAsqgqS6AGApbNOEarQ2W/\nZ5v74O99jJ4fLwfk67HKmiXVANIxjWDQpYduXW+ctait8goZsdSSUEOFx+hM\npkUT\r\n=WsK2\r\n-----END PGP SIGNATURE-----\r\n"},"main":"artifacts.json","gitHead":"5e6900aee6aa6eea70392481a65708c2e16fa89f","scripts":{"lint":"npx ethlint -d contracts","test":"truffle test test/unit/* --network skaled","build":"rm -r ./build; truffle build","slither":"slither . --filter-path strings --filter-path Migrations","version":"node -e \"console.log(require('./package.json').version);\"","lint-fix":"npm run lint -- --fix","generate-config":"node -e 'require(\"./test/utils/helper.js\").generateTestConfig()'"},"_npmUser":{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},"repository":{"url":"git+https://github.com/skalenetwork/filestorage.git","type":"git"},"_npmVersion":"6.14.12","description":"SKALE Filestorage contracts","directories":{},"_nodeVersion":"12.22.1","dependencies":{"@openzeppelin/upgrades-core":"^1.5.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"chai":"^4.2.0","web3":"^1.2.1","dotenv":"^8.2.0","codecov":"^3.3.0","truffle":"^5.0.27","randomstring":"^1.1.5","chai-as-promised":"^7.1.1","solidity-coverage":"^0.6.7","@truffle/hdwallet-provider":"^1.0.18"},"_npmOperationalInternal":{"tmp":"tmp/filestorage_1.0.0-develop.2_1630325161526_0.8678276274484933","host":"s3://npm-registry-packages"}},"1.0.0-develop.3":{"name":"@skalenetwork/filestorage","version":"1.0.0-develop.3","keywords":["SKALE","blockchain","ethereum"],"author":{"name":"SKALE Labs and contributors"},"license":"AGPL-3.0","_id":"@skalenetwork/filestorage@1.0.0-develop.3","maintainers":[{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},{"name":"dmitrytk","email":"dmitry.tkachuk@skalelabs.com"},{"name":"cstrange","email":"chadwick@skalelabs.com"},{"name":"skalelabsdev","email":"dev@skalelabs.com"},{"name":"theskyunicorn","email":"christine@skalelabs.com"},{"name":"stebaev","email":"dimastebaev@gmail.com"},{"name":"l_sergiy","email":"sergiy@skalelabs.com"}],"homepage":"https://github.com/skalenetwork/filestorage#readme","bugs":{"url":"https://github.com/skalenetwork/filestorage/issues"},"dist":{"shasum":"1edc573ee894428dd00ca3dd86dc9e3236184126","tarball":"https://registry.npmjs.org/@skalenetwork/filestorage/-/filestorage-1.0.0-develop.3.tgz","fileCount":5,"integrity":"sha512-vkqxMgcMvQklAvQNhXbiNAD7wQqGELA02YaAM23y2kRLZZdCcL7juOuYi7XERRH8nIo15n1PxkWjZ2n0xrg2FA==","signatures":[{"sig":"MEUCIECgwMAUuRa34R7UNLFLYTtzE7Fo3Hx+9Py83vt+FEqDAiEAjQHpaw10wW+EkpD0jb5rAX3ewc0W6pDX3JHK0yohT0E=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":49477,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhLM+SCRA9TVsSAnZWagAAi50P+wVNaGxyMsjZgu/iqebN\nbcaQ+8ml8FsdrT+bDrh7XTbXO4L3PPcoYF4exPzb4zLhnFrrwFPFuugeJ0TQ\nLpI1hF9LfmvwXHkWhsTC6WGDiEKNPP32uKHMr2Thmm6BsTiAa6WFjefFiqSU\npMixS2hRe5+yDZ+xMomT51+Xo1lJssm0MuOvPdOa4VCuEYJnucDEkZDXhsTH\nlWJsYEubOV/evUInXxp7RlcP+aRIkUwePymUVC55K0W1InBkpy88pW6BuWu6\nqw3VP4SQGX3zBj6hZDmYnaUejR9um0OERXooh6B/ZWTkbWZpP2GXcn78xc0+\nF1FNlrMW+UJp+REzeZH1RQu/ZY8OTXxDLbRrChz33m1Xk2eLf0x87HfNSfxW\nCicJZcxnMtHydTL9HDDmNEbc/4RTmLqfoGj9cDISr4qTbdBDR5SiuyRucHMF\nFZiKtZ6wx6Vm9J/Cv4NUQ1MC2EBTUwvSnOrJI6n5mQRAZTFf0sfNRM7WTAbR\nlSuDiU2nBbECSAnIzQCZKqB0nx3RRwhJ2q6phhoAIIxHek9RS5z/wkXftkhX\n9ZilygzWZGI0elCbHnl5YLh02klufvk8jpRCZo7f5eRutzhlq54oVboLoVQq\nIz/McHeVcULYqcOtpEoSISKlu4AWyamd8e8I0EIxoKt4/JVhLqobp3DIZnAZ\n7SnH\r\n=f+k8\r\n-----END PGP SIGNATURE-----\r\n"},"main":"artifacts.json","gitHead":"5e6900aee6aa6eea70392481a65708c2e16fa89f","scripts":{"lint":"npx ethlint -d contracts","test":"truffle test test/unit/* --network skaled","build":"rm -r ./build; truffle build","slither":"slither . --filter-path strings --filter-path Migrations","version":"node -e \"console.log(require('./package.json').version);\"","lint-fix":"npm run lint -- --fix","generate-config":"node -e 'require(\"./test/utils/helper.js\").generateTestConfig()'"},"_npmUser":{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},"repository":{"url":"git+https://github.com/skalenetwork/filestorage.git","type":"git"},"_npmVersion":"6.14.12","description":"SKALE Filestorage contracts","directories":{},"_nodeVersion":"12.22.1","dependencies":{"@openzeppelin/upgrades-core":"^1.5.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"chai":"^4.2.0","web3":"^1.2.1","dotenv":"^8.2.0","codecov":"^3.3.0","truffle":"^5.0.27","randomstring":"^1.1.5","chai-as-promised":"^7.1.1","solidity-coverage":"^0.6.7","@truffle/hdwallet-provider":"^1.0.18"},"_npmOperationalInternal":{"tmp":"tmp/filestorage_1.0.0-develop.3_1630326674420_0.6681365876541334","host":"s3://npm-registry-packages"}},"1.0.0-develop.4":{"name":"@skalenetwork/filestorage","version":"1.0.0-develop.4","keywords":["SKALE","blockchain","ethereum"],"author":{"name":"SKALE Labs and contributors"},"license":"AGPL-3.0","_id":"@skalenetwork/filestorage@1.0.0-develop.4","maintainers":[{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},{"name":"dmitrytk","email":"dmitry.tkachuk@skalelabs.com"},{"name":"cstrange","email":"chadwick@skalelabs.com"},{"name":"skalelabsdev","email":"dev@skalelabs.com"},{"name":"theskyunicorn","email":"christine@skalelabs.com"},{"name":"stebaev","email":"dimastebaev@gmail.com"},{"name":"l_sergiy","email":"sergiy@skalelabs.com"}],"homepage":"https://github.com/skalenetwork/filestorage#readme","bugs":{"url":"https://github.com/skalenetwork/filestorage/issues"},"dist":{"shasum":"b72e0586c2ed79a1b917073c882f805c11a9551c","tarball":"https://registry.npmjs.org/@skalenetwork/filestorage/-/filestorage-1.0.0-develop.4.tgz","fileCount":5,"integrity":"sha512-Mh88wbP36+BF+XCQBpDafyAwnWOU5sDCBetF0kcpjg/z82OInnmSVVlhjsQyXZDIGQogkGU/uatT80cfQ/QruQ==","signatures":[{"sig":"MEUCIQDP8rNtotk4IDOwF48XNd++K2CWZ0Gd3tE+/2NNb9W3/QIgBU8UlLP/w0A19QbwB7qIPRO90tMt7VO6UFhrVQysRDw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":49477,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhOel7CRA9TVsSAnZWagAAe7AP/jerToxIuEC1G9ToSKSP\nWaaP9LlN4J0EzN2/ZLM6NagPdLkJgm4IoUCFq6MTncQ9T2z4LSJ65NpHbeE+\noHoKj/U0eJbS4Wr9TBJmXpbMUjmLyMZzQa7NLERmDV0am46nMPnXKfSj1TT5\nrmEq9GmoKZC5RCCPBEXhVbqvM+cvg1aHjHshSHMNDRZ+bU/6GzhdALXOZ32B\ndirP5P5DPLqtpL6OdCArQgtWvzJQL0YCuu8z9TlTf9kwPMZC1MwH+Bicfesh\nJrugOqh7IWLP5U058S+T4s1p5lq+5lTadSTj+Jg+J81Zv6NHiqYwtlr5tFt4\nQ/h1qzebET1/7my7gaH4UjfO6Yh55q3GwRVQBT5ekmeW/V739fdrsdS3U7i/\nxxRnit8tN/IbsszAKtA07Ad2ft7rHl5+jAqGDQ+RXC44OjYt7sQF2uf4Cq84\nPdO/DF+KYPj4FKUcWun4WMH2EeRGYy+IwS/h7mrcJ4cyS8LbsSDluNb3qz9Q\nrYwVvWAh2b7ELOOTtkJVyDPthPKg2o9MMJRVQbSJ7zVWa0B2NqhUaSB9gS1S\nuSwlf3WJzqG1IyFHWDdtA7zu5Su8tFbjVbJsi7TVB7p5cZiMMwUTbVcOpwPI\nE8fmXiOuK2B/RVp1esK78ObKBx+ov20g3ynDjdsAis3Ytsb30E1UUalGHecL\nuXBd\r\n=zP0J\r\n-----END PGP SIGNATURE-----\r\n"},"main":"artifacts.json","readme":"# SKALE Filestorage\n\n[![Build Status](https://travis-ci.com/skalenetwork/filestorage.svg?token=HYnwEPctUzUdXVcsecA6&branch=develop)](https://travis-ci.com/skalenetwork/filestorage)\n[![codecov](https://codecov.io/gh/skalenetwork/filestorage/branch/develop/graph/badge.svg?token=2wkF3kZTXh)](https://codecov.io/gh/skalenetwork/filestorage)\n[![Discord](https://img.shields.io/discord/534485763354787851.svg)](https://discord.gg/vvUtWJB)\n\nFilestorage - smart contract, that controls decentralized file storage on SKALE chains.\n\n## Description\n\nFilestorage is a cost-effective storage layer within Ethereum capable of handling files up to 100MB. Filestorage uses UNIX-based filesystem of SKALE chains. Filestorage smart contract is a set of functions to interact with files on EVM. This contract may be predeployed on SKALE chains. It contains functions to work with Filestorage precompiled smart contracts. \n\nSmart contract language - Solidity 0.5.3\n\n## API Reference\n\n### File interaction methods\n\nTo begin the uploading process, the file should be broken into chunks of 1MB (&lt; 1MB for the last chunk) which are uploaded as separate transactions to FileStorage.sol. \nThe pipeline of the uploading file is:\n\n1.  creating empty file of fixed size on EVM by calling `startUpload`,\n2.  uploading data chunk by chunk with `uploadChunk`,\n3.  checking the file validity and finishing process with `finishUpload`.\n\n#### startUpload\n\n```solidity\nfunction startUpload(string memory filePath, uint256 fileSize)\n```\n\nCreates empty file on EVM with specific name and size. Owner of the file - message sender. \n\n-   Function is called by file owner\n-   Maximum amount of directories and files in one directory is **8196**\n-   Maximum filesize is **100,000,000** bytes\n-   Owner should have enough free space\n\n**Parameters:**\n\n| Parameter          | Description                           |\n| ------------------ | ------------------------------------- |\n| `string` filePath  | Path to the file in account directory |\n| `uint256` fileSize | Uploaded file size in bytes           |\n\n#### uploadChunk\n\n```solidity\nfunction uploadChunk(string memory filePath, uint position, bytes memory data)\n```\n\nUploads 1MB chunk of data from specific position in specific file by file owner.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n| `uint` position   | Uploaded chunk position               |\n| `bytes` data      | Uploaded chunk data                   |\n\n#### finishUpload\n\n```solidity\nfunction finishUpload(string memory filePath)\n```\n\nFinishes uploading of the file. Checks whether all chunks are uploaded correctly.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### deleteFile\n\n```solidity\nfunction deleteFile(string memory filePath)\n```\n\nDeletes file from Filestorage.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### readChunk\n\n```solidity\nfunction readChunk(string memory storagePath, uint position, uint length)\n        public\n        view\n        returns (bytes32[MAX_BLOCK_COUNT] memory out)\n```\n\nReads chunk from file from specific position with specific length. Returns `bytes32` array of fixed size with requested data.\n\n-   Maximum length of the chunk to read is 1Mb\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n| `uint` position      | First byte to read from              |\n| `uint` length        | Uploaded chunk length                |\n\n**Returns:**\n\n| Parameter       | Description                                       |\n| --------------- | ------------------------------------------------- |\n| `bytes32[]` out | Requested chunk data split across `bytes32` array |\n\n#### getFileSize\n\n```solidity\nfunction getFileSize(string memory storagePath) \n        public \n        view \n        returns (uint fileSize)\n```\n\nGets size of the requested file in bytes.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description            |\n| --------------- | ---------------------- |\n| `uint` fileSize | Size of requested file |\n\n#### getFileStatus\n\n```solidity\nfunction getFileStatus(string memory storagePath) \n        public \n        view \n        returns (int)\n```\n\nReturns status of the requested file:\n\n-   0 - file does not exist\n-   1 - file is created but has not finished uploading\n-   2 - file is fully uploaded\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter         | Description              |\n| ----------------- | ------------------------ |\n| `uint` fileStatus | Status of requested file |\n\n### Directory interaction methods\n\nFilestorage is represented with UNIX-based filesystem that consisted of files and directories. Directories are stored in `Directory` structure that contains information about its content in `ContentInfo` structure. Maximum amount of content in separate directory is **8196**.\n\n#### createDirectory\n\n```solidity\nfunction createDirectory(string memory directoryPath)\n```\n\nCreates directory in Filestorage. Owner of the directory - message sender. \n\n-   Function is called by directory owner\n-   Maximum amount of directories and files in one directory is **8196**\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### deleteDirectory\n\n```solidity\nfunction deleteDirectory(string memory directoryPath)\n```\n\nDeletes directory from Filestorage.\n\n-   Function is called by directory owner\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### listDirectory\n\n```solidity\nfunction listDirectory(string memory storagePath) \n        public \n        view \n        returns (ContentInfo[])\n```\n\nList information about content of the specific directory.\n\n**Parameters:**\n\n| Parameter            | Description                               |\n| -------------------- | ----------------------------------------- |\n| `string` storagePath | Full path of the directory in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description                          |\n| --------------- | ------------------------------------ |\n| `ContentInfo[]` | Array of content stored in directory |\n\nObject `ContentInfo` can be file or directory and contains:\n\n| Field                    | Description                                                                      |\n| ------------------------ | -------------------------------------------------------------------------------- |\n| `string` name            | Content name                                                                     |\n| `bool` isFile            | Whether content is file                                                          |\n| `uint` size              | File size, in bytes                                                              |\n| `int` status             | File uploading status                                                            |\n| `bool[]` isChunkUploaded | Array with statuses of each chunk (`true` - chunk uploaded, `false` - otherwise) |\n\n## Build\n\nCreate an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nPRIVATEKEY='Private key for test account'\n```\n\nCompile `FileStorage.sol`:\n\n```bash\ntruffle compile\n```\n\n## Test\n\nTests run only on SKALE chains. Create an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nSCHAIN_OWNER_PK='Private key of SKALE endpoint owner (or account with money)'\nPRIVATEKEY='Private key for test account'\n```\n\nRun tests:\n\n```bash\ntruffle test --network skaled\n```\n","gitHead":"08fc02ee1586d84073aecd5407b8317edb0b6ba5","scripts":{"lint":"npx ethlint -d contracts","test":"truffle test test/unit/* --network skaled","build":"rm -r ./build; truffle build","slither":"slither . --filter-path strings --filter-path Migrations","version":"node -e \"console.log(require('./package.json').version);\"","lint-fix":"npm run lint -- --fix","generate-config":"node -e 'require(\"./test/utils/helper.js\").generateTestConfig()'"},"_npmUser":{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},"repository":{"url":"git+https://github.com/skalenetwork/filestorage.git","type":"git"},"_npmVersion":"6.14.12","description":"SKALE Filestorage contracts","directories":{},"_nodeVersion":"10.24.1","dependencies":{"@openzeppelin/upgrades-core":"^1.5.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"chai":"^4.2.0","web3":"^1.2.1","dotenv":"^8.2.0","codecov":"^3.3.0","truffle":"^5.0.27","randomstring":"^1.1.5","chai-as-promised":"^7.1.1","solidity-coverage":"^0.6.7","@truffle/hdwallet-provider":"^1.0.18"},"_npmOperationalInternal":{"tmp":"tmp/filestorage_1.0.0-develop.4_1631185275246_0.3050161206996733","host":"s3://npm-registry-packages"}},"1.0.0-develop.5":{"name":"@skalenetwork/filestorage","version":"1.0.0-develop.5","keywords":["SKALE","blockchain","ethereum"],"author":{"name":"SKALE Labs and contributors"},"license":"AGPL-3.0","_id":"@skalenetwork/filestorage@1.0.0-develop.5","maintainers":[{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},{"name":"dmitrytk","email":"dmitry.tkachuk@skalelabs.com"},{"name":"cstrange","email":"chadwick@skalelabs.com"},{"name":"skalelabsdev","email":"dev@skalelabs.com"},{"name":"theskyunicorn","email":"christine@skalelabs.com"},{"name":"stebaev","email":"dimastebaev@gmail.com"},{"name":"l_sergiy","email":"sergiy@skalelabs.com"}],"homepage":"https://github.com/skalenetwork/filestorage#readme","bugs":{"url":"https://github.com/skalenetwork/filestorage/issues"},"dist":{"shasum":"d7f759cee277d23bc7acee51cb9cd7d38f0d13e4","tarball":"https://registry.npmjs.org/@skalenetwork/filestorage/-/filestorage-1.0.0-develop.5.tgz","fileCount":5,"integrity":"sha512-stfUvoHWO8MCjp+wytPI8i9HeOIUDvkvqwGzsopCkOflGS9Ty4BBd8xyJaLlFwAYz6I9/e9B7y4aq3lw6i0AJQ==","signatures":[{"sig":"MEQCIBPxTkTFwjpYtRs2qJ2MhlWWViE2RKh4N8pKL2AoW7mkAiAgpo+0Ffiw+gzrAZy3b6aayT0ZC78nEUAGfvEZKVPT1A==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":50444,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhOxsaCRA9TVsSAnZWagAA1YgP/RaIL2dGlb3+WabvgHDt\nHx1OMJeeM7c+FOvsT8xpvExlX2op9EwIF6du4CADBlksT4qSGO3SNFNQgWiC\nRkEjySfaOVYdSBpfuw13ojJUwMX/Jegr5JTAM6uRejuJBvyE35//3+Bt0izp\nGEAW2XkSiEIQ6lQ4oLecL2hSC1I/LTsJmE0PCAa0e4XcFrdOS8VtLiCeiHKS\n0F1laQ2yWEACBCl32o54DA6ubrvLnwiV7Zmat2HJuKt+L2bhATTAXwGucHO1\njNjACJMtqsqqkN3kQRhaCLLhba/AQ1qG5fn8yu4DHHiNaG8Z6zdNKACknu22\nXspxXxwDA/aeXOHwB+AlUHuLwbBI/LWP3AWCDi7e0pekS9dPFvplLsZkB8Zu\nbp+OYxmhlfsMhKtE0HNrey6Izs6tW1jvdl7kQqpzbU6OtEZrcaOIpcI3q2d9\nVh46QeSp847kJZOfEdBwPr3ov+4uETD1Nu/rpBmRbp5EYxhZF6NVBch5gYnW\nDGU0I3OGSj0JUbs/CrtnYKRljNjyb2uL0dHuWGolReK37fWeR7SkicsmxaKm\nd+VgLmq6o1dhK6oo48SSwpSJFt2Pjt8zJEDh42OEktrA3FDJTwVD9JDndS7H\nAvHCSuWisww7xfORIgah85UzjaN0iOvRy+HrkYXm9Uf6HjRMOYSGzy3MPIwV\nvZjo\r\n=gLS8\r\n-----END PGP SIGNATURE-----\r\n"},"main":"artifacts.json","readme":"# SKALE Filestorage\n\n[![Build Status](https://travis-ci.com/skalenetwork/filestorage.svg?token=HYnwEPctUzUdXVcsecA6&branch=develop)](https://travis-ci.com/skalenetwork/filestorage)\n[![codecov](https://codecov.io/gh/skalenetwork/filestorage/branch/develop/graph/badge.svg?token=2wkF3kZTXh)](https://codecov.io/gh/skalenetwork/filestorage)\n[![Discord](https://img.shields.io/discord/534485763354787851.svg)](https://discord.gg/vvUtWJB)\n\nFilestorage - smart contract, that controls decentralized file storage on SKALE chains.\n\n## Description\n\nFilestorage is a cost-effective storage layer within Ethereum capable of handling files up to 100MB. Filestorage uses UNIX-based filesystem of SKALE chains. Filestorage smart contract is a set of functions to interact with files on EVM. This contract may be predeployed on SKALE chains. It contains functions to work with Filestorage precompiled smart contracts. \n\nSmart contract language - Solidity 0.5.3\n\n## API Reference\n\n### File interaction methods\n\nTo begin the uploading process, the file should be broken into chunks of 1MB (&lt; 1MB for the last chunk) which are uploaded as separate transactions to FileStorage.sol. \nThe pipeline of the uploading file is:\n\n1.  creating empty file of fixed size on EVM by calling `startUpload`,\n2.  uploading data chunk by chunk with `uploadChunk`,\n3.  checking the file validity and finishing process with `finishUpload`.\n\n#### startUpload\n\n```solidity\nfunction startUpload(string memory filePath, uint256 fileSize)\n```\n\nCreates empty file on EVM with specific name and size. Owner of the file - message sender. \n\n-   Function is called by file owner\n-   Maximum amount of directories and files in one directory is **8196**\n-   Maximum filesize is **100,000,000** bytes\n-   Owner should have enough free space\n\n**Parameters:**\n\n| Parameter          | Description                           |\n| ------------------ | ------------------------------------- |\n| `string` filePath  | Path to the file in account directory |\n| `uint256` fileSize | Uploaded file size in bytes           |\n\n#### uploadChunk\n\n```solidity\nfunction uploadChunk(string memory filePath, uint position, bytes memory data)\n```\n\nUploads 1MB chunk of data from specific position in specific file by file owner.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n| `uint` position   | Uploaded chunk position               |\n| `bytes` data      | Uploaded chunk data                   |\n\n#### finishUpload\n\n```solidity\nfunction finishUpload(string memory filePath)\n```\n\nFinishes uploading of the file. Checks whether all chunks are uploaded correctly.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### deleteFile\n\n```solidity\nfunction deleteFile(string memory filePath)\n```\n\nDeletes file from Filestorage.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### readChunk\n\n```solidity\nfunction readChunk(string memory storagePath, uint position, uint length)\n        public\n        view\n        returns (bytes32[MAX_BLOCK_COUNT] memory out)\n```\n\nReads chunk from file from specific position with specific length. Returns `bytes32` array of fixed size with requested data.\n\n-   Maximum length of the chunk to read is 1Mb\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n| `uint` position      | First byte to read from              |\n| `uint` length        | Uploaded chunk length                |\n\n**Returns:**\n\n| Parameter       | Description                                       |\n| --------------- | ------------------------------------------------- |\n| `bytes32[]` out | Requested chunk data split across `bytes32` array |\n\n#### getFileSize\n\n```solidity\nfunction getFileSize(string memory storagePath) \n        public \n        view \n        returns (uint fileSize)\n```\n\nGets size of the requested file in bytes.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description            |\n| --------------- | ---------------------- |\n| `uint` fileSize | Size of requested file |\n\n#### getFileStatus\n\n```solidity\nfunction getFileStatus(string memory storagePath) \n        public \n        view \n        returns (int)\n```\n\nReturns status of the requested file:\n\n-   0 - file does not exist\n-   1 - file is created but has not finished uploading\n-   2 - file is fully uploaded\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter         | Description              |\n| ----------------- | ------------------------ |\n| `uint` fileStatus | Status of requested file |\n\n### Directory interaction methods\n\nFilestorage is represented with UNIX-based filesystem that consisted of files and directories. Directories are stored in `Directory` structure that contains information about its content in `ContentInfo` structure. Maximum amount of content in separate directory is **8196**.\n\n#### createDirectory\n\n```solidity\nfunction createDirectory(string memory directoryPath)\n```\n\nCreates directory in Filestorage. Owner of the directory - message sender. \n\n-   Function is called by directory owner\n-   Maximum amount of directories and files in one directory is **8196**\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### deleteDirectory\n\n```solidity\nfunction deleteDirectory(string memory directoryPath)\n```\n\nDeletes directory from Filestorage.\n\n-   Function is called by directory owner\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### listDirectory\n\n```solidity\nfunction listDirectory(string memory storagePath) \n        public \n        view \n        returns (ContentInfo[])\n```\n\nList information about content of the specific directory.\n\n**Parameters:**\n\n| Parameter            | Description                               |\n| -------------------- | ----------------------------------------- |\n| `string` storagePath | Full path of the directory in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description                          |\n| --------------- | ------------------------------------ |\n| `ContentInfo[]` | Array of content stored in directory |\n\nObject `ContentInfo` can be file or directory and contains:\n\n| Field                    | Description                                                                      |\n| ------------------------ | -------------------------------------------------------------------------------- |\n| `string` name            | Content name                                                                     |\n| `bool` isFile            | Whether content is file                                                          |\n| `uint` size              | File size, in bytes                                                              |\n| `int` status             | File uploading status                                                            |\n| `bool[]` isChunkUploaded | Array with statuses of each chunk (`true` - chunk uploaded, `false` - otherwise) |\n\n## Build\n\nCreate an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nPRIVATEKEY='Private key for test account'\n```\n\nCompile `FileStorage.sol`:\n\n```bash\ntruffle compile\n```\n\n## Test\n\nTests run only on SKALE chains. Create an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nSCHAIN_OWNER_PK='Private key of SKALE endpoint owner (or account with money)'\nPRIVATEKEY='Private key for test account'\n```\n\nRun tests:\n\n```bash\ntruffle test --network skaled\n```\n","gitHead":"8faeb24b06ca860edf9e523fffb48b1ec9801c49","scripts":{"lint":"npx ethlint -d contracts","test":"truffle test test/unit/* --network skaled","build":"rm -r ./build; truffle build","slither":"slither . --filter-path strings --filter-path Migrations","version":"node -e \"console.log(require('./package.json').version);\"","lint-fix":"npm run lint -- --fix","generate-config":"node -e 'require(\"./test/utils/helper.js\").generateTestConfig()'"},"_npmUser":{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},"repository":{"url":"git+https://github.com/skalenetwork/filestorage.git","type":"git"},"_npmVersion":"6.14.15","description":"SKALE Filestorage contracts","directories":{},"_nodeVersion":"12.22.6","dependencies":{"@openzeppelin/upgrades-core":"^1.5.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"chai":"^4.2.0","web3":"^1.2.1","dotenv":"^8.2.0","codecov":"^3.3.0","truffle":"^5.0.27","randomstring":"^1.1.5","chai-as-promised":"^7.1.1","solidity-coverage":"^0.6.7","@truffle/hdwallet-provider":"^1.0.18"},"_npmOperationalInternal":{"tmp":"tmp/filestorage_1.0.0-develop.5_1631263514780_0.19774444896695176","host":"s3://npm-registry-packages"}},"1.0.1-develop.0":{"name":"@skalenetwork/filestorage","version":"1.0.1-develop.0","keywords":["SKALE","blockchain","ethereum"],"author":{"name":"SKALE Labs and contributors"},"license":"AGPL-3.0","_id":"@skalenetwork/filestorage@1.0.1-develop.0","maintainers":[{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},{"name":"dmitrytk","email":"dmitry.tkachuk@skalelabs.com"},{"name":"cstrange","email":"chadwick@skalelabs.com"},{"name":"skalelabsdev","email":"dev@skalelabs.com"},{"name":"theskyunicorn","email":"christine@skalelabs.com"},{"name":"stebaev","email":"dimastebaev@gmail.com"},{"name":"l_sergiy","email":"sergiy@skalelabs.com"}],"homepage":"https://github.com/skalenetwork/filestorage#readme","bugs":{"url":"https://github.com/skalenetwork/filestorage/issues"},"dist":{"shasum":"b24d5c43f93f6d14f07f993903639a76f8516071","tarball":"https://registry.npmjs.org/@skalenetwork/filestorage/-/filestorage-1.0.1-develop.0.tgz","fileCount":5,"integrity":"sha512-UZwSCGkLe/KjZHjXMTwV7Liw7tOd/1V4NKSijSpMrZB5FAq8lXHf6Wgt+Q4PD76RgV7lWrBcdVmSrDAHj66pSA==","signatures":[{"sig":"MEYCIQDxcpLQ6WM05iuOX3eW4U8eG4xh/Mow7TEWQ3sQuMkOvgIhAKmLERxf+CSzNzIomM9KMoVAUQ2hgVVboAJZIefl2wXY","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":49477},"main":"artifacts.json","gitHead":"d9d62f30a9a8fe052917371fd141d16a61607e58","scripts":{"lint":"npx ethlint -d contracts","test":"truffle test test/unit/* --network skaled","build":"rm -r ./build; truffle build","slither":"slither . --filter-path strings --filter-path Migrations","version":"node -e \"console.log(require('./package.json').version);\"","lint-fix":"npm run lint -- --fix","generate-config":"node -e 'require(\"./test/utils/helper.js\").generateTestConfig()'"},"_npmUser":{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},"repository":{"url":"git+https://github.com/skalenetwork/filestorage.git","type":"git"},"_npmVersion":"6.14.12","description":"SKALE Filestorage contracts","directories":{},"_nodeVersion":"12.22.1","dependencies":{"@openzeppelin/upgrades-core":"^1.5.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"chai":"^4.2.0","web3":"^1.2.1","dotenv":"^8.2.0","codecov":"^3.3.0","truffle":"^5.0.27","randomstring":"^1.1.5","chai-as-promised":"^7.1.1","solidity-coverage":"^0.6.7","@truffle/hdwallet-provider":"^1.0.18"},"_npmOperationalInternal":{"tmp":"tmp/filestorage_1.0.1-develop.0_1632331833345_0.7200418585327235","host":"s3://npm-registry-packages"}},"1.0.1-develop.1":{"name":"@skalenetwork/filestorage","version":"1.0.1-develop.1","keywords":["SKALE","blockchain","ethereum"],"author":{"name":"SKALE Labs and contributors"},"license":"AGPL-3.0","_id":"@skalenetwork/filestorage@1.0.1-develop.1","maintainers":[{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},{"name":"dmitrytk","email":"dmitry.tkachuk@skalelabs.com"},{"name":"cstrange","email":"chadwick@skalelabs.com"},{"name":"skalelabsdev","email":"dev@skalelabs.com"},{"name":"theskyunicorn","email":"christine@skalelabs.com"},{"name":"stebaev","email":"dimastebaev@gmail.com"},{"name":"l_sergiy","email":"sergiy@skalelabs.com"}],"homepage":"https://github.com/skalenetwork/filestorage#readme","bugs":{"url":"https://github.com/skalenetwork/filestorage/issues"},"dist":{"shasum":"6f69de366dd693ae471e8e74c496046d2094ed99","tarball":"https://registry.npmjs.org/@skalenetwork/filestorage/-/filestorage-1.0.1-develop.1.tgz","fileCount":5,"integrity":"sha512-nbyegZQ2OaIpTWXpX6yjgmS625e4IQqmrP/76MBpvTQ8G0wrxdpygPJcJ/gvQO3LfwuUIbQ12VExFlSLigX3PQ==","signatures":[{"sig":"MEQCIGdktgefmqOn0EU+OdWjveTI0m7vSRwLXr7/a+vFIrZyAiBaXwVXctpz+ni+FvgNDPtFFXB6jbjKNluQykP5EBZbPQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":50444},"main":"artifacts.json","gitHead":"d9d62f30a9a8fe052917371fd141d16a61607e58","scripts":{"lint":"npx ethlint -d contracts","test":"truffle test test/unit/* --network skaled","build":"rm -r ./build; truffle build","slither":"slither . --filter-path strings --filter-path Migrations","version":"node -e \"console.log(require('./package.json').version);\"","lint-fix":"npm run lint -- --fix","generate-config":"node -e 'require(\"./test/utils/helper.js\").generateTestConfig()'"},"_npmUser":{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},"repository":{"url":"git+https://github.com/skalenetwork/filestorage.git","type":"git"},"_npmVersion":"6.14.12","description":"SKALE Filestorage contracts","directories":{},"_nodeVersion":"12.22.1","dependencies":{"@openzeppelin/upgrades-core":"^1.5.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"chai":"^4.2.0","web3":"^1.2.1","dotenv":"^8.2.0","codecov":"^3.3.0","truffle":"^5.0.27","randomstring":"^1.1.5","chai-as-promised":"^7.1.1","solidity-coverage":"^0.6.7","@truffle/hdwallet-provider":"^1.0.18"},"_npmOperationalInternal":{"tmp":"tmp/filestorage_1.0.1-develop.1_1632389366311_0.5234209392111209","host":"s3://npm-registry-packages"}},"1.0.1-develop.2":{"name":"@skalenetwork/filestorage","version":"1.0.1-develop.2","keywords":["SKALE","blockchain","ethereum"],"author":{"name":"SKALE Labs and contributors"},"license":"AGPL-3.0","_id":"@skalenetwork/filestorage@1.0.1-develop.2","maintainers":[{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},{"name":"dmitrytk","email":"dmitry.tkachuk@skalelabs.com"},{"name":"cstrange","email":"chadwick@skalelabs.com"},{"name":"skalelabsdev","email":"dev@skalelabs.com"},{"name":"theskyunicorn","email":"christine@skalelabs.com"},{"name":"stebaev","email":"dimastebaev@gmail.com"},{"name":"l_sergiy","email":"sergiy@skalelabs.com"}],"homepage":"https://github.com/skalenetwork/filestorage#readme","bugs":{"url":"https://github.com/skalenetwork/filestorage/issues"},"dist":{"shasum":"4407e2c00500a5dc83a3a413209a1e582ef0d0d3","tarball":"https://registry.npmjs.org/@skalenetwork/filestorage/-/filestorage-1.0.1-develop.2.tgz","fileCount":5,"integrity":"sha512-wuDWeDtOh7LadUSS/Usl2Re6WG020cbixn8URgaMVLmpbevTVNt8FepSijvsWQP4ib0dO6tzFEpvUMCFgBnCew==","signatures":[{"sig":"MEUCIQC8zdpZoVkYA+Lf7jyPXd60z7o+snu7fQNs4VkRC6Uu9QIgEYUtFaHJ83N/Y1rncI/h94XhltrOlSe9gr5UXMIRJsQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":50505},"main":"artifacts.json","readme":"# SKALE Filestorage\n\n[![Build Status](https://travis-ci.com/skalenetwork/filestorage.svg?token=HYnwEPctUzUdXVcsecA6&branch=develop)](https://travis-ci.com/skalenetwork/filestorage)\n[![codecov](https://codecov.io/gh/skalenetwork/filestorage/branch/develop/graph/badge.svg?token=2wkF3kZTXh)](https://codecov.io/gh/skalenetwork/filestorage)\n[![Discord](https://img.shields.io/discord/534485763354787851.svg)](https://discord.gg/vvUtWJB)\n\nFilestorage - smart contract, that controls decentralized file storage on SKALE chains.\n\n## Description\n\nFilestorage is a cost-effective storage layer within Ethereum capable of handling files up to 100MB. Filestorage uses UNIX-based filesystem of SKALE chains. Filestorage smart contract is a set of functions to interact with files on EVM. This contract may be predeployed on SKALE chains. It contains functions to work with Filestorage precompiled smart contracts. \n\nSmart contract language - Solidity 0.5.3\n\n## API Reference\n\n### File interaction methods\n\nTo begin the uploading process, the file should be broken into chunks of 1MB (&lt; 1MB for the last chunk) which are uploaded as separate transactions to FileStorage.sol. \nThe pipeline of the uploading file is:\n\n1.  creating empty file of fixed size on EVM by calling `startUpload`,\n2.  uploading data chunk by chunk with `uploadChunk`,\n3.  checking the file validity and finishing process with `finishUpload`.\n\n#### startUpload\n\n```solidity\nfunction startUpload(string memory filePath, uint256 fileSize)\n```\n\nCreates empty file on EVM with specific name and size. Owner of the file - message sender. \n\n-   Function is called by file owner\n-   Maximum amount of directories and files in one directory is **8196**\n-   Maximum filesize is **100,000,000** bytes\n-   Owner should have enough free space\n\n**Parameters:**\n\n| Parameter          | Description                           |\n| ------------------ | ------------------------------------- |\n| `string` filePath  | Path to the file in account directory |\n| `uint256` fileSize | Uploaded file size in bytes           |\n\n#### uploadChunk\n\n```solidity\nfunction uploadChunk(string memory filePath, uint position, bytes memory data)\n```\n\nUploads 1MB chunk of data from specific position in specific file by file owner.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n| `uint` position   | Uploaded chunk position               |\n| `bytes` data      | Uploaded chunk data                   |\n\n#### finishUpload\n\n```solidity\nfunction finishUpload(string memory filePath)\n```\n\nFinishes uploading of the file. Checks whether all chunks are uploaded correctly.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### deleteFile\n\n```solidity\nfunction deleteFile(string memory filePath)\n```\n\nDeletes file from Filestorage.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### readChunk\n\n```solidity\nfunction readChunk(string memory storagePath, uint position, uint length)\n        public\n        view\n        returns (bytes32[MAX_BLOCK_COUNT] memory out)\n```\n\nReads chunk from file from specific position with specific length. Returns `bytes32` array of fixed size with requested data.\n\n-   Maximum length of the chunk to read is 1Mb\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n| `uint` position      | First byte to read from              |\n| `uint` length        | Uploaded chunk length                |\n\n**Returns:**\n\n| Parameter       | Description                                       |\n| --------------- | ------------------------------------------------- |\n| `bytes32[]` out | Requested chunk data split across `bytes32` array |\n\n#### getFileSize\n\n```solidity\nfunction getFileSize(string memory storagePath) \n        public \n        view \n        returns (uint fileSize)\n```\n\nGets size of the requested file in bytes.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description            |\n| --------------- | ---------------------- |\n| `uint` fileSize | Size of requested file |\n\n#### getFileStatus\n\n```solidity\nfunction getFileStatus(string memory storagePath) \n        public \n        view \n        returns (int)\n```\n\nReturns status of the requested file:\n\n-   0 - file does not exist\n-   1 - file is created but has not finished uploading\n-   2 - file is fully uploaded\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter         | Description              |\n| ----------------- | ------------------------ |\n| `uint` fileStatus | Status of requested file |\n\n### Directory interaction methods\n\nFilestorage is represented with UNIX-based filesystem that consisted of files and directories. Directories are stored in `Directory` structure that contains information about its content in `ContentInfo` structure. Maximum amount of content in separate directory is **8196**.\n\n#### createDirectory\n\n```solidity\nfunction createDirectory(string memory directoryPath)\n```\n\nCreates directory in Filestorage. Owner of the directory - message sender. \n\n-   Function is called by directory owner\n-   Maximum amount of directories and files in one directory is **8196**\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### deleteDirectory\n\n```solidity\nfunction deleteDirectory(string memory directoryPath)\n```\n\nDeletes directory from Filestorage.\n\n-   Function is called by directory owner\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### listDirectory\n\n```solidity\nfunction listDirectory(string memory storagePath) \n        public \n        view \n        returns (ContentInfo[])\n```\n\nList information about content of the specific directory.\n\n**Parameters:**\n\n| Parameter            | Description                               |\n| -------------------- | ----------------------------------------- |\n| `string` storagePath | Full path of the directory in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description                          |\n| --------------- | ------------------------------------ |\n| `ContentInfo[]` | Array of content stored in directory |\n\nObject `ContentInfo` can be file or directory and contains:\n\n| Field                    | Description                                                                      |\n| ------------------------ | -------------------------------------------------------------------------------- |\n| `string` name            | Content name                                                                     |\n| `bool` isFile            | Whether content is file                                                          |\n| `uint` size              | File size, in bytes                                                              |\n| `int` status             | File uploading status                                                            |\n| `bool[]` isChunkUploaded | Array with statuses of each chunk (`true` - chunk uploaded, `false` - otherwise) |\n\n## Build\n\nCreate an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nPRIVATEKEY='Private key for test account'\n```\n\nCompile `FileStorage.sol`:\n\n```bash\ntruffle compile\n```\n\n## Test\n\nTests run only on SKALE chains. Create an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nSCHAIN_OWNER_PK='Private key of SKALE endpoint owner (or account with money)'\nPRIVATEKEY='Private key for test account'\n```\n\nRun tests:\n\n```bash\ntruffle test --network skaled\n```\n","gitHead":"4d59ee1ebe1a265b6b39e6feef1ef8ed727e18fe","scripts":{"lint":"npx ethlint -d contracts","test":"truffle test test/unit/* --network skaled","build":"rm -r ./build; truffle build","slither":"slither . --filter-path strings --filter-path Migrations","version":"node -e \"console.log(require('./package.json').version);\"","coverage":"truffle run coverage --file=\"test/unit/*\"","lint-fix":"npm run lint -- --fix","generate-config":"node -e 'require(\"./test/utils/helper.js\").generateTestConfig()'"},"_npmUser":{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},"repository":{"url":"git+https://github.com/skalenetwork/filestorage.git","type":"git"},"_npmVersion":"6.14.15","description":"SKALE Filestorage contracts","directories":{},"_nodeVersion":"12.22.7","dependencies":{"@openzeppelin/upgrades-core":"^1.5.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"chai":"^4.2.0","web3":"^1.2.1","dotenv":"^8.2.0","codecov":"^3.3.0","truffle":"5.1.0","randomstring":"^1.1.5","chai-as-promised":"^7.1.1","solidity-coverage":"^0.7.17","@truffle/hdwallet-provider":"^1.5.1"},"_npmOperationalInternal":{"tmp":"tmp/filestorage_1.0.1-develop.2_1635510382294_0.5056120551072043","host":"s3://npm-registry-packages"}},"1.0.1-develop.3":{"name":"@skalenetwork/filestorage","version":"1.0.1-develop.3","keywords":["SKALE","blockchain","ethereum"],"author":{"name":"SKALE Labs and contributors"},"license":"AGPL-3.0","_id":"@skalenetwork/filestorage@1.0.1-develop.3","maintainers":[{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},{"name":"dmitrytk","email":"dmitry.tkachuk@skalelabs.com"},{"name":"cstrange","email":"chadwick@skalelabs.com"},{"name":"skalelabsdev","email":"dev@skalelabs.com"},{"name":"theskyunicorn","email":"christine@skalelabs.com"},{"name":"stebaev","email":"dimastebaev@gmail.com"},{"name":"l_sergiy","email":"sergiy@skalelabs.com"}],"homepage":"https://github.com/skalenetwork/filestorage#readme","bugs":{"url":"https://github.com/skalenetwork/filestorage/issues"},"dist":{"shasum":"709da8213c0be501b6562069575d68c4924c1c9a","tarball":"https://registry.npmjs.org/@skalenetwork/filestorage/-/filestorage-1.0.1-develop.3.tgz","fileCount":5,"integrity":"sha512-HM7rm3hpDzhhWmfJ9Wlarksnr8COpCpp22RckWXwXcKOdlG5B9QJkilgn9fVd8wu81Yq72ZteL0Hy/dE9N6vnA==","signatures":[{"sig":"MEQCIE4iVAltKYtk6S97XdyIr1Ju1BdOsicPj9Q2NlPKYussAiAc+qzazcssDyeGxFjy4X4o3RQf+ZcPS5VocqOoX2ty1w==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":62931},"main":"artifacts.json","readme":"# SKALE Filestorage\n\n[![Build Status](https://travis-ci.com/skalenetwork/filestorage.svg?token=HYnwEPctUzUdXVcsecA6&branch=develop)](https://travis-ci.com/skalenetwork/filestorage)\n[![codecov](https://codecov.io/gh/skalenetwork/filestorage/branch/develop/graph/badge.svg?token=2wkF3kZTXh)](https://codecov.io/gh/skalenetwork/filestorage)\n[![Discord](https://img.shields.io/discord/534485763354787851.svg)](https://discord.gg/vvUtWJB)\n\nFilestorage - smart contract, that controls decentralized file storage on SKALE chains.\n\n## Description\n\nFilestorage is a cost-effective storage layer within Ethereum capable of handling files up to 100MB. Filestorage uses UNIX-based filesystem of SKALE chains. Filestorage smart contract is a set of functions to interact with files on EVM. This contract may be predeployed on SKALE chains. It contains functions to work with Filestorage precompiled smart contracts. \n\nSmart contract language - Solidity 0.5.3\n\n## API Reference\n\n### File interaction methods\n\nTo begin the uploading process, the file should be broken into chunks of 1MB (&lt; 1MB for the last chunk) which are uploaded as separate transactions to FileStorage.sol. \nThe pipeline of the uploading file is:\n\n1.  creating empty file of fixed size on EVM by calling `startUpload`,\n2.  uploading data chunk by chunk with `uploadChunk`,\n3.  checking the file validity and finishing process with `finishUpload`.\n\n#### startUpload\n\n```solidity\nfunction startUpload(string memory filePath, uint256 fileSize)\n```\n\nCreates empty file on EVM with specific name and size. Owner of the file - message sender. \n\n-   Function is called by file owner\n-   Maximum amount of directories and files in one directory is **8196**\n-   Maximum filesize is **100,000,000** bytes\n-   Owner should have enough free space\n\n**Parameters:**\n\n| Parameter          | Description                           |\n| ------------------ | ------------------------------------- |\n| `string` filePath  | Path to the file in account directory |\n| `uint256` fileSize | Uploaded file size in bytes           |\n\n#### uploadChunk\n\n```solidity\nfunction uploadChunk(string memory filePath, uint position, bytes memory data)\n```\n\nUploads 1MB chunk of data from specific position in specific file by file owner.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n| `uint` position   | Uploaded chunk position               |\n| `bytes` data      | Uploaded chunk data                   |\n\n#### finishUpload\n\n```solidity\nfunction finishUpload(string memory filePath)\n```\n\nFinishes uploading of the file. Checks whether all chunks are uploaded correctly.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### deleteFile\n\n```solidity\nfunction deleteFile(string memory filePath)\n```\n\nDeletes file from Filestorage.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### readChunk\n\n```solidity\nfunction readChunk(string memory storagePath, uint position, uint length)\n        public\n        view\n        returns (bytes32[MAX_BLOCK_COUNT] memory out)\n```\n\nReads chunk from file from specific position with specific length. Returns `bytes32` array of fixed size with requested data.\n\n-   Maximum length of the chunk to read is 1Mb\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n| `uint` position      | First byte to read from              |\n| `uint` length        | Uploaded chunk length                |\n\n**Returns:**\n\n| Parameter       | Description                                       |\n| --------------- | ------------------------------------------------- |\n| `bytes32[]` out | Requested chunk data split across `bytes32` array |\n\n#### getFileSize\n\n```solidity\nfunction getFileSize(string memory storagePath) \n        public \n        view \n        returns (uint fileSize)\n```\n\nGets size of the requested file in bytes.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description            |\n| --------------- | ---------------------- |\n| `uint` fileSize | Size of requested file |\n\n#### getFileStatus\n\n```solidity\nfunction getFileStatus(string memory storagePath) \n        public \n        view \n        returns (int)\n```\n\nReturns status of the requested file:\n\n-   0 - file does not exist\n-   1 - file is created but has not finished uploading\n-   2 - file is fully uploaded\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter         | Description              |\n| ----------------- | ------------------------ |\n| `uint` fileStatus | Status of requested file |\n\n### Directory interaction methods\n\nFilestorage is represented with UNIX-based filesystem that consisted of files and directories. Directories are stored in `Directory` structure that contains information about its content in `ContentInfo` structure. Maximum amount of content in separate directory is **8196**.\n\n#### createDirectory\n\n```solidity\nfunction createDirectory(string memory directoryPath)\n```\n\nCreates directory in Filestorage. Owner of the directory - message sender. \n\n-   Function is called by directory owner\n-   Maximum amount of directories and files in one directory is **8196**\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### deleteDirectory\n\n```solidity\nfunction deleteDirectory(string memory directoryPath)\n```\n\nDeletes directory from Filestorage.\n\n-   Function is called by directory owner\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### listDirectory\n\n```solidity\nfunction listDirectory(string memory storagePath) \n        public \n        view \n        returns (ContentInfo[])\n```\n\nList information about content of the specific directory.\n\n**Parameters:**\n\n| Parameter            | Description                               |\n| -------------------- | ----------------------------------------- |\n| `string` storagePath | Full path of the directory in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description                          |\n| --------------- | ------------------------------------ |\n| `ContentInfo[]` | Array of content stored in directory |\n\nObject `ContentInfo` can be file or directory and contains:\n\n| Field                    | Description                                                                      |\n| ------------------------ | -------------------------------------------------------------------------------- |\n| `string` name            | Content name                                                                     |\n| `bool` isFile            | Whether content is file                                                          |\n| `uint` size              | File size, in bytes                                                              |\n| `int` status             | File uploading status                                                            |\n| `bool[]` isChunkUploaded | Array with statuses of each chunk (`true` - chunk uploaded, `false` - otherwise) |\n\n## Build\n\nCreate an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nPRIVATEKEY='Private key for test account'\n```\n\nCompile `FileStorage.sol`:\n\n```bash\ntruffle compile\n```\n\n## Test\n\nTests run only on SKALE chains. Create an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nSCHAIN_OWNER_PK='Private key of SKALE endpoint owner (or account with money)'\nPRIVATEKEY='Private key for test account'\n```\n\nRun tests:\n\n```bash\ntruffle test --network skaled\n```\n","gitHead":"d6ad6f8379f608603e2d1068a43eda3f50103271","scripts":{"lint":"npx ethlint -d contracts","test":"npx truffle test test/unit/* --network skaled","build":"rm -r ./build; npx truffle build","compile":"npx truffle compile; cp build/contracts/FileStorage.json predeployed/filestorage_predeployed/artifacts/","slither":"slither . --filter-path strings --filter-path Migrations","version":"node -e \"console.log(require('./package.json').version);\"","coverage":"npx truffle run coverage --file=\"test/unit/*\"","lint-fix":"npm run lint -- --fix","predeployed-test":"npx truffle test test/predeployed/* --network skaled"},"_npmUser":{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},"repository":{"url":"git+https://github.com/skalenetwork/filestorage.git","type":"git"},"_npmVersion":"6.14.15","description":"SKALE Filestorage contracts","directories":{},"_nodeVersion":"14.18.1","dependencies":{"@openzeppelin/contracts-upgradeable":"^4.3.2"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"chai":"^4.2.0","web3":"^1.2.1","dotenv":"^8.2.0","codecov":"^3.3.0","truffle":"5.1.30","randomstring":"^1.1.5","chai-as-promised":"^7.1.1","solidity-coverage":"^0.7.17","@truffle/hdwallet-provider":"^1.5.1"},"_npmOperationalInternal":{"tmp":"tmp/filestorage_1.0.1-develop.3_1636557779189_0.5322231444223344","host":"s3://npm-registry-packages"}},"1.0.1-develop.5":{"name":"@skalenetwork/filestorage","version":"1.0.1-develop.5","keywords":["SKALE","blockchain","ethereum"],"author":{"name":"SKALE Labs and contributors"},"license":"AGPL-3.0","_id":"@skalenetwork/filestorage@1.0.1-develop.5","maintainers":[{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},{"name":"dmitrytk","email":"dmitry.tkachuk@skalelabs.com"},{"name":"cstrange","email":"chadwick@skalelabs.com"},{"name":"skalelabsdev","email":"dev@skalelabs.com"},{"name":"theskyunicorn","email":"christine@skalelabs.com"},{"name":"stebaev","email":"dimastebaev@gmail.com"},{"name":"l_sergiy","email":"sergiy@skalelabs.com"}],"homepage":"https://github.com/skalenetwork/filestorage#readme","bugs":{"url":"https://github.com/skalenetwork/filestorage/issues"},"dist":{"shasum":"20ada970fc86cc8c9322b94787c3043903ffe7f0","tarball":"https://registry.npmjs.org/@skalenetwork/filestorage/-/filestorage-1.0.1-develop.5.tgz","fileCount":5,"integrity":"sha512-cJ6RGmunAXb8HP6mNc4sOT3exDso8BqczTeJ2IiL1nfxeZNzp58e/WFTYJApHkHITksxGDrxv/mONWQu119rGA==","signatures":[{"sig":"MEUCIQDgLUOKnrnZtvfYNQyic9YwJvPxItDMBxnu3TGPo5WKMwIgcjfvuodBfFAx6Bif98CmMlO4QxmaqJMBfYFIwNKsonU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":62931},"main":"artifacts.json","readme":"# SKALE Filestorage\n\n[![Build Status](https://travis-ci.com/skalenetwork/filestorage.svg?token=HYnwEPctUzUdXVcsecA6&branch=develop)](https://travis-ci.com/skalenetwork/filestorage)\n[![codecov](https://codecov.io/gh/skalenetwork/filestorage/branch/develop/graph/badge.svg?token=2wkF3kZTXh)](https://codecov.io/gh/skalenetwork/filestorage)\n[![Discord](https://img.shields.io/discord/534485763354787851.svg)](https://discord.gg/vvUtWJB)\n\nFilestorage - smart contract, that controls decentralized file storage on SKALE chains.\n\n## Description\n\nFilestorage is a cost-effective storage layer within Ethereum capable of handling files up to 100MB. Filestorage uses UNIX-based filesystem of SKALE chains. Filestorage smart contract is a set of functions to interact with files on EVM. This contract may be predeployed on SKALE chains. It contains functions to work with Filestorage precompiled smart contracts. \n\nSmart contract language - Solidity 0.5.3\n\n## API Reference\n\n### File interaction methods\n\nTo begin the uploading process, the file should be broken into chunks of 1MB (&lt; 1MB for the last chunk) which are uploaded as separate transactions to FileStorage.sol. \nThe pipeline of the uploading file is:\n\n1.  creating empty file of fixed size on EVM by calling `startUpload`,\n2.  uploading data chunk by chunk with `uploadChunk`,\n3.  checking the file validity and finishing process with `finishUpload`.\n\n#### startUpload\n\n```solidity\nfunction startUpload(string memory filePath, uint256 fileSize)\n```\n\nCreates empty file on EVM with specific name and size. Owner of the file - message sender. \n\n-   Function is called by file owner\n-   Maximum amount of directories and files in one directory is **8196**\n-   Maximum filesize is **100,000,000** bytes\n-   Owner should have enough free space\n\n**Parameters:**\n\n| Parameter          | Description                           |\n| ------------------ | ------------------------------------- |\n| `string` filePath  | Path to the file in account directory |\n| `uint256` fileSize | Uploaded file size in bytes           |\n\n#### uploadChunk\n\n```solidity\nfunction uploadChunk(string memory filePath, uint position, bytes memory data)\n```\n\nUploads 1MB chunk of data from specific position in specific file by file owner.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n| `uint` position   | Uploaded chunk position               |\n| `bytes` data      | Uploaded chunk data                   |\n\n#### finishUpload\n\n```solidity\nfunction finishUpload(string memory filePath)\n```\n\nFinishes uploading of the file. Checks whether all chunks are uploaded correctly.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### deleteFile\n\n```solidity\nfunction deleteFile(string memory filePath)\n```\n\nDeletes file from Filestorage.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### readChunk\n\n```solidity\nfunction readChunk(string memory storagePath, uint position, uint length)\n        public\n        view\n        returns (bytes32[MAX_BLOCK_COUNT] memory out)\n```\n\nReads chunk from file from specific position with specific length. Returns `bytes32` array of fixed size with requested data.\n\n-   Maximum length of the chunk to read is 1Mb\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n| `uint` position      | First byte to read from              |\n| `uint` length        | Uploaded chunk length                |\n\n**Returns:**\n\n| Parameter       | Description                                       |\n| --------------- | ------------------------------------------------- |\n| `bytes32[]` out | Requested chunk data split across `bytes32` array |\n\n#### getFileSize\n\n```solidity\nfunction getFileSize(string memory storagePath) \n        public \n        view \n        returns (uint fileSize)\n```\n\nGets size of the requested file in bytes.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description            |\n| --------------- | ---------------------- |\n| `uint` fileSize | Size of requested file |\n\n#### getFileStatus\n\n```solidity\nfunction getFileStatus(string memory storagePath) \n        public \n        view \n        returns (int)\n```\n\nReturns status of the requested file:\n\n-   0 - file does not exist\n-   1 - file is created but has not finished uploading\n-   2 - file is fully uploaded\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter         | Description              |\n| ----------------- | ------------------------ |\n| `uint` fileStatus | Status of requested file |\n\n### Directory interaction methods\n\nFilestorage is represented with UNIX-based filesystem that consisted of files and directories. Directories are stored in `Directory` structure that contains information about its content in `ContentInfo` structure. Maximum amount of content in separate directory is **8196**.\n\n#### createDirectory\n\n```solidity\nfunction createDirectory(string memory directoryPath)\n```\n\nCreates directory in Filestorage. Owner of the directory - message sender. \n\n-   Function is called by directory owner\n-   Maximum amount of directories and files in one directory is **8196**\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### deleteDirectory\n\n```solidity\nfunction deleteDirectory(string memory directoryPath)\n```\n\nDeletes directory from Filestorage.\n\n-   Function is called by directory owner\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### listDirectory\n\n```solidity\nfunction listDirectory(string memory storagePath) \n        public \n        view \n        returns (ContentInfo[])\n```\n\nList information about content of the specific directory.\n\n**Parameters:**\n\n| Parameter            | Description                               |\n| -------------------- | ----------------------------------------- |\n| `string` storagePath | Full path of the directory in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description                          |\n| --------------- | ------------------------------------ |\n| `ContentInfo[]` | Array of content stored in directory |\n\nObject `ContentInfo` can be file or directory and contains:\n\n| Field                    | Description                                                                      |\n| ------------------------ | -------------------------------------------------------------------------------- |\n| `string` name            | Content name                                                                     |\n| `bool` isFile            | Whether content is file                                                          |\n| `uint` size              | File size, in bytes                                                              |\n| `int` status             | File uploading status                                                            |\n| `bool[]` isChunkUploaded | Array with statuses of each chunk (`true` - chunk uploaded, `false` - otherwise) |\n\n## Build\n\nCreate an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nPRIVATEKEY='Private key for test account'\n```\n\nCompile `FileStorage.sol`:\n\n```bash\ntruffle compile\n```\n\n## Test\n\nTests run only on SKALE chains. Create an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nSCHAIN_OWNER_PK='Private key of SKALE endpoint owner (or account with money)'\nPRIVATEKEY='Private key for test account'\n```\n\nRun tests:\n\n```bash\ntruffle test --network skaled\n```\n","gitHead":"2c0d6e7983077fd8fe70692b339d71f819b7ee78","scripts":{"lint":"npx ethlint -d contracts","test":"npx truffle test test/unit/* --network skaled","build":"rm -r ./build; npx truffle build","compile":"npx truffle compile; cp build/contracts/FileStorage.json predeployed/filestorage_predeployed/artifacts/","slither":"slither . --filter-path strings --filter-path Migrations","version":"node -e \"console.log(require('./package.json').version);\"","coverage":"npx truffle run coverage --file=\"test/unit/*\"","lint-fix":"npm run lint -- --fix","predeployed-test":"npx truffle test test/predeployed/* --network skaled"},"_npmUser":{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},"repository":{"url":"git+https://github.com/skalenetwork/filestorage.git","type":"git"},"_npmVersion":"6.14.15","description":"SKALE Filestorage contracts","directories":{},"_nodeVersion":"14.18.1","dependencies":{"@openzeppelin/contracts-upgradeable":"^4.3.2"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"chai":"^4.2.0","web3":"^1.2.1","dotenv":"^8.2.0","codecov":"^3.3.0","truffle":"5.1.30","randomstring":"^1.1.5","chai-as-promised":"^7.1.1","solidity-coverage":"^0.7.17","@truffle/hdwallet-provider":"^1.5.1"},"_npmOperationalInternal":{"tmp":"tmp/filestorage_1.0.1-develop.5_1636558403753_0.37072019567147496","host":"s3://npm-registry-packages"}},"1.0.1-develop.6":{"name":"@skalenetwork/filestorage","version":"1.0.1-develop.6","keywords":["SKALE","blockchain","ethereum"],"author":{"name":"SKALE Labs and contributors"},"license":"AGPL-3.0","_id":"@skalenetwork/filestorage@1.0.1-develop.6","maintainers":[{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},{"name":"dmitrytk","email":"dmitry.tkachuk@skalelabs.com"},{"name":"cstrange","email":"chadwick@skalelabs.com"},{"name":"skalelabsdev","email":"dev@skalelabs.com"},{"name":"theskyunicorn","email":"christine@skalelabs.com"},{"name":"stebaev","email":"dimastebaev@gmail.com"},{"name":"l_sergiy","email":"sergiy@skalelabs.com"}],"homepage":"https://github.com/skalenetwork/filestorage#readme","bugs":{"url":"https://github.com/skalenetwork/filestorage/issues"},"dist":{"shasum":"fbe3db1061c6d373b9645e21862291e5b6f6f3f1","tarball":"https://registry.npmjs.org/@skalenetwork/filestorage/-/filestorage-1.0.1-develop.6.tgz","fileCount":5,"integrity":"sha512-LCzdNg9MNlDArQWKUcdW8LEYYl5jyDeu9coOtt2h47toGVH5Fz1S9WG6H7gmQuZFlhH7StBWTau+T4W/1y0d4Q==","signatures":[{"sig":"MEQCIDqtUoHlMDEA3d3h4TyHgfBHMMBXbS2BdzFWq6XM2hCEAiB1jxzA+szQCbdBl+6IP7HktQYyab24dzSaUBv+fhU5IQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":62931},"main":"artifacts.json","readme":"# SKALE Filestorage\n\n[![Build Status](https://travis-ci.com/skalenetwork/filestorage.svg?token=HYnwEPctUzUdXVcsecA6&branch=develop)](https://travis-ci.com/skalenetwork/filestorage)\n[![codecov](https://codecov.io/gh/skalenetwork/filestorage/branch/develop/graph/badge.svg?token=2wkF3kZTXh)](https://codecov.io/gh/skalenetwork/filestorage)\n[![Discord](https://img.shields.io/discord/534485763354787851.svg)](https://discord.gg/vvUtWJB)\n\nFilestorage - smart contract, that controls decentralized file storage on SKALE chains.\n\n## Description\n\nFilestorage is a cost-effective storage layer within Ethereum capable of handling files up to 100MB. Filestorage uses UNIX-based filesystem of SKALE chains. Filestorage smart contract is a set of functions to interact with files on EVM. This contract may be predeployed on SKALE chains. It contains functions to work with Filestorage precompiled smart contracts. \n\nSmart contract language - Solidity 0.5.3\n\n## API Reference\n\n### File interaction methods\n\nTo begin the uploading process, the file should be broken into chunks of 1MB (&lt; 1MB for the last chunk) which are uploaded as separate transactions to FileStorage.sol. \nThe pipeline of the uploading file is:\n\n1.  creating empty file of fixed size on EVM by calling `startUpload`,\n2.  uploading data chunk by chunk with `uploadChunk`,\n3.  checking the file validity and finishing process with `finishUpload`.\n\n#### startUpload\n\n```solidity\nfunction startUpload(string memory filePath, uint256 fileSize)\n```\n\nCreates empty file on EVM with specific name and size. Owner of the file - message sender. \n\n-   Function is called by file owner\n-   Maximum amount of directories and files in one directory is **8196**\n-   Maximum filesize is **100,000,000** bytes\n-   Owner should have enough free space\n\n**Parameters:**\n\n| Parameter          | Description                           |\n| ------------------ | ------------------------------------- |\n| `string` filePath  | Path to the file in account directory |\n| `uint256` fileSize | Uploaded file size in bytes           |\n\n#### uploadChunk\n\n```solidity\nfunction uploadChunk(string memory filePath, uint position, bytes memory data)\n```\n\nUploads 1MB chunk of data from specific position in specific file by file owner.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n| `uint` position   | Uploaded chunk position               |\n| `bytes` data      | Uploaded chunk data                   |\n\n#### finishUpload\n\n```solidity\nfunction finishUpload(string memory filePath)\n```\n\nFinishes uploading of the file. Checks whether all chunks are uploaded correctly.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### deleteFile\n\n```solidity\nfunction deleteFile(string memory filePath)\n```\n\nDeletes file from Filestorage.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### readChunk\n\n```solidity\nfunction readChunk(string memory storagePath, uint position, uint length)\n        public\n        view\n        returns (bytes32[MAX_BLOCK_COUNT] memory out)\n```\n\nReads chunk from file from specific position with specific length. Returns `bytes32` array of fixed size with requested data.\n\n-   Maximum length of the chunk to read is 1Mb\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n| `uint` position      | First byte to read from              |\n| `uint` length        | Uploaded chunk length                |\n\n**Returns:**\n\n| Parameter       | Description                                       |\n| --------------- | ------------------------------------------------- |\n| `bytes32[]` out | Requested chunk data split across `bytes32` array |\n\n#### getFileSize\n\n```solidity\nfunction getFileSize(string memory storagePath) \n        public \n        view \n        returns (uint fileSize)\n```\n\nGets size of the requested file in bytes.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description            |\n| --------------- | ---------------------- |\n| `uint` fileSize | Size of requested file |\n\n#### getFileStatus\n\n```solidity\nfunction getFileStatus(string memory storagePath) \n        public \n        view \n        returns (int)\n```\n\nReturns status of the requested file:\n\n-   0 - file does not exist\n-   1 - file is created but has not finished uploading\n-   2 - file is fully uploaded\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter         | Description              |\n| ----------------- | ------------------------ |\n| `uint` fileStatus | Status of requested file |\n\n### Directory interaction methods\n\nFilestorage is represented with UNIX-based filesystem that consisted of files and directories. Directories are stored in `Directory` structure that contains information about its content in `ContentInfo` structure. Maximum amount of content in separate directory is **8196**.\n\n#### createDirectory\n\n```solidity\nfunction createDirectory(string memory directoryPath)\n```\n\nCreates directory in Filestorage. Owner of the directory - message sender. \n\n-   Function is called by directory owner\n-   Maximum amount of directories and files in one directory is **8196**\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### deleteDirectory\n\n```solidity\nfunction deleteDirectory(string memory directoryPath)\n```\n\nDeletes directory from Filestorage.\n\n-   Function is called by directory owner\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### listDirectory\n\n```solidity\nfunction listDirectory(string memory storagePath) \n        public \n        view \n        returns (ContentInfo[])\n```\n\nList information about content of the specific directory.\n\n**Parameters:**\n\n| Parameter            | Description                               |\n| -------------------- | ----------------------------------------- |\n| `string` storagePath | Full path of the directory in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description                          |\n| --------------- | ------------------------------------ |\n| `ContentInfo[]` | Array of content stored in directory |\n\nObject `ContentInfo` can be file or directory and contains:\n\n| Field                    | Description                                                                      |\n| ------------------------ | -------------------------------------------------------------------------------- |\n| `string` name            | Content name                                                                     |\n| `bool` isFile            | Whether content is file                                                          |\n| `uint` size              | File size, in bytes                                                              |\n| `int` status             | File uploading status                                                            |\n| `bool[]` isChunkUploaded | Array with statuses of each chunk (`true` - chunk uploaded, `false` - otherwise) |\n\n## Build\n\nCreate an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nPRIVATEKEY='Private key for test account'\n```\n\nCompile `FileStorage.sol`:\n\n```bash\ntruffle compile\n```\n\n## Test\n\nTests run only on SKALE chains. Create an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nSCHAIN_OWNER_PK='Private key of SKALE endpoint owner (or account with money)'\nPRIVATEKEY='Private key for test account'\n```\n\nRun tests:\n\n```bash\ntruffle test --network skaled\n```\n","gitHead":"32c2c19a8140b0a9a9e47e3cfe2a7b01eb3fee47","scripts":{"lint":"npx ethlint -d contracts","test":"npx truffle test test/unit/* --network skaled","build":"rm -r ./build; npx truffle build","compile":"npx truffle compile; cp build/contracts/FileStorage.json predeployed/filestorage_predeployed/artifacts/","slither":"slither . --filter-path strings --filter-path Migrations","version":"node -e \"console.log(require('./package.json').version);\"","coverage":"npx truffle run coverage --file=\"test/unit/*\"","lint-fix":"npm run lint -- --fix","predeployed-test":"npx truffle test test/predeployed/* --network skaled"},"_npmUser":{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},"repository":{"url":"git+https://github.com/skalenetwork/filestorage.git","type":"git"},"_npmVersion":"6.14.15","description":"SKALE Filestorage contracts","directories":{},"_nodeVersion":"14.18.1","dependencies":{"@openzeppelin/contracts-upgradeable":"^4.3.2"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"chai":"^4.2.0","web3":"^1.2.1","dotenv":"^8.2.0","codecov":"^3.3.0","truffle":"5.1.30","randomstring":"^1.1.5","chai-as-promised":"^7.1.1","solidity-coverage":"^0.7.17","@truffle/hdwallet-provider":"^1.5.1"},"_npmOperationalInternal":{"tmp":"tmp/filestorage_1.0.1-develop.6_1636563894545_0.23843764223401043","host":"s3://npm-registry-packages"}},"1.0.1-develop.7":{"name":"@skalenetwork/filestorage","version":"1.0.1-develop.7","keywords":["SKALE","blockchain","ethereum"],"author":{"name":"SKALE Labs and contributors"},"license":"AGPL-3.0","_id":"@skalenetwork/filestorage@1.0.1-develop.7","maintainers":[{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},{"name":"dmitrytk","email":"dmitry.tkachuk@skalelabs.com"},{"name":"cstrange","email":"chadwick@skalelabs.com"},{"name":"skalelabsdev","email":"dev@skalelabs.com"},{"name":"theskyunicorn","email":"christine@skalelabs.com"},{"name":"stebaev","email":"dimastebaev@gmail.com"},{"name":"l_sergiy","email":"sergiy@skalelabs.com"}],"homepage":"https://github.com/skalenetwork/filestorage#readme","bugs":{"url":"https://github.com/skalenetwork/filestorage/issues"},"dist":{"shasum":"0bdb4f3cae51c7206edca5b140c004b8c8aa882b","tarball":"https://registry.npmjs.org/@skalenetwork/filestorage/-/filestorage-1.0.1-develop.7.tgz","fileCount":5,"integrity":"sha512-xVS7s6LLoxRpt1SqMsth2KNNc6ygOrvNsfLT3JIB8UHQLMFJkUWOsHQH6q8ZNsUv1oCSI2NtexN6yTfjTXc+bg==","signatures":[{"sig":"MEYCIQCDiWsSclk5LnzhOnPYbEQwP1CW7Z+2UCwV7SlRx3vY2QIhAPORUNIg3RRbTG81OuyoRXDx/m7nVXYR1YwlxnXDR5U4","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":62931},"main":"artifacts.json","readme":"# SKALE Filestorage\n\n[![Build Status](https://travis-ci.com/skalenetwork/filestorage.svg?token=HYnwEPctUzUdXVcsecA6&branch=develop)](https://travis-ci.com/skalenetwork/filestorage)\n[![codecov](https://codecov.io/gh/skalenetwork/filestorage/branch/develop/graph/badge.svg?token=2wkF3kZTXh)](https://codecov.io/gh/skalenetwork/filestorage)\n[![Discord](https://img.shields.io/discord/534485763354787851.svg)](https://discord.gg/vvUtWJB)\n\nFilestorage - smart contract, that controls decentralized file storage on SKALE chains.\n\n## Description\n\nFilestorage is a cost-effective storage layer within Ethereum capable of handling files up to 100MB. Filestorage uses UNIX-based filesystem of SKALE chains. Filestorage smart contract is a set of functions to interact with files on EVM. This contract may be predeployed on SKALE chains. It contains functions to work with Filestorage precompiled smart contracts. \n\nSmart contract language - Solidity 0.5.3\n\n## API Reference\n\n### File interaction methods\n\nTo begin the uploading process, the file should be broken into chunks of 1MB (&lt; 1MB for the last chunk) which are uploaded as separate transactions to FileStorage.sol. \nThe pipeline of the uploading file is:\n\n1.  creating empty file of fixed size on EVM by calling `startUpload`,\n2.  uploading data chunk by chunk with `uploadChunk`,\n3.  checking the file validity and finishing process with `finishUpload`.\n\n#### startUpload\n\n```solidity\nfunction startUpload(string memory filePath, uint256 fileSize)\n```\n\nCreates empty file on EVM with specific name and size. Owner of the file - message sender. \n\n-   Function is called by file owner\n-   Maximum amount of directories and files in one directory is **8196**\n-   Maximum filesize is **100,000,000** bytes\n-   Owner should have enough free space\n\n**Parameters:**\n\n| Parameter          | Description                           |\n| ------------------ | ------------------------------------- |\n| `string` filePath  | Path to the file in account directory |\n| `uint256` fileSize | Uploaded file size in bytes           |\n\n#### uploadChunk\n\n```solidity\nfunction uploadChunk(string memory filePath, uint position, bytes memory data)\n```\n\nUploads 1MB chunk of data from specific position in specific file by file owner.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n| `uint` position   | Uploaded chunk position               |\n| `bytes` data      | Uploaded chunk data                   |\n\n#### finishUpload\n\n```solidity\nfunction finishUpload(string memory filePath)\n```\n\nFinishes uploading of the file. Checks whether all chunks are uploaded correctly.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### deleteFile\n\n```solidity\nfunction deleteFile(string memory filePath)\n```\n\nDeletes file from Filestorage.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### readChunk\n\n```solidity\nfunction readChunk(string memory storagePath, uint position, uint length)\n        public\n        view\n        returns (bytes32[MAX_BLOCK_COUNT] memory out)\n```\n\nReads chunk from file from specific position with specific length. Returns `bytes32` array of fixed size with requested data.\n\n-   Maximum length of the chunk to read is 1Mb\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n| `uint` position      | First byte to read from              |\n| `uint` length        | Uploaded chunk length                |\n\n**Returns:**\n\n| Parameter       | Description                                       |\n| --------------- | ------------------------------------------------- |\n| `bytes32[]` out | Requested chunk data split across `bytes32` array |\n\n#### getFileSize\n\n```solidity\nfunction getFileSize(string memory storagePath) \n        public \n        view \n        returns (uint fileSize)\n```\n\nGets size of the requested file in bytes.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description            |\n| --------------- | ---------------------- |\n| `uint` fileSize | Size of requested file |\n\n#### getFileStatus\n\n```solidity\nfunction getFileStatus(string memory storagePath) \n        public \n        view \n        returns (int)\n```\n\nReturns status of the requested file:\n\n-   0 - file does not exist\n-   1 - file is created but has not finished uploading\n-   2 - file is fully uploaded\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter         | Description              |\n| ----------------- | ------------------------ |\n| `uint` fileStatus | Status of requested file |\n\n### Directory interaction methods\n\nFilestorage is represented with UNIX-based filesystem that consisted of files and directories. Directories are stored in `Directory` structure that contains information about its content in `ContentInfo` structure. Maximum amount of content in separate directory is **8196**.\n\n#### createDirectory\n\n```solidity\nfunction createDirectory(string memory directoryPath)\n```\n\nCreates directory in Filestorage. Owner of the directory - message sender. \n\n-   Function is called by directory owner\n-   Maximum amount of directories and files in one directory is **8196**\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### deleteDirectory\n\n```solidity\nfunction deleteDirectory(string memory directoryPath)\n```\n\nDeletes directory from Filestorage.\n\n-   Function is called by directory owner\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### listDirectory\n\n```solidity\nfunction listDirectory(string memory storagePath) \n        public \n        view \n        returns (ContentInfo[])\n```\n\nList information about content of the specific directory.\n\n**Parameters:**\n\n| Parameter            | Description                               |\n| -------------------- | ----------------------------------------- |\n| `string` storagePath | Full path of the directory in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description                          |\n| --------------- | ------------------------------------ |\n| `ContentInfo[]` | Array of content stored in directory |\n\nObject `ContentInfo` can be file or directory and contains:\n\n| Field                    | Description                                                                      |\n| ------------------------ | -------------------------------------------------------------------------------- |\n| `string` name            | Content name                                                                     |\n| `bool` isFile            | Whether content is file                                                          |\n| `uint` size              | File size, in bytes                                                              |\n| `int` status             | File uploading status                                                            |\n| `bool[]` isChunkUploaded | Array with statuses of each chunk (`true` - chunk uploaded, `false` - otherwise) |\n\n## Build\n\nCreate an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nPRIVATEKEY='Private key for test account'\n```\n\nCompile `FileStorage.sol`:\n\n```bash\ntruffle compile\n```\n\n## Test\n\nTests run only on SKALE chains. Create an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nSCHAIN_OWNER_PK='Private key of SKALE endpoint owner (or account with money)'\nPRIVATEKEY='Private key for test account'\n```\n\nRun tests:\n\n```bash\ntruffle test --network skaled\n```\n","gitHead":"4027ed01871720681361c38b84ee814a78ae0682","scripts":{"lint":"npx ethlint -d contracts","test":"npx truffle test test/unit/* --network skaled","build":"rm -r ./build; npx truffle build","compile":"npx truffle compile; cp build/contracts/FileStorage.json predeployed/filestorage_predeployed/artifacts/","slither":"slither . --filter-path strings --filter-path Migrations","version":"node -e \"console.log(require('./package.json').version);\"","coverage":"npx truffle run coverage --file=\"test/unit/*\"","lint-fix":"npm run lint -- --fix","predeployed-test":"npx truffle test test/predeployed/* --network skaled"},"_npmUser":{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},"repository":{"url":"git+https://github.com/skalenetwork/filestorage.git","type":"git"},"_npmVersion":"6.14.15","description":"SKALE Filestorage contracts","directories":{},"_nodeVersion":"14.18.1","dependencies":{"@openzeppelin/contracts-upgradeable":"^4.3.2"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"chai":"^4.2.0","web3":"^1.2.1","dotenv":"^8.2.0","codecov":"^3.3.0","truffle":"5.1.30","randomstring":"^1.1.5","chai-as-promised":"^7.1.1","solidity-coverage":"^0.7.17","@truffle/hdwallet-provider":"^1.5.1"},"_npmOperationalInternal":{"tmp":"tmp/filestorage_1.0.1-develop.7_1636564826460_0.07281304680704692","host":"s3://npm-registry-packages"}},"1.0.1-develop.8":{"name":"@skalenetwork/filestorage","version":"1.0.1-develop.8","keywords":["SKALE","blockchain","ethereum"],"author":{"name":"SKALE Labs and contributors"},"license":"AGPL-3.0","_id":"@skalenetwork/filestorage@1.0.1-develop.8","maintainers":[{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},{"name":"dmitrytk","email":"dmitry.tkachuk@skalelabs.com"},{"name":"cstrange","email":"chadwick@skalelabs.com"},{"name":"skalelabsdev","email":"dev@skalelabs.com"},{"name":"theskyunicorn","email":"christine@skalelabs.com"},{"name":"stebaev","email":"dimastebaev@gmail.com"},{"name":"l_sergiy","email":"sergiy@skalelabs.com"}],"homepage":"https://github.com/skalenetwork/filestorage#readme","bugs":{"url":"https://github.com/skalenetwork/filestorage/issues"},"dist":{"shasum":"89c7923727f255a222a0e8130aee4b5517a8bfff","tarball":"https://registry.npmjs.org/@skalenetwork/filestorage/-/filestorage-1.0.1-develop.8.tgz","fileCount":5,"integrity":"sha512-/eHxCJd5pIvyZzulsvcsGK/WXCu9qJbb+nbO8zYnCKDs3TqzAmifHUWRcwfBeI3wZTmfqtJTVPJbWt4HZmTa/Q==","signatures":[{"sig":"MEQCIAQ6drcxRf1QH2FD31GM+lciczR2PXS9AInYXybYpo6OAiApHyMkEyM815KXPtbEkgwHmyirjIqwc2jJrI0EGguO4A==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":66031,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhqkAtCRA9TVsSAnZWagAAeusQAJ1dCJkf7JoP9ZVKzpN8\nGELaBnuhgNXuIPsQ+J9umG0kbosfmlOj9O+QVojXGeVvCeKQ+74rw+rjiubb\nMKYwx4uh6bAB1HebTJf7dgBsqd5v0zhCUY5u+672i6TNAn0nApPZzpvDecKB\n+YRdB9Ic9EHrjnEwXRmMnd69jYYHtLsbIxfoa9sZaZYgwzh9dnEzP4yIzYwp\na4Xj778aviKsO4zowVSDore6ALO4oV/ZxVn/CqtyEIJwFbW5enUI/TBX3HEI\nl/ugN7yTwOOJ8HeBB88YfIrh1qxZP/v6FhehqV6c2EkLKJgX0cD51AivRW+4\nfFzxlE08NrKrb9JUZY45P1bK/LLtl9kxA7WLSdF87igYtOayUt+EwIIhD40r\nZJlefnoTdRUzyZR75RV1jq00UovSMzDkz2wnS4IatQTzhZrPUb9Vo5mRHuat\nlz94nhCe3I/VO9nLMhscBvS3KMV82/dBFkW65fAOR7Cy5sgDhjAwK8kUyhNx\ne+86zm3kPmg012slxknkznXuRk8lIGkwUo5TvlpBDkbG/thq+vdlL6tLJ/i2\nc2HB5br91cb2GIByFOT0xCXwa13HFbCXcaEAEKr8lZTvv+zybky/bpirC51g\nqBOBHfrsmADtY59x7kpZoQdXWJm31FJuIAXPoWEcDP7AfU2uJkM4mp5/Lmxn\nyT4A\r\n=sVRB\r\n-----END PGP SIGNATURE-----\r\n"},"main":"artifacts.json","readme":"# SKALE Filestorage\n\n[![Build Status](https://travis-ci.com/skalenetwork/filestorage.svg?token=HYnwEPctUzUdXVcsecA6&branch=develop)](https://travis-ci.com/skalenetwork/filestorage)\n[![codecov](https://codecov.io/gh/skalenetwork/filestorage/branch/develop/graph/badge.svg?token=2wkF3kZTXh)](https://codecov.io/gh/skalenetwork/filestorage)\n[![Discord](https://img.shields.io/discord/534485763354787851.svg)](https://discord.gg/vvUtWJB)\n\nFilestorage - smart contract, that controls decentralized file storage on SKALE chains.\n\n## Description\n\nFilestorage is a cost-effective storage layer within Ethereum capable of handling files up to 100MB. Filestorage uses UNIX-based filesystem of SKALE chains. Filestorage smart contract is a set of functions to interact with files on EVM. This contract may be predeployed on SKALE chains. It contains functions to work with Filestorage precompiled smart contracts. \n\nSmart contract language - Solidity 0.8.9\n\n## API Reference\n\n### Filestorage space handling \n\nTo start using Filestorage (upload/delete files and create/remove directories) the space should be allocated for specific account, it could be done from account that is given ALLOCATOR_ROLE. \nRules of occupying space in Filestorage:\n\n1. For directory **4096** bytes is taken\n2. File could be uploaded up to **100** MB (104857600 bytes)\n3. Occupying space for file is rounded up to the nearest multiple of **4096** bytes\n4. **Empty** file takes 4096 bytes of free space\n\nAfter deleting file/directory's amount of space is freed according to the rules above\n\n### Space handling API\n#### reserveSpace\n\n```solidity\nfunction reserveSpace(address userAddress, uint reservedSpace)\n```\n\nReserves the Filestorage space for specific address. Could be called only with ALLOCATOR_ROLE\n\n**Parameters:**\n\n| Parameter             | Description                           |\n| --------------------- | ------------------------------------- |\n| `address` userAddress | Address to allocate space for         |\n| `uint` reservedSpace  | Amount of space to reserve in bytes   |\n\n#### getTotalStorageSpace\n\n```solidity\nfunction getTotalStorageSpace()\n```\n\nGets total space in Filestorage in bytes.\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Space in bytes                     |\n\n#### getTotalReservedSpace\n\n```solidity\nfunction getTotalStorageSpace()\n```\n\nGets total reserved space in Filestorage in bytes.\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Space in bytes                     |\n\n#### getReservedSpace\n\n```solidity\nfunction getReservedSpace(address owner)\n```\n\nGets reserved space for account.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `address` owner      | Account address                      |\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Size of reserved space for account |\n\n#### getOccupiedSpace\n\n```solidity\nfunction getOccupiedSpace(address owner)\n```\n\nGets occupied space for account.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `address` owner      | Account address                      |\n\n**Returns:**\n\n| Parameter       | Description                                 |\n| --------------- | ------------------------------------------- |\n| `uint`          | Size of occupied space for account in bytes |\n\n### File interaction methods\n\nTo begin the uploading process, the file should be broken into chunks of 1MB (&lt; 1MB for the last chunk) which are uploaded as separate transactions to FileStorage.sol. \nThe pipeline of the uploading file is:\n\n1.  creating empty file of fixed size on EVM by calling `startUpload`,\n2.  uploading data chunk by chunk with `uploadChunk`,\n3.  checking the file validity and finishing process with `finishUpload`.\n\n#### startUpload\n\n```solidity\nfunction startUpload(string memory filePath, uint256 fileSize)\n```\n\nCreates empty file on EVM with specific name and size. Owner of the file - message sender. \n\n-   Function is called by file owner\n-   Maximum amount of directories and files in one directory is **8196**\n-   Maximum filesize is **100,000,000** bytes\n-   Owner should have enough free space\n\n**Parameters:**\n\n| Parameter          | Description                           |\n| ------------------ | ------------------------------------- |\n| `string` filePath  | Path to the file in account directory |\n| `uint256` fileSize | Uploaded file size in bytes           |\n\n#### uploadChunk\n\n```solidity\nfunction uploadChunk(string memory filePath, uint position, bytes memory data)\n```\n\nUploads 1MB chunk of data from specific position in specific file by file owner.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n| `uint` position   | Uploaded chunk position               |\n| `bytes` data      | Uploaded chunk data                   |\n\n#### finishUpload\n\n```solidity\nfunction finishUpload(string memory filePath)\n```\n\nFinishes uploading of the file. Checks whether all chunks are uploaded correctly.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### deleteFile\n\n```solidity\nfunction deleteFile(string memory filePath)\n```\n\nDeletes file from Filestorage.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### readChunk\n\n```solidity\nfunction readChunk(string memory storagePath, uint position, uint length)\n        public\n        view\n        returns (bytes32[MAX_BLOCK_COUNT] memory out)\n```\n\nReads chunk from file from specific position with specific length. Returns `bytes32` array of fixed size with requested data.\n\n-   Maximum length of the chunk to read is 1Mb\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n| `uint` position      | First byte to read from              |\n| `uint` length        | Uploaded chunk length                |\n\n**Returns:**\n\n| Parameter       | Description                                       |\n| --------------- | ------------------------------------------------- |\n| `bytes32[]` out | Requested chunk data split across `bytes32` array |\n\n#### getFileSize\n\n```solidity\nfunction getFileSize(string memory storagePath) \n        public \n        view \n        returns (uint fileSize)\n```\n\nGets size of the requested file in bytes.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description            |\n| --------------- | ---------------------- |\n| `uint` fileSize | Size of requested file |\n\n#### getFileStatus\n\n```solidity\nfunction getFileStatus(string memory storagePath) \n        public \n        view \n        returns (int)\n```\n\nReturns status of the requested file:\n\n-   0 - file does not exist\n-   1 - file is created but has not finished uploading\n-   2 - file is fully uploaded\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter         | Description              |\n| ----------------- | ------------------------ |\n| `uint` fileStatus | Status of requested file |\n\n### Directory interaction methods\n\nFilestorage is represented with UNIX-based filesystem that consisted of files and directories. Directories are stored in `Directory` structure that contains information about its content in `ContentInfo` structure. Maximum amount of content in separate directory is **8196**.\n\n#### createDirectory\n\n```solidity\nfunction createDirectory(string memory directoryPath)\n```\n\nCreates directory in Filestorage. Owner of the directory - message sender. \n\n-   Function is called by directory owner\n-   Maximum amount of directories and files in one directory is **8196**\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### deleteDirectory\n\n```solidity\nfunction deleteDirectory(string memory directoryPath)\n```\n\nDeletes directory from Filestorage.\n\n-   Function is called by directory owner\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### listDirectory\n\n```solidity\nfunction listDirectory(string memory storagePath) \n        public \n        view \n        returns (ContentInfo[])\n```\n\nList information about content of the specific directory.\n\n**Parameters:**\n\n| Parameter            | Description                               |\n| -------------------- | ----------------------------------------- |\n| `string` storagePath | Full path of the directory in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description                          |\n| --------------- | ------------------------------------ |\n| `ContentInfo[]` | Array of content stored in directory |\n\nObject `ContentInfo` can be file or directory and contains:\n\n| Field                    | Description                                                                      |\n| ------------------------ | -------------------------------------------------------------------------------- |\n| `string` name            | Content name                                                                     |\n| `bool` isFile            | Whether content is file                                                          |\n| `uint` size              | File size, in bytes                                                              |\n| `int` status             | File uploading status                                                            |\n| `bool[]` isChunkUploaded | Array with statuses of each chunk (`true` - chunk uploaded, `false` - otherwise) |\n\n## Build\n\nCreate an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nPRIVATEKEY='Private key for test account'\n```\n\nCompile `FileStorage.sol`:\n\n```bash\ntruffle compile\n```\n\n## Test\n\nTests run only on SKALE chains. Create an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nSCHAIN_OWNER_PK='Private key of SKALE endpoint owner (or account with money)'\nPRIVATEKEY='Private key for test account'\n```\n\nRun tests:\n\n```bash\ntruffle test --network skaled\n```\n","gitHead":"a7fe56021ee283e968031c9275eccf5345902b56","scripts":{"lint":"npx ethlint -d contracts","test":"npx truffle test test/unit/* --network skaled","build":"rm -r ./build; npx truffle build","compile":"npx truffle compile; cp build/contracts/FileStorage.json predeployed/filestorage_predeployed/artifacts/","slither":"slither . --filter-path strings --filter-path Migrations","version":"node -e \"console.log(require('./package.json').version);\"","coverage":"npx truffle run coverage --file=\"test/unit/*\"","lint-fix":"npm run lint -- --fix","predeployed-test":"npx truffle test test/predeployed/* --network skaled"},"_npmUser":{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},"repository":{"url":"git+https://github.com/skalenetwork/filestorage.git","type":"git"},"_npmVersion":"6.14.15","description":"SKALE Filestorage contracts","directories":{},"_nodeVersion":"14.18.1","dependencies":{"@openzeppelin/contracts-upgradeable":"^4.3.2"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"chai":"^4.2.0","web3":"^1.2.1","dotenv":"^8.2.0","codecov":"^3.3.0","truffle":"5.1.30","randomstring":"^1.1.5","chai-as-promised":"^7.1.1","solidity-coverage":"^0.7.17","@truffle/hdwallet-provider":"^1.5.1"},"_npmOperationalInternal":{"tmp":"tmp/filestorage_1.0.1-develop.8_1638547501587_0.9476947154604414","host":"s3://npm-registry-packages"}},"1.0.1-develop.9":{"name":"@skalenetwork/filestorage","version":"1.0.1-develop.9","keywords":["SKALE","blockchain","ethereum"],"author":{"name":"SKALE Labs and contributors"},"license":"AGPL-3.0","_id":"@skalenetwork/filestorage@1.0.1-develop.9","maintainers":[{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},{"name":"dmitrytk","email":"dmitry.tkachuk@skalelabs.com"},{"name":"cstrange","email":"chadwick@skalelabs.com"},{"name":"skalelabsdev","email":"dev@skalelabs.com"},{"name":"theskyunicorn","email":"christine@skalelabs.com"},{"name":"stebaev","email":"dimastebaev@gmail.com"},{"name":"l_sergiy","email":"sergiy@skalelabs.com"}],"homepage":"https://github.com/skalenetwork/filestorage#readme","bugs":{"url":"https://github.com/skalenetwork/filestorage/issues"},"dist":{"shasum":"1268804082e24a31b7a06b5d9d9fe1632cda8957","tarball":"https://registry.npmjs.org/@skalenetwork/filestorage/-/filestorage-1.0.1-develop.9.tgz","fileCount":5,"integrity":"sha512-XTROyrHt2QklrKhVovDuAldzbvbDJuw9SaCuBFYlfOLOcqIPFLJKRH4mYDqbsf26BJdlwmLceFJWG+p2nHNjSA==","signatures":[{"sig":"MEUCIFkB0vNzHw8D0c6WVHhVXj6msMiXXQ7fRXbf9E2FkYNPAiEAmEoEn5esG1SmuaNd8n/OBD2TXJjqdazHpYSszRt/uZQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":66031,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhxHjICRA9TVsSAnZWagAAP+IQAIeNPXlNU/gjmrNhzK/s\nw8e7qamzWoM/mwZAcvnM0kcoURY9GCy2tWGT/Z9BGquDVhakxEW//i9ZkgJl\nLDoeEFie8bNiAT9cT+oKIeaYM/OH65HVO2ZDMJgoi2w+McVZJHBaT41PSId5\n63Y6PStRnRpZdmcfV0lvsQmhfd7GjhjhhvMwowabyi51aB04RwXlLvP7mTbs\nTnvZPufNDXxoQ/zB/2yVzXjlDtG+wGzKrQfJlHVX5UVciyYlMp8zL7M3KoS7\ngf1Pu0DULojWaS257jD/cBmlrKCDSmW6ky2wX++NXFs+F1HkzyL4TapFyCtY\n1vLzZHOE8qWzgcbvc6gHiC9lXS4hLkncCNhhbsD97Su2tHooD/asMTXmWkEP\n9jP+Wgk1cyiKLZUg16++b/kMy4uOUI2HVYzm/UPy/J6ViBL/HpEBf4avifdH\n+x8gA3xUFqZO04C5Q0CW8UCx7XyNqwVUoEYGjzHrIa4AL9ip5rcY71pkrvvP\nrMUZINVPgPQF1xi0PWLxZAGudtEuFZa9uW7vv9PyEs9tJntzfv1x2KT7Rwe2\n+rFySuc7WZYSZE89YiH/HAm9H0C09e5N266u/bI23eIyOHOO1C4cGjDG6X8m\nINJb0EQU6AHQfeBQ8gZZIyDvqt0Tw7MPo1EB3/1YK2D6JXU53plJsXTVYC56\nEA5m\r\n=QR2B\r\n-----END PGP SIGNATURE-----\r\n"},"main":"artifacts.json","readme":"# SKALE Filestorage\n\n[![Build Status](https://travis-ci.com/skalenetwork/filestorage.svg?token=HYnwEPctUzUdXVcsecA6&branch=develop)](https://travis-ci.com/skalenetwork/filestorage)\n[![codecov](https://codecov.io/gh/skalenetwork/filestorage/branch/develop/graph/badge.svg?token=2wkF3kZTXh)](https://codecov.io/gh/skalenetwork/filestorage)\n[![Discord](https://img.shields.io/discord/534485763354787851.svg)](https://discord.gg/vvUtWJB)\n\nFilestorage - smart contract, that controls decentralized file storage on SKALE chains.\n\n## Description\n\nFilestorage is a cost-effective storage layer within Ethereum capable of handling files up to 100MB. Filestorage uses UNIX-based filesystem of SKALE chains. Filestorage smart contract is a set of functions to interact with files on EVM. This contract may be predeployed on SKALE chains. It contains functions to work with Filestorage precompiled smart contracts. \n\nSmart contract language - Solidity 0.8.9\n\n## API Reference\n\n### Filestorage space handling \n\nTo start using Filestorage (upload/delete files and create/remove directories) the space should be allocated for specific account, it could be done from account that is given ALLOCATOR_ROLE. \nRules of occupying space in Filestorage:\n\n1. For directory **4096** bytes is taken\n2. File could be uploaded up to **100** MB (104857600 bytes)\n3. Occupying space for file is rounded up to the nearest multiple of **4096** bytes\n4. **Empty** file takes 4096 bytes of free space\n\nAfter deleting file/directory's amount of space is freed according to the rules above\n\n### Space handling API\n#### reserveSpace\n\n```solidity\nfunction reserveSpace(address userAddress, uint reservedSpace)\n```\n\nReserves the Filestorage space for specific address. Could be called only with ALLOCATOR_ROLE\n\n**Parameters:**\n\n| Parameter             | Description                           |\n| --------------------- | ------------------------------------- |\n| `address` userAddress | Address to allocate space for         |\n| `uint` reservedSpace  | Amount of space to reserve in bytes   |\n\n#### getTotalStorageSpace\n\n```solidity\nfunction getTotalStorageSpace()\n```\n\nGets total space in Filestorage in bytes.\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Space in bytes                     |\n\n#### getTotalReservedSpace\n\n```solidity\nfunction getTotalStorageSpace()\n```\n\nGets total reserved space in Filestorage in bytes.\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Space in bytes                     |\n\n#### getReservedSpace\n\n```solidity\nfunction getReservedSpace(address owner)\n```\n\nGets reserved space for account.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `address` owner      | Account address                      |\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Size of reserved space for account |\n\n#### getOccupiedSpace\n\n```solidity\nfunction getOccupiedSpace(address owner)\n```\n\nGets occupied space for account.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `address` owner      | Account address                      |\n\n**Returns:**\n\n| Parameter       | Description                                 |\n| --------------- | ------------------------------------------- |\n| `uint`          | Size of occupied space for account in bytes |\n\n### File interaction methods\n\nTo begin the uploading process, the file should be broken into chunks of 1MB (&lt; 1MB for the last chunk) which are uploaded as separate transactions to FileStorage.sol. \nThe pipeline of the uploading file is:\n\n1.  creating empty file of fixed size on EVM by calling `startUpload`,\n2.  uploading data chunk by chunk with `uploadChunk`,\n3.  checking the file validity and finishing process with `finishUpload`.\n\n#### startUpload\n\n```solidity\nfunction startUpload(string memory filePath, uint256 fileSize)\n```\n\nCreates empty file on EVM with specific name and size. Owner of the file - message sender. \n\n-   Function is called by file owner\n-   Maximum amount of directories and files in one directory is **8196**\n-   Maximum filesize is **100,000,000** bytes\n-   Owner should have enough free space\n\n**Parameters:**\n\n| Parameter          | Description                           |\n| ------------------ | ------------------------------------- |\n| `string` filePath  | Path to the file in account directory |\n| `uint256` fileSize | Uploaded file size in bytes           |\n\n#### uploadChunk\n\n```solidity\nfunction uploadChunk(string memory filePath, uint position, bytes memory data)\n```\n\nUploads 1MB chunk of data from specific position in specific file by file owner.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n| `uint` position   | Uploaded chunk position               |\n| `bytes` data      | Uploaded chunk data                   |\n\n#### finishUpload\n\n```solidity\nfunction finishUpload(string memory filePath)\n```\n\nFinishes uploading of the file. Checks whether all chunks are uploaded correctly.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### deleteFile\n\n```solidity\nfunction deleteFile(string memory filePath)\n```\n\nDeletes file from Filestorage.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### readChunk\n\n```solidity\nfunction readChunk(string memory storagePath, uint position, uint length)\n        public\n        view\n        returns (bytes32[MAX_BLOCK_COUNT] memory out)\n```\n\nReads chunk from file from specific position with specific length. Returns `bytes32` array of fixed size with requested data.\n\n-   Maximum length of the chunk to read is 1Mb\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n| `uint` position      | First byte to read from              |\n| `uint` length        | Uploaded chunk length                |\n\n**Returns:**\n\n| Parameter       | Description                                       |\n| --------------- | ------------------------------------------------- |\n| `bytes32[]` out | Requested chunk data split across `bytes32` array |\n\n#### getFileSize\n\n```solidity\nfunction getFileSize(string memory storagePath) \n        public \n        view \n        returns (uint fileSize)\n```\n\nGets size of the requested file in bytes.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description            |\n| --------------- | ---------------------- |\n| `uint` fileSize | Size of requested file |\n\n#### getFileStatus\n\n```solidity\nfunction getFileStatus(string memory storagePath) \n        public \n        view \n        returns (int)\n```\n\nReturns status of the requested file:\n\n-   0 - file does not exist\n-   1 - file is created but has not finished uploading\n-   2 - file is fully uploaded\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter         | Description              |\n| ----------------- | ------------------------ |\n| `uint` fileStatus | Status of requested file |\n\n### Directory interaction methods\n\nFilestorage is represented with UNIX-based filesystem that consisted of files and directories. Directories are stored in `Directory` structure that contains information about its content in `ContentInfo` structure. Maximum amount of content in separate directory is **8196**.\n\n#### createDirectory\n\n```solidity\nfunction createDirectory(string memory directoryPath)\n```\n\nCreates directory in Filestorage. Owner of the directory - message sender. \n\n-   Function is called by directory owner\n-   Maximum amount of directories and files in one directory is **8196**\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### deleteDirectory\n\n```solidity\nfunction deleteDirectory(string memory directoryPath)\n```\n\nDeletes directory from Filestorage.\n\n-   Function is called by directory owner\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### listDirectory\n\n```solidity\nfunction listDirectory(string memory storagePath) \n        public \n        view \n        returns (ContentInfo[])\n```\n\nList information about content of the specific directory.\n\n**Parameters:**\n\n| Parameter            | Description                               |\n| -------------------- | ----------------------------------------- |\n| `string` storagePath | Full path of the directory in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description                          |\n| --------------- | ------------------------------------ |\n| `ContentInfo[]` | Array of content stored in directory |\n\nObject `ContentInfo` can be file or directory and contains:\n\n| Field                    | Description                                                                      |\n| ------------------------ | -------------------------------------------------------------------------------- |\n| `string` name            | Content name                                                                     |\n| `bool` isFile            | Whether content is file                                                          |\n| `uint` size              | File size, in bytes                                                              |\n| `int` status             | File uploading status                                                            |\n| `bool[]` isChunkUploaded | Array with statuses of each chunk (`true` - chunk uploaded, `false` - otherwise) |\n\n## Build\n\nCreate an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nPRIVATEKEY='Private key for test account'\n```\n\nCompile `FileStorage.sol`:\n\n```bash\ntruffle compile\n```\n\n## Test\n\nTests run only on SKALE chains. Create an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nSCHAIN_OWNER_PK='Private key of SKALE endpoint owner (or account with money)'\nPRIVATEKEY='Private key for test account'\n```\n\nRun tests:\n\n```bash\ntruffle test --network skaled\n```\n","gitHead":"5d1ecbfaf9368cb79875805495dc0ebe12506a6d","scripts":{"lint":"npx ethlint -d contracts","test":"npx truffle test test/unit/* --network skaled","build":"rm -r ./build; npx truffle build","compile":"npx truffle compile; cp build/contracts/FileStorage.json predeployed/filestorage_predeployed/artifacts/","slither":"slither . --filter-path strings --filter-path Migrations","version":"node -e \"console.log(require('./package.json').version);\"","coverage":"npx truffle run coverage --file=\"test/unit/*\"","lint-fix":"npm run lint -- --fix","predeployed-test":"npx truffle test test/predeployed/* --network skaled"},"_npmUser":{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},"repository":{"url":"git+https://github.com/skalenetwork/filestorage.git","type":"git"},"_npmVersion":"6.14.15","description":"SKALE Filestorage contracts","directories":{},"_nodeVersion":"14.18.2","dependencies":{"@openzeppelin/contracts-upgradeable":"^4.3.2"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"chai":"^4.2.0","web3":"^1.2.1","dotenv":"^8.2.0","codecov":"^3.3.0","truffle":"5.1.30","randomstring":"^1.1.5","chai-as-promised":"^7.1.1","solidity-coverage":"^0.7.17","@truffle/hdwallet-provider":"^1.5.1"},"_npmOperationalInternal":{"tmp":"tmp/filestorage_1.0.1-develop.9_1640265928683_0.8688455063522884","host":"s3://npm-registry-packages"}},"1.0.1-develop.10":{"name":"@skalenetwork/filestorage","version":"1.0.1-develop.10","keywords":["SKALE","blockchain","ethereum"],"author":{"name":"SKALE Labs and contributors"},"license":"AGPL-3.0","_id":"@skalenetwork/filestorage@1.0.1-develop.10","maintainers":[{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},{"name":"dmitrytk","email":"dmitry.tkachuk@skalelabs.com"},{"name":"cstrange","email":"chadwick@skalelabs.com"},{"name":"skalelabsdev","email":"dev@skalelabs.com"},{"name":"theskyunicorn","email":"christine@skalelabs.com"},{"name":"stebaev","email":"dimastebaev@gmail.com"},{"name":"l_sergiy","email":"sergiy@skalelabs.com"}],"homepage":"https://github.com/skalenetwork/filestorage#readme","bugs":{"url":"https://github.com/skalenetwork/filestorage/issues"},"dist":{"shasum":"f2c26dfee00f50b4c0492518f4e5c9a1605a90d9","tarball":"https://registry.npmjs.org/@skalenetwork/filestorage/-/filestorage-1.0.1-develop.10.tgz","fileCount":5,"integrity":"sha512-P1RC2lBaNrkpYX2bgUANgTFMAHVhRrEYBC9SXIjtUvb+G5R79TKKMl4ibettv/yNsj1LaVumXt7jSan26qH2pw==","signatures":[{"sig":"MEYCIQDZiNhxCPUx+Zeba3zZGgzGygcGZ4V6gJUxWkaLzhcOOQIhAPHNgkaOqGRcGg737/6XIygiohIjcgRoKJhEEX6hKkRi","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":66032,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh8/xMCRA9TVsSAnZWagAAVMkP/1pkNiYojRAIymiCpRUU\n9mgskd87k0DdSwDygvUmbvP4xoWv2FL+wmaT5QOP9CvvK9+rEqiXMMSHuWqX\nT8zgVupN7WPHvbRZXzMS3bN/mtyC9MNygkbW4Az1m1mj2jZAhOdw2i4OBI7s\n8NQwv83B/52Pixjjs8dkWYUEAcCHAaXaxfk3K7sXHlDeK+zQTLO7vOqCmDGe\nKaD8XAXnCB6xF1tEQcMw0/8COvaECSGO8N3i7Y746i1Hg6+wp8s5aaVjTZMV\nC3SUFPmw5ao94Emr6TgLf+qvFX2N4Wr/GSfDVTTzdo9We87FJmTG/v6m2Qtr\nLBMl5u0bSkKjS/C6IZvUUo2+jh+tohWfo0zQFGq19PnfF7eDIcriIBRf07rW\nAzNkA8mH1NsIVeUlNPq/vIMHB//50jQbZxMC6XUxa3g87jxq2qoZtbkT3pnF\nyTHJHxahcnlsm1oFjwEwR7yV0pvHui6mjP1v2hcQLif1kfjlaDXs1NUSco9Z\n6/dYjpwChCTSrprqxzWEAPcfucvAdq6nyyB6QFyLVLRXp4rE2XvtG4pQ6cl0\n7E9ATjup0fFEi2K78YFGz4Uoa1pIUcyrxeYUaiq/LUDmSh6k7RiYg4xo3eZe\nq+lyDDxqPYXn5oRS082a/go2g62oJTfuFeJwT8MLrvp0MmE3HvVMD9ge3H93\nxkiT\r\n=f0lo\r\n-----END PGP SIGNATURE-----\r\n"},"main":"artifacts.json","readme":"# SKALE Filestorage\n\n[![Build Status](https://travis-ci.com/skalenetwork/filestorage.svg?token=HYnwEPctUzUdXVcsecA6&branch=develop)](https://travis-ci.com/skalenetwork/filestorage)\n[![codecov](https://codecov.io/gh/skalenetwork/filestorage/branch/develop/graph/badge.svg?token=2wkF3kZTXh)](https://codecov.io/gh/skalenetwork/filestorage)\n[![Discord](https://img.shields.io/discord/534485763354787851.svg)](https://discord.gg/vvUtWJB)\n\nFilestorage - smart contract, that controls decentralized file storage on SKALE chains.\n\n## Description\n\nFilestorage is a cost-effective storage layer within Ethereum capable of handling files up to 100MB. Filestorage uses UNIX-based filesystem of SKALE chains. Filestorage smart contract is a set of functions to interact with files on EVM. This contract may be predeployed on SKALE chains. It contains functions to work with Filestorage precompiled smart contracts. \n\nSmart contract language - Solidity 0.8.9\n\n## API Reference\n\n### Filestorage space handling \n\nTo start using Filestorage (upload/delete files and create/remove directories) the space should be allocated for specific account, it could be done from account that is given ALLOCATOR_ROLE. \nRules of occupying space in Filestorage:\n\n1. For directory **4096** bytes is taken\n2. File could be uploaded up to **100** MB (104857600 bytes)\n3. Occupying space for file is rounded up to the nearest multiple of **4096** bytes\n4. **Empty** file takes 4096 bytes of free space\n\nAfter deleting file/directory's amount of space is freed according to the rules above\n\n### Space handling API\n#### reserveSpace\n\n```solidity\nfunction reserveSpace(address userAddress, uint reservedSpace)\n```\n\nReserves the Filestorage space for specific address. Could be called only with ALLOCATOR_ROLE\n\n**Parameters:**\n\n| Parameter             | Description                           |\n| --------------------- | ------------------------------------- |\n| `address` userAddress | Address to allocate space for         |\n| `uint` reservedSpace  | Amount of space to reserve in bytes   |\n\n#### getTotalStorageSpace\n\n```solidity\nfunction getTotalStorageSpace()\n```\n\nGets total space in Filestorage in bytes.\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Space in bytes                     |\n\n#### getTotalReservedSpace\n\n```solidity\nfunction getTotalStorageSpace()\n```\n\nGets total reserved space in Filestorage in bytes.\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Space in bytes                     |\n\n#### getReservedSpace\n\n```solidity\nfunction getReservedSpace(address owner)\n```\n\nGets reserved space for account.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `address` owner      | Account address                      |\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Size of reserved space for account |\n\n#### getOccupiedSpace\n\n```solidity\nfunction getOccupiedSpace(address owner)\n```\n\nGets occupied space for account.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `address` owner      | Account address                      |\n\n**Returns:**\n\n| Parameter       | Description                                 |\n| --------------- | ------------------------------------------- |\n| `uint`          | Size of occupied space for account in bytes |\n\n### File interaction methods\n\nTo begin the uploading process, the file should be broken into chunks of 1MB (&lt; 1MB for the last chunk) which are uploaded as separate transactions to FileStorage.sol. \nThe pipeline of the uploading file is:\n\n1.  creating empty file of fixed size on EVM by calling `startUpload`,\n2.  uploading data chunk by chunk with `uploadChunk`,\n3.  checking the file validity and finishing process with `finishUpload`.\n\n#### startUpload\n\n```solidity\nfunction startUpload(string memory filePath, uint256 fileSize)\n```\n\nCreates empty file on EVM with specific name and size. Owner of the file - message sender. \n\n-   Function is called by file owner\n-   Maximum amount of directories and files in one directory is **8196**\n-   Maximum filesize is **100,000,000** bytes\n-   Owner should have enough free space\n\n**Parameters:**\n\n| Parameter          | Description                           |\n| ------------------ | ------------------------------------- |\n| `string` filePath  | Path to the file in account directory |\n| `uint256` fileSize | Uploaded file size in bytes           |\n\n#### uploadChunk\n\n```solidity\nfunction uploadChunk(string memory filePath, uint position, bytes memory data)\n```\n\nUploads 1MB chunk of data from specific position in specific file by file owner.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n| `uint` position   | Uploaded chunk position               |\n| `bytes` data      | Uploaded chunk data                   |\n\n#### finishUpload\n\n```solidity\nfunction finishUpload(string memory filePath)\n```\n\nFinishes uploading of the file. Checks whether all chunks are uploaded correctly.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### deleteFile\n\n```solidity\nfunction deleteFile(string memory filePath)\n```\n\nDeletes file from Filestorage.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### readChunk\n\n```solidity\nfunction readChunk(string memory storagePath, uint position, uint length)\n        public\n        view\n        returns (bytes32[MAX_BLOCK_COUNT] memory out)\n```\n\nReads chunk from file from specific position with specific length. Returns `bytes32` array of fixed size with requested data.\n\n-   Maximum length of the chunk to read is 1Mb\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n| `uint` position      | First byte to read from              |\n| `uint` length        | Uploaded chunk length                |\n\n**Returns:**\n\n| Parameter       | Description                                       |\n| --------------- | ------------------------------------------------- |\n| `bytes32[]` out | Requested chunk data split across `bytes32` array |\n\n#### getFileSize\n\n```solidity\nfunction getFileSize(string memory storagePath) \n        public \n        view \n        returns (uint fileSize)\n```\n\nGets size of the requested file in bytes.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description            |\n| --------------- | ---------------------- |\n| `uint` fileSize | Size of requested file |\n\n#### getFileStatus\n\n```solidity\nfunction getFileStatus(string memory storagePath) \n        public \n        view \n        returns (int)\n```\n\nReturns status of the requested file:\n\n-   0 - file does not exist\n-   1 - file is created but has not finished uploading\n-   2 - file is fully uploaded\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter         | Description              |\n| ----------------- | ------------------------ |\n| `uint` fileStatus | Status of requested file |\n\n### Directory interaction methods\n\nFilestorage is represented with UNIX-based filesystem that consisted of files and directories. Directories are stored in `Directory` structure that contains information about its content in `ContentInfo` structure. Maximum amount of content in separate directory is **8196**.\n\n#### createDirectory\n\n```solidity\nfunction createDirectory(string memory directoryPath)\n```\n\nCreates directory in Filestorage. Owner of the directory - message sender. \n\n-   Function is called by directory owner\n-   Maximum amount of directories and files in one directory is **8196**\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### deleteDirectory\n\n```solidity\nfunction deleteDirectory(string memory directoryPath)\n```\n\nDeletes directory from Filestorage.\n\n-   Function is called by directory owner\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### listDirectory\n\n```solidity\nfunction listDirectory(string memory storagePath) \n        public \n        view \n        returns (ContentInfo[])\n```\n\nList information about content of the specific directory.\n\n**Parameters:**\n\n| Parameter            | Description                               |\n| -------------------- | ----------------------------------------- |\n| `string` storagePath | Full path of the directory in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description                          |\n| --------------- | ------------------------------------ |\n| `ContentInfo[]` | Array of content stored in directory |\n\nObject `ContentInfo` can be file or directory and contains:\n\n| Field                    | Description                                                                      |\n| ------------------------ | -------------------------------------------------------------------------------- |\n| `string` name            | Content name                                                                     |\n| `bool` isFile            | Whether content is file                                                          |\n| `uint` size              | File size, in bytes                                                              |\n| `int` status             | File uploading status                                                            |\n| `bool[]` isChunkUploaded | Array with statuses of each chunk (`true` - chunk uploaded, `false` - otherwise) |\n\n## Build\n\nCreate an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nPRIVATEKEY='Private key for test account'\n```\n\nCompile `FileStorage.sol`:\n\n```bash\ntruffle compile\n```\n\n## Test\n\nTests run only on SKALE chains. Create an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nSCHAIN_OWNER_PK='Private key of SKALE endpoint owner (or account with money)'\nPRIVATEKEY='Private key for test account'\n```\n\nRun tests:\n\n```bash\ntruffle test --network skaled\n```\n","gitHead":"5510759efaedb91a82f503e390d22d6588984a0d","scripts":{"lint":"npx ethlint -d contracts","test":"npx truffle test test/unit/* --network skaled","build":"rm -r ./build; npx truffle build","compile":"npx truffle compile; cp build/contracts/FileStorage.json predeployed/filestorage_predeployed/artifacts/","slither":"slither . --filter-path strings --filter-path Migrations","version":"node -e \"console.log(require('./package.json').version);\"","coverage":"npx truffle run coverage --file=\"test/unit/*\"","lint-fix":"npm run lint -- --fix","predeployed-test":"npx truffle test test/predeployed/* --network skaled"},"_npmUser":{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},"repository":{"url":"git+https://github.com/skalenetwork/filestorage.git","type":"git"},"_npmVersion":"6.14.15","description":"SKALE Filestorage contracts","directories":{},"_nodeVersion":"14.18.3","dependencies":{"@openzeppelin/contracts-upgradeable":"^4.3.2"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"chai":"^4.2.0","web3":"^1.2.1","dotenv":"^8.2.0","codecov":"^3.3.0","truffle":"5.1.30","randomstring":"^1.1.5","chai-as-promised":"^7.1.1","solidity-coverage":"^0.7.17","@truffle/hdwallet-provider":"^1.5.1"},"_npmOperationalInternal":{"tmp":"tmp/filestorage_1.0.1-develop.10_1643379787847_0.013910670222576416","host":"s3://npm-registry-packages"}},"1.0.1-beta.0":{"name":"@skalenetwork/filestorage","version":"1.0.1-beta.0","keywords":["SKALE","blockchain","ethereum"],"author":{"name":"SKALE Labs and contributors"},"license":"AGPL-3.0","_id":"@skalenetwork/filestorage@1.0.1-beta.0","maintainers":[{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},{"name":"dmitrytk","email":"dmitry.tkachuk@skalelabs.com"},{"name":"cstrange","email":"chadwick@skalelabs.com"},{"name":"skalelabsdev","email":"dev@skalelabs.com"},{"name":"theskyunicorn","email":"christine@skalelabs.com"},{"name":"stebaev","email":"dimastebaev@gmail.com"},{"name":"l_sergiy","email":"sergiy@skalelabs.com"}],"homepage":"https://github.com/skalenetwork/filestorage#readme","bugs":{"url":"https://github.com/skalenetwork/filestorage/issues"},"dist":{"shasum":"1c730309ae6949200cfb4ca5720219d41ee60a45","tarball":"https://registry.npmjs.org/@skalenetwork/filestorage/-/filestorage-1.0.1-beta.0.tgz","fileCount":5,"integrity":"sha512-WU+7VUYPaxSQhqZJHrCj4G/zr/ERvSVTX1ls2RsG7Xl5esCprsgWTQgpghrKytcpW7g15bLsrYNAZTzfHvEbOQ==","signatures":[{"sig":"MEQCIF3P2eP5viTbhP+Hhww1vowCPieXqB2fRAHEbCFjM5ZhAiBQ941RZZCMoCSOrlhliAuakDzdvporTiRXCYirdRb+bA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":66028,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiOJLfACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmr4fRAAm/nV12cn93fyeOOwt4QoISd1FcIU40/zqYx66AGKbsz8RBvt\r\nsdCbrb6mat8JIb0STBYmvRaqgSUbBckFpwyAq5f24dEydn0Gnfr1/63abo9n\r\noiJqgLp2Eiu/Makm5mb60jnKAXfc6G/+PVomN858sdRGp8gLL+i1X3+LWUS5\r\nItZwwLgL3SWXkDa7Y8z1MnggBUbYNLuzuB9LisXj1HEmx8J9qUuRypfhp3hf\r\nJarxO9AhmBInZtG/cVHAYshVnh1ySuqBWNDsGTBdEmhExGNGbfDQqH2hxUXo\r\n05vYIR5v+X+4UGIHzFzRjJgpJiPId0LeEKMtOr5teI24PiArqtm25YUDGUtZ\r\nT33UiUU00K30CSzq90UwYjhIyjl6JRnmvlpKVeROvlBgqjb5GfSh2f49K15z\r\nw6TPJ0Zuuooy/C0o4irVGdkF8WLEiVh5wc2ST0HRQhNOcXjdoVI1Ack76xiu\r\nvKVn19+KlnydLw+qZyc1w8TiH4k7stufRflzYiWEAT1f2lh95prVvgfgR7mO\r\n51460qbg5LUO/Nq8maTcdttstQ5FJBCCMEfYWu1zgA2tIQKbpWDhz4FMscYC\r\nuNFrQBgW2jE8SLIFB5AOKNhM8Z0XIHr1wM1s1Jz6gquuXecBsKb9hGk0c8O3\r\nBt+A0U/zWYKxsWvARDptNFeFg2/JcGfqcJw=\r\n=gFhh\r\n-----END PGP SIGNATURE-----\r\n"},"main":"artifacts.json","readme":"# SKALE Filestorage\n\n[![Build Status](https://travis-ci.com/skalenetwork/filestorage.svg?token=HYnwEPctUzUdXVcsecA6&branch=develop)](https://travis-ci.com/skalenetwork/filestorage)\n[![codecov](https://codecov.io/gh/skalenetwork/filestorage/branch/develop/graph/badge.svg?token=2wkF3kZTXh)](https://codecov.io/gh/skalenetwork/filestorage)\n[![Discord](https://img.shields.io/discord/534485763354787851.svg)](https://discord.gg/vvUtWJB)\n\nFilestorage - smart contract, that controls decentralized file storage on SKALE chains.\n\n## Description\n\nFilestorage is a cost-effective storage layer within Ethereum capable of handling files up to 100MB. Filestorage uses UNIX-based filesystem of SKALE chains. Filestorage smart contract is a set of functions to interact with files on EVM. This contract may be predeployed on SKALE chains. It contains functions to work with Filestorage precompiled smart contracts. \n\nSmart contract language - Solidity 0.8.9\n\n## API Reference\n\n### Filestorage space handling \n\nTo start using Filestorage (upload/delete files and create/remove directories) the space should be allocated for specific account, it could be done from account that is given ALLOCATOR_ROLE. \nRules of occupying space in Filestorage:\n\n1. For directory **4096** bytes is taken\n2. File could be uploaded up to **100** MB (104857600 bytes)\n3. Occupying space for file is rounded up to the nearest multiple of **4096** bytes\n4. **Empty** file takes 4096 bytes of free space\n\nAfter deleting file/directory's amount of space is freed according to the rules above\n\n### Space handling API\n#### reserveSpace\n\n```solidity\nfunction reserveSpace(address userAddress, uint reservedSpace)\n```\n\nReserves the Filestorage space for specific address. Could be called only with ALLOCATOR_ROLE\n\n**Parameters:**\n\n| Parameter             | Description                           |\n| --------------------- | ------------------------------------- |\n| `address` userAddress | Address to allocate space for         |\n| `uint` reservedSpace  | Amount of space to reserve in bytes   |\n\n#### getTotalStorageSpace\n\n```solidity\nfunction getTotalStorageSpace()\n```\n\nGets total space in Filestorage in bytes.\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Space in bytes                     |\n\n#### getTotalReservedSpace\n\n```solidity\nfunction getTotalStorageSpace()\n```\n\nGets total reserved space in Filestorage in bytes.\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Space in bytes                     |\n\n#### getReservedSpace\n\n```solidity\nfunction getReservedSpace(address owner)\n```\n\nGets reserved space for account.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `address` owner      | Account address                      |\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Size of reserved space for account |\n\n#### getOccupiedSpace\n\n```solidity\nfunction getOccupiedSpace(address owner)\n```\n\nGets occupied space for account.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `address` owner      | Account address                      |\n\n**Returns:**\n\n| Parameter       | Description                                 |\n| --------------- | ------------------------------------------- |\n| `uint`          | Size of occupied space for account in bytes |\n\n### File interaction methods\n\nTo begin the uploading process, the file should be broken into chunks of 1MB (&lt; 1MB for the last chunk) which are uploaded as separate transactions to FileStorage.sol. \nThe pipeline of the uploading file is:\n\n1.  creating empty file of fixed size on EVM by calling `startUpload`,\n2.  uploading data chunk by chunk with `uploadChunk`,\n3.  checking the file validity and finishing process with `finishUpload`.\n\n#### startUpload\n\n```solidity\nfunction startUpload(string memory filePath, uint256 fileSize)\n```\n\nCreates empty file on EVM with specific name and size. Owner of the file - message sender. \n\n-   Function is called by file owner\n-   Maximum amount of directories and files in one directory is **8196**\n-   Maximum filesize is **100,000,000** bytes\n-   Owner should have enough free space\n\n**Parameters:**\n\n| Parameter          | Description                           |\n| ------------------ | ------------------------------------- |\n| `string` filePath  | Path to the file in account directory |\n| `uint256` fileSize | Uploaded file size in bytes           |\n\n#### uploadChunk\n\n```solidity\nfunction uploadChunk(string memory filePath, uint position, bytes memory data)\n```\n\nUploads 1MB chunk of data from specific position in specific file by file owner.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n| `uint` position   | Uploaded chunk position               |\n| `bytes` data      | Uploaded chunk data                   |\n\n#### finishUpload\n\n```solidity\nfunction finishUpload(string memory filePath)\n```\n\nFinishes uploading of the file. Checks whether all chunks are uploaded correctly.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### deleteFile\n\n```solidity\nfunction deleteFile(string memory filePath)\n```\n\nDeletes file from Filestorage.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### readChunk\n\n```solidity\nfunction readChunk(string memory storagePath, uint position, uint length)\n        public\n        view\n        returns (bytes32[MAX_BLOCK_COUNT] memory out)\n```\n\nReads chunk from file from specific position with specific length. Returns `bytes32` array of fixed size with requested data.\n\n-   Maximum length of the chunk to read is 1Mb\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n| `uint` position      | First byte to read from              |\n| `uint` length        | Uploaded chunk length                |\n\n**Returns:**\n\n| Parameter       | Description                                       |\n| --------------- | ------------------------------------------------- |\n| `bytes32[]` out | Requested chunk data split across `bytes32` array |\n\n#### getFileSize\n\n```solidity\nfunction getFileSize(string memory storagePath) \n        public \n        view \n        returns (uint fileSize)\n```\n\nGets size of the requested file in bytes.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description            |\n| --------------- | ---------------------- |\n| `uint` fileSize | Size of requested file |\n\n#### getFileStatus\n\n```solidity\nfunction getFileStatus(string memory storagePath) \n        public \n        view \n        returns (int)\n```\n\nReturns status of the requested file:\n\n-   0 - file does not exist\n-   1 - file is created but has not finished uploading\n-   2 - file is fully uploaded\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter         | Description              |\n| ----------------- | ------------------------ |\n| `uint` fileStatus | Status of requested file |\n\n### Directory interaction methods\n\nFilestorage is represented with UNIX-based filesystem that consisted of files and directories. Directories are stored in `Directory` structure that contains information about its content in `ContentInfo` structure. Maximum amount of content in separate directory is **8196**.\n\n#### createDirectory\n\n```solidity\nfunction createDirectory(string memory directoryPath)\n```\n\nCreates directory in Filestorage. Owner of the directory - message sender. \n\n-   Function is called by directory owner\n-   Maximum amount of directories and files in one directory is **8196**\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### deleteDirectory\n\n```solidity\nfunction deleteDirectory(string memory directoryPath)\n```\n\nDeletes directory from Filestorage.\n\n-   Function is called by directory owner\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### listDirectory\n\n```solidity\nfunction listDirectory(string memory storagePath) \n        public \n        view \n        returns (ContentInfo[])\n```\n\nList information about content of the specific directory.\n\n**Parameters:**\n\n| Parameter            | Description                               |\n| -------------------- | ----------------------------------------- |\n| `string` storagePath | Full path of the directory in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description                          |\n| --------------- | ------------------------------------ |\n| `ContentInfo[]` | Array of content stored in directory |\n\nObject `ContentInfo` can be file or directory and contains:\n\n| Field                    | Description                                                                      |\n| ------------------------ | -------------------------------------------------------------------------------- |\n| `string` name            | Content name                                                                     |\n| `bool` isFile            | Whether content is file                                                          |\n| `uint` size              | File size, in bytes                                                              |\n| `int` status             | File uploading status                                                            |\n| `bool[]` isChunkUploaded | Array with statuses of each chunk (`true` - chunk uploaded, `false` - otherwise) |\n\n## Build\n\nCreate an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nPRIVATEKEY='Private key for test account'\n```\n\nCompile `FileStorage.sol`:\n\n```bash\ntruffle compile\n```\n\n## Test\n\nTests run only on SKALE chains. Create an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nSCHAIN_OWNER_PK='Private key of SKALE endpoint owner (or account with money)'\nPRIVATEKEY='Private key for test account'\n```\n\nRun tests:\n\n```bash\ntruffle test --network skaled\n```\n","gitHead":"accf4df65504ef2e664806cc4115be34c2267d6f","scripts":{"lint":"npx ethlint -d contracts","test":"npx truffle test test/unit/* --network skaled","build":"rm -r ./build; npx truffle build","compile":"npx truffle compile; cp build/contracts/FileStorage.json predeployed/filestorage_predeployed/artifacts/","slither":"slither . --filter-path strings --filter-path Migrations","version":"node -e \"console.log(require('./package.json').version);\"","coverage":"npx truffle run coverage --file=\"test/unit/*\"","lint-fix":"npm run lint -- --fix","predeployed-test":"npx truffle test test/predeployed/* --network skaled"},"_npmUser":{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},"repository":{"url":"git+https://github.com/skalenetwork/filestorage.git","type":"git"},"_npmVersion":"6.14.16","description":"SKALE Filestorage contracts","directories":{},"_nodeVersion":"14.19.0","dependencies":{"@openzeppelin/contracts-upgradeable":"^4.3.2"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"chai":"^4.2.0","web3":"^1.2.1","dotenv":"^8.2.0","codecov":"^3.3.0","truffle":"5.1.30","randomstring":"^1.1.5","chai-as-promised":"^7.1.1","solidity-coverage":"^0.7.17","@truffle/hdwallet-provider":"^1.5.1"},"_npmOperationalInternal":{"tmp":"tmp/filestorage_1.0.1-beta.0_1647874783095_0.7870777263921791","host":"s3://npm-registry-packages"}},"1.0.1-develop.11":{"name":"@skalenetwork/filestorage","version":"1.0.1-develop.11","keywords":["SKALE","blockchain","ethereum"],"author":{"name":"SKALE Labs and contributors"},"license":"AGPL-3.0","_id":"@skalenetwork/filestorage@1.0.1-develop.11","maintainers":[{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},{"name":"dmitrytk","email":"dmitry.tkachuk@skalelabs.com"},{"name":"cstrange","email":"chadwick@skalelabs.com"},{"name":"skalelabsdev","email":"dev@skalelabs.com"},{"name":"theskyunicorn","email":"christine@skalelabs.com"},{"name":"stebaev","email":"dimastebaev@gmail.com"},{"name":"l_sergiy","email":"sergiy@skalelabs.com"}],"homepage":"https://github.com/skalenetwork/filestorage#readme","bugs":{"url":"https://github.com/skalenetwork/filestorage/issues"},"dist":{"shasum":"98a79e7eadbe759b61cedd4ad7ff7d77cbbbaa0a","tarball":"https://registry.npmjs.org/@skalenetwork/filestorage/-/filestorage-1.0.1-develop.11.tgz","fileCount":5,"integrity":"sha512-VMS3f8UMJxRy0/YWNbC3vxeOeZBfD9g7qJp4ZsFkaFnONgoJu844JEfV/REMNCBNtYIej5jMYcibwTGj1eSTaA==","signatures":[{"sig":"MEUCIQD7CW+yBn4Tn/NVYEm8uXbgS6TKMgo3SgSlF+EON/UjaAIgGpcKtS1XuQGPMwYGGGw3btecl+6b6gOEf84zpf7lDjg=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":66032,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJibPvWACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoRzQ//eE4bEmybyWhpisohCUII2cu/np3H3z1PqVtx5qLczGDEfPKx\r\nbKxVEeqz9t4GHQW7XN29NI8YdnyxhfQIDRVumUbrz4jeBNjf9IoM8uS26eXh\r\nG7mqRGrEApNYx0p1lzvVBwDQjOqORanhzcRLalWGoB1kHtOlblpYrOUHguMi\r\nf70DRxOSxk6xCXh1CSgGpcX06f0E+i+Dt6BZqY9bTWX4ARtfn+jLNZj41U3R\r\nA7vWx89GYDLO2sKn1xG/8wikhhNjFW7nf6fPN2EXAWMsO/nnaJosyW0vCmtK\r\ne5eM8k01D2U0WiGOwj+lPnOVtdPJn+rhPtBM5Q0OpsVHfxew+ZzoMT5KPZp3\r\nfxYGFAyuMvoeMMLpu8bGsBj2c0gkIBTVtXEKr95qcFruBxJgElXWoyIKx9m5\r\nPcF9oc7ZAdJE0BHH6JgspGYy0SLcgAJ2S84KUKJYBc4LojMqgm5S+oDthANd\r\n/mePBX2gnPU4d6JPMCSE95zs339AUCLCSVpan4uAxCQoM2cD7zqEihWG6D/t\r\nZtBBE9xw/UG2elmLMKeI7WCQW9+Ei7BgWVAugWQ/JB5/j5lMNMg/gITmI1B7\r\nkJ/vPqNdulYgVT0eR4+soatqfqtE8TKhg29ZuYpBT9ixpQVd5aPr63i23AI2\r\n02c0PGqONITZL0Zcn8lb6krTjECHZzKqjWU=\r\n=ej5V\r\n-----END PGP SIGNATURE-----\r\n"},"main":"artifacts.json","readme":"# SKALE Filestorage\n\n[![Build Status](https://travis-ci.com/skalenetwork/filestorage.svg?token=HYnwEPctUzUdXVcsecA6&branch=develop)](https://travis-ci.com/skalenetwork/filestorage)\n[![codecov](https://codecov.io/gh/skalenetwork/filestorage/branch/develop/graph/badge.svg?token=2wkF3kZTXh)](https://codecov.io/gh/skalenetwork/filestorage)\n[![Discord](https://img.shields.io/discord/534485763354787851.svg)](https://discord.gg/vvUtWJB)\n\nFilestorage - smart contract, that controls decentralized file storage on SKALE chains.\n\n## Description\n\nFilestorage is a cost-effective storage layer within Ethereum capable of handling files up to 100MB. Filestorage uses UNIX-based filesystem of SKALE chains. Filestorage smart contract is a set of functions to interact with files on EVM. This contract may be predeployed on SKALE chains. It contains functions to work with Filestorage precompiled smart contracts. \n\nSmart contract language - Solidity 0.8.9\n\n## API Reference\n\n### Filestorage space handling \n\nTo start using Filestorage (upload/delete files and create/remove directories) the space should be allocated for specific account, it could be done from account that is given ALLOCATOR_ROLE. \nRules of occupying space in Filestorage:\n\n1. For directory **4096** bytes is taken\n2. File could be uploaded up to **100** MB (104857600 bytes)\n3. Occupying space for file is rounded up to the nearest multiple of **4096** bytes\n4. **Empty** file takes 4096 bytes of free space\n\nAfter deleting file/directory's amount of space is freed according to the rules above\n\n### Space handling API\n#### reserveSpace\n\n```solidity\nfunction reserveSpace(address userAddress, uint reservedSpace)\n```\n\nReserves the Filestorage space for specific address. Could be called only with ALLOCATOR_ROLE\n\n**Parameters:**\n\n| Parameter             | Description                           |\n| --------------------- | ------------------------------------- |\n| `address` userAddress | Address to allocate space for         |\n| `uint` reservedSpace  | Amount of space to reserve in bytes   |\n\n#### getTotalStorageSpace\n\n```solidity\nfunction getTotalStorageSpace()\n```\n\nGets total space in Filestorage in bytes.\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Space in bytes                     |\n\n#### getTotalReservedSpace\n\n```solidity\nfunction getTotalStorageSpace()\n```\n\nGets total reserved space in Filestorage in bytes.\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Space in bytes                     |\n\n#### getReservedSpace\n\n```solidity\nfunction getReservedSpace(address owner)\n```\n\nGets reserved space for account.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `address` owner      | Account address                      |\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Size of reserved space for account |\n\n#### getOccupiedSpace\n\n```solidity\nfunction getOccupiedSpace(address owner)\n```\n\nGets occupied space for account.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `address` owner      | Account address                      |\n\n**Returns:**\n\n| Parameter       | Description                                 |\n| --------------- | ------------------------------------------- |\n| `uint`          | Size of occupied space for account in bytes |\n\n### File interaction methods\n\nTo begin the uploading process, the file should be broken into chunks of 1MB (&lt; 1MB for the last chunk) which are uploaded as separate transactions to FileStorage.sol. \nThe pipeline of the uploading file is:\n\n1.  creating empty file of fixed size on EVM by calling `startUpload`,\n2.  uploading data chunk by chunk with `uploadChunk`,\n3.  checking the file validity and finishing process with `finishUpload`.\n\n#### startUpload\n\n```solidity\nfunction startUpload(string memory filePath, uint256 fileSize)\n```\n\nCreates empty file on EVM with specific name and size. Owner of the file - message sender. \n\n-   Function is called by file owner\n-   Maximum amount of directories and files in one directory is **8196**\n-   Maximum filesize is **100,000,000** bytes\n-   Owner should have enough free space\n\n**Parameters:**\n\n| Parameter          | Description                           |\n| ------------------ | ------------------------------------- |\n| `string` filePath  | Path to the file in account directory |\n| `uint256` fileSize | Uploaded file size in bytes           |\n\n#### uploadChunk\n\n```solidity\nfunction uploadChunk(string memory filePath, uint position, bytes memory data)\n```\n\nUploads 1MB chunk of data from specific position in specific file by file owner.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n| `uint` position   | Uploaded chunk position               |\n| `bytes` data      | Uploaded chunk data                   |\n\n#### finishUpload\n\n```solidity\nfunction finishUpload(string memory filePath)\n```\n\nFinishes uploading of the file. Checks whether all chunks are uploaded correctly.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### deleteFile\n\n```solidity\nfunction deleteFile(string memory filePath)\n```\n\nDeletes file from Filestorage.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### readChunk\n\n```solidity\nfunction readChunk(string memory storagePath, uint position, uint length)\n        public\n        view\n        returns (bytes32[MAX_BLOCK_COUNT] memory out)\n```\n\nReads chunk from file from specific position with specific length. Returns `bytes32` array of fixed size with requested data.\n\n-   Maximum length of the chunk to read is 1Mb\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n| `uint` position      | First byte to read from              |\n| `uint` length        | Uploaded chunk length                |\n\n**Returns:**\n\n| Parameter       | Description                                       |\n| --------------- | ------------------------------------------------- |\n| `bytes32[]` out | Requested chunk data split across `bytes32` array |\n\n#### getFileSize\n\n```solidity\nfunction getFileSize(string memory storagePath) \n        public \n        view \n        returns (uint fileSize)\n```\n\nGets size of the requested file in bytes.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description            |\n| --------------- | ---------------------- |\n| `uint` fileSize | Size of requested file |\n\n#### getFileStatus\n\n```solidity\nfunction getFileStatus(string memory storagePath) \n        public \n        view \n        returns (int)\n```\n\nReturns status of the requested file:\n\n-   0 - file does not exist\n-   1 - file is created but has not finished uploading\n-   2 - file is fully uploaded\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter         | Description              |\n| ----------------- | ------------------------ |\n| `uint` fileStatus | Status of requested file |\n\n### Directory interaction methods\n\nFilestorage is represented with UNIX-based filesystem that consisted of files and directories. Directories are stored in `Directory` structure that contains information about its content in `ContentInfo` structure. Maximum amount of content in separate directory is **8196**.\n\n#### createDirectory\n\n```solidity\nfunction createDirectory(string memory directoryPath)\n```\n\nCreates directory in Filestorage. Owner of the directory - message sender. \n\n-   Function is called by directory owner\n-   Maximum amount of directories and files in one directory is **8196**\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### deleteDirectory\n\n```solidity\nfunction deleteDirectory(string memory directoryPath)\n```\n\nDeletes directory from Filestorage.\n\n-   Function is called by directory owner\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### listDirectory\n\n```solidity\nfunction listDirectory(string memory storagePath) \n        public \n        view \n        returns (ContentInfo[])\n```\n\nList information about content of the specific directory.\n\n**Parameters:**\n\n| Parameter            | Description                               |\n| -------------------- | ----------------------------------------- |\n| `string` storagePath | Full path of the directory in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description                          |\n| --------------- | ------------------------------------ |\n| `ContentInfo[]` | Array of content stored in directory |\n\nObject `ContentInfo` can be file or directory and contains:\n\n| Field                    | Description                                                                      |\n| ------------------------ | -------------------------------------------------------------------------------- |\n| `string` name            | Content name                                                                     |\n| `bool` isFile            | Whether content is file                                                          |\n| `uint` size              | File size, in bytes                                                              |\n| `int` status             | File uploading status                                                            |\n| `bool[]` isChunkUploaded | Array with statuses of each chunk (`true` - chunk uploaded, `false` - otherwise) |\n\n## Build\n\nCreate an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nPRIVATEKEY='Private key for test account'\n```\n\nCompile `FileStorage.sol`:\n\n```bash\ntruffle compile\n```\n\n## Test\n\nTests run only on SKALE chains. Create an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nSCHAIN_OWNER_PK='Private key of SKALE endpoint owner (or account with money)'\nPRIVATEKEY='Private key for test account'\n```\n\nRun tests:\n\n```bash\ntruffle test --network skaled\n```\n","gitHead":"bdf813bc0f946a974146d171681aa50ea14f56d4","scripts":{"lint":"npx ethlint -d contracts","test":"npx truffle test test/unit/* --network skaled","build":"rm -r ./build; npx truffle build","compile":"npx truffle compile; cp build/contracts/FileStorage.json predeployed/filestorage_predeployed/artifacts/","slither":"slither . --filter-path strings --filter-path Migrations","version":"node -e \"console.log(require('./package.json').version);\"","coverage":"npx truffle run coverage --file=\"test/unit/*\"","lint-fix":"npm run lint -- --fix","predeployed-test":"npx truffle test test/predeployed/* --network skaled"},"_npmUser":{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},"repository":{"url":"git+https://github.com/skalenetwork/filestorage.git","type":"git"},"_npmVersion":"6.14.16","description":"SKALE Filestorage contracts","directories":{},"_nodeVersion":"14.19.1","dependencies":{"@openzeppelin/contracts-upgradeable":"^4.3.2"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"chai":"^4.2.0","web3":"^1.2.1","dotenv":"^8.2.0","codecov":"^3.3.0","truffle":"5.1.30","randomstring":"^1.1.5","chai-as-promised":"^7.1.1","solidity-coverage":"^0.7.17","@truffle/hdwallet-provider":"^1.5.1"},"_npmOperationalInternal":{"tmp":"tmp/filestorage_1.0.1-develop.11_1651309526431_0.4225236093296485","host":"s3://npm-registry-packages"}},"1.0.1-beta.1":{"name":"@skalenetwork/filestorage","version":"1.0.1-beta.1","keywords":["SKALE","blockchain","ethereum"],"author":{"name":"SKALE Labs and contributors"},"license":"AGPL-3.0","_id":"@skalenetwork/filestorage@1.0.1-beta.1","maintainers":[{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},{"name":"dmitrytk","email":"dmitry.tkachuk@skalelabs.com"},{"name":"cstrange","email":"chadwick@skalelabs.com"},{"name":"skalelabsdev","email":"dev@skalelabs.com"},{"name":"theskyunicorn","email":"christine@skalelabs.com"},{"name":"stebaev","email":"dimastebaev@gmail.com"},{"name":"l_sergiy","email":"sergiy@skalelabs.com"}],"homepage":"https://github.com/skalenetwork/filestorage#readme","bugs":{"url":"https://github.com/skalenetwork/filestorage/issues"},"dist":{"shasum":"f3d1a59eb5c4de31c5da3b863a9dbcbc7946d8c4","tarball":"https://registry.npmjs.org/@skalenetwork/filestorage/-/filestorage-1.0.1-beta.1.tgz","fileCount":5,"integrity":"sha512-AI0QFfFPgH2RsEIe5POC0J2RMPRp8wsdPsqJszfb+6FaiHJ/HB3NhyMZeVmL8rAx3bQtusBxufC28Je2hXUEfA==","signatures":[{"sig":"MEUCIQD7kRe9L/53W+4QdpNkwPZpvbzFvJP8dRyz/VVU4KuN5QIgboEDGSjdDzpxmvfK8CL1klagVGy/4M2SunYikWfQWnU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":66028,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJibR+WACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpP/g/+ObbI5jPh15ybNuFwMxTQo2OlvwTtQqS2o9RNMKja/553YcQw\r\nvXf0EeHv4mcnaIcSn2wj2P3J8jp+0lFe8mR7Hb2i/I5u6Ww9Mk3GKVC8GOdd\r\nDRY+kgl4Z+xv3a49k+yzkmnA0zDmEzcaf9s977kx+nqQ7LlHMQikzF5QGIar\r\nj0moKN25qQi1AbNzD5gwrbTnwZODNN/mTy6akduPVq79tGi3t1KvyPdDo5GN\r\nhIjh1BDHLL/6GuCHXJr63dGMw5fkwDAiLZzdbmpu0KcOn8PNINxOKvJzeBV4\r\n+65EB+oFBEIA4G9k9th/86JZY4uJPdv9IkVk+hAlt8SIYEkaGKCgXJ+b5bvk\r\nDYmdnmgYGORTERDXO3WxdsA3pMYLX83Fa7zShBm2m7OdcUduIsVGrJXgz3AL\r\n/vTDfD5pbnhUtVvRqp1zej2ixpxHnQw2iTfBc7fyDIsLrqcYvZRzMpl7sWLh\r\nbrX10A7Fc1mDo7wqyYk6ofMY3hQHn+idp6B+aBcpyv/0GWWgnh00ja/Zdqfh\r\n4tU4jAisDt2B6o8nuHPgdv1lg7DCsQjvKhn1dLd/45mtUDi9Utz7wbxFRan4\r\nfQDEgPs0jtPafs60VqBEsFUwdQ4iz+jUpDy7l4caPvVYt0817r7MX1j4L9WI\r\n4AF4WWnelyVsAW1RbSpEzu/PnC4WxpNV/co=\r\n=rUWd\r\n-----END PGP SIGNATURE-----\r\n"},"main":"artifacts.json","readme":"# SKALE Filestorage\n\n[![Build Status](https://travis-ci.com/skalenetwork/filestorage.svg?token=HYnwEPctUzUdXVcsecA6&branch=develop)](https://travis-ci.com/skalenetwork/filestorage)\n[![codecov](https://codecov.io/gh/skalenetwork/filestorage/branch/develop/graph/badge.svg?token=2wkF3kZTXh)](https://codecov.io/gh/skalenetwork/filestorage)\n[![Discord](https://img.shields.io/discord/534485763354787851.svg)](https://discord.gg/vvUtWJB)\n\nFilestorage - smart contract, that controls decentralized file storage on SKALE chains.\n\n## Description\n\nFilestorage is a cost-effective storage layer within Ethereum capable of handling files up to 100MB. Filestorage uses UNIX-based filesystem of SKALE chains. Filestorage smart contract is a set of functions to interact with files on EVM. This contract may be predeployed on SKALE chains. It contains functions to work with Filestorage precompiled smart contracts. \n\nSmart contract language - Solidity 0.8.9\n\n## API Reference\n\n### Filestorage space handling \n\nTo start using Filestorage (upload/delete files and create/remove directories) the space should be allocated for specific account, it could be done from account that is given ALLOCATOR_ROLE. \nRules of occupying space in Filestorage:\n\n1. For directory **4096** bytes is taken\n2. File could be uploaded up to **100** MB (104857600 bytes)\n3. Occupying space for file is rounded up to the nearest multiple of **4096** bytes\n4. **Empty** file takes 4096 bytes of free space\n\nAfter deleting file/directory's amount of space is freed according to the rules above\n\n### Space handling API\n#### reserveSpace\n\n```solidity\nfunction reserveSpace(address userAddress, uint reservedSpace)\n```\n\nReserves the Filestorage space for specific address. Could be called only with ALLOCATOR_ROLE\n\n**Parameters:**\n\n| Parameter             | Description                           |\n| --------------------- | ------------------------------------- |\n| `address` userAddress | Address to allocate space for         |\n| `uint` reservedSpace  | Amount of space to reserve in bytes   |\n\n#### getTotalStorageSpace\n\n```solidity\nfunction getTotalStorageSpace()\n```\n\nGets total space in Filestorage in bytes.\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Space in bytes                     |\n\n#### getTotalReservedSpace\n\n```solidity\nfunction getTotalStorageSpace()\n```\n\nGets total reserved space in Filestorage in bytes.\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Space in bytes                     |\n\n#### getReservedSpace\n\n```solidity\nfunction getReservedSpace(address owner)\n```\n\nGets reserved space for account.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `address` owner      | Account address                      |\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Size of reserved space for account |\n\n#### getOccupiedSpace\n\n```solidity\nfunction getOccupiedSpace(address owner)\n```\n\nGets occupied space for account.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `address` owner      | Account address                      |\n\n**Returns:**\n\n| Parameter       | Description                                 |\n| --------------- | ------------------------------------------- |\n| `uint`          | Size of occupied space for account in bytes |\n\n### File interaction methods\n\nTo begin the uploading process, the file should be broken into chunks of 1MB (&lt; 1MB for the last chunk) which are uploaded as separate transactions to FileStorage.sol. \nThe pipeline of the uploading file is:\n\n1.  creating empty file of fixed size on EVM by calling `startUpload`,\n2.  uploading data chunk by chunk with `uploadChunk`,\n3.  checking the file validity and finishing process with `finishUpload`.\n\n#### startUpload\n\n```solidity\nfunction startUpload(string memory filePath, uint256 fileSize)\n```\n\nCreates empty file on EVM with specific name and size. Owner of the file - message sender. \n\n-   Function is called by file owner\n-   Maximum amount of directories and files in one directory is **8196**\n-   Maximum filesize is **100,000,000** bytes\n-   Owner should have enough free space\n\n**Parameters:**\n\n| Parameter          | Description                           |\n| ------------------ | ------------------------------------- |\n| `string` filePath  | Path to the file in account directory |\n| `uint256` fileSize | Uploaded file size in bytes           |\n\n#### uploadChunk\n\n```solidity\nfunction uploadChunk(string memory filePath, uint position, bytes memory data)\n```\n\nUploads 1MB chunk of data from specific position in specific file by file owner.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n| `uint` position   | Uploaded chunk position               |\n| `bytes` data      | Uploaded chunk data                   |\n\n#### finishUpload\n\n```solidity\nfunction finishUpload(string memory filePath)\n```\n\nFinishes uploading of the file. Checks whether all chunks are uploaded correctly.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### deleteFile\n\n```solidity\nfunction deleteFile(string memory filePath)\n```\n\nDeletes file from Filestorage.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### readChunk\n\n```solidity\nfunction readChunk(string memory storagePath, uint position, uint length)\n        public\n        view\n        returns (bytes32[MAX_BLOCK_COUNT] memory out)\n```\n\nReads chunk from file from specific position with specific length. Returns `bytes32` array of fixed size with requested data.\n\n-   Maximum length of the chunk to read is 1Mb\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n| `uint` position      | First byte to read from              |\n| `uint` length        | Uploaded chunk length                |\n\n**Returns:**\n\n| Parameter       | Description                                       |\n| --------------- | ------------------------------------------------- |\n| `bytes32[]` out | Requested chunk data split across `bytes32` array |\n\n#### getFileSize\n\n```solidity\nfunction getFileSize(string memory storagePath) \n        public \n        view \n        returns (uint fileSize)\n```\n\nGets size of the requested file in bytes.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description            |\n| --------------- | ---------------------- |\n| `uint` fileSize | Size of requested file |\n\n#### getFileStatus\n\n```solidity\nfunction getFileStatus(string memory storagePath) \n        public \n        view \n        returns (int)\n```\n\nReturns status of the requested file:\n\n-   0 - file does not exist\n-   1 - file is created but has not finished uploading\n-   2 - file is fully uploaded\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter         | Description              |\n| ----------------- | ------------------------ |\n| `uint` fileStatus | Status of requested file |\n\n### Directory interaction methods\n\nFilestorage is represented with UNIX-based filesystem that consisted of files and directories. Directories are stored in `Directory` structure that contains information about its content in `ContentInfo` structure. Maximum amount of content in separate directory is **8196**.\n\n#### createDirectory\n\n```solidity\nfunction createDirectory(string memory directoryPath)\n```\n\nCreates directory in Filestorage. Owner of the directory - message sender. \n\n-   Function is called by directory owner\n-   Maximum amount of directories and files in one directory is **8196**\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### deleteDirectory\n\n```solidity\nfunction deleteDirectory(string memory directoryPath)\n```\n\nDeletes directory from Filestorage.\n\n-   Function is called by directory owner\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### listDirectory\n\n```solidity\nfunction listDirectory(string memory storagePath) \n        public \n        view \n        returns (ContentInfo[])\n```\n\nList information about content of the specific directory.\n\n**Parameters:**\n\n| Parameter            | Description                               |\n| -------------------- | ----------------------------------------- |\n| `string` storagePath | Full path of the directory in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description                          |\n| --------------- | ------------------------------------ |\n| `ContentInfo[]` | Array of content stored in directory |\n\nObject `ContentInfo` can be file or directory and contains:\n\n| Field                    | Description                                                                      |\n| ------------------------ | -------------------------------------------------------------------------------- |\n| `string` name            | Content name                                                                     |\n| `bool` isFile            | Whether content is file                                                          |\n| `uint` size              | File size, in bytes                                                              |\n| `int` status             | File uploading status                                                            |\n| `bool[]` isChunkUploaded | Array with statuses of each chunk (`true` - chunk uploaded, `false` - otherwise) |\n\n## Build\n\nCreate an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nPRIVATEKEY='Private key for test account'\n```\n\nCompile `FileStorage.sol`:\n\n```bash\ntruffle compile\n```\n\n## Test\n\nTests run only on SKALE chains. Create an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nSCHAIN_OWNER_PK='Private key of SKALE endpoint owner (or account with money)'\nPRIVATEKEY='Private key for test account'\n```\n\nRun tests:\n\n```bash\ntruffle test --network skaled\n```\n","gitHead":"f4d260a85801796f27144ffde83bc386f13adff1","scripts":{"lint":"npx ethlint -d contracts","test":"npx truffle test test/unit/* --network skaled","build":"rm -r ./build; npx truffle build","compile":"npx truffle compile; cp build/contracts/FileStorage.json predeployed/filestorage_predeployed/artifacts/","slither":"slither . --filter-path strings --filter-path Migrations","version":"node -e \"console.log(require('./package.json').version);\"","coverage":"npx truffle run coverage --file=\"test/unit/*\"","lint-fix":"npm run lint -- --fix","predeployed-test":"npx truffle test test/predeployed/* --network skaled"},"_npmUser":{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},"repository":{"url":"git+https://github.com/skalenetwork/filestorage.git","type":"git"},"_npmVersion":"6.14.16","description":"SKALE Filestorage contracts","directories":{},"_nodeVersion":"14.19.1","dependencies":{"@openzeppelin/contracts-upgradeable":"^4.3.2"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"chai":"^4.2.0","web3":"^1.2.1","dotenv":"^8.2.0","codecov":"^3.3.0","truffle":"5.1.30","randomstring":"^1.1.5","chai-as-promised":"^7.1.1","solidity-coverage":"^0.7.17","@truffle/hdwallet-provider":"^1.5.1"},"_npmOperationalInternal":{"tmp":"tmp/filestorage_1.0.1-beta.1_1651318677824_0.6099349325912442","host":"s3://npm-registry-packages"}},"1.0.1-develop.12":{"name":"@skalenetwork/filestorage","version":"1.0.1-develop.12","keywords":["SKALE","blockchain","ethereum"],"author":{"name":"SKALE Labs and contributors"},"license":"AGPL-3.0","_id":"@skalenetwork/filestorage@1.0.1-develop.12","maintainers":[{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},{"name":"dmitrytk","email":"dmitry.tkachuk@skalelabs.com"},{"name":"cstrange","email":"chadwick@skalelabs.com"},{"name":"skalelabsdev","email":"dev@skalelabs.com"},{"name":"theskyunicorn","email":"christine@skalelabs.com"},{"name":"stebaev","email":"dimastebaev@gmail.com"},{"name":"l_sergiy","email":"sergiy@skalelabs.com"}],"homepage":"https://github.com/skalenetwork/filestorage#readme","bugs":{"url":"https://github.com/skalenetwork/filestorage/issues"},"dist":{"shasum":"088d3e5f008ce277cd414240e71997dc6b842e6a","tarball":"https://registry.npmjs.org/@skalenetwork/filestorage/-/filestorage-1.0.1-develop.12.tgz","fileCount":5,"integrity":"sha512-7Mldb4KDMdPBjsfGEI2w40TkAz6xnUrPJZ/9gJTG1yQ6Sh0B00ChQ6VcWkoJ+/rZIv2Brkq8RnGqhqaTrQFdMg==","signatures":[{"sig":"MEUCIBSrtstT+aOEPEcdPfFn55W+1PQ73lQHA25XSRhaV9JAAiEAi6ennvKKBetcRmKtXw6bzQEC13+MkhAsCnihfBjuRFA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":66032,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJihm55ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrmbA//WhcDG2AJQsjaPW3iTvNu+xyWrRgdC7qOpkolNx2XxZxPJip4\r\nL26dnQq3wO87VyXpbeO7QcaglSKHlpFYQOPfjueC3cUSK5IfTQDnJwAqReWO\r\nqChXoQk2+ppRQzWMgkz3LxI3F/bLhQCJ88h+MBuDjm/NBNosXzA6Eysiuvq5\r\npr6W1MeC2utXkxxQiw8PFw0fRoz00Qxnru5bN/D40ZwUo0D9LUKfkuQ3xPxx\r\nNuSlwX+P2YOlYORjjiBB4RlBr9PES7YTbTN9IH2p2u3Hdc1yRXsdZZ51PFY6\r\nEU8meWwkYN8fgQeqVH+4OZpxb91AiC2+YIRFXEDbyFZgjwZxdfzLv591hPHx\r\nB5jvthHIzo8mYgYGA9ZYHLZW4yBKRahaKcVtWHEKofmjRnaToxIk/BY8oTZ5\r\nwm/DwjXXIXflPHFzJQD53fbAXx0WprWMENVg6QkZqd56PnZikc/YN1QhYVcq\r\n7owpKPtSorq6K3f2GLSEYv0eg8x/Eww3ACXfxmxx0ewNtQST1XDjN7An/pq9\r\n6PyuSWFVyw0xpxB+bmh5sK+W7h+jQgM0lKGPvq3rGBWzUp2KYFQ8TSK83hCb\r\nJpbN8cR9crZRymXEyreufii5BZEkPV5++lI7IbK22PbX0YFoKGTXCWAjnrwv\r\nSz0kfGTOl5s9aH4V65besaanwBIcSrSBA6A=\r\n=mgJS\r\n-----END PGP SIGNATURE-----\r\n"},"main":"artifacts.json","readme":"# SKALE Filestorage\n\n[![Build Status](https://travis-ci.com/skalenetwork/filestorage.svg?token=HYnwEPctUzUdXVcsecA6&branch=develop)](https://travis-ci.com/skalenetwork/filestorage)\n[![codecov](https://codecov.io/gh/skalenetwork/filestorage/branch/develop/graph/badge.svg?token=2wkF3kZTXh)](https://codecov.io/gh/skalenetwork/filestorage)\n[![Discord](https://img.shields.io/discord/534485763354787851.svg)](https://discord.gg/vvUtWJB)\n\nFilestorage - smart contract, that controls decentralized file storage on SKALE chains.\n\n## Description\n\nFilestorage is a cost-effective storage layer within Ethereum capable of handling files up to 100MB. Filestorage uses UNIX-based filesystem of SKALE chains. Filestorage smart contract is a set of functions to interact with files on EVM. This contract may be predeployed on SKALE chains. It contains functions to work with Filestorage precompiled smart contracts. \n\nSmart contract language - Solidity 0.8.9\n\n## API Reference\n\n### Filestorage space handling \n\nTo start using Filestorage (upload/delete files and create/remove directories) the space should be allocated for specific account, it could be done from account that is given ALLOCATOR_ROLE. \nRules of occupying space in Filestorage:\n\n1. For directory **4096** bytes is taken\n2. File could be uploaded up to **100** MB (104857600 bytes)\n3. Occupying space for file is rounded up to the nearest multiple of **4096** bytes\n4. **Empty** file takes 4096 bytes of free space\n\nAfter deleting file/directory's amount of space is freed according to the rules above\n\n### Space handling API\n#### reserveSpace\n\n```solidity\nfunction reserveSpace(address userAddress, uint reservedSpace)\n```\n\nReserves the Filestorage space for specific address. Could be called only with ALLOCATOR_ROLE\n\n**Parameters:**\n\n| Parameter             | Description                           |\n| --------------------- | ------------------------------------- |\n| `address` userAddress | Address to allocate space for         |\n| `uint` reservedSpace  | Amount of space to reserve in bytes   |\n\n#### getTotalStorageSpace\n\n```solidity\nfunction getTotalStorageSpace()\n```\n\nGets total space in Filestorage in bytes.\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Space in bytes                     |\n\n#### getTotalReservedSpace\n\n```solidity\nfunction getTotalStorageSpace()\n```\n\nGets total reserved space in Filestorage in bytes.\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Space in bytes                     |\n\n#### getReservedSpace\n\n```solidity\nfunction getReservedSpace(address owner)\n```\n\nGets reserved space for account.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `address` owner      | Account address                      |\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Size of reserved space for account |\n\n#### getOccupiedSpace\n\n```solidity\nfunction getOccupiedSpace(address owner)\n```\n\nGets occupied space for account.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `address` owner      | Account address                      |\n\n**Returns:**\n\n| Parameter       | Description                                 |\n| --------------- | ------------------------------------------- |\n| `uint`          | Size of occupied space for account in bytes |\n\n### File interaction methods\n\nTo begin the uploading process, the file should be broken into chunks of 1MB (&lt; 1MB for the last chunk) which are uploaded as separate transactions to FileStorage.sol. \nThe pipeline of the uploading file is:\n\n1.  creating empty file of fixed size on EVM by calling `startUpload`,\n2.  uploading data chunk by chunk with `uploadChunk`,\n3.  checking the file validity and finishing process with `finishUpload`.\n\n#### startUpload\n\n```solidity\nfunction startUpload(string memory filePath, uint256 fileSize)\n```\n\nCreates empty file on EVM with specific name and size. Owner of the file - message sender. \n\n-   Function is called by file owner\n-   Maximum amount of directories and files in one directory is **8196**\n-   Maximum filesize is **100,000,000** bytes\n-   Owner should have enough free space\n\n**Parameters:**\n\n| Parameter          | Description                           |\n| ------------------ | ------------------------------------- |\n| `string` filePath  | Path to the file in account directory |\n| `uint256` fileSize | Uploaded file size in bytes           |\n\n#### uploadChunk\n\n```solidity\nfunction uploadChunk(string memory filePath, uint position, bytes memory data)\n```\n\nUploads 1MB chunk of data from specific position in specific file by file owner.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n| `uint` position   | Uploaded chunk position               |\n| `bytes` data      | Uploaded chunk data                   |\n\n#### finishUpload\n\n```solidity\nfunction finishUpload(string memory filePath)\n```\n\nFinishes uploading of the file. Checks whether all chunks are uploaded correctly.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### deleteFile\n\n```solidity\nfunction deleteFile(string memory filePath)\n```\n\nDeletes file from Filestorage.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### readChunk\n\n```solidity\nfunction readChunk(string memory storagePath, uint position, uint length)\n        public\n        view\n        returns (bytes32[MAX_BLOCK_COUNT] memory out)\n```\n\nReads chunk from file from specific position with specific length. Returns `bytes32` array of fixed size with requested data.\n\n-   Maximum length of the chunk to read is 1Mb\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n| `uint` position      | First byte to read from              |\n| `uint` length        | Uploaded chunk length                |\n\n**Returns:**\n\n| Parameter       | Description                                       |\n| --------------- | ------------------------------------------------- |\n| `bytes32[]` out | Requested chunk data split across `bytes32` array |\n\n#### getFileSize\n\n```solidity\nfunction getFileSize(string memory storagePath) \n        public \n        view \n        returns (uint fileSize)\n```\n\nGets size of the requested file in bytes.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description            |\n| --------------- | ---------------------- |\n| `uint` fileSize | Size of requested file |\n\n#### getFileStatus\n\n```solidity\nfunction getFileStatus(string memory storagePath) \n        public \n        view \n        returns (int)\n```\n\nReturns status of the requested file:\n\n-   0 - file does not exist\n-   1 - file is created but has not finished uploading\n-   2 - file is fully uploaded\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter         | Description              |\n| ----------------- | ------------------------ |\n| `uint` fileStatus | Status of requested file |\n\n### Directory interaction methods\n\nFilestorage is represented with UNIX-based filesystem that consisted of files and directories. Directories are stored in `Directory` structure that contains information about its content in `ContentInfo` structure. Maximum amount of content in separate directory is **8196**.\n\n#### createDirectory\n\n```solidity\nfunction createDirectory(string memory directoryPath)\n```\n\nCreates directory in Filestorage. Owner of the directory - message sender. \n\n-   Function is called by directory owner\n-   Maximum amount of directories and files in one directory is **8196**\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### deleteDirectory\n\n```solidity\nfunction deleteDirectory(string memory directoryPath)\n```\n\nDeletes directory from Filestorage.\n\n-   Function is called by directory owner\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### listDirectory\n\n```solidity\nfunction listDirectory(string memory storagePath) \n        public \n        view \n        returns (ContentInfo[])\n```\n\nList information about content of the specific directory.\n\n**Parameters:**\n\n| Parameter            | Description                               |\n| -------------------- | ----------------------------------------- |\n| `string` storagePath | Full path of the directory in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description                          |\n| --------------- | ------------------------------------ |\n| `ContentInfo[]` | Array of content stored in directory |\n\nObject `ContentInfo` can be file or directory and contains:\n\n| Field                    | Description                                                                      |\n| ------------------------ | -------------------------------------------------------------------------------- |\n| `string` name            | Content name                                                                     |\n| `bool` isFile            | Whether content is file                                                          |\n| `uint` size              | File size, in bytes                                                              |\n| `int` status             | File uploading status                                                            |\n| `bool[]` isChunkUploaded | Array with statuses of each chunk (`true` - chunk uploaded, `false` - otherwise) |\n\n## Build\n\nCreate an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nPRIVATEKEY='Private key for test account'\n```\n\nCompile `FileStorage.sol`:\n\n```bash\ntruffle compile\n```\n\n## Test\n\nTests run only on SKALE chains. Create an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nSCHAIN_OWNER_PK='Private key of SKALE endpoint owner (or account with money)'\nPRIVATEKEY='Private key for test account'\n```\n\nRun tests:\n\n```bash\ntruffle test --network skaled\n```\n","gitHead":"4ea6912d919b120489157dbd17fbfbf9b97d9d5e","scripts":{"lint":"npx ethlint -d contracts","test":"npx truffle test test/unit/* --network skaled","build":"rm -r ./build; npx truffle build","compile":"npx truffle compile; cp build/contracts/FileStorage.json predeployed/filestorage_predeployed/artifacts/","slither":"slither . --filter-path strings --filter-path Migrations","version":"node -e \"console.log(require('./package.json').version);\"","coverage":"npx truffle run coverage --file=\"test/unit/*\"","lint-fix":"npm run lint -- --fix","predeployed-test":"npx truffle test test/predeployed/* --network skaled"},"_npmUser":{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},"repository":{"url":"git+https://github.com/skalenetwork/filestorage.git","type":"git"},"_npmVersion":"6.14.17","description":"SKALE Filestorage contracts","directories":{},"_nodeVersion":"14.19.2","dependencies":{"@openzeppelin/contracts-upgradeable":"^4.3.2"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"chai":"^4.2.0","web3":"^1.2.1","dotenv":"^8.2.0","codecov":"^3.3.0","truffle":"5.1.30","randomstring":"^1.1.5","chai-as-promised":"^7.1.1","solidity-coverage":"^0.7.17","@truffle/hdwallet-provider":"^1.5.1"},"_npmOperationalInternal":{"tmp":"tmp/filestorage_1.0.1-develop.12_1652977273613_0.739964151531755","host":"s3://npm-registry-packages"}},"1.0.1-develop.13":{"name":"@skalenetwork/filestorage","version":"1.0.1-develop.13","keywords":["SKALE","blockchain","ethereum"],"author":{"name":"SKALE Labs and contributors"},"license":"AGPL-3.0","_id":"@skalenetwork/filestorage@1.0.1-develop.13","maintainers":[{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},{"name":"dmitrytk","email":"dmitry.tkachuk@skalelabs.com"},{"name":"cstrange","email":"chadwick@skalelabs.com"},{"name":"skalelabsdev","email":"dev@skalelabs.com"},{"name":"theskyunicorn","email":"christine@skalelabs.com"},{"name":"stebaev","email":"dimastebaev@gmail.com"},{"name":"l_sergiy","email":"sergiy@skalelabs.com"}],"homepage":"https://github.com/skalenetwork/filestorage#readme","bugs":{"url":"https://github.com/skalenetwork/filestorage/issues"},"dist":{"shasum":"59c00e97dccca807c7aa8e7f7fd9f0155a778219","tarball":"https://registry.npmjs.org/@skalenetwork/filestorage/-/filestorage-1.0.1-develop.13.tgz","fileCount":5,"integrity":"sha512-tprFk1eCH6+T9nsypMjmdXvPBCqWcOgFmd5lDrBnvetrlgabu77V3ezGXmg/nveSC2cgePG+nzY/is8qPsZZmQ==","signatures":[{"sig":"MEYCIQC1648k0WUHK7fiIULcI9/4pefPVK9jxEm7hrjt3AAh0AIhAJKMsdbPy74wPJTJFQA6F2SfsfCGhQZw3+itvZ/URFJS","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":66032,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJihnDgACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrgiA/7BjKAaxyo2Wmjre6+F1FnZF8+0Nv/EShNP58947cnskBRmsH+\r\nTibgjq7F73Ka41ZGRrBqw2XakSZWvHNzoh08LkDK45t8PMPB1GQYaat7Txvc\r\nnWbav6jl9bHPPZT53A6ynOjuIbHyw9B0x6zn0lHORns7LM11VyMD1ilPTnH2\r\nyZeJ9ZprcjSHpJDjJQ1WL9qmrUnlIfc8DiXWWZgVgKdyrvm4pKE12MBq5smL\r\nxa6hjquPFZZANLsyEyIaRTHHo59/Gn7+EB5ossS9JPc7fGIioyyV8YSdlkNs\r\nDkpnJF0r0a7CGuRBfBT51ZjvRi+65lSz0PobRx6BxCR1tp4vhQr5XLhyIl2P\r\nSShASlg++mDfXRN5PbSlWvt49wQb1LMRCYT4/z8ykBnUP3Q0FzjdwOBSBQCS\r\nhEK59fOytu67W1fuIKgnQ9ha7paQGTt6hAXLF2gb23p9PwKDTMegvrnyKVB4\r\nz4hdi8TW+x0PhJN3yMGSQ8za/tXsBOh4Qe6JRwizffz/slj/KOmmYqvq/adW\r\nDm4ZhxAX8aD1DoZEvBKl2vrxuQ2GP2Y70V/q1qd0c1zEpk8rbqd5vfmqFCZx\r\nBVV/tTLXgA6OBE9vAFg/06xL9Yjl5Yx5lguPkqhf2s6jTkYGm/+ntUSfIyyh\r\nbZwSX5CdbNh5lWpHOofsdlsB1oA9p9v8E8A=\r\n=QhVF\r\n-----END PGP SIGNATURE-----\r\n"},"main":"artifacts.json","readme":"# SKALE Filestorage\n\n[![Build Status](https://travis-ci.com/skalenetwork/filestorage.svg?token=HYnwEPctUzUdXVcsecA6&branch=develop)](https://travis-ci.com/skalenetwork/filestorage)\n[![codecov](https://codecov.io/gh/skalenetwork/filestorage/branch/develop/graph/badge.svg?token=2wkF3kZTXh)](https://codecov.io/gh/skalenetwork/filestorage)\n[![Discord](https://img.shields.io/discord/534485763354787851.svg)](https://discord.gg/vvUtWJB)\n\nFilestorage - smart contract, that controls decentralized file storage on SKALE chains.\n\n## Description\n\nFilestorage is a cost-effective storage layer within Ethereum capable of handling files up to 100MB. Filestorage uses UNIX-based filesystem of SKALE chains. Filestorage smart contract is a set of functions to interact with files on EVM. This contract may be predeployed on SKALE chains. It contains functions to work with Filestorage precompiled smart contracts. \n\nSmart contract language - Solidity 0.8.9\n\n## API Reference\n\n### Filestorage space handling \n\nTo start using Filestorage (upload/delete files and create/remove directories) the space should be allocated for specific account, it could be done from account that is given ALLOCATOR_ROLE. \nRules of occupying space in Filestorage:\n\n1. For directory **4096** bytes is taken\n2. File could be uploaded up to **100** MB (104857600 bytes)\n3. Occupying space for file is rounded up to the nearest multiple of **4096** bytes\n4. **Empty** file takes 4096 bytes of free space\n\nAfter deleting file/directory's amount of space is freed according to the rules above\n\n### Space handling API\n#### reserveSpace\n\n```solidity\nfunction reserveSpace(address userAddress, uint reservedSpace)\n```\n\nReserves the Filestorage space for specific address. Could be called only with ALLOCATOR_ROLE\n\n**Parameters:**\n\n| Parameter             | Description                           |\n| --------------------- | ------------------------------------- |\n| `address` userAddress | Address to allocate space for         |\n| `uint` reservedSpace  | Amount of space to reserve in bytes   |\n\n#### getTotalStorageSpace\n\n```solidity\nfunction getTotalStorageSpace()\n```\n\nGets total space in Filestorage in bytes.\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Space in bytes                     |\n\n#### getTotalReservedSpace\n\n```solidity\nfunction getTotalStorageSpace()\n```\n\nGets total reserved space in Filestorage in bytes.\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Space in bytes                     |\n\n#### getReservedSpace\n\n```solidity\nfunction getReservedSpace(address owner)\n```\n\nGets reserved space for account.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `address` owner      | Account address                      |\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Size of reserved space for account |\n\n#### getOccupiedSpace\n\n```solidity\nfunction getOccupiedSpace(address owner)\n```\n\nGets occupied space for account.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `address` owner      | Account address                      |\n\n**Returns:**\n\n| Parameter       | Description                                 |\n| --------------- | ------------------------------------------- |\n| `uint`          | Size of occupied space for account in bytes |\n\n### File interaction methods\n\nTo begin the uploading process, the file should be broken into chunks of 1MB (&lt; 1MB for the last chunk) which are uploaded as separate transactions to FileStorage.sol. \nThe pipeline of the uploading file is:\n\n1.  creating empty file of fixed size on EVM by calling `startUpload`,\n2.  uploading data chunk by chunk with `uploadChunk`,\n3.  checking the file validity and finishing process with `finishUpload`.\n\n#### startUpload\n\n```solidity\nfunction startUpload(string memory filePath, uint256 fileSize)\n```\n\nCreates empty file on EVM with specific name and size. Owner of the file - message sender. \n\n-   Function is called by file owner\n-   Maximum amount of directories and files in one directory is **8196**\n-   Maximum filesize is **100,000,000** bytes\n-   Owner should have enough free space\n\n**Parameters:**\n\n| Parameter          | Description                           |\n| ------------------ | ------------------------------------- |\n| `string` filePath  | Path to the file in account directory |\n| `uint256` fileSize | Uploaded file size in bytes           |\n\n#### uploadChunk\n\n```solidity\nfunction uploadChunk(string memory filePath, uint position, bytes memory data)\n```\n\nUploads 1MB chunk of data from specific position in specific file by file owner.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n| `uint` position   | Uploaded chunk position               |\n| `bytes` data      | Uploaded chunk data                   |\n\n#### finishUpload\n\n```solidity\nfunction finishUpload(string memory filePath)\n```\n\nFinishes uploading of the file. Checks whether all chunks are uploaded correctly.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### deleteFile\n\n```solidity\nfunction deleteFile(string memory filePath)\n```\n\nDeletes file from Filestorage.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### readChunk\n\n```solidity\nfunction readChunk(string memory storagePath, uint position, uint length)\n        public\n        view\n        returns (bytes32[MAX_BLOCK_COUNT] memory out)\n```\n\nReads chunk from file from specific position with specific length. Returns `bytes32` array of fixed size with requested data.\n\n-   Maximum length of the chunk to read is 1Mb\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n| `uint` position      | First byte to read from              |\n| `uint` length        | Uploaded chunk length                |\n\n**Returns:**\n\n| Parameter       | Description                                       |\n| --------------- | ------------------------------------------------- |\n| `bytes32[]` out | Requested chunk data split across `bytes32` array |\n\n#### getFileSize\n\n```solidity\nfunction getFileSize(string memory storagePath) \n        public \n        view \n        returns (uint fileSize)\n```\n\nGets size of the requested file in bytes.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description            |\n| --------------- | ---------------------- |\n| `uint` fileSize | Size of requested file |\n\n#### getFileStatus\n\n```solidity\nfunction getFileStatus(string memory storagePath) \n        public \n        view \n        returns (int)\n```\n\nReturns status of the requested file:\n\n-   0 - file does not exist\n-   1 - file is created but has not finished uploading\n-   2 - file is fully uploaded\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter         | Description              |\n| ----------------- | ------------------------ |\n| `uint` fileStatus | Status of requested file |\n\n### Directory interaction methods\n\nFilestorage is represented with UNIX-based filesystem that consisted of files and directories. Directories are stored in `Directory` structure that contains information about its content in `ContentInfo` structure. Maximum amount of content in separate directory is **8196**.\n\n#### createDirectory\n\n```solidity\nfunction createDirectory(string memory directoryPath)\n```\n\nCreates directory in Filestorage. Owner of the directory - message sender. \n\n-   Function is called by directory owner\n-   Maximum amount of directories and files in one directory is **8196**\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### deleteDirectory\n\n```solidity\nfunction deleteDirectory(string memory directoryPath)\n```\n\nDeletes directory from Filestorage.\n\n-   Function is called by directory owner\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### listDirectory\n\n```solidity\nfunction listDirectory(string memory storagePath) \n        public \n        view \n        returns (ContentInfo[])\n```\n\nList information about content of the specific directory.\n\n**Parameters:**\n\n| Parameter            | Description                               |\n| -------------------- | ----------------------------------------- |\n| `string` storagePath | Full path of the directory in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description                          |\n| --------------- | ------------------------------------ |\n| `ContentInfo[]` | Array of content stored in directory |\n\nObject `ContentInfo` can be file or directory and contains:\n\n| Field                    | Description                                                                      |\n| ------------------------ | -------------------------------------------------------------------------------- |\n| `string` name            | Content name                                                                     |\n| `bool` isFile            | Whether content is file                                                          |\n| `uint` size              | File size, in bytes                                                              |\n| `int` status             | File uploading status                                                            |\n| `bool[]` isChunkUploaded | Array with statuses of each chunk (`true` - chunk uploaded, `false` - otherwise) |\n\n## Build\n\nCreate an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nPRIVATEKEY='Private key for test account'\n```\n\nCompile `FileStorage.sol`:\n\n```bash\ntruffle compile\n```\n\n## Test\n\nTests run only on SKALE chains. Create an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nSCHAIN_OWNER_PK='Private key of SKALE endpoint owner (or account with money)'\nPRIVATEKEY='Private key for test account'\n```\n\nRun tests:\n\n```bash\ntruffle test --network skaled\n```\n","gitHead":"d8adfaa4adc3ebf1c409263f82390cf1eab093e8","scripts":{"lint":"npx ethlint -d contracts","test":"npx truffle test test/unit/* --network skaled","build":"rm -r ./build; npx truffle build","compile":"npx truffle compile; cp build/contracts/FileStorage.json predeployed/filestorage_predeployed/artifacts/","slither":"slither . --filter-path strings --filter-path Migrations","version":"node -e \"console.log(require('./package.json').version);\"","coverage":"npx truffle run coverage --file=\"test/unit/*\"","lint-fix":"npm run lint -- --fix","predeployed-test":"npx truffle test test/predeployed/* --network skaled"},"_npmUser":{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},"repository":{"url":"git+https://github.com/skalenetwork/filestorage.git","type":"git"},"_npmVersion":"6.14.17","description":"SKALE Filestorage contracts","directories":{},"_nodeVersion":"14.19.2","dependencies":{"@openzeppelin/contracts-upgradeable":"^4.3.2"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"chai":"^4.2.0","web3":"^1.2.1","dotenv":"^8.2.0","codecov":"^3.3.0","truffle":"5.1.30","randomstring":"^1.1.5","chai-as-promised":"^7.1.1","solidity-coverage":"^0.7.17","@truffle/hdwallet-provider":"^1.5.1"},"_npmOperationalInternal":{"tmp":"tmp/filestorage_1.0.1-develop.13_1652977888471_0.13859928941436372","host":"s3://npm-registry-packages"}},"1.0.1-beta.2":{"name":"@skalenetwork/filestorage","version":"1.0.1-beta.2","keywords":["SKALE","blockchain","ethereum"],"author":{"name":"SKALE Labs and contributors"},"license":"AGPL-3.0","_id":"@skalenetwork/filestorage@1.0.1-beta.2","maintainers":[{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},{"name":"dmitrytk","email":"dmitry.tkachuk@skalelabs.com"},{"name":"cstrange","email":"chadwick@skalelabs.com"},{"name":"skalelabsdev","email":"dev@skalelabs.com"},{"name":"theskyunicorn","email":"christine@skalelabs.com"},{"name":"stebaev","email":"dimastebaev@gmail.com"},{"name":"l_sergiy","email":"sergiy@skalelabs.com"}],"homepage":"https://github.com/skalenetwork/filestorage#readme","bugs":{"url":"https://github.com/skalenetwork/filestorage/issues"},"dist":{"shasum":"bb2941e9d274149fcb1b5a11954e0cdec1aac204","tarball":"https://registry.npmjs.org/@skalenetwork/filestorage/-/filestorage-1.0.1-beta.2.tgz","fileCount":5,"integrity":"sha512-84ib/f+MuGbevdwjRNqx3FwJJnPf0tFTKPxRtHJ5NIsRSfAtXv8yNShEdzx2B3bXGxik17oqemdss2d2n0Phwg==","signatures":[{"sig":"MEQCIDXQjZc87Vr+DBgo1gr6mwFYNaUnaqPZeA0oOGC1QQO7AiAnDsIO63RE5l/QTgGPAT/FRhgnkY2yPcFC8VeYJDRyfw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":66028,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJihnL1ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrOag//fZw9yb1j1lq1hclAuU/8F+CJ2eKgXmjD8dynl6zu/X0GUa/O\r\nx+w2at87rPE+6qxvcpCvd74Aj+O2LqBUTx2dfTsOXWIt/9z5iI9hon4iGUfD\r\nJC7FuSlPrCpfFJqTpX96z9auubXcYv1jUgf+S/yJjVEtdzOzzPC+y0ikzT+b\r\nRY83fETgIUU7VFmIT6+7d916RatuMf/x9HLQ5An9DbKsSH2T7PbHz4p6p51P\r\n4+D8YBwiCry1rrRYNPH60xgu+h/NqJxEJxE3Ue+DWV+LazG9aoXxFPnRmDiV\r\npvEsMrC2R5TU7gvr+FFkgdMG9bueuHA5QwFypZLJZLewkbNuvEYX2g6dVYeg\r\nCEvHmEcUfRPlNMPVYpr61aFwKPoPtJyR6qXhFIHmyN4NQSuH6VeLfH7ZDaot\r\nZu88clv1tbr9++72UDi36C7yb7ICXwr/OOgycD93Cvd94m6gf1vu52sv2I7M\r\nW2+2QR06VrphNNGqZfU7Z/r8PITTh8m4vg6KbOfvc+LASwANM03FE95Nvma8\r\n2jita3Kc1pxKoQELYd9aMUzJmSw2PrXbiKBx5IMkH2SeTb6C01njEcAvPgPZ\r\n9JkNceELh/BLBhZuDufIXCzMvsnqIoJd8kcjHpLaQTUqb4GYN/U8KBoEJS5K\r\nBxrwRr9AsLbw0tALXh4ugRACqofIEp5TLxc=\r\n=D4MW\r\n-----END PGP SIGNATURE-----\r\n"},"main":"artifacts.json","readme":"# SKALE Filestorage\n\n[![Build Status](https://travis-ci.com/skalenetwork/filestorage.svg?token=HYnwEPctUzUdXVcsecA6&branch=develop)](https://travis-ci.com/skalenetwork/filestorage)\n[![codecov](https://codecov.io/gh/skalenetwork/filestorage/branch/develop/graph/badge.svg?token=2wkF3kZTXh)](https://codecov.io/gh/skalenetwork/filestorage)\n[![Discord](https://img.shields.io/discord/534485763354787851.svg)](https://discord.gg/vvUtWJB)\n\nFilestorage - smart contract, that controls decentralized file storage on SKALE chains.\n\n## Description\n\nFilestorage is a cost-effective storage layer within Ethereum capable of handling files up to 100MB. Filestorage uses UNIX-based filesystem of SKALE chains. Filestorage smart contract is a set of functions to interact with files on EVM. This contract may be predeployed on SKALE chains. It contains functions to work with Filestorage precompiled smart contracts. \n\nSmart contract language - Solidity 0.8.9\n\n## API Reference\n\n### Filestorage space handling \n\nTo start using Filestorage (upload/delete files and create/remove directories) the space should be allocated for specific account, it could be done from account that is given ALLOCATOR_ROLE. \nRules of occupying space in Filestorage:\n\n1. For directory **4096** bytes is taken\n2. File could be uploaded up to **100** MB (104857600 bytes)\n3. Occupying space for file is rounded up to the nearest multiple of **4096** bytes\n4. **Empty** file takes 4096 bytes of free space\n\nAfter deleting file/directory's amount of space is freed according to the rules above\n\n### Space handling API\n#### reserveSpace\n\n```solidity\nfunction reserveSpace(address userAddress, uint reservedSpace)\n```\n\nReserves the Filestorage space for specific address. Could be called only with ALLOCATOR_ROLE\n\n**Parameters:**\n\n| Parameter             | Description                           |\n| --------------------- | ------------------------------------- |\n| `address` userAddress | Address to allocate space for         |\n| `uint` reservedSpace  | Amount of space to reserve in bytes   |\n\n#### getTotalStorageSpace\n\n```solidity\nfunction getTotalStorageSpace()\n```\n\nGets total space in Filestorage in bytes.\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Space in bytes                     |\n\n#### getTotalReservedSpace\n\n```solidity\nfunction getTotalStorageSpace()\n```\n\nGets total reserved space in Filestorage in bytes.\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Space in bytes                     |\n\n#### getReservedSpace\n\n```solidity\nfunction getReservedSpace(address owner)\n```\n\nGets reserved space for account.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `address` owner      | Account address                      |\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Size of reserved space for account |\n\n#### getOccupiedSpace\n\n```solidity\nfunction getOccupiedSpace(address owner)\n```\n\nGets occupied space for account.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `address` owner      | Account address                      |\n\n**Returns:**\n\n| Parameter       | Description                                 |\n| --------------- | ------------------------------------------- |\n| `uint`          | Size of occupied space for account in bytes |\n\n### File interaction methods\n\nTo begin the uploading process, the file should be broken into chunks of 1MB (&lt; 1MB for the last chunk) which are uploaded as separate transactions to FileStorage.sol. \nThe pipeline of the uploading file is:\n\n1.  creating empty file of fixed size on EVM by calling `startUpload`,\n2.  uploading data chunk by chunk with `uploadChunk`,\n3.  checking the file validity and finishing process with `finishUpload`.\n\n#### startUpload\n\n```solidity\nfunction startUpload(string memory filePath, uint256 fileSize)\n```\n\nCreates empty file on EVM with specific name and size. Owner of the file - message sender. \n\n-   Function is called by file owner\n-   Maximum amount of directories and files in one directory is **8196**\n-   Maximum filesize is **100,000,000** bytes\n-   Owner should have enough free space\n\n**Parameters:**\n\n| Parameter          | Description                           |\n| ------------------ | ------------------------------------- |\n| `string` filePath  | Path to the file in account directory |\n| `uint256` fileSize | Uploaded file size in bytes           |\n\n#### uploadChunk\n\n```solidity\nfunction uploadChunk(string memory filePath, uint position, bytes memory data)\n```\n\nUploads 1MB chunk of data from specific position in specific file by file owner.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n| `uint` position   | Uploaded chunk position               |\n| `bytes` data      | Uploaded chunk data                   |\n\n#### finishUpload\n\n```solidity\nfunction finishUpload(string memory filePath)\n```\n\nFinishes uploading of the file. Checks whether all chunks are uploaded correctly.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### deleteFile\n\n```solidity\nfunction deleteFile(string memory filePath)\n```\n\nDeletes file from Filestorage.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### readChunk\n\n```solidity\nfunction readChunk(string memory storagePath, uint position, uint length)\n        public\n        view\n        returns (bytes32[MAX_BLOCK_COUNT] memory out)\n```\n\nReads chunk from file from specific position with specific length. Returns `bytes32` array of fixed size with requested data.\n\n-   Maximum length of the chunk to read is 1Mb\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n| `uint` position      | First byte to read from              |\n| `uint` length        | Uploaded chunk length                |\n\n**Returns:**\n\n| Parameter       | Description                                       |\n| --------------- | ------------------------------------------------- |\n| `bytes32[]` out | Requested chunk data split across `bytes32` array |\n\n#### getFileSize\n\n```solidity\nfunction getFileSize(string memory storagePath) \n        public \n        view \n        returns (uint fileSize)\n```\n\nGets size of the requested file in bytes.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description            |\n| --------------- | ---------------------- |\n| `uint` fileSize | Size of requested file |\n\n#### getFileStatus\n\n```solidity\nfunction getFileStatus(string memory storagePath) \n        public \n        view \n        returns (int)\n```\n\nReturns status of the requested file:\n\n-   0 - file does not exist\n-   1 - file is created but has not finished uploading\n-   2 - file is fully uploaded\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter         | Description              |\n| ----------------- | ------------------------ |\n| `uint` fileStatus | Status of requested file |\n\n### Directory interaction methods\n\nFilestorage is represented with UNIX-based filesystem that consisted of files and directories. Directories are stored in `Directory` structure that contains information about its content in `ContentInfo` structure. Maximum amount of content in separate directory is **8196**.\n\n#### createDirectory\n\n```solidity\nfunction createDirectory(string memory directoryPath)\n```\n\nCreates directory in Filestorage. Owner of the directory - message sender. \n\n-   Function is called by directory owner\n-   Maximum amount of directories and files in one directory is **8196**\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### deleteDirectory\n\n```solidity\nfunction deleteDirectory(string memory directoryPath)\n```\n\nDeletes directory from Filestorage.\n\n-   Function is called by directory owner\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### listDirectory\n\n```solidity\nfunction listDirectory(string memory storagePath) \n        public \n        view \n        returns (ContentInfo[])\n```\n\nList information about content of the specific directory.\n\n**Parameters:**\n\n| Parameter            | Description                               |\n| -------------------- | ----------------------------------------- |\n| `string` storagePath | Full path of the directory in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description                          |\n| --------------- | ------------------------------------ |\n| `ContentInfo[]` | Array of content stored in directory |\n\nObject `ContentInfo` can be file or directory and contains:\n\n| Field                    | Description                                                                      |\n| ------------------------ | -------------------------------------------------------------------------------- |\n| `string` name            | Content name                                                                     |\n| `bool` isFile            | Whether content is file                                                          |\n| `uint` size              | File size, in bytes                                                              |\n| `int` status             | File uploading status                                                            |\n| `bool[]` isChunkUploaded | Array with statuses of each chunk (`true` - chunk uploaded, `false` - otherwise) |\n\n## Build\n\nCreate an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nPRIVATEKEY='Private key for test account'\n```\n\nCompile `FileStorage.sol`:\n\n```bash\ntruffle compile\n```\n\n## Test\n\nTests run only on SKALE chains. Create an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nSCHAIN_OWNER_PK='Private key of SKALE endpoint owner (or account with money)'\nPRIVATEKEY='Private key for test account'\n```\n\nRun tests:\n\n```bash\ntruffle test --network skaled\n```\n","gitHead":"0f8954f3b4b566d259e1d438541afb87aaa43653","scripts":{"lint":"npx ethlint -d contracts","test":"npx truffle test test/unit/* --network skaled","build":"rm -r ./build; npx truffle build","compile":"npx truffle compile; cp build/contracts/FileStorage.json predeployed/filestorage_predeployed/artifacts/","slither":"slither . --filter-path strings --filter-path Migrations","version":"node -e \"console.log(require('./package.json').version);\"","coverage":"npx truffle run coverage --file=\"test/unit/*\"","lint-fix":"npm run lint -- --fix","predeployed-test":"npx truffle test test/predeployed/* --network skaled"},"_npmUser":{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},"repository":{"url":"git+https://github.com/skalenetwork/filestorage.git","type":"git"},"_npmVersion":"6.14.17","description":"SKALE Filestorage contracts","directories":{},"_nodeVersion":"14.19.2","dependencies":{"@openzeppelin/contracts-upgradeable":"^4.3.2"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"chai":"^4.2.0","web3":"^1.2.1","dotenv":"^8.2.0","codecov":"^3.3.0","truffle":"5.1.30","randomstring":"^1.1.5","chai-as-promised":"^7.1.1","solidity-coverage":"^0.7.17","@truffle/hdwallet-provider":"^1.5.1"},"_npmOperationalInternal":{"tmp":"tmp/filestorage_1.0.1-beta.2_1652978421636_0.4602062528651538","host":"s3://npm-registry-packages"}},"1.0.1-develop.14":{"name":"@skalenetwork/filestorage","version":"1.0.1-develop.14","keywords":["SKALE","blockchain","ethereum"],"author":{"name":"SKALE Labs and contributors"},"license":"AGPL-3.0","_id":"@skalenetwork/filestorage@1.0.1-develop.14","maintainers":[{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},{"name":"dmitrytk","email":"dmitry.tkachuk@skalelabs.com"},{"name":"cstrange","email":"chadwick@skalelabs.com"},{"name":"skalelabsdev","email":"dev@skalelabs.com"},{"name":"theskyunicorn","email":"christine@skalelabs.com"},{"name":"stebaev","email":"dimastebaev@gmail.com"},{"name":"l_sergiy","email":"sergiy@skalelabs.com"}],"homepage":"https://github.com/skalenetwork/filestorage#readme","bugs":{"url":"https://github.com/skalenetwork/filestorage/issues"},"dist":{"shasum":"39ae8a96ce1494a6f768d94d85d368eb88d2678b","tarball":"https://registry.npmjs.org/@skalenetwork/filestorage/-/filestorage-1.0.1-develop.14.tgz","fileCount":5,"integrity":"sha512-gR3Ap3bESrKOcL0slQkwGRosTxoBcgnogmlzTm4FUPENOcHbnTTVOlUSkyoZXQBFkIv/83GKNZygI+z/gz2YoQ==","signatures":[{"sig":"MEUCIH87Cx4EaXFM0mmqK6azmuFbKWknqM7sEALJwW9s1/fzAiEAj/vSFV+qZ08Xy3nriEdEO+7UblNlBvKzlckya4dKoOY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":66032,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiho2HACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpY1w/9FesbEc8dKDLlfXzHQt9bdtPqJ/vI6ybnJI6N7bQw0NRig192\r\npOIzCj0P4m8ibxTZqdm/dfwQbNSj24YNogh9ONZ+OUr9AjOAku/Z1vHOMrWv\r\n/je35Hm4pnEWwrBVMYdYnFT1swRdJpAZLlg6b8f9ajDyO98ft2hqufWmxMp9\r\nIgGyXRgInlY5d450r5VtzwOgHisscJGebPbTsWpRRuxVD1FLlENWxKYICjV9\r\nPnsBV0L294Cxi98bYM960TjjkgwP7chczmwX/89UjEvxi0qMJrG1sVdj4lfz\r\nPGbpFoarSmEwuB7JUDbscGG9HslDSNDxD2j0DBDJ30lERKX16kKiaZr3LgPV\r\nULzy7yiulqBE7JFoOUYtyiTJq6Z8/HxB6+JchRn9R3Mf2oY5XJhO5yhVzTI/\r\n95gYANOOxjVAbftWY1SL3Fu5R8ZYxht9x2AsSAW2zCaWymsbFgD6vQTwsncG\r\nwbrJDucLuIESKM8e6a1nBTHb0/12bErZgmBeL5/A01A609bOlExjomFmB7gk\r\nLt/+pez5eAnM3MHlyf0oKZqBNjWXxXioi8ECfDyLcSAe1T1DvIlfOqP4OIGq\r\ngFW9iX7TNJ/32Rd6+D3PsFyMwDNCyiKfgJ9WxIDBn2bUHGbO+5tRmzBNyyDc\r\n8AyGLiNHZsg/2Wmm+F0vX6jXH1rhaTHE0RQ=\r\n=ZduH\r\n-----END PGP SIGNATURE-----\r\n"},"main":"artifacts.json","readme":"# SKALE Filestorage\n\n[![Build Status](https://travis-ci.com/skalenetwork/filestorage.svg?token=HYnwEPctUzUdXVcsecA6&branch=develop)](https://travis-ci.com/skalenetwork/filestorage)\n[![codecov](https://codecov.io/gh/skalenetwork/filestorage/branch/develop/graph/badge.svg?token=2wkF3kZTXh)](https://codecov.io/gh/skalenetwork/filestorage)\n[![Discord](https://img.shields.io/discord/534485763354787851.svg)](https://discord.gg/vvUtWJB)\n\nFilestorage - smart contract, that controls decentralized file storage on SKALE chains.\n\n## Description\n\nFilestorage is a cost-effective storage layer within Ethereum capable of handling files up to 100MB. Filestorage uses UNIX-based filesystem of SKALE chains. Filestorage smart contract is a set of functions to interact with files on EVM. This contract may be predeployed on SKALE chains. It contains functions to work with Filestorage precompiled smart contracts. \n\nSmart contract language - Solidity 0.8.9\n\n## API Reference\n\n### Filestorage space handling \n\nTo start using Filestorage (upload/delete files and create/remove directories) the space should be allocated for specific account, it could be done from account that is given ALLOCATOR_ROLE. \nRules of occupying space in Filestorage:\n\n1. For directory **4096** bytes is taken\n2. File could be uploaded up to **100** MB (104857600 bytes)\n3. Occupying space for file is rounded up to the nearest multiple of **4096** bytes\n4. **Empty** file takes 4096 bytes of free space\n\nAfter deleting file/directory's amount of space is freed according to the rules above\n\n### Space handling API\n#### reserveSpace\n\n```solidity\nfunction reserveSpace(address userAddress, uint reservedSpace)\n```\n\nReserves the Filestorage space for specific address. Could be called only with ALLOCATOR_ROLE\n\n**Parameters:**\n\n| Parameter             | Description                           |\n| --------------------- | ------------------------------------- |\n| `address` userAddress | Address to allocate space for         |\n| `uint` reservedSpace  | Amount of space to reserve in bytes   |\n\n#### getTotalStorageSpace\n\n```solidity\nfunction getTotalStorageSpace()\n```\n\nGets total space in Filestorage in bytes.\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Space in bytes                     |\n\n#### getTotalReservedSpace\n\n```solidity\nfunction getTotalStorageSpace()\n```\n\nGets total reserved space in Filestorage in bytes.\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Space in bytes                     |\n\n#### getReservedSpace\n\n```solidity\nfunction getReservedSpace(address owner)\n```\n\nGets reserved space for account.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `address` owner      | Account address                      |\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Size of reserved space for account |\n\n#### getOccupiedSpace\n\n```solidity\nfunction getOccupiedSpace(address owner)\n```\n\nGets occupied space for account.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `address` owner      | Account address                      |\n\n**Returns:**\n\n| Parameter       | Description                                 |\n| --------------- | ------------------------------------------- |\n| `uint`          | Size of occupied space for account in bytes |\n\n### File interaction methods\n\nTo begin the uploading process, the file should be broken into chunks of 1MB (&lt; 1MB for the last chunk) which are uploaded as separate transactions to FileStorage.sol. \nThe pipeline of the uploading file is:\n\n1.  creating empty file of fixed size on EVM by calling `startUpload`,\n2.  uploading data chunk by chunk with `uploadChunk`,\n3.  checking the file validity and finishing process with `finishUpload`.\n\n#### startUpload\n\n```solidity\nfunction startUpload(string memory filePath, uint256 fileSize)\n```\n\nCreates empty file on EVM with specific name and size. Owner of the file - message sender. \n\n-   Function is called by file owner\n-   Maximum amount of directories and files in one directory is **8196**\n-   Maximum filesize is **100,000,000** bytes\n-   Owner should have enough free space\n\n**Parameters:**\n\n| Parameter          | Description                           |\n| ------------------ | ------------------------------------- |\n| `string` filePath  | Path to the file in account directory |\n| `uint256` fileSize | Uploaded file size in bytes           |\n\n#### uploadChunk\n\n```solidity\nfunction uploadChunk(string memory filePath, uint position, bytes memory data)\n```\n\nUploads 1MB chunk of data from specific position in specific file by file owner.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n| `uint` position   | Uploaded chunk position               |\n| `bytes` data      | Uploaded chunk data                   |\n\n#### finishUpload\n\n```solidity\nfunction finishUpload(string memory filePath)\n```\n\nFinishes uploading of the file. Checks whether all chunks are uploaded correctly.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### deleteFile\n\n```solidity\nfunction deleteFile(string memory filePath)\n```\n\nDeletes file from Filestorage.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### readChunk\n\n```solidity\nfunction readChunk(string memory storagePath, uint position, uint length)\n        public\n        view\n        returns (bytes32[MAX_BLOCK_COUNT] memory out)\n```\n\nReads chunk from file from specific position with specific length. Returns `bytes32` array of fixed size with requested data.\n\n-   Maximum length of the chunk to read is 1Mb\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n| `uint` position      | First byte to read from              |\n| `uint` length        | Uploaded chunk length                |\n\n**Returns:**\n\n| Parameter       | Description                                       |\n| --------------- | ------------------------------------------------- |\n| `bytes32[]` out | Requested chunk data split across `bytes32` array |\n\n#### getFileSize\n\n```solidity\nfunction getFileSize(string memory storagePath) \n        public \n        view \n        returns (uint fileSize)\n```\n\nGets size of the requested file in bytes.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description            |\n| --------------- | ---------------------- |\n| `uint` fileSize | Size of requested file |\n\n#### getFileStatus\n\n```solidity\nfunction getFileStatus(string memory storagePath) \n        public \n        view \n        returns (int)\n```\n\nReturns status of the requested file:\n\n-   0 - file does not exist\n-   1 - file is created but has not finished uploading\n-   2 - file is fully uploaded\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter         | Description              |\n| ----------------- | ------------------------ |\n| `uint` fileStatus | Status of requested file |\n\n### Directory interaction methods\n\nFilestorage is represented with UNIX-based filesystem that consisted of files and directories. Directories are stored in `Directory` structure that contains information about its content in `ContentInfo` structure. Maximum amount of content in separate directory is **8196**.\n\n#### createDirectory\n\n```solidity\nfunction createDirectory(string memory directoryPath)\n```\n\nCreates directory in Filestorage. Owner of the directory - message sender. \n\n-   Function is called by directory owner\n-   Maximum amount of directories and files in one directory is **8196**\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### deleteDirectory\n\n```solidity\nfunction deleteDirectory(string memory directoryPath)\n```\n\nDeletes directory from Filestorage.\n\n-   Function is called by directory owner\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### listDirectory\n\n```solidity\nfunction listDirectory(string memory storagePath) \n        public \n        view \n        returns (ContentInfo[])\n```\n\nList information about content of the specific directory.\n\n**Parameters:**\n\n| Parameter            | Description                               |\n| -------------------- | ----------------------------------------- |\n| `string` storagePath | Full path of the directory in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description                          |\n| --------------- | ------------------------------------ |\n| `ContentInfo[]` | Array of content stored in directory |\n\nObject `ContentInfo` can be file or directory and contains:\n\n| Field                    | Description                                                                      |\n| ------------------------ | -------------------------------------------------------------------------------- |\n| `string` name            | Content name                                                                     |\n| `bool` isFile            | Whether content is file                                                          |\n| `uint` size              | File size, in bytes                                                              |\n| `int` status             | File uploading status                                                            |\n| `bool[]` isChunkUploaded | Array with statuses of each chunk (`true` - chunk uploaded, `false` - otherwise) |\n\n## Build\n\nCreate an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nPRIVATEKEY='Private key for test account'\n```\n\nCompile `FileStorage.sol`:\n\n```bash\ntruffle compile\n```\n\n## Test\n\nTests run only on SKALE chains. Create an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nSCHAIN_OWNER_PK='Private key of SKALE endpoint owner (or account with money)'\nPRIVATEKEY='Private key for test account'\n```\n\nRun tests:\n\n```bash\ntruffle test --network skaled\n```\n","gitHead":"5a6e31e7d4cfbd4380d2ee6e785a3533743ce669","scripts":{"lint":"npx ethlint -d contracts","test":"npx truffle test test/unit/* --network skaled","build":"rm -r ./build; npx truffle build","compile":"npx truffle compile; cp build/contracts/FileStorage.json predeployed/filestorage_predeployed/artifacts/","slither":"slither . --filter-path strings --filter-path Migrations","version":"node -e \"console.log(require('./package.json').version);\"","coverage":"npx truffle run coverage --file=\"test/unit/*\"","lint-fix":"npm run lint -- --fix","predeployed-test":"npx truffle test test/predeployed/* --network skaled"},"_npmUser":{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},"repository":{"url":"git+https://github.com/skalenetwork/filestorage.git","type":"git"},"_npmVersion":"6.14.17","description":"SKALE Filestorage contracts","directories":{},"_nodeVersion":"14.19.2","dependencies":{"@openzeppelin/contracts-upgradeable":"^4.3.2"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"chai":"^4.2.0","web3":"^1.2.1","dotenv":"^8.2.0","codecov":"^3.3.0","truffle":"5.1.30","randomstring":"^1.1.5","chai-as-promised":"^7.1.1","solidity-coverage":"^0.7.17","@truffle/hdwallet-provider":"^1.5.1"},"_npmOperationalInternal":{"tmp":"tmp/filestorage_1.0.1-develop.14_1652985223459_0.47740528967139473","host":"s3://npm-registry-packages"}},"1.0.1-beta.3":{"name":"@skalenetwork/filestorage","version":"1.0.1-beta.3","keywords":["SKALE","blockchain","ethereum"],"author":{"name":"SKALE Labs and contributors"},"license":"AGPL-3.0","_id":"@skalenetwork/filestorage@1.0.1-beta.3","maintainers":[{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},{"name":"dmitrytk","email":"dmitry.tkachuk@skalelabs.com"},{"name":"cstrange","email":"chadwick@skalelabs.com"},{"name":"skalelabsdev","email":"dev@skalelabs.com"},{"name":"theskyunicorn","email":"christine@skalelabs.com"},{"name":"stebaev","email":"dimastebaev@gmail.com"},{"name":"l_sergiy","email":"sergiy@skalelabs.com"}],"homepage":"https://github.com/skalenetwork/filestorage#readme","bugs":{"url":"https://github.com/skalenetwork/filestorage/issues"},"dist":{"shasum":"02c85d1e78817e7c4f5714da082cfc3b227b8b47","tarball":"https://registry.npmjs.org/@skalenetwork/filestorage/-/filestorage-1.0.1-beta.3.tgz","fileCount":5,"integrity":"sha512-Bsjy3z4eUc1Gs7JmfRVqK5VZNrI4GQscMsf0tiNWs6wL2tzzWG5qvrC3c+9UbveB4opn+N4tQFzu3MaYmqMClw==","signatures":[{"sig":"MEUCIQDhqBe88y8uOM725PeD28meOBDj0H4FJuGjmlitiuOm/wIgZSENIKUj8vnwVND6WXpkMg7Dk+I92EyvMTubK3CUd+8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":66028,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiho6XACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqJCA//dOBk2VtyMfFICXPso+sYhaiXGSps3sg5w9E6oZ3DU6hKQmN+\r\na86R66jVDqVOzHkBzicyPq7jfWyCZeoop3GC+4UOrstamHYXbTYP1tnu2fqO\r\nSDKggh/eNzM1IxemvlQRiyvZTbjpnS9vmYfK45s2Ten6hCCsIwsHLiMSNef3\r\nNAEhrB3j03JaPO1iuPHPxAOMrp4sYkjVlYvnE4kFKyNM5D6W2rJaP6kA58Uk\r\nI8m1kaXMPBZW1x7vY7HrDGah+wHZKCIxyb5WGdwysui6BxVPuzoMe6rWWixl\r\nVdVXUj/2itZOmGOT4e7juk8vLgs9l8FeKkCrxTkc0LhxOdskxonvobLw5jJZ\r\nZ1K1n9ft+9T0iCzbgbnSlk2gktjD3fjCOe8SiKYzDz1SumSlesehrVt/rYOC\r\nrMDFszWAtpHh3tt3avQh4c9EfB0I8OYTCdZzNigqLKOtMZZybKNcxCPJ3W3K\r\nT9cO4z22DFLyWTnML8kKr2BXPAk+JPc3JG8OPcQYMqha5MVSxb8yC+ySoGGm\r\nGv8VBZnhW/GxuO5Orvoz9AlYVQ54c1AaV8IfZAceH61KP63k3L4Ke/yHFogA\r\nZEQRMKxDWSHGwVtefkwhenqQwQK5caja4l6Y0MUdhJeO+yRF/x4JpHlxfOYy\r\nLIle4qxFxLx95ywQnZCizx9SAmADoQr6lZk=\r\n=IcMW\r\n-----END PGP SIGNATURE-----\r\n"},"main":"artifacts.json","readme":"# SKALE Filestorage\n\n[![Build Status](https://travis-ci.com/skalenetwork/filestorage.svg?token=HYnwEPctUzUdXVcsecA6&branch=develop)](https://travis-ci.com/skalenetwork/filestorage)\n[![codecov](https://codecov.io/gh/skalenetwork/filestorage/branch/develop/graph/badge.svg?token=2wkF3kZTXh)](https://codecov.io/gh/skalenetwork/filestorage)\n[![Discord](https://img.shields.io/discord/534485763354787851.svg)](https://discord.gg/vvUtWJB)\n\nFilestorage - smart contract, that controls decentralized file storage on SKALE chains.\n\n## Description\n\nFilestorage is a cost-effective storage layer within Ethereum capable of handling files up to 100MB. Filestorage uses UNIX-based filesystem of SKALE chains. Filestorage smart contract is a set of functions to interact with files on EVM. This contract may be predeployed on SKALE chains. It contains functions to work with Filestorage precompiled smart contracts. \n\nSmart contract language - Solidity 0.8.9\n\n## API Reference\n\n### Filestorage space handling \n\nTo start using Filestorage (upload/delete files and create/remove directories) the space should be allocated for specific account, it could be done from account that is given ALLOCATOR_ROLE. \nRules of occupying space in Filestorage:\n\n1. For directory **4096** bytes is taken\n2. File could be uploaded up to **100** MB (104857600 bytes)\n3. Occupying space for file is rounded up to the nearest multiple of **4096** bytes\n4. **Empty** file takes 4096 bytes of free space\n\nAfter deleting file/directory's amount of space is freed according to the rules above\n\n### Space handling API\n#### reserveSpace\n\n```solidity\nfunction reserveSpace(address userAddress, uint reservedSpace)\n```\n\nReserves the Filestorage space for specific address. Could be called only with ALLOCATOR_ROLE\n\n**Parameters:**\n\n| Parameter             | Description                           |\n| --------------------- | ------------------------------------- |\n| `address` userAddress | Address to allocate space for         |\n| `uint` reservedSpace  | Amount of space to reserve in bytes   |\n\n#### getTotalStorageSpace\n\n```solidity\nfunction getTotalStorageSpace()\n```\n\nGets total space in Filestorage in bytes.\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Space in bytes                     |\n\n#### getTotalReservedSpace\n\n```solidity\nfunction getTotalStorageSpace()\n```\n\nGets total reserved space in Filestorage in bytes.\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Space in bytes                     |\n\n#### getReservedSpace\n\n```solidity\nfunction getReservedSpace(address owner)\n```\n\nGets reserved space for account.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `address` owner      | Account address                      |\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Size of reserved space for account |\n\n#### getOccupiedSpace\n\n```solidity\nfunction getOccupiedSpace(address owner)\n```\n\nGets occupied space for account.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `address` owner      | Account address                      |\n\n**Returns:**\n\n| Parameter       | Description                                 |\n| --------------- | ------------------------------------------- |\n| `uint`          | Size of occupied space for account in bytes |\n\n### File interaction methods\n\nTo begin the uploading process, the file should be broken into chunks of 1MB (&lt; 1MB for the last chunk) which are uploaded as separate transactions to FileStorage.sol. \nThe pipeline of the uploading file is:\n\n1.  creating empty file of fixed size on EVM by calling `startUpload`,\n2.  uploading data chunk by chunk with `uploadChunk`,\n3.  checking the file validity and finishing process with `finishUpload`.\n\n#### startUpload\n\n```solidity\nfunction startUpload(string memory filePath, uint256 fileSize)\n```\n\nCreates empty file on EVM with specific name and size. Owner of the file - message sender. \n\n-   Function is called by file owner\n-   Maximum amount of directories and files in one directory is **8196**\n-   Maximum filesize is **100,000,000** bytes\n-   Owner should have enough free space\n\n**Parameters:**\n\n| Parameter          | Description                           |\n| ------------------ | ------------------------------------- |\n| `string` filePath  | Path to the file in account directory |\n| `uint256` fileSize | Uploaded file size in bytes           |\n\n#### uploadChunk\n\n```solidity\nfunction uploadChunk(string memory filePath, uint position, bytes memory data)\n```\n\nUploads 1MB chunk of data from specific position in specific file by file owner.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n| `uint` position   | Uploaded chunk position               |\n| `bytes` data      | Uploaded chunk data                   |\n\n#### finishUpload\n\n```solidity\nfunction finishUpload(string memory filePath)\n```\n\nFinishes uploading of the file. Checks whether all chunks are uploaded correctly.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### deleteFile\n\n```solidity\nfunction deleteFile(string memory filePath)\n```\n\nDeletes file from Filestorage.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### readChunk\n\n```solidity\nfunction readChunk(string memory storagePath, uint position, uint length)\n        public\n        view\n        returns (bytes32[MAX_BLOCK_COUNT] memory out)\n```\n\nReads chunk from file from specific position with specific length. Returns `bytes32` array of fixed size with requested data.\n\n-   Maximum length of the chunk to read is 1Mb\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n| `uint` position      | First byte to read from              |\n| `uint` length        | Uploaded chunk length                |\n\n**Returns:**\n\n| Parameter       | Description                                       |\n| --------------- | ------------------------------------------------- |\n| `bytes32[]` out | Requested chunk data split across `bytes32` array |\n\n#### getFileSize\n\n```solidity\nfunction getFileSize(string memory storagePath) \n        public \n        view \n        returns (uint fileSize)\n```\n\nGets size of the requested file in bytes.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description            |\n| --------------- | ---------------------- |\n| `uint` fileSize | Size of requested file |\n\n#### getFileStatus\n\n```solidity\nfunction getFileStatus(string memory storagePath) \n        public \n        view \n        returns (int)\n```\n\nReturns status of the requested file:\n\n-   0 - file does not exist\n-   1 - file is created but has not finished uploading\n-   2 - file is fully uploaded\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter         | Description              |\n| ----------------- | ------------------------ |\n| `uint` fileStatus | Status of requested file |\n\n### Directory interaction methods\n\nFilestorage is represented with UNIX-based filesystem that consisted of files and directories. Directories are stored in `Directory` structure that contains information about its content in `ContentInfo` structure. Maximum amount of content in separate directory is **8196**.\n\n#### createDirectory\n\n```solidity\nfunction createDirectory(string memory directoryPath)\n```\n\nCreates directory in Filestorage. Owner of the directory - message sender. \n\n-   Function is called by directory owner\n-   Maximum amount of directories and files in one directory is **8196**\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### deleteDirectory\n\n```solidity\nfunction deleteDirectory(string memory directoryPath)\n```\n\nDeletes directory from Filestorage.\n\n-   Function is called by directory owner\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### listDirectory\n\n```solidity\nfunction listDirectory(string memory storagePath) \n        public \n        view \n        returns (ContentInfo[])\n```\n\nList information about content of the specific directory.\n\n**Parameters:**\n\n| Parameter            | Description                               |\n| -------------------- | ----------------------------------------- |\n| `string` storagePath | Full path of the directory in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description                          |\n| --------------- | ------------------------------------ |\n| `ContentInfo[]` | Array of content stored in directory |\n\nObject `ContentInfo` can be file or directory and contains:\n\n| Field                    | Description                                                                      |\n| ------------------------ | -------------------------------------------------------------------------------- |\n| `string` name            | Content name                                                                     |\n| `bool` isFile            | Whether content is file                                                          |\n| `uint` size              | File size, in bytes                                                              |\n| `int` status             | File uploading status                                                            |\n| `bool[]` isChunkUploaded | Array with statuses of each chunk (`true` - chunk uploaded, `false` - otherwise) |\n\n## Build\n\nCreate an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nPRIVATEKEY='Private key for test account'\n```\n\nCompile `FileStorage.sol`:\n\n```bash\ntruffle compile\n```\n\n## Test\n\nTests run only on SKALE chains. Create an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nSCHAIN_OWNER_PK='Private key of SKALE endpoint owner (or account with money)'\nPRIVATEKEY='Private key for test account'\n```\n\nRun tests:\n\n```bash\ntruffle test --network skaled\n```\n","gitHead":"25704c43d49d5fb6d3ad31039840190b482ae614","scripts":{"lint":"npx ethlint -d contracts","test":"npx truffle test test/unit/* --network skaled","build":"rm -r ./build; npx truffle build","compile":"npx truffle compile; cp build/contracts/FileStorage.json predeployed/filestorage_predeployed/artifacts/","slither":"slither . --filter-path strings --filter-path Migrations","version":"node -e \"console.log(require('./package.json').version);\"","coverage":"npx truffle run coverage --file=\"test/unit/*\"","lint-fix":"npm run lint -- --fix","predeployed-test":"npx truffle test test/predeployed/* --network skaled"},"_npmUser":{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},"repository":{"url":"git+https://github.com/skalenetwork/filestorage.git","type":"git"},"_npmVersion":"6.14.17","description":"SKALE Filestorage contracts","directories":{},"_nodeVersion":"14.19.2","dependencies":{"@openzeppelin/contracts-upgradeable":"^4.3.2"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"chai":"^4.2.0","web3":"^1.2.1","dotenv":"^8.2.0","codecov":"^3.3.0","truffle":"5.1.30","randomstring":"^1.1.5","chai-as-promised":"^7.1.1","solidity-coverage":"^0.7.17","@truffle/hdwallet-provider":"^1.5.1"},"_npmOperationalInternal":{"tmp":"tmp/filestorage_1.0.1-beta.3_1652985495520_0.03583368482081517","host":"s3://npm-registry-packages"}},"1.0.1":{"name":"@skalenetwork/filestorage","version":"1.0.1","keywords":["SKALE","blockchain","ethereum"],"author":{"name":"SKALE Labs and contributors"},"license":"AGPL-3.0","_id":"@skalenetwork/filestorage@1.0.1","maintainers":[{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},{"name":"dmitrytk","email":"dmitry.tkachuk@skalelabs.com"},{"name":"cstrange","email":"chadwick@skalelabs.com"},{"name":"skalelabsdev","email":"dev@skalelabs.com"},{"name":"theskyunicorn","email":"christine@skalelabs.com"},{"name":"stebaev","email":"dimastebaev@gmail.com"},{"name":"l_sergiy","email":"sergiy@skalelabs.com"}],"homepage":"https://github.com/skalenetwork/filestorage#readme","bugs":{"url":"https://github.com/skalenetwork/filestorage/issues"},"dist":{"shasum":"a0e2fe292aaa8b56faa106b39ec01091c554ecad","tarball":"https://registry.npmjs.org/@skalenetwork/filestorage/-/filestorage-1.0.1.tgz","fileCount":5,"integrity":"sha512-3FQ1xA3UOPmspIDz6krVVPJUJQqa/GhpH68VjF9gU7oKeawnT6K/j3GyNbvZgq0ktNYtEXh42zpQCaon2VmFlA==","signatures":[{"sig":"MEQCIBGmkcWqnekkACGm9Xts0oT+yJaPHbP1Te8EvJcshl54AiBum92mlCPO39roNSN2J3zeiwVJ2/nkMUginuK+feFRQA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":66021,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiho/iACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmos2w/+N/Jfxy/RlqhDdl4kBzATqMR3AUZVzhuC7M8deWNuep786IxZ\r\nskWzmqjoqfDEJKDQN6CXbU8NUkv1uXliLyoO8KQSmIhouVJQOyKOV7Qckx3l\r\nioSkUEo5MXcf5YDHzw0997d2ApVP/w1vzwlcAmLT2Kuj6VpOjs/lxoE/r4sK\r\nlp9Ksyb6FYHqxmVpwXRLyWMJzOcJGksxbz9U6VYE9uQ9ILAopa2ncyzAxdjE\r\naXZ4G+qTlJr10wAc7iIrlhFPVXiADHPCuu8tLQxIyhOFY/u+MBXU1zmLw+Yj\r\nJm50KTV3IVShEBqojWo5YbS2TS8yrt5m1rBDrPNx6xpRR+Io2pfW5PPktSkH\r\nx/0kWIlF0qlDrfqkkL+xCnDfNgPX8WeXqxGxH97f4RWBNPhVIp5ElkCZtT7z\r\n5uJv37mZx5N1zlr9GbNirYqh9mq+gC98uEWnlpnbdha74vw8S2lH5yJWmIQ1\r\nMhrMToVFgbDPIeOc7jTwnh1Pnn1ouwLRjsXCyRS7Z4SL0mvuL9HNM6kKDCnQ\r\nFdGGxPiC2/GxH5DP7boTpTlCpNr2LQsfDBmETrYzUZeAhV9vsaZe0cgoVy34\r\nSmUQPTmtZE4Cdihe9rkAPzVJyEVfDjlekuyadfLri9aN8iRKTQXZWbvX9ks9\r\nR6oMRjaBP49TgGJVtFqAOrnf5fTyJnM0ORc=\r\n=NupX\r\n-----END PGP SIGNATURE-----\r\n"},"main":"artifacts.json","gitHead":"d772ddd79a45f80272fd50cb688f52346d45fbe2","scripts":{"lint":"npx ethlint -d contracts","test":"npx truffle test test/unit/* --network skaled","build":"rm -r ./build; npx truffle build","compile":"npx truffle compile; cp build/contracts/FileStorage.json predeployed/filestorage_predeployed/artifacts/","slither":"slither . --filter-path strings --filter-path Migrations","version":"node -e \"console.log(require('./package.json').version);\"","coverage":"npx truffle run coverage --file=\"test/unit/*\"","lint-fix":"npm run lint -- --fix","predeployed-test":"npx truffle test test/predeployed/* --network skaled"},"_npmUser":{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},"repository":{"url":"git+https://github.com/skalenetwork/filestorage.git","type":"git"},"_npmVersion":"6.14.17","description":"SKALE Filestorage contracts","directories":{},"_nodeVersion":"14.19.2","dependencies":{"@openzeppelin/contracts-upgradeable":"^4.3.2"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"chai":"^4.2.0","web3":"^1.2.1","dotenv":"^8.2.0","codecov":"^3.3.0","truffle":"5.1.30","randomstring":"^1.1.5","chai-as-promised":"^7.1.1","solidity-coverage":"^0.7.17","@truffle/hdwallet-provider":"^1.5.1"},"_npmOperationalInternal":{"tmp":"tmp/filestorage_1.0.1_1652985826494_0.9383749709242206","host":"s3://npm-registry-packages"}},"1.1.0-develop.1":{"name":"@skalenetwork/filestorage","version":"1.1.0-develop.1","keywords":["SKALE","blockchain","ethereum"],"author":{"name":"SKALE Labs and contributors"},"license":"AGPL-3.0","_id":"@skalenetwork/filestorage@1.1.0-develop.1","maintainers":[{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},{"name":"dmitrytk","email":"dmitry.tkachuk@skalelabs.com"},{"name":"cstrange","email":"chadwick@skalelabs.com"},{"name":"skalelabsdev","email":"dev@skalelabs.com"},{"name":"theskyunicorn","email":"christine@skalelabs.com"},{"name":"stebaev","email":"dimastebaev@gmail.com"},{"name":"l_sergiy","email":"sergiy@skalelabs.com"}],"homepage":"https://github.com/skalenetwork/filestorage#readme","bugs":{"url":"https://github.com/skalenetwork/filestorage/issues"},"dist":{"shasum":"dc982cd49433744b6fb13339dd4175edf90e8f66","tarball":"https://registry.npmjs.org/@skalenetwork/filestorage/-/filestorage-1.1.0-develop.1.tgz","fileCount":5,"integrity":"sha512-gwkvFg5V7C1m/djlNyysJ3Lu/CSRmoaF5JpIw2rjONElm20noNIkAMVTwMxOemYgcIiroD2K058WI4hwXXZngw==","signatures":[{"sig":"MEQCIBuseOY6HT+5Sh7OMlvCbwu+DKxGITp35lGh0LF3aBHcAiBNmIAIsqMSsjXb2xsq/zEdSHW30m1xh8YQ2SYZDheLGw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":66093,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJixy3lACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqjGQ//TsX55/Yk2LvOmcts0LDgT7GzRIOihn3Mk4FzYTTPbPGDlMB6\r\nOtogvuILJD7whjyEMuG8DjhytKL7UNBNWqpALUQ71pF6RRoIto0fs9on6kpF\r\nqxP1/M7a9pnYxaCsIiUpPyOg9HJLC4vGljeeSCdEG65W4reYqNSIA7TzGXzb\r\nr/ffqsdOIUqhjZRc8u8mmSR1y83btuI/9FUzOeSUIw1QGf07V68QPh6B6Kgc\r\ntewjgJJpxx5K++GbdiHcvxsH+7JszQZmpBht99r7yAbSbjcA/g7+TfoVo1ue\r\n/TlSinGudIjg4YBvgRCXQSPU56FUKm72Xqw7oZEfix73BvKFHrPQxkSyMEeH\r\nbtcEFj/hHimgC8K49ds8Xm5fhuU34OuSeHQyJlZgfo8JJQqE4mLyBgKhB1LY\r\noFuMsgMt3wl+lEGQbzmw5fNico6sCmuz6NzPwaCWR65vu3NX2RwzfvBMSwHY\r\ncnx2Cp6V/YncwgXo8U8WLkpZ+KJ1wzEhALQOx206lLl+EaoUp63mBnApGiII\r\nxQn1XOnY5n8etCVMZaXcxckYAlVSluCm9SPs4/o2QKHOcs32jBjEyg4LG07Q\r\n5Cqut/0HzBV5Ll111j0Fiv0m6a+fRkVt2oZVLHA3p1pSeDgciqKk3oEABany\r\nqIbAat0hZJh7bpI+vn+501f8eJkeW5FibVg=\r\n=U9ui\r\n-----END PGP SIGNATURE-----\r\n"},"main":"artifacts.json","readme":"# SKALE Filestorage\n\n[![Build Status](https://travis-ci.com/skalenetwork/filestorage.svg?token=HYnwEPctUzUdXVcsecA6&branch=develop)](https://travis-ci.com/skalenetwork/filestorage)\n[![codecov](https://codecov.io/gh/skalenetwork/filestorage/branch/develop/graph/badge.svg?token=2wkF3kZTXh)](https://codecov.io/gh/skalenetwork/filestorage)\n[![Discord](https://img.shields.io/discord/534485763354787851.svg)](https://discord.gg/vvUtWJB)\n\nFilestorage - smart contract, that controls decentralized file storage on SKALE chains.\n\n## Description\n\nFilestorage is a cost-effective storage layer within Ethereum capable of handling files up to 100MB. Filestorage uses UNIX-based filesystem of SKALE chains. Filestorage smart contract is a set of functions to interact with files on EVM. This contract may be predeployed on SKALE chains. It contains functions to work with Filestorage precompiled smart contracts. \n\nSmart contract language - Solidity 0.8.9\n\n## API Reference\n\n### Filestorage space handling \n\nTo start using Filestorage (upload/delete files and create/remove directories) the space should be allocated for specific account, it could be done from account that is given ALLOCATOR_ROLE. \nRules of occupying space in Filestorage:\n\n1. For directory **4096** bytes is taken\n2. File could be uploaded up to **100** MB (104857600 bytes)\n3. Occupying space for file is rounded up to the nearest multiple of **4096** bytes\n4. **Empty** file takes 4096 bytes of free space\n\nAfter deleting file/directory's amount of space is freed according to the rules above\n\n### Space handling API\n#### reserveSpace\n\n```solidity\nfunction reserveSpace(address userAddress, uint reservedSpace)\n```\n\nReserves the Filestorage space for specific address. Could be called only with ALLOCATOR_ROLE\n\n**Parameters:**\n\n| Parameter             | Description                           |\n| --------------------- | ------------------------------------- |\n| `address` userAddress | Address to allocate space for         |\n| `uint` reservedSpace  | Amount of space to reserve in bytes   |\n\n#### getTotalStorageSpace\n\n```solidity\nfunction getTotalStorageSpace()\n```\n\nGets total space in Filestorage in bytes.\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Space in bytes                     |\n\n#### getTotalReservedSpace\n\n```solidity\nfunction getTotalStorageSpace()\n```\n\nGets total reserved space in Filestorage in bytes.\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Space in bytes                     |\n\n#### getReservedSpace\n\n```solidity\nfunction getReservedSpace(address owner)\n```\n\nGets reserved space for account.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `address` owner      | Account address                      |\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Size of reserved space for account |\n\n#### getOccupiedSpace\n\n```solidity\nfunction getOccupiedSpace(address owner)\n```\n\nGets occupied space for account.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `address` owner      | Account address                      |\n\n**Returns:**\n\n| Parameter       | Description                                 |\n| --------------- | ------------------------------------------- |\n| `uint`          | Size of occupied space for account in bytes |\n\n### File interaction methods\n\nTo begin the uploading process, the file should be broken into chunks of 1MB (&lt; 1MB for the last chunk) which are uploaded as separate transactions to FileStorage.sol. \nThe pipeline of the uploading file is:\n\n1.  creating empty file of fixed size on EVM by calling `startUpload`,\n2.  uploading data chunk by chunk with `uploadChunk`,\n3.  checking the file validity and finishing process with `finishUpload`.\n\n#### startUpload\n\n```solidity\nfunction startUpload(string memory filePath, uint256 fileSize)\n```\n\nCreates empty file on EVM with specific name and size. Owner of the file - message sender. \n\n-   Function is called by file owner\n-   Maximum amount of directories and files in one directory is **8196**\n-   Maximum filesize is **100,000,000** bytes\n-   Owner should have enough free space\n\n**Parameters:**\n\n| Parameter          | Description                           |\n| ------------------ | ------------------------------------- |\n| `string` filePath  | Path to the file in account directory |\n| `uint256` fileSize | Uploaded file size in bytes           |\n\n#### uploadChunk\n\n```solidity\nfunction uploadChunk(string memory filePath, uint position, bytes memory data)\n```\n\nUploads 1MB chunk of data from specific position in specific file by file owner.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n| `uint` position   | Uploaded chunk position               |\n| `bytes` data      | Uploaded chunk data                   |\n\n#### finishUpload\n\n```solidity\nfunction finishUpload(string memory filePath)\n```\n\nFinishes uploading of the file. Checks whether all chunks are uploaded correctly.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### deleteFile\n\n```solidity\nfunction deleteFile(string memory filePath)\n```\n\nDeletes file from Filestorage.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### readChunk\n\n```solidity\nfunction readChunk(string memory storagePath, uint position, uint length)\n        public\n        view\n        returns (bytes32[MAX_BLOCK_COUNT] memory out)\n```\n\nReads chunk from file from specific position with specific length. Returns `bytes32` array of fixed size with requested data.\n\n-   Maximum length of the chunk to read is 1Mb\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n| `uint` position      | First byte to read from              |\n| `uint` length        | Uploaded chunk length                |\n\n**Returns:**\n\n| Parameter       | Description                                       |\n| --------------- | ------------------------------------------------- |\n| `bytes32[]` out | Requested chunk data split across `bytes32` array |\n\n#### getFileSize\n\n```solidity\nfunction getFileSize(string memory storagePath) \n        public \n        view \n        returns (uint fileSize)\n```\n\nGets size of the requested file in bytes.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description            |\n| --------------- | ---------------------- |\n| `uint` fileSize | Size of requested file |\n\n#### getFileStatus\n\n```solidity\nfunction getFileStatus(string memory storagePath) \n        public \n        view \n        returns (int)\n```\n\nReturns status of the requested file:\n\n-   0 - file does not exist\n-   1 - file is created but has not finished uploading\n-   2 - file is fully uploaded\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter         | Description              |\n| ----------------- | ------------------------ |\n| `uint` fileStatus | Status of requested file |\n\n### Directory interaction methods\n\nFilestorage is represented with UNIX-based filesystem that consisted of files and directories. Directories are stored in `Directory` structure that contains information about its content in `ContentInfo` structure. Maximum amount of content in separate directory is **8196**.\n\n#### createDirectory\n\n```solidity\nfunction createDirectory(string memory directoryPath)\n```\n\nCreates directory in Filestorage. Owner of the directory - message sender. \n\n-   Function is called by directory owner\n-   Maximum amount of directories and files in one directory is **8196**\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### deleteDirectory\n\n```solidity\nfunction deleteDirectory(string memory directoryPath)\n```\n\nDeletes directory from Filestorage.\n\n-   Function is called by directory owner\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### listDirectory\n\n```solidity\nfunction listDirectory(string memory storagePath) \n        public \n        view \n        returns (ContentInfo[])\n```\n\nList information about content of the specific directory.\n\n**Parameters:**\n\n| Parameter            | Description                               |\n| -------------------- | ----------------------------------------- |\n| `string` storagePath | Full path of the directory in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description                          |\n| --------------- | ------------------------------------ |\n| `ContentInfo[]` | Array of content stored in directory |\n\nObject `ContentInfo` can be file or directory and contains:\n\n| Field                    | Description                                                                      |\n| ------------------------ | -------------------------------------------------------------------------------- |\n| `string` name            | Content name                                                                     |\n| `bool` isFile            | Whether content is file                                                          |\n| `uint` size              | File size, in bytes                                                              |\n| `int` status             | File uploading status                                                            |\n| `bool[]` isChunkUploaded | Array with statuses of each chunk (`true` - chunk uploaded, `false` - otherwise) |\n\n## Build\n\nCreate an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nPRIVATEKEY='Private key for test account'\n```\n\nCompile `FileStorage.sol`:\n\n```bash\ntruffle compile\n```\n\n## Test\n\nTests run only on SKALE chains. Create an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nSCHAIN_OWNER_PK='Private key of SKALE endpoint owner (or account with money)'\nPRIVATEKEY='Private key for test account'\n```\n\nRun tests:\n\n```bash\ntruffle test --network skaled\n```\n","gitHead":"974d2e2e14645b211548a31d26ecf50297a8d3c8","scripts":{"lint":"npx ethlint -d contracts","test":"npx truffle test test/unit/* --network skaled","build":"rm -r ./build; npx truffle build","compile":"npx truffle compile","slither":"slither . --filter-path strings --filter-path Migrations","version":"node -e \"console.log(require('./package.json').version);\"","coverage":"npx truffle run coverage --file=\"test/unit/*\"","lint-fix":"npm run lint -- --fix","compile-hardhat":"npx hardhat clean && npx hardhat compile","predeployed-test":"npx truffle test test/predeployed/* --network skaled"},"_npmUser":{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},"repository":{"url":"git+https://github.com/skalenetwork/filestorage.git","type":"git"},"_npmVersion":"6.14.17","description":"SKALE Filestorage contracts","directories":{},"_nodeVersion":"14.19.3","dependencies":{"@openzeppelin/contracts-upgradeable":"^4.3.2"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"chai":"^4.2.0","web3":"^1.2.1","dotenv":"^8.2.0","codecov":"^3.3.0","hardhat":"^2.6.4","truffle":"5.1.30","ts-node":"^10.2.1","typescript":"^4.4.3","randomstring":"^1.1.5","chai-as-promised":"^7.1.1","solidity-coverage":"^0.7.17","@truffle/hdwallet-provider":"^1.5.1"},"_npmOperationalInternal":{"tmp":"tmp/filestorage_1.1.0-develop.1_1657220581102_0.867941707961158","host":"s3://npm-registry-packages"}},"1.1.0-develop.2":{"name":"@skalenetwork/filestorage","version":"1.1.0-develop.2","keywords":["SKALE","blockchain","ethereum"],"author":{"name":"SKALE Labs and contributors"},"license":"AGPL-3.0","_id":"@skalenetwork/filestorage@1.1.0-develop.2","maintainers":[{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},{"name":"dmitrytk","email":"dmitry.tkachuk@skalelabs.com"},{"name":"cstrange","email":"chadwick@skalelabs.com"},{"name":"skalelabsdev","email":"dev@skalelabs.com"},{"name":"theskyunicorn","email":"christine@skalelabs.com"},{"name":"stebaev","email":"dimastebaev@gmail.com"},{"name":"l_sergiy","email":"sergiy@skalelabs.com"}],"homepage":"https://github.com/skalenetwork/filestorage#readme","bugs":{"url":"https://github.com/skalenetwork/filestorage/issues"},"dist":{"shasum":"28333e769eed60cf81eda7b60b6224dad600115e","tarball":"https://registry.npmjs.org/@skalenetwork/filestorage/-/filestorage-1.1.0-develop.2.tgz","fileCount":5,"integrity":"sha512-qJeR841qP01aVFzHAKLl6j4BuS72ASC3o7KnboKTX8/JOc0KIk2H9mpFYUeX3ynpbnr6JYwBfNn+TZ9ZJO48rg==","signatures":[{"sig":"MEYCIQC9a+6qX+Uhw1GycPFRnDdJGLoez+oRt5gPzCRncNLwOAIhAKDhhrD1yOeqEpFjvSMpFmg1SZWVi0H289ubMRvmSr+6","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":66093,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJixzFiACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqaTg//QACNyC2GHLn+WRHOOfZKg4WTK0eW95x88odLhHMO7stJ9sdc\r\n+FZT9Np34KW3hZJsbI2utDDLNhgLmG6RfCCDaFKPAEkwCABWsed0k/1SRGVF\r\n5um2zGhVGxGOywrBNF+6JxQ9ZMyZr34LmpYeRGJjbUiEOJTp8xgBoCbPMBJI\r\n2/nA+fr3iShXtN35oqVvbvawDqXy9ZyznzGetiiVzWfkPxD6EIoEfgJC7jo4\r\nLhMOq40cya/5h3sTDi8HKobyu5WdlfEiQptoXj+2z0tXJcEN3irLTpLzrtSi\r\nfXJ49wApUMqrLsAoyMri8WDYKvh2MNsWhxDa0STxruv6Y9yPfwsaUXmn90Js\r\njx3LfwbblbGIRrNo5f+SZbQFASqUy0l+qVflUt3FwPEbrQiitOMsqG5vOTN6\r\nu6PwopCW0H5Udu10EVv2vQrJiiyOc3BntHFHF55BJ/+emlY2G05LzDwa/T4i\r\nmGU5F++1LiCc5mdYhoNsECOEVD5d3ncl88gWVT6zjrb4VwWEnFNmUEc52jHQ\r\nYXqwYpAGqZvcsuVqYIAo39UuPJTuJOvpAyeUr9yLK0dLOnAFhT0GUhw/DjW5\r\nRHfJeVHR1EQmP4ouT/KNO7NBGAcq9NeYEMHSErp1xB9vh2aEFjHBR495xIU4\r\nLkeWxbSdtZNlZRzoYV9JrVgBjtOA1N3NzSE=\r\n=Bcss\r\n-----END PGP SIGNATURE-----\r\n"},"main":"artifacts.json","readme":"# SKALE Filestorage\n\n[![Build Status](https://travis-ci.com/skalenetwork/filestorage.svg?token=HYnwEPctUzUdXVcsecA6&branch=develop)](https://travis-ci.com/skalenetwork/filestorage)\n[![codecov](https://codecov.io/gh/skalenetwork/filestorage/branch/develop/graph/badge.svg?token=2wkF3kZTXh)](https://codecov.io/gh/skalenetwork/filestorage)\n[![Discord](https://img.shields.io/discord/534485763354787851.svg)](https://discord.gg/vvUtWJB)\n\nFilestorage - smart contract, that controls decentralized file storage on SKALE chains.\n\n## Description\n\nFilestorage is a cost-effective storage layer within Ethereum capable of handling files up to 100MB. Filestorage uses UNIX-based filesystem of SKALE chains. Filestorage smart contract is a set of functions to interact with files on EVM. This contract may be predeployed on SKALE chains. It contains functions to work with Filestorage precompiled smart contracts. \n\nSmart contract language - Solidity 0.8.9\n\n## API Reference\n\n### Filestorage space handling \n\nTo start using Filestorage (upload/delete files and create/remove directories) the space should be allocated for specific account, it could be done from account that is given ALLOCATOR_ROLE. \nRules of occupying space in Filestorage:\n\n1. For directory **4096** bytes is taken\n2. File could be uploaded up to **100** MB (104857600 bytes)\n3. Occupying space for file is rounded up to the nearest multiple of **4096** bytes\n4. **Empty** file takes 4096 bytes of free space\n\nAfter deleting file/directory's amount of space is freed according to the rules above\n\n### Space handling API\n#### reserveSpace\n\n```solidity\nfunction reserveSpace(address userAddress, uint reservedSpace)\n```\n\nReserves the Filestorage space for specific address. Could be called only with ALLOCATOR_ROLE\n\n**Parameters:**\n\n| Parameter             | Description                           |\n| --------------------- | ------------------------------------- |\n| `address` userAddress | Address to allocate space for         |\n| `uint` reservedSpace  | Amount of space to reserve in bytes   |\n\n#### getTotalStorageSpace\n\n```solidity\nfunction getTotalStorageSpace()\n```\n\nGets total space in Filestorage in bytes.\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Space in bytes                     |\n\n#### getTotalReservedSpace\n\n```solidity\nfunction getTotalStorageSpace()\n```\n\nGets total reserved space in Filestorage in bytes.\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Space in bytes                     |\n\n#### getReservedSpace\n\n```solidity\nfunction getReservedSpace(address owner)\n```\n\nGets reserved space for account.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `address` owner      | Account address                      |\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Size of reserved space for account |\n\n#### getOccupiedSpace\n\n```solidity\nfunction getOccupiedSpace(address owner)\n```\n\nGets occupied space for account.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `address` owner      | Account address                      |\n\n**Returns:**\n\n| Parameter       | Description                                 |\n| --------------- | ------------------------------------------- |\n| `uint`          | Size of occupied space for account in bytes |\n\n### File interaction methods\n\nTo begin the uploading process, the file should be broken into chunks of 1MB (&lt; 1MB for the last chunk) which are uploaded as separate transactions to FileStorage.sol. \nThe pipeline of the uploading file is:\n\n1.  creating empty file of fixed size on EVM by calling `startUpload`,\n2.  uploading data chunk by chunk with `uploadChunk`,\n3.  checking the file validity and finishing process with `finishUpload`.\n\n#### startUpload\n\n```solidity\nfunction startUpload(string memory filePath, uint256 fileSize)\n```\n\nCreates empty file on EVM with specific name and size. Owner of the file - message sender. \n\n-   Function is called by file owner\n-   Maximum amount of directories and files in one directory is **8196**\n-   Maximum filesize is **100,000,000** bytes\n-   Owner should have enough free space\n\n**Parameters:**\n\n| Parameter          | Description                           |\n| ------------------ | ------------------------------------- |\n| `string` filePath  | Path to the file in account directory |\n| `uint256` fileSize | Uploaded file size in bytes           |\n\n#### uploadChunk\n\n```solidity\nfunction uploadChunk(string memory filePath, uint position, bytes memory data)\n```\n\nUploads 1MB chunk of data from specific position in specific file by file owner.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n| `uint` position   | Uploaded chunk position               |\n| `bytes` data      | Uploaded chunk data                   |\n\n#### finishUpload\n\n```solidity\nfunction finishUpload(string memory filePath)\n```\n\nFinishes uploading of the file. Checks whether all chunks are uploaded correctly.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### deleteFile\n\n```solidity\nfunction deleteFile(string memory filePath)\n```\n\nDeletes file from Filestorage.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### readChunk\n\n```solidity\nfunction readChunk(string memory storagePath, uint position, uint length)\n        public\n        view\n        returns (bytes32[MAX_BLOCK_COUNT] memory out)\n```\n\nReads chunk from file from specific position with specific length. Returns `bytes32` array of fixed size with requested data.\n\n-   Maximum length of the chunk to read is 1Mb\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n| `uint` position      | First byte to read from              |\n| `uint` length        | Uploaded chunk length                |\n\n**Returns:**\n\n| Parameter       | Description                                       |\n| --------------- | ------------------------------------------------- |\n| `bytes32[]` out | Requested chunk data split across `bytes32` array |\n\n#### getFileSize\n\n```solidity\nfunction getFileSize(string memory storagePath) \n        public \n        view \n        returns (uint fileSize)\n```\n\nGets size of the requested file in bytes.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description            |\n| --------------- | ---------------------- |\n| `uint` fileSize | Size of requested file |\n\n#### getFileStatus\n\n```solidity\nfunction getFileStatus(string memory storagePath) \n        public \n        view \n        returns (int)\n```\n\nReturns status of the requested file:\n\n-   0 - file does not exist\n-   1 - file is created but has not finished uploading\n-   2 - file is fully uploaded\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter         | Description              |\n| ----------------- | ------------------------ |\n| `uint` fileStatus | Status of requested file |\n\n### Directory interaction methods\n\nFilestorage is represented with UNIX-based filesystem that consisted of files and directories. Directories are stored in `Directory` structure that contains information about its content in `ContentInfo` structure. Maximum amount of content in separate directory is **8196**.\n\n#### createDirectory\n\n```solidity\nfunction createDirectory(string memory directoryPath)\n```\n\nCreates directory in Filestorage. Owner of the directory - message sender. \n\n-   Function is called by directory owner\n-   Maximum amount of directories and files in one directory is **8196**\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### deleteDirectory\n\n```solidity\nfunction deleteDirectory(string memory directoryPath)\n```\n\nDeletes directory from Filestorage.\n\n-   Function is called by directory owner\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### listDirectory\n\n```solidity\nfunction listDirectory(string memory storagePath) \n        public \n        view \n        returns (ContentInfo[])\n```\n\nList information about content of the specific directory.\n\n**Parameters:**\n\n| Parameter            | Description                               |\n| -------------------- | ----------------------------------------- |\n| `string` storagePath | Full path of the directory in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description                          |\n| --------------- | ------------------------------------ |\n| `ContentInfo[]` | Array of content stored in directory |\n\nObject `ContentInfo` can be file or directory and contains:\n\n| Field                    | Description                                                                      |\n| ------------------------ | -------------------------------------------------------------------------------- |\n| `string` name            | Content name                                                                     |\n| `bool` isFile            | Whether content is file                                                          |\n| `uint` size              | File size, in bytes                                                              |\n| `int` status             | File uploading status                                                            |\n| `bool[]` isChunkUploaded | Array with statuses of each chunk (`true` - chunk uploaded, `false` - otherwise) |\n\n## Build\n\nCreate an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nPRIVATEKEY='Private key for test account'\n```\n\nCompile `FileStorage.sol`:\n\n```bash\ntruffle compile\n```\n\n## Test\n\nTests run only on SKALE chains. Create an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nSCHAIN_OWNER_PK='Private key of SKALE endpoint owner (or account with money)'\nPRIVATEKEY='Private key for test account'\n```\n\nRun tests:\n\n```bash\ntruffle test --network skaled\n```\n","gitHead":"c69cbb47171132087f26fdb52f47c88c68178ef1","scripts":{"lint":"npx ethlint -d contracts","test":"npx truffle test test/unit/* --network skaled","build":"rm -r ./build; npx truffle build","compile":"npx truffle compile","slither":"slither . --filter-path strings --filter-path Migrations","version":"node -e \"console.log(require('./package.json').version);\"","coverage":"npx truffle run coverage --file=\"test/unit/*\"","lint-fix":"npm run lint -- --fix","compile-hardhat":"npx hardhat clean && npx hardhat compile","predeployed-test":"npx truffle test test/predeployed/* --network skaled"},"_npmUser":{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},"repository":{"url":"git+https://github.com/skalenetwork/filestorage.git","type":"git"},"_npmVersion":"6.14.17","description":"SKALE Filestorage contracts","directories":{},"_nodeVersion":"14.19.3","dependencies":{"@openzeppelin/contracts-upgradeable":"^4.3.2"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"chai":"^4.2.0","web3":"^1.2.1","dotenv":"^8.2.0","codecov":"^3.3.0","hardhat":"^2.6.4","truffle":"5.1.30","ts-node":"^10.2.1","typescript":"^4.4.3","randomstring":"^1.1.5","chai-as-promised":"^7.1.1","solidity-coverage":"^0.7.17","@truffle/hdwallet-provider":"^1.5.1"},"_npmOperationalInternal":{"tmp":"tmp/filestorage_1.1.0-develop.2_1657221474024_0.7294026861093299","host":"s3://npm-registry-packages"}},"1.1.0-develop.3":{"name":"@skalenetwork/filestorage","version":"1.1.0-develop.3","keywords":["SKALE","blockchain","ethereum"],"author":{"name":"SKALE Labs and contributors"},"license":"AGPL-3.0","_id":"@skalenetwork/filestorage@1.1.0-develop.3","maintainers":[{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},{"name":"dmitrytk","email":"dmitry.tkachuk@skalelabs.com"},{"name":"cstrange","email":"chadwick@skalelabs.com"},{"name":"skalelabsdev","email":"dev@skalelabs.com"},{"name":"theskyunicorn","email":"christine@skalelabs.com"},{"name":"stebaev","email":"dimastebaev@gmail.com"},{"name":"l_sergiy","email":"sergiy@skalelabs.com"}],"homepage":"https://github.com/skalenetwork/filestorage#readme","bugs":{"url":"https://github.com/skalenetwork/filestorage/issues"},"dist":{"shasum":"723b3c8765598a0d5c95765236c5dca9e9c0133a","tarball":"https://registry.npmjs.org/@skalenetwork/filestorage/-/filestorage-1.1.0-develop.3.tgz","fileCount":5,"integrity":"sha512-yaclhzrVT4licqXURVx1wHPXYrB1EhHo3yy48uMnbXbqYjhxRYMx6pyd+QW9UvGJoXkR+wJlgX5YAKQABmTF8w==","signatures":[{"sig":"MEQCIDvyP4zm8IlcU4enGyaddErEGTs9r31/26S45O/lvPKGAiAd9ZwUuIyrjI5VlFuvhEpwHZDbwoB1M2tfklN/xdNqjA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":66093,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi5+W3ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrExxAAiB411ZvU3P7Wg5J3h6YytXAekSR2TxaoRtIzlHD/e68PMhIC\r\nPccpoyBfiChu0y7a3j7GY7uOjb7eq9gzC0W9uvB3w/qQRu/WZSjZWgzECUBh\r\n7fQwtAfru5K77mIzBHElvYnZ+pyxprGNs/1R8NbqTVMWmwOWAMwX9WEYZbea\r\np50EXv2TQmrzU9+iYQBgSau5WIoNbf8pGX84BXJgIsk3C3N4/R6ruWZ78nrq\r\naF8HmYJT8g6HYNn3PKFpGPYIQ/GNkPS72FmkF+/JHKdC3S8JzlxhZbvlKZUF\r\n4AWnpROBvD5wDJXnoWs/zJOa2qR2Y33wrxBgiBICTs7DEyg7Uc8FcD56wnD3\r\n1reIogzg4xAYhdSr734N8vHVJDygJdFT/VkSG6qvqB8VzO/gCobonwEwiwrk\r\npfHDeJk4R/c+x+iA5e5ee4zaDLrlOIT+XyuAUJlvOdqGVQaBkhnBBktROtlD\r\n3FYH+nn6EUwLycP4b6qwe5rFhIkoVNPPykHGGW0zEK1gZCXOtBV+pT4G9OVb\r\npbKfc8SCJCjNy5O604DlqZfJ2uz//Gy9zXHg3/CdFBG6xWZeQ704oU7Pg8XI\r\nEGCWiGeE2wXqNay09mYb6zHlZrW7JCtPhyC2jUIv7w3amckwv+ejfU/8EOrb\r\n6r7Pc0UVQaRYQTCIPVTFleIxRCG0ejKiKfM=\r\n=2Trf\r\n-----END PGP SIGNATURE-----\r\n"},"main":"artifacts.json","readme":"# SKALE Filestorage\n\n[![Build Status](https://travis-ci.com/skalenetwork/filestorage.svg?token=HYnwEPctUzUdXVcsecA6&branch=develop)](https://travis-ci.com/skalenetwork/filestorage)\n[![codecov](https://codecov.io/gh/skalenetwork/filestorage/branch/develop/graph/badge.svg?token=2wkF3kZTXh)](https://codecov.io/gh/skalenetwork/filestorage)\n[![Discord](https://img.shields.io/discord/534485763354787851.svg)](https://discord.gg/vvUtWJB)\n\nFilestorage - smart contract, that controls decentralized file storage on SKALE chains.\n\n## Description\n\nFilestorage is a cost-effective storage layer within Ethereum capable of handling files up to 100MB. Filestorage uses UNIX-based filesystem of SKALE chains. Filestorage smart contract is a set of functions to interact with files on EVM. This contract may be predeployed on SKALE chains. It contains functions to work with Filestorage precompiled smart contracts. \n\nSmart contract language - Solidity 0.8.9\n\n## API Reference\n\n### Filestorage space handling \n\nTo start using Filestorage (upload/delete files and create/remove directories) the space should be allocated for specific account, it could be done from account that is given ALLOCATOR_ROLE. \nRules of occupying space in Filestorage:\n\n1. For directory **4096** bytes is taken\n2. File could be uploaded up to **100** MB (104857600 bytes)\n3. Occupying space for file is rounded up to the nearest multiple of **4096** bytes\n4. **Empty** file takes 4096 bytes of free space\n\nAfter deleting file/directory's amount of space is freed according to the rules above\n\n### Space handling API\n#### reserveSpace\n\n```solidity\nfunction reserveSpace(address userAddress, uint reservedSpace)\n```\n\nReserves the Filestorage space for specific address. Could be called only with ALLOCATOR_ROLE\n\n**Parameters:**\n\n| Parameter             | Description                           |\n| --------------------- | ------------------------------------- |\n| `address` userAddress | Address to allocate space for         |\n| `uint` reservedSpace  | Amount of space to reserve in bytes   |\n\n#### getTotalStorageSpace\n\n```solidity\nfunction getTotalStorageSpace()\n```\n\nGets total space in Filestorage in bytes.\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Space in bytes                     |\n\n#### getTotalReservedSpace\n\n```solidity\nfunction getTotalStorageSpace()\n```\n\nGets total reserved space in Filestorage in bytes.\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Space in bytes                     |\n\n#### getReservedSpace\n\n```solidity\nfunction getReservedSpace(address owner)\n```\n\nGets reserved space for account.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `address` owner      | Account address                      |\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Size of reserved space for account |\n\n#### getOccupiedSpace\n\n```solidity\nfunction getOccupiedSpace(address owner)\n```\n\nGets occupied space for account.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `address` owner      | Account address                      |\n\n**Returns:**\n\n| Parameter       | Description                                 |\n| --------------- | ------------------------------------------- |\n| `uint`          | Size of occupied space for account in bytes |\n\n### File interaction methods\n\nTo begin the uploading process, the file should be broken into chunks of 1MB (&lt; 1MB for the last chunk) which are uploaded as separate transactions to FileStorage.sol. \nThe pipeline of the uploading file is:\n\n1.  creating empty file of fixed size on EVM by calling `startUpload`,\n2.  uploading data chunk by chunk with `uploadChunk`,\n3.  checking the file validity and finishing process with `finishUpload`.\n\n#### startUpload\n\n```solidity\nfunction startUpload(string memory filePath, uint256 fileSize)\n```\n\nCreates empty file on EVM with specific name and size. Owner of the file - message sender. \n\n-   Function is called by file owner\n-   Maximum amount of directories and files in one directory is **8196**\n-   Maximum filesize is **100,000,000** bytes\n-   Owner should have enough free space\n\n**Parameters:**\n\n| Parameter          | Description                           |\n| ------------------ | ------------------------------------- |\n| `string` filePath  | Path to the file in account directory |\n| `uint256` fileSize | Uploaded file size in bytes           |\n\n#### uploadChunk\n\n```solidity\nfunction uploadChunk(string memory filePath, uint position, bytes memory data)\n```\n\nUploads 1MB chunk of data from specific position in specific file by file owner.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n| `uint` position   | Uploaded chunk position               |\n| `bytes` data      | Uploaded chunk data                   |\n\n#### finishUpload\n\n```solidity\nfunction finishUpload(string memory filePath)\n```\n\nFinishes uploading of the file. Checks whether all chunks are uploaded correctly.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### deleteFile\n\n```solidity\nfunction deleteFile(string memory filePath)\n```\n\nDeletes file from Filestorage.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### readChunk\n\n```solidity\nfunction readChunk(string memory storagePath, uint position, uint length)\n        public\n        view\n        returns (bytes32[MAX_BLOCK_COUNT] memory out)\n```\n\nReads chunk from file from specific position with specific length. Returns `bytes32` array of fixed size with requested data.\n\n-   Maximum length of the chunk to read is 1Mb\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n| `uint` position      | First byte to read from              |\n| `uint` length        | Uploaded chunk length                |\n\n**Returns:**\n\n| Parameter       | Description                                       |\n| --------------- | ------------------------------------------------- |\n| `bytes32[]` out | Requested chunk data split across `bytes32` array |\n\n#### getFileSize\n\n```solidity\nfunction getFileSize(string memory storagePath) \n        public \n        view \n        returns (uint fileSize)\n```\n\nGets size of the requested file in bytes.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description            |\n| --------------- | ---------------------- |\n| `uint` fileSize | Size of requested file |\n\n#### getFileStatus\n\n```solidity\nfunction getFileStatus(string memory storagePath) \n        public \n        view \n        returns (int)\n```\n\nReturns status of the requested file:\n\n-   0 - file does not exist\n-   1 - file is created but has not finished uploading\n-   2 - file is fully uploaded\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter         | Description              |\n| ----------------- | ------------------------ |\n| `uint` fileStatus | Status of requested file |\n\n### Directory interaction methods\n\nFilestorage is represented with UNIX-based filesystem that consisted of files and directories. Directories are stored in `Directory` structure that contains information about its content in `ContentInfo` structure. Maximum amount of content in separate directory is **8196**.\n\n#### createDirectory\n\n```solidity\nfunction createDirectory(string memory directoryPath)\n```\n\nCreates directory in Filestorage. Owner of the directory - message sender. \n\n-   Function is called by directory owner\n-   Maximum amount of directories and files in one directory is **8196**\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### deleteDirectory\n\n```solidity\nfunction deleteDirectory(string memory directoryPath)\n```\n\nDeletes directory from Filestorage.\n\n-   Function is called by directory owner\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### listDirectory\n\n```solidity\nfunction listDirectory(string memory storagePath) \n        public \n        view \n        returns (ContentInfo[])\n```\n\nList information about content of the specific directory.\n\n**Parameters:**\n\n| Parameter            | Description                               |\n| -------------------- | ----------------------------------------- |\n| `string` storagePath | Full path of the directory in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description                          |\n| --------------- | ------------------------------------ |\n| `ContentInfo[]` | Array of content stored in directory |\n\nObject `ContentInfo` can be file or directory and contains:\n\n| Field                    | Description                                                                      |\n| ------------------------ | -------------------------------------------------------------------------------- |\n| `string` name            | Content name                                                                     |\n| `bool` isFile            | Whether content is file                                                          |\n| `uint` size              | File size, in bytes                                                              |\n| `int` status             | File uploading status                                                            |\n| `bool[]` isChunkUploaded | Array with statuses of each chunk (`true` - chunk uploaded, `false` - otherwise) |\n\n## Build\n\nCreate an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nPRIVATEKEY='Private key for test account'\n```\n\nCompile `FileStorage.sol`:\n\n```bash\ntruffle compile\n```\n\n## Test\n\nTests run only on SKALE chains. Create an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nSCHAIN_OWNER_PK='Private key of SKALE endpoint owner (or account with money)'\nPRIVATEKEY='Private key for test account'\n```\n\nRun tests:\n\n```bash\ntruffle test --network skaled\n```\n","gitHead":"1b4edbdc2b765d36743982481e4da3c269a8c81d","scripts":{"lint":"npx ethlint -d contracts","test":"npx truffle test test/unit/* --network skaled","build":"rm -r ./build; npx truffle build","compile":"npx truffle compile","slither":"slither . --filter-path strings --filter-path Migrations","version":"node -e \"console.log(require('./package.json').version);\"","coverage":"npx truffle run coverage --file=\"test/unit/*\"","lint-fix":"npm run lint -- --fix","compile-hardhat":"npx hardhat clean && npx hardhat compile","predeployed-test":"npx truffle test test/predeployed/* --network skaled"},"_npmUser":{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},"repository":{"url":"git+https://github.com/skalenetwork/filestorage.git","type":"git"},"_npmVersion":"6.14.17","description":"SKALE Filestorage contracts","directories":{},"_nodeVersion":"14.20.0","dependencies":{"@openzeppelin/contracts-upgradeable":"^4.3.2"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"chai":"^4.2.0","web3":"^1.2.1","dotenv":"^8.2.0","codecov":"^3.3.0","hardhat":"^2.6.4","truffle":"5.1.30","ts-node":"^10.2.1","typescript":"^4.4.3","randomstring":"^1.1.5","chai-as-promised":"^7.1.1","solidity-coverage":"^0.7.17","@truffle/hdwallet-provider":"^1.5.1"},"_npmOperationalInternal":{"tmp":"tmp/filestorage_1.1.0-develop.3_1659364791086_0.4127588909554254","host":"s3://npm-registry-packages"}},"1.1.0-beta.0":{"name":"@skalenetwork/filestorage","version":"1.1.0-beta.0","keywords":["SKALE","blockchain","ethereum"],"author":{"name":"SKALE Labs and contributors"},"license":"AGPL-3.0","_id":"@skalenetwork/filestorage@1.1.0-beta.0","maintainers":[{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},{"name":"dmitrytk","email":"dmitry.tkachuk@skalelabs.com"},{"name":"cstrange","email":"chadwick@skalelabs.com"},{"name":"skalelabsdev","email":"dev@skalelabs.com"},{"name":"theskyunicorn","email":"christine@skalelabs.com"},{"name":"stebaev","email":"dimastebaev@gmail.com"},{"name":"l_sergiy","email":"sergiy@skalelabs.com"}],"homepage":"https://github.com/skalenetwork/filestorage#readme","bugs":{"url":"https://github.com/skalenetwork/filestorage/issues"},"dist":{"shasum":"0fcf7fa22a203cd22bff56d30a485295d3fb3d6d","tarball":"https://registry.npmjs.org/@skalenetwork/filestorage/-/filestorage-1.1.0-beta.0.tgz","fileCount":5,"integrity":"sha512-UbZxkl1QhvGl5t3y7i25FMo49Gm/t7jjD9oEWjpVK+WohiFKYo+7QOhUPcJA3e8opHKYqev2vxZWWtC6Ptt3nA==","signatures":[{"sig":"MEUCIECP3zMqebDqMrJ12bMF1gzcyIm105u9hGXqmkbHNhlHAiEA0JiTFprab2osjJVkMobGgE+PARgF+lBfxqIdqafR44A=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":66090,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi5/VKACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmowrA//ewHzol3hK0pmm6NPccvuDNhg+0Hw0NI9uLzaWLZL/9xg7ag9\r\nfdK1sO2GuhYGE/zNsVFPBpw8BtUduWcmBAZhPT/uzD2nEXwHlok/pLNCwlZX\r\nB1GTRfWbfSrsCo10BV9pcICCaHD+RzS0e14drUwSdfp8z8w8/iiEXykmb5YQ\r\nEthWhqS8Gs2cGqHTrlJOu5rF99fXHOTZjs0cL3hKT5vximZ/S8mJNt/fhBbr\r\nPCY1/0Zr5Butz0T63amv+YeuPcnEYktsk+1/m+OLtF8+oJlLRMpwa78uMA2r\r\nViljpWWCFx+T9pjaNo+Zt/7TkMk5zoDRDDIV2XcuUHxioLpyILXvpVIgTm3U\r\n/jZoTcUXCZG434h97MxMpjyZl8XwO2osVSfP7R1RRMraCDNbd5DWBOQiaW+2\r\nt9LMWoPfH/kuDVJ3QXs8WOJRpHGH45GnjO6NVPPdZAgl0dIIU734mbHlAW9V\r\nEAdyBag2buDYrT8cDxzszKOohflR3MIVQKVL+w4gX1B5DmBiNtAANYticFrn\r\nPtHQaz10/tKviBfJVNjdqxptxqBj+MuySMZTdBuFW3CUVWsCbHRTqikSKEvL\r\n3LEJPuy7V0UWFoeIMZ0e7RT/tDy7LO2kEFa9L7Qsx9te84Ygec9MZ04X0Fu4\r\nGdy3tbqEi87BcdPRwChbGMdX5tDmBrQE120=\r\n=OtS4\r\n-----END PGP SIGNATURE-----\r\n"},"main":"artifacts.json","readme":"# SKALE Filestorage\n\n[![Build Status](https://travis-ci.com/skalenetwork/filestorage.svg?token=HYnwEPctUzUdXVcsecA6&branch=develop)](https://travis-ci.com/skalenetwork/filestorage)\n[![codecov](https://codecov.io/gh/skalenetwork/filestorage/branch/develop/graph/badge.svg?token=2wkF3kZTXh)](https://codecov.io/gh/skalenetwork/filestorage)\n[![Discord](https://img.shields.io/discord/534485763354787851.svg)](https://discord.gg/vvUtWJB)\n\nFilestorage - smart contract, that controls decentralized file storage on SKALE chains.\n\n## Description\n\nFilestorage is a cost-effective storage layer within Ethereum capable of handling files up to 100MB. Filestorage uses UNIX-based filesystem of SKALE chains. Filestorage smart contract is a set of functions to interact with files on EVM. This contract may be predeployed on SKALE chains. It contains functions to work with Filestorage precompiled smart contracts. \n\nSmart contract language - Solidity 0.8.9\n\n## API Reference\n\n### Filestorage space handling \n\nTo start using Filestorage (upload/delete files and create/remove directories) the space should be allocated for specific account, it could be done from account that is given ALLOCATOR_ROLE. \nRules of occupying space in Filestorage:\n\n1. For directory **4096** bytes is taken\n2. File could be uploaded up to **100** MB (104857600 bytes)\n3. Occupying space for file is rounded up to the nearest multiple of **4096** bytes\n4. **Empty** file takes 4096 bytes of free space\n\nAfter deleting file/directory's amount of space is freed according to the rules above\n\n### Space handling API\n#### reserveSpace\n\n```solidity\nfunction reserveSpace(address userAddress, uint reservedSpace)\n```\n\nReserves the Filestorage space for specific address. Could be called only with ALLOCATOR_ROLE\n\n**Parameters:**\n\n| Parameter             | Description                           |\n| --------------------- | ------------------------------------- |\n| `address` userAddress | Address to allocate space for         |\n| `uint` reservedSpace  | Amount of space to reserve in bytes   |\n\n#### getTotalStorageSpace\n\n```solidity\nfunction getTotalStorageSpace()\n```\n\nGets total space in Filestorage in bytes.\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Space in bytes                     |\n\n#### getTotalReservedSpace\n\n```solidity\nfunction getTotalStorageSpace()\n```\n\nGets total reserved space in Filestorage in bytes.\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Space in bytes                     |\n\n#### getReservedSpace\n\n```solidity\nfunction getReservedSpace(address owner)\n```\n\nGets reserved space for account.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `address` owner      | Account address                      |\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Size of reserved space for account |\n\n#### getOccupiedSpace\n\n```solidity\nfunction getOccupiedSpace(address owner)\n```\n\nGets occupied space for account.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `address` owner      | Account address                      |\n\n**Returns:**\n\n| Parameter       | Description                                 |\n| --------------- | ------------------------------------------- |\n| `uint`          | Size of occupied space for account in bytes |\n\n### File interaction methods\n\nTo begin the uploading process, the file should be broken into chunks of 1MB (&lt; 1MB for the last chunk) which are uploaded as separate transactions to FileStorage.sol. \nThe pipeline of the uploading file is:\n\n1.  creating empty file of fixed size on EVM by calling `startUpload`,\n2.  uploading data chunk by chunk with `uploadChunk`,\n3.  checking the file validity and finishing process with `finishUpload`.\n\n#### startUpload\n\n```solidity\nfunction startUpload(string memory filePath, uint256 fileSize)\n```\n\nCreates empty file on EVM with specific name and size. Owner of the file - message sender. \n\n-   Function is called by file owner\n-   Maximum amount of directories and files in one directory is **8196**\n-   Maximum filesize is **100,000,000** bytes\n-   Owner should have enough free space\n\n**Parameters:**\n\n| Parameter          | Description                           |\n| ------------------ | ------------------------------------- |\n| `string` filePath  | Path to the file in account directory |\n| `uint256` fileSize | Uploaded file size in bytes           |\n\n#### uploadChunk\n\n```solidity\nfunction uploadChunk(string memory filePath, uint position, bytes memory data)\n```\n\nUploads 1MB chunk of data from specific position in specific file by file owner.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n| `uint` position   | Uploaded chunk position               |\n| `bytes` data      | Uploaded chunk data                   |\n\n#### finishUpload\n\n```solidity\nfunction finishUpload(string memory filePath)\n```\n\nFinishes uploading of the file. Checks whether all chunks are uploaded correctly.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### deleteFile\n\n```solidity\nfunction deleteFile(string memory filePath)\n```\n\nDeletes file from Filestorage.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### readChunk\n\n```solidity\nfunction readChunk(string memory storagePath, uint position, uint length)\n        public\n        view\n        returns (bytes32[MAX_BLOCK_COUNT] memory out)\n```\n\nReads chunk from file from specific position with specific length. Returns `bytes32` array of fixed size with requested data.\n\n-   Maximum length of the chunk to read is 1Mb\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n| `uint` position      | First byte to read from              |\n| `uint` length        | Uploaded chunk length                |\n\n**Returns:**\n\n| Parameter       | Description                                       |\n| --------------- | ------------------------------------------------- |\n| `bytes32[]` out | Requested chunk data split across `bytes32` array |\n\n#### getFileSize\n\n```solidity\nfunction getFileSize(string memory storagePath) \n        public \n        view \n        returns (uint fileSize)\n```\n\nGets size of the requested file in bytes.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description            |\n| --------------- | ---------------------- |\n| `uint` fileSize | Size of requested file |\n\n#### getFileStatus\n\n```solidity\nfunction getFileStatus(string memory storagePath) \n        public \n        view \n        returns (int)\n```\n\nReturns status of the requested file:\n\n-   0 - file does not exist\n-   1 - file is created but has not finished uploading\n-   2 - file is fully uploaded\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter         | Description              |\n| ----------------- | ------------------------ |\n| `uint` fileStatus | Status of requested file |\n\n### Directory interaction methods\n\nFilestorage is represented with UNIX-based filesystem that consisted of files and directories. Directories are stored in `Directory` structure that contains information about its content in `ContentInfo` structure. Maximum amount of content in separate directory is **8196**.\n\n#### createDirectory\n\n```solidity\nfunction createDirectory(string memory directoryPath)\n```\n\nCreates directory in Filestorage. Owner of the directory - message sender. \n\n-   Function is called by directory owner\n-   Maximum amount of directories and files in one directory is **8196**\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### deleteDirectory\n\n```solidity\nfunction deleteDirectory(string memory directoryPath)\n```\n\nDeletes directory from Filestorage.\n\n-   Function is called by directory owner\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### listDirectory\n\n```solidity\nfunction listDirectory(string memory storagePath) \n        public \n        view \n        returns (ContentInfo[])\n```\n\nList information about content of the specific directory.\n\n**Parameters:**\n\n| Parameter            | Description                               |\n| -------------------- | ----------------------------------------- |\n| `string` storagePath | Full path of the directory in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description                          |\n| --------------- | ------------------------------------ |\n| `ContentInfo[]` | Array of content stored in directory |\n\nObject `ContentInfo` can be file or directory and contains:\n\n| Field                    | Description                                                                      |\n| ------------------------ | -------------------------------------------------------------------------------- |\n| `string` name            | Content name                                                                     |\n| `bool` isFile            | Whether content is file                                                          |\n| `uint` size              | File size, in bytes                                                              |\n| `int` status             | File uploading status                                                            |\n| `bool[]` isChunkUploaded | Array with statuses of each chunk (`true` - chunk uploaded, `false` - otherwise) |\n\n## Build\n\nCreate an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nPRIVATEKEY='Private key for test account'\n```\n\nCompile `FileStorage.sol`:\n\n```bash\ntruffle compile\n```\n\n## Test\n\nTests run only on SKALE chains. Create an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nSCHAIN_OWNER_PK='Private key of SKALE endpoint owner (or account with money)'\nPRIVATEKEY='Private key for test account'\n```\n\nRun tests:\n\n```bash\ntruffle test --network skaled\n```\n","gitHead":"f2ea49f8cc094d2feb70c5d903cbc021b2d14da8","scripts":{"lint":"npx ethlint -d contracts","test":"npx truffle test test/unit/* --network skaled","build":"rm -r ./build; npx truffle build","compile":"npx truffle compile","slither":"slither . --filter-path strings --filter-path Migrations","version":"node -e \"console.log(require('./package.json').version);\"","coverage":"npx truffle run coverage --file=\"test/unit/*\"","lint-fix":"npm run lint -- --fix","compile-hardhat":"npx hardhat clean && npx hardhat compile","predeployed-test":"npx truffle test test/predeployed/* --network skaled"},"_npmUser":{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},"repository":{"url":"git+https://github.com/skalenetwork/filestorage.git","type":"git"},"_npmVersion":"6.14.17","description":"SKALE Filestorage contracts","directories":{},"_nodeVersion":"14.20.0","dependencies":{"@openzeppelin/contracts-upgradeable":"^4.3.2"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"chai":"^4.2.0","web3":"^1.2.1","dotenv":"^8.2.0","codecov":"^3.3.0","hardhat":"^2.6.4","truffle":"5.1.30","ts-node":"^10.2.1","typescript":"^4.4.3","randomstring":"^1.1.5","chai-as-promised":"^7.1.1","solidity-coverage":"^0.7.17","@truffle/hdwallet-provider":"^1.5.1"},"_npmOperationalInternal":{"tmp":"tmp/filestorage_1.1.0-beta.0_1659368777712_0.2583333253612734","host":"s3://npm-registry-packages"}},"1.1.0-develop.4":{"name":"@skalenetwork/filestorage","version":"1.1.0-develop.4","keywords":["SKALE","blockchain","ethereum"],"author":{"name":"SKALE Labs and contributors"},"license":"AGPL-3.0","_id":"@skalenetwork/filestorage@1.1.0-develop.4","maintainers":[{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},{"name":"dmitrytk","email":"dmitry.tkachuk@skalelabs.com"},{"name":"cstrange","email":"chadwick@skalelabs.com"},{"name":"skalelabsdev","email":"dev@skalelabs.com"},{"name":"theskyunicorn","email":"christine@skalelabs.com"},{"name":"stebaev","email":"dimastebaev@gmail.com"},{"name":"l_sergiy","email":"sergiy@skalelabs.com"}],"homepage":"https://github.com/skalenetwork/filestorage#readme","bugs":{"url":"https://github.com/skalenetwork/filestorage/issues"},"dist":{"shasum":"85c9e74011846b3203eadf2829d65c1136d075f7","tarball":"https://registry.npmjs.org/@skalenetwork/filestorage/-/filestorage-1.1.0-develop.4.tgz","fileCount":5,"integrity":"sha512-AViLCUQkljmpOs9jiRTNbRmj9GlzP79IK/jkTTtdV5DdWTabSQqwJneHSrlaZS1NixBUwXvsvxRtloh2AVRVAA==","signatures":[{"sig":"MEQCIGUa5Q4ApMqpa/7eo+I6AAbSgmDTxuieaNX+ZNsRnP1sAiBqxuJ7e5utYqJJC2XosROFRaOp9daG8EaG2h1XxSQuTg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":67461,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjCR7dACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqQIQ//cDLa7m29rocwjy3agY1NYtiKK3XZg0pe8EDqd/gaE237J1MJ\r\nfxpL6yl5pAjxJmCxDpmE64XA0wn8g+iEjUJ+uiHig5BMM0KnB+rWqX1MZ3iI\r\nBpduxJm+bR5/1GdPj45kyn8sJhElmndvFuIRHqkjC2ShIPIoOcsJ7kbdVpKQ\r\nogir4goNJWL9uMV42hfT8/lxDoeZ6q8V3Moh3qu3HFhbVrQu4L5ffZrbeIRr\r\nK9gPtj4k76IMCq52O6nua3WoyRwhaUkvdwcZF0Djz4FdWZgANi6swFnWdsu7\r\nPHv0PVaX+S2ybTLNiUTaN+om+eCI0HzFf8mOZ+1mPR82+7gDgedk7Q9sQfl+\r\npsMdfJ9aW202SnYe/9NTHOo9ujlRyPIbbQTycyNm1z4GufeIn9GNgOklUOUs\r\nDhFhwBt7lkkH6R0nkZcSSXD5cOnNNwfEhadVLZyGAUdHI2inRnxhwfFr7fv4\r\n3+6QQLkxzDbqNIrANKuJ9mcUJXsSz0JlN4KPsTY67OBJo7Lddh9+//f/toCB\r\nbCpektbdMRSJkxhmXDjtRxmpkHR12W+i/glEee9wHfYNKaX5UHWCT16lWu3P\r\nBzjeBT/cCQi20pg1OZ5WagAvPnx5QhGnYgpzCvK/tyH0U2DWK4uyyytgK8MS\r\nsM5wgjXc3How3WqlwUuPijZAud4wYZlLVPA=\r\n=pTMf\r\n-----END PGP SIGNATURE-----\r\n"},"main":"artifacts.json","readme":"# SKALE Filestorage\n\n[![Build Status](https://travis-ci.com/skalenetwork/filestorage.svg?token=HYnwEPctUzUdXVcsecA6&branch=develop)](https://travis-ci.com/skalenetwork/filestorage)\n[![codecov](https://codecov.io/gh/skalenetwork/filestorage/branch/develop/graph/badge.svg?token=2wkF3kZTXh)](https://codecov.io/gh/skalenetwork/filestorage)\n[![Discord](https://img.shields.io/discord/534485763354787851.svg)](https://discord.gg/vvUtWJB)\n\nFilestorage - smart contract, that controls decentralized file storage on SKALE chains.\n\n## Description\n\nFilestorage is a cost-effective storage layer within Ethereum capable of handling files up to 100MB. Filestorage uses UNIX-based filesystem of SKALE chains. Filestorage smart contract is a set of functions to interact with files on EVM. This contract may be predeployed on SKALE chains. It contains functions to work with Filestorage precompiled smart contracts. \n\nSmart contract language - Solidity 0.8.9\n\n## API Reference\n\n### Filestorage space handling \n\nTo start using Filestorage (upload/delete files and create/remove directories) the space should be allocated for specific account, it could be done from account that is given ALLOCATOR_ROLE. \nRules of occupying space in Filestorage:\n\n1. For directory **4096** bytes is taken\n2. File could be uploaded up to **100** MB (104857600 bytes)\n3. Occupying space for file is rounded up to the nearest multiple of **4096** bytes\n4. **Empty** file takes 4096 bytes of free space\n\nAfter deleting file/directory's amount of space is freed according to the rules above\n\n### FileStorage managing API\n#### reserveSpace\n\n```solidity\nfunction reserveSpace(address userAddress, uint reservedSpace)\n```\n\nReserves the Filestorage space for specific address. Could be called only with ALLOCATOR_ROLE\n\n**Parameters:**\n\n| Parameter             | Description                           |\n| --------------------- | ------------------------------------- |\n| `address` userAddress | Address to allocate space for         |\n| `uint` reservedSpace  | Amount of space to reserve in bytes   |\n\n#### Set version\n\n```solidity\nfunction setVersion(string newVersion)\n```\n\nSet the Filestorage version. Could be called only with DEFAULT_ADMIN_ROLE\n\n**Parameters:**\n\n| Parameter             | Description                           |\n| --------------------- | ------------------------------------- |\n| `string` newVersion   | New version of the Filestorage        |\n\n#### Get version\n\n```solidity\nfunction version()\n```\n\nGet the Filestorage version.\n\n**Parameters:**\n\n| Parameter             | Description                           |\n| --------------------- | ------------------------------------- |\n| `string`              | Version of the Filestorage            |\n\n#### getTotalStorageSpace\n\n```solidity\nfunction getTotalStorageSpace()\n```\n\nGets total space in Filestorage in bytes.\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Space in bytes                     |\n\n#### getTotalReservedSpace\n\n```solidity\nfunction getTotalStorageSpace()\n```\n\nGets total reserved space in Filestorage in bytes.\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Space in bytes                     |\n\n#### getReservedSpace\n\n```solidity\nfunction getReservedSpace(address owner)\n```\n\nGets reserved space for account.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `address` owner      | Account address                      |\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Size of reserved space for account |\n\n#### getOccupiedSpace\n\n```solidity\nfunction getOccupiedSpace(address owner)\n```\n\nGets occupied space for account.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `address` owner      | Account address                      |\n\n**Returns:**\n\n| Parameter       | Description                                 |\n| --------------- | ------------------------------------------- |\n| `uint`          | Size of occupied space for account in bytes |\n\n### File interaction methods\n\nTo begin the uploading process, the file should be broken into chunks of 1MB (&lt; 1MB for the last chunk) which are uploaded as separate transactions to FileStorage.sol. \nThe pipeline of the uploading file is:\n\n1.  creating empty file of fixed size on EVM by calling `startUpload`,\n2.  uploading data chunk by chunk with `uploadChunk`,\n3.  checking the file validity and finishing process with `finishUpload`.\n\n#### startUpload\n\n```solidity\nfunction startUpload(string memory filePath, uint256 fileSize)\n```\n\nCreates empty file on EVM with specific name and size. Owner of the file - message sender. \n\n-   Function is called by file owner\n-   Maximum amount of directories and files in one directory is **8196**\n-   Maximum filesize is **100,000,000** bytes\n-   Owner should have enough free space\n\n**Parameters:**\n\n| Parameter          | Description                           |\n| ------------------ | ------------------------------------- |\n| `string` filePath  | Path to the file in account directory |\n| `uint256` fileSize | Uploaded file size in bytes           |\n\n#### uploadChunk\n\n```solidity\nfunction uploadChunk(string memory filePath, uint position, bytes memory data)\n```\n\nUploads 1MB chunk of data from specific position in specific file by file owner.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n| `uint` position   | Uploaded chunk position               |\n| `bytes` data      | Uploaded chunk data                   |\n\n#### finishUpload\n\n```solidity\nfunction finishUpload(string memory filePath)\n```\n\nFinishes uploading of the file. Checks whether all chunks are uploaded correctly.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### deleteFile\n\n```solidity\nfunction deleteFile(string memory filePath)\n```\n\nDeletes file from Filestorage.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### readChunk\n\n```solidity\nfunction readChunk(string memory storagePath, uint position, uint length)\n        public\n        view\n        returns (bytes32[MAX_BLOCK_COUNT] memory out)\n```\n\nReads chunk from file from specific position with specific length. Returns `bytes32` array of fixed size with requested data.\n\n-   Maximum length of the chunk to read is 1Mb\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n| `uint` position      | First byte to read from              |\n| `uint` length        | Uploaded chunk length                |\n\n**Returns:**\n\n| Parameter       | Description                                       |\n| --------------- | ------------------------------------------------- |\n| `bytes32[]` out | Requested chunk data split across `bytes32` array |\n\n#### getFileSize\n\n```solidity\nfunction getFileSize(string memory storagePath) \n        public \n        view \n        returns (uint fileSize)\n```\n\nGets size of the requested file in bytes.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description            |\n| --------------- | ---------------------- |\n| `uint` fileSize | Size of requested file |\n\n#### getFileStatus\n\n```solidity\nfunction getFileStatus(string memory storagePath) \n        public \n        view \n        returns (int)\n```\n\nReturns status of the requested file:\n\n-   0 - file does not exist\n-   1 - file is created but has not finished uploading\n-   2 - file is fully uploaded\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter         | Description              |\n| ----------------- | ------------------------ |\n| `uint` fileStatus | Status of requested file |\n\n### Directory interaction methods\n\nFilestorage is represented with UNIX-based filesystem that consisted of files and directories. Directories are stored in `Directory` structure that contains information about its content in `ContentInfo` structure. Maximum amount of content in separate directory is **8196**.\n\n#### createDirectory\n\n```solidity\nfunction createDirectory(string memory directoryPath)\n```\n\nCreates directory in Filestorage. Owner of the directory - message sender. \n\n-   Function is called by directory owner\n-   Maximum amount of directories and files in one directory is **8196**\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### deleteDirectory\n\n```solidity\nfunction deleteDirectory(string memory directoryPath)\n```\n\nDeletes directory from Filestorage.\n\n-   Function is called by directory owner\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### listDirectory\n\n```solidity\nfunction listDirectory(string memory storagePath) \n        public \n        view \n        returns (ContentInfo[])\n```\n\nList information about content of the specific directory.\n\n**Parameters:**\n\n| Parameter            | Description                               |\n| -------------------- | ----------------------------------------- |\n| `string` storagePath | Full path of the directory in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description                          |\n| --------------- | ------------------------------------ |\n| `ContentInfo[]` | Array of content stored in directory |\n\nObject `ContentInfo` can be file or directory and contains:\n\n| Field                    | Description                                                                      |\n| ------------------------ | -------------------------------------------------------------------------------- |\n| `string` name            | Content name                                                                     |\n| `bool` isFile            | Whether content is file                                                          |\n| `uint` size              | File size, in bytes                                                              |\n| `int` status             | File uploading status                                                            |\n| `bool[]` isChunkUploaded | Array with statuses of each chunk (`true` - chunk uploaded, `false` - otherwise) |\n\n## Build\n\nCreate an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nPRIVATEKEY='Private key for test account'\n```\n\nCompile `FileStorage.sol`:\n\n```bash\ntruffle compile\n```\n\n## Test\n\nTests run only on SKALE chains. Create an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nSCHAIN_OWNER_PK='Private key of SKALE endpoint owner (or account with money)'\nPRIVATEKEY='Private key for test account'\n```\n\nRun tests:\n\n```bash\ntruffle test --network skaled\n```\n","gitHead":"8d218d89db553251b75dc4b46862395ee45da5e4","scripts":{"lint":"npx ethlint -d contracts","test":"npx truffle test test/unit/* --network skaled","build":"rm -r ./build; npx truffle build","compile":"npx truffle compile","slither":"slither . --filter-path strings --filter-path Migrations","version":"node -e \"console.log(require('./package.json').version);\"","coverage":"npx truffle run coverage --file=\"test/unit/*\"","lint-fix":"npm run lint -- --fix","compile-hardhat":"npx hardhat clean && npx hardhat compile","predeployed-test":"npx truffle test test/predeployed/* --network skaled"},"_npmUser":{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},"repository":{"url":"git+https://github.com/skalenetwork/filestorage.git","type":"git"},"_npmVersion":"6.14.17","description":"SKALE Filestorage contracts","directories":{},"_nodeVersion":"14.20.0","dependencies":{"@openzeppelin/contracts-upgradeable":"^4.3.2"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"chai":"^4.2.0","web3":"^1.2.1","dotenv":"^8.2.0","codecov":"^3.3.0","hardhat":"^2.6.4","truffle":"5.1.30","ts-node":"^10.2.1","typescript":"^4.4.3","randomstring":"^1.1.5","chai-as-promised":"^7.1.1","solidity-coverage":"^0.7.17","@truffle/hdwallet-provider":"^1.5.1"},"_npmOperationalInternal":{"tmp":"tmp/filestorage_1.1.0-develop.4_1661542109065_0.31082809874168205","host":"s3://npm-registry-packages"}},"1.1.0-develop.5":{"name":"@skalenetwork/filestorage","version":"1.1.0-develop.5","keywords":["SKALE","blockchain","ethereum"],"author":{"name":"SKALE Labs and contributors"},"license":"AGPL-3.0","_id":"@skalenetwork/filestorage@1.1.0-develop.5","maintainers":[{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},{"name":"dmitrytk","email":"dmitry.tkachuk@skalelabs.com"},{"name":"cstrange","email":"chadwick@skalelabs.com"},{"name":"skalelabsdev","email":"dev@skalelabs.com"},{"name":"theskyunicorn","email":"christine@skalelabs.com"},{"name":"stebaev","email":"dimastebaev@gmail.com"},{"name":"l_sergiy","email":"sergiy@skalelabs.com"}],"homepage":"https://github.com/skalenetwork/filestorage#readme","bugs":{"url":"https://github.com/skalenetwork/filestorage/issues"},"dist":{"shasum":"a0b5d230de1dd316ecb19bfa8fdb45a3dd0ca35c","tarball":"https://registry.npmjs.org/@skalenetwork/filestorage/-/filestorage-1.1.0-develop.5.tgz","fileCount":5,"integrity":"sha512-VlGHODqJ0eLdZeC2G4gKfuEDuMOqn+zB/1hog3TwA6tn8hljeBTCFZSlc+RWzUTLL6YepkB2GTFFgsQeGU+AUg==","signatures":[{"sig":"MEUCIBdYvXGwyvI88Zyl0K7FyDkIPv7A+P04kLkJIQ+k3hpFAiEA+pir0wORkRL2Rm50XY3AdSrWvbIqRsdXrPn7yWwUVXA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":68336,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjIb/iACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmr4RQ//VJtuz1UrK0n3gWuTE2yTfS8qDPrJfM084HZfy4aUfrlCuWXE\r\nmjQ1J99Pa4aotRpAlx3BGom2ah/XnuGw2XyLGD+Ciqc/CB8hye+IZ5Ao96pG\r\nd8giXWb8txQu/XEsGsE7ISQMRUSfva0D9qNeSs4iG6YOZrHN+au3ueE2L9+v\r\n3Zph2ykIPpx+6GvkX4KDf6YXwCC2s/VhoTlBFfxhnBniDKb/H/P/AcLS6zjT\r\nGAzx5GG/GdA5c3Un/wzKy05xM3ccMU+PBwDhTAUM58Ut0Esv0Z6xRE2Ybk8v\r\nYwc6OEMhBJK/UuC/qm2sLWHaeRHbh6Pij1DUUyaN5Z2Yqt8VuFExpTkSKvEu\r\nSm73yo48KWv9tTg7cIMGdJK6la6rlVw1hkjFPiJr8BQh4nAPE79NLPji6TQo\r\nw6D09WcyPeHYzpExx8wKq9vjuF3p1Ee048RJCSkajW+tua5ts47zB+8hOlup\r\nKHc1oMI1zfwlLDfUrrSP0d9Dzfe53j60GXQJVE9504FGQljpOBK+Wko6/8fm\r\nUVp33ukiWNyJtKa/0S4FVQO4YB07H8GvLcXC88GIWRgl6Gv1P24u4b/408rb\r\nQFs9an9S+CqEipG2Bjlvmbd/s46Z4/C0+Mu7uU29MUH78zPcM/7flYp68LgQ\r\nyX99Mwz9yOnFoWqFwmeb/xGiXH8GW3UpQmQ=\r\n=aFF4\r\n-----END PGP SIGNATURE-----\r\n"},"main":"artifacts.json","readme":"# SKALE Filestorage\n\n[![Build Status](https://travis-ci.com/skalenetwork/filestorage.svg?token=HYnwEPctUzUdXVcsecA6&branch=develop)](https://travis-ci.com/skalenetwork/filestorage)\n[![codecov](https://codecov.io/gh/skalenetwork/filestorage/branch/develop/graph/badge.svg?token=2wkF3kZTXh)](https://codecov.io/gh/skalenetwork/filestorage)\n[![Discord](https://img.shields.io/discord/534485763354787851.svg)](https://discord.gg/vvUtWJB)\n\nFilestorage - smart contract, that controls decentralized file storage on SKALE chains.\n\n## Description\n\nFilestorage is a cost-effective storage layer within Ethereum capable of handling files up to 100MB. Filestorage uses UNIX-based filesystem of SKALE chains. Filestorage smart contract is a set of functions to interact with files on EVM. This contract may be predeployed on SKALE chains. It contains functions to work with Filestorage precompiled smart contracts. \n\nSmart contract language - Solidity 0.8.9\n\n## API Reference\n\n### Filestorage space handling \n\nTo start using Filestorage (upload/delete files and create/remove directories) the space should be allocated for specific account, it could be done from account that is given ALLOCATOR_ROLE. \nRules of occupying space in Filestorage:\n\n1. For directory **4096** bytes is taken\n2. File could be uploaded up to **100** MB (104857600 bytes)\n3. Occupying space for file is rounded up to the nearest multiple of **4096** bytes\n4. **Empty** file takes 4096 bytes of free space\n\nAfter deleting file/directory's amount of space is freed according to the rules above\n\n### FileStorage managing API\n#### reserveSpace\n\n```solidity\nfunction reserveSpace(address userAddress, uint reservedSpace)\n```\n\nReserves the Filestorage space for specific address. Could be called only with ALLOCATOR_ROLE\n\n**Parameters:**\n\n| Parameter             | Description                           |\n| --------------------- | ------------------------------------- |\n| `address` userAddress | Address to allocate space for         |\n| `uint` reservedSpace  | Amount of space to reserve in bytes   |\n\n#### Set version\n\n```solidity\nfunction setVersion(string newVersion)\n```\n\nSet the Filestorage version. Could be called only with DEFAULT_ADMIN_ROLE\n\n**Parameters:**\n\n| Parameter             | Description                           |\n| --------------------- | ------------------------------------- |\n| `string` newVersion   | New version of the Filestorage        |\n\n#### Get version\n\n```solidity\nfunction version()\n```\n\nGet the Filestorage version.\n\n**Parameters:**\n\n| Parameter             | Description                           |\n| --------------------- | ------------------------------------- |\n| `string`              | Version of the Filestorage            |\n\n#### getTotalStorageSpace\n\n```solidity\nfunction getTotalStorageSpace()\n```\n\nGets total space in Filestorage in bytes.\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Space in bytes                     |\n\n#### getTotalReservedSpace\n\n```solidity\nfunction getTotalStorageSpace()\n```\n\nGets total reserved space in Filestorage in bytes.\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Space in bytes                     |\n\n#### getReservedSpace\n\n```solidity\nfunction getReservedSpace(address owner)\n```\n\nGets reserved space for account.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `address` owner      | Account address                      |\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Size of reserved space for account |\n\n#### getOccupiedSpace\n\n```solidity\nfunction getOccupiedSpace(address owner)\n```\n\nGets occupied space for account.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `address` owner      | Account address                      |\n\n**Returns:**\n\n| Parameter       | Description                                 |\n| --------------- | ------------------------------------------- |\n| `uint`          | Size of occupied space for account in bytes |\n\n### File interaction methods\n\nTo begin the uploading process, the file should be broken into chunks of 1MB (&lt; 1MB for the last chunk) which are uploaded as separate transactions to FileStorage.sol. \nThe pipeline of the uploading file is:\n\n1.  creating empty file of fixed size on EVM by calling `startUpload`,\n2.  uploading data chunk by chunk with `uploadChunk`,\n3.  checking the file validity and finishing process with `finishUpload`.\n\n#### startUpload\n\n```solidity\nfunction startUpload(string memory filePath, uint256 fileSize)\n```\n\nCreates empty file on EVM with specific name and size. Owner of the file - message sender. \n\n-   Function is called by file owner\n-   Maximum amount of directories and files in one directory is **8196**\n-   Maximum filesize is **100,000,000** bytes\n-   Owner should have enough free space\n\n**Parameters:**\n\n| Parameter          | Description                           |\n| ------------------ | ------------------------------------- |\n| `string` filePath  | Path to the file in account directory |\n| `uint256` fileSize | Uploaded file size in bytes           |\n\n#### uploadChunk\n\n```solidity\nfunction uploadChunk(string memory filePath, uint position, bytes memory data)\n```\n\nUploads 1MB chunk of data from specific position in specific file by file owner.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n| `uint` position   | Uploaded chunk position               |\n| `bytes` data      | Uploaded chunk data                   |\n\n#### finishUpload\n\n```solidity\nfunction finishUpload(string memory filePath)\n```\n\nFinishes uploading of the file. Checks whether all chunks are uploaded correctly.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### deleteFile\n\n```solidity\nfunction deleteFile(string memory filePath)\n```\n\nDeletes file from Filestorage.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### readChunk\n\n```solidity\nfunction readChunk(string memory storagePath, uint position, uint length)\n        public\n        view\n        returns (bytes32[MAX_BLOCK_COUNT] memory out)\n```\n\nReads chunk from file from specific position with specific length. Returns `bytes32` array of fixed size with requested data.\n\n-   Maximum length of the chunk to read is 1Mb\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n| `uint` position      | First byte to read from              |\n| `uint` length        | Uploaded chunk length                |\n\n**Returns:**\n\n| Parameter       | Description                                       |\n| --------------- | ------------------------------------------------- |\n| `bytes32[]` out | Requested chunk data split across `bytes32` array |\n\n#### getFileSize\n\n```solidity\nfunction getFileSize(string memory storagePath) \n        public \n        view \n        returns (uint fileSize)\n```\n\nGets size of the requested file in bytes.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description            |\n| --------------- | ---------------------- |\n| `uint` fileSize | Size of requested file |\n\n#### getFileStatus\n\n```solidity\nfunction getFileStatus(string memory storagePath) \n        public \n        view \n        returns (int)\n```\n\nReturns status of the requested file:\n\n-   0 - file does not exist\n-   1 - file is created but has not finished uploading\n-   2 - file is fully uploaded\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter         | Description              |\n| ----------------- | ------------------------ |\n| `uint` fileStatus | Status of requested file |\n\n### Directory interaction methods\n\nFilestorage is represented with UNIX-based filesystem that consisted of files and directories. Directories are stored in `Directory` structure that contains information about its content in `ContentInfo` structure. Maximum amount of content in separate directory is **8196**.\n\n#### createDirectory\n\n```solidity\nfunction createDirectory(string memory directoryPath)\n```\n\nCreates directory in Filestorage. Owner of the directory - message sender. \n\n-   Function is called by directory owner\n-   Maximum amount of directories and files in one directory is **8196**\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### deleteDirectory\n\n```solidity\nfunction deleteDirectory(string memory directoryPath)\n```\n\nDeletes directory from Filestorage.\n\n-   Function is called by directory owner\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### listDirectory\n\n```solidity\nfunction listDirectory(string memory storagePath) \n        public \n        view \n        returns (ContentInfo[])\n```\n\nList information about content of the specific directory.\n\n**Parameters:**\n\n| Parameter            | Description                               |\n| -------------------- | ----------------------------------------- |\n| `string` storagePath | Full path of the directory in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description                          |\n| --------------- | ------------------------------------ |\n| `ContentInfo[]` | Array of content stored in directory |\n\nObject `ContentInfo` can be file or directory and contains:\n\n| Field                    | Description                                                                      |\n| ------------------------ | -------------------------------------------------------------------------------- |\n| `string` name            | Content name                                                                     |\n| `bool` isFile            | Whether content is file                                                          |\n| `uint` size              | File size, in bytes                                                              |\n| `int` status             | File uploading status                                                            |\n| `bool[]` isChunkUploaded | Array with statuses of each chunk (`true` - chunk uploaded, `false` - otherwise) |\n\n## Build\n\nCreate an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nPRIVATEKEY='Private key for test account'\n```\n\nCompile `FileStorage.sol`:\n\n```bash\ntruffle compile\n```\n\n## Test\n\nTests run only on SKALE chains. Create an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nSCHAIN_OWNER_PK='Private key of SKALE endpoint owner (or account with money)'\nPRIVATEKEY='Private key for test account'\n```\n\nRun tests:\n\n```bash\ntruffle test --network skaled\n```\n","gitHead":"e4bbfc0789ad9ddce8486b572e7acbcac7ef34c0","scripts":{"lint":"npx ethlint -d contracts","test":"npx truffle test test/unit/* --network skaled","build":"rm -r ./build; npx truffle build","compile":"npx truffle compile","slither":"slither . --filter-path strings --filter-path Migrations","version":"node -e \"console.log(require('./package.json').version);\"","coverage":"npx truffle run coverage --file=\"test/unit/*\"","lint-fix":"npm run lint -- --fix","compile-hardhat":"npx hardhat clean && npx hardhat compile","predeployed-test":"npx truffle test test/predeployed/* --network skaled"},"_npmUser":{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},"repository":{"url":"git+https://github.com/skalenetwork/filestorage.git","type":"git"},"_npmVersion":"6.14.17","description":"SKALE Filestorage contracts","directories":{},"_nodeVersion":"14.20.0","dependencies":{"@openzeppelin/contracts-upgradeable":"^4.3.2"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"chai":"^4.2.0","web3":"^1.2.1","dotenv":"^8.2.0","codecov":"^3.3.0","hardhat":"^2.6.4","truffle":"5.1.30","ts-node":"^10.2.1","typescript":"^4.4.3","randomstring":"^1.1.5","chai-as-promised":"^7.1.1","solidity-coverage":"^0.7.17","@truffle/hdwallet-provider":"^1.5.1"},"_npmOperationalInternal":{"tmp":"tmp/filestorage_1.1.0-develop.5_1663156194181_0.9562181804770777","host":"s3://npm-registry-packages"}},"1.1.0-beta.1":{"name":"@skalenetwork/filestorage","version":"1.1.0-beta.1","keywords":["SKALE","blockchain","ethereum"],"author":{"name":"SKALE Labs and contributors"},"license":"AGPL-3.0","_id":"@skalenetwork/filestorage@1.1.0-beta.1","maintainers":[{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},{"name":"dmitrytk","email":"dmitry.tkachuk@skalelabs.com"},{"name":"cstrange","email":"chadwick@skalelabs.com"},{"name":"skalelabsdev","email":"dev@skalelabs.com"},{"name":"theskyunicorn","email":"christine@skalelabs.com"},{"name":"stebaev","email":"dimastebaev@gmail.com"},{"name":"l_sergiy","email":"sergiy@skalelabs.com"}],"homepage":"https://github.com/skalenetwork/filestorage#readme","bugs":{"url":"https://github.com/skalenetwork/filestorage/issues"},"dist":{"shasum":"75b6fcd1a6f51b2f41f8f363c80556da7cc07ccf","tarball":"https://registry.npmjs.org/@skalenetwork/filestorage/-/filestorage-1.1.0-beta.1.tgz","fileCount":5,"integrity":"sha512-XTAbEBmmKnjhik3ASKZsNmDpN9c4W/IFfePUzJlXDYsKnXXPO/RCx++w7AD4fe0sYBEmns8uigughFj8pV98jA==","signatures":[{"sig":"MEUCIE65vk1l3FTj/na2fkKi7Ve7jqWG83U7NEdrLxK8dgm9AiEA/11npkYvQYqcyYyblgqDSZqyC9bHeqcfT6ECVaBXhNQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":68333,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjLEyxACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpGLg//YUx5WnxHqQdMkLbRiLtuWnxEGOU9lNT+ZSnu4mUqTq0JGQpg\r\ngX4M3+gI4InZmtByR/Oz4oDsW9hq85vXcSNunP+QMvyGkytdQHPnzYAWIwbr\r\n9C5pfWdWkHyj8BesUYCm5BrXP/9F48v7rJ9GMEshabHG8UFM5o/SR1cRGqCx\r\nPuxs6is6d0Wx1rhaO5RHOzntEVQpa3DTqEHkP1kTBF/3mqGRBJbAmr5dZojC\r\nyF5sZtYkTtPGEjzc6Gj23IaMqxf7VT63FiByhlabkAG6+/psfljsNTwJmuRD\r\n9txOEO/nPF2wqiA0/SROhv0VTquUU0fxKMnU4+Y3eG139PWteRk8KiTT/ZcO\r\nDAvDs9NaSw8gJ7iwqQ+jXZY+OrbTDy9Nwz0p5BmW6cfgBebEjnVHGqNR0YLI\r\nWlMRn6FEs8xDNZbdZsevyxsVcHdhRCMw1q00P1iGxfOtejqESLjbOZXp8DhD\r\n+IwKYWy5YpK6lKCqCL3qw6wZuYFH3ICUF56zMKZKmAG2y9TwKbCV13KtEP5x\r\n1+q7cyyy3jB7ARW6Gc4azeMWKBO1W267i7fAZ8Cg8buxYGuBY+nMeyXN2dPc\r\nivKtMidY+wDavR1FfWb+S7S1vIjGLV4ORcVaQaPnEbDeEbNP5naQzHZXtKE6\r\nm70jatUQs5VypVFW9Ede+tBocCWZTCTsMBQ=\r\n=rfxu\r\n-----END PGP SIGNATURE-----\r\n"},"main":"artifacts.json","readme":"# SKALE Filestorage\n\n[![Build Status](https://travis-ci.com/skalenetwork/filestorage.svg?token=HYnwEPctUzUdXVcsecA6&branch=develop)](https://travis-ci.com/skalenetwork/filestorage)\n[![codecov](https://codecov.io/gh/skalenetwork/filestorage/branch/develop/graph/badge.svg?token=2wkF3kZTXh)](https://codecov.io/gh/skalenetwork/filestorage)\n[![Discord](https://img.shields.io/discord/534485763354787851.svg)](https://discord.gg/vvUtWJB)\n\nFilestorage - smart contract, that controls decentralized file storage on SKALE chains.\n\n## Description\n\nFilestorage is a cost-effective storage layer within Ethereum capable of handling files up to 100MB. Filestorage uses UNIX-based filesystem of SKALE chains. Filestorage smart contract is a set of functions to interact with files on EVM. This contract may be predeployed on SKALE chains. It contains functions to work with Filestorage precompiled smart contracts. \n\nSmart contract language - Solidity 0.8.9\n\n## API Reference\n\n### Filestorage space handling \n\nTo start using Filestorage (upload/delete files and create/remove directories) the space should be allocated for specific account, it could be done from account that is given ALLOCATOR_ROLE. \nRules of occupying space in Filestorage:\n\n1. For directory **4096** bytes is taken\n2. File could be uploaded up to **100** MB (104857600 bytes)\n3. Occupying space for file is rounded up to the nearest multiple of **4096** bytes\n4. **Empty** file takes 4096 bytes of free space\n\nAfter deleting file/directory's amount of space is freed according to the rules above\n\n### FileStorage managing API\n#### reserveSpace\n\n```solidity\nfunction reserveSpace(address userAddress, uint reservedSpace)\n```\n\nReserves the Filestorage space for specific address. Could be called only with ALLOCATOR_ROLE\n\n**Parameters:**\n\n| Parameter             | Description                           |\n| --------------------- | ------------------------------------- |\n| `address` userAddress | Address to allocate space for         |\n| `uint` reservedSpace  | Amount of space to reserve in bytes   |\n\n#### Set version\n\n```solidity\nfunction setVersion(string newVersion)\n```\n\nSet the Filestorage version. Could be called only with DEFAULT_ADMIN_ROLE\n\n**Parameters:**\n\n| Parameter             | Description                           |\n| --------------------- | ------------------------------------- |\n| `string` newVersion   | New version of the Filestorage        |\n\n#### Get version\n\n```solidity\nfunction version()\n```\n\nGet the Filestorage version.\n\n**Parameters:**\n\n| Parameter             | Description                           |\n| --------------------- | ------------------------------------- |\n| `string`              | Version of the Filestorage            |\n\n#### getTotalStorageSpace\n\n```solidity\nfunction getTotalStorageSpace()\n```\n\nGets total space in Filestorage in bytes.\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Space in bytes                     |\n\n#### getTotalReservedSpace\n\n```solidity\nfunction getTotalStorageSpace()\n```\n\nGets total reserved space in Filestorage in bytes.\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Space in bytes                     |\n\n#### getReservedSpace\n\n```solidity\nfunction getReservedSpace(address owner)\n```\n\nGets reserved space for account.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `address` owner      | Account address                      |\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Size of reserved space for account |\n\n#### getOccupiedSpace\n\n```solidity\nfunction getOccupiedSpace(address owner)\n```\n\nGets occupied space for account.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `address` owner      | Account address                      |\n\n**Returns:**\n\n| Parameter       | Description                                 |\n| --------------- | ------------------------------------------- |\n| `uint`          | Size of occupied space for account in bytes |\n\n### File interaction methods\n\nTo begin the uploading process, the file should be broken into chunks of 1MB (&lt; 1MB for the last chunk) which are uploaded as separate transactions to FileStorage.sol. \nThe pipeline of the uploading file is:\n\n1.  creating empty file of fixed size on EVM by calling `startUpload`,\n2.  uploading data chunk by chunk with `uploadChunk`,\n3.  checking the file validity and finishing process with `finishUpload`.\n\n#### startUpload\n\n```solidity\nfunction startUpload(string memory filePath, uint256 fileSize)\n```\n\nCreates empty file on EVM with specific name and size. Owner of the file - message sender. \n\n-   Function is called by file owner\n-   Maximum amount of directories and files in one directory is **8196**\n-   Maximum filesize is **100,000,000** bytes\n-   Owner should have enough free space\n\n**Parameters:**\n\n| Parameter          | Description                           |\n| ------------------ | ------------------------------------- |\n| `string` filePath  | Path to the file in account directory |\n| `uint256` fileSize | Uploaded file size in bytes           |\n\n#### uploadChunk\n\n```solidity\nfunction uploadChunk(string memory filePath, uint position, bytes memory data)\n```\n\nUploads 1MB chunk of data from specific position in specific file by file owner.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n| `uint` position   | Uploaded chunk position               |\n| `bytes` data      | Uploaded chunk data                   |\n\n#### finishUpload\n\n```solidity\nfunction finishUpload(string memory filePath)\n```\n\nFinishes uploading of the file. Checks whether all chunks are uploaded correctly.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### deleteFile\n\n```solidity\nfunction deleteFile(string memory filePath)\n```\n\nDeletes file from Filestorage.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### readChunk\n\n```solidity\nfunction readChunk(string memory storagePath, uint position, uint length)\n        public\n        view\n        returns (bytes32[MAX_BLOCK_COUNT] memory out)\n```\n\nReads chunk from file from specific position with specific length. Returns `bytes32` array of fixed size with requested data.\n\n-   Maximum length of the chunk to read is 1Mb\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n| `uint` position      | First byte to read from              |\n| `uint` length        | Uploaded chunk length                |\n\n**Returns:**\n\n| Parameter       | Description                                       |\n| --------------- | ------------------------------------------------- |\n| `bytes32[]` out | Requested chunk data split across `bytes32` array |\n\n#### getFileSize\n\n```solidity\nfunction getFileSize(string memory storagePath) \n        public \n        view \n        returns (uint fileSize)\n```\n\nGets size of the requested file in bytes.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description            |\n| --------------- | ---------------------- |\n| `uint` fileSize | Size of requested file |\n\n#### getFileStatus\n\n```solidity\nfunction getFileStatus(string memory storagePath) \n        public \n        view \n        returns (int)\n```\n\nReturns status of the requested file:\n\n-   0 - file does not exist\n-   1 - file is created but has not finished uploading\n-   2 - file is fully uploaded\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter         | Description              |\n| ----------------- | ------------------------ |\n| `uint` fileStatus | Status of requested file |\n\n### Directory interaction methods\n\nFilestorage is represented with UNIX-based filesystem that consisted of files and directories. Directories are stored in `Directory` structure that contains information about its content in `ContentInfo` structure. Maximum amount of content in separate directory is **8196**.\n\n#### createDirectory\n\n```solidity\nfunction createDirectory(string memory directoryPath)\n```\n\nCreates directory in Filestorage. Owner of the directory - message sender. \n\n-   Function is called by directory owner\n-   Maximum amount of directories and files in one directory is **8196**\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### deleteDirectory\n\n```solidity\nfunction deleteDirectory(string memory directoryPath)\n```\n\nDeletes directory from Filestorage.\n\n-   Function is called by directory owner\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### listDirectory\n\n```solidity\nfunction listDirectory(string memory storagePath) \n        public \n        view \n        returns (ContentInfo[])\n```\n\nList information about content of the specific directory.\n\n**Parameters:**\n\n| Parameter            | Description                               |\n| -------------------- | ----------------------------------------- |\n| `string` storagePath | Full path of the directory in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description                          |\n| --------------- | ------------------------------------ |\n| `ContentInfo[]` | Array of content stored in directory |\n\nObject `ContentInfo` can be file or directory and contains:\n\n| Field                    | Description                                                                      |\n| ------------------------ | -------------------------------------------------------------------------------- |\n| `string` name            | Content name                                                                     |\n| `bool` isFile            | Whether content is file                                                          |\n| `uint` size              | File size, in bytes                                                              |\n| `int` status             | File uploading status                                                            |\n| `bool[]` isChunkUploaded | Array with statuses of each chunk (`true` - chunk uploaded, `false` - otherwise) |\n\n## Build\n\nCreate an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nPRIVATEKEY='Private key for test account'\n```\n\nCompile `FileStorage.sol`:\n\n```bash\ntruffle compile\n```\n\n## Test\n\nTests run only on SKALE chains. Create an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nSCHAIN_OWNER_PK='Private key of SKALE endpoint owner (or account with money)'\nPRIVATEKEY='Private key for test account'\n```\n\nRun tests:\n\n```bash\ntruffle test --network skaled\n```\n","gitHead":"8fc2b070d8fcff74d2358b0f18a0924a256bd3b1","scripts":{"lint":"npx ethlint -d contracts","test":"npx truffle test test/unit/* --network skaled","build":"rm -r ./build; npx truffle build","compile":"npx truffle compile","slither":"slither . --filter-path strings --filter-path Migrations","version":"node -e \"console.log(require('./package.json').version);\"","coverage":"npx truffle run coverage --file=\"test/unit/*\"","lint-fix":"npm run lint -- --fix","compile-hardhat":"npx hardhat clean && npx hardhat compile","predeployed-test":"npx truffle test test/predeployed/* --network skaled"},"_npmUser":{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},"repository":{"url":"git+https://github.com/skalenetwork/filestorage.git","type":"git"},"_npmVersion":"6.14.17","description":"SKALE Filestorage contracts","directories":{},"_nodeVersion":"14.20.0","dependencies":{"@openzeppelin/contracts-upgradeable":"^4.3.2"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"chai":"^4.2.0","web3":"^1.2.1","dotenv":"^8.2.0","codecov":"^3.3.0","hardhat":"^2.6.4","truffle":"5.1.30","ts-node":"^10.2.1","typescript":"^4.4.3","randomstring":"^1.1.5","chai-as-promised":"^7.1.1","solidity-coverage":"^0.7.17","@truffle/hdwallet-provider":"^1.5.1"},"_npmOperationalInternal":{"tmp":"tmp/filestorage_1.1.0-beta.1_1663847601767_0.30508084072966635","host":"s3://npm-registry-packages"}},"1.1.0-develop.6":{"name":"@skalenetwork/filestorage","version":"1.1.0-develop.6","keywords":["SKALE","blockchain","ethereum"],"author":{"name":"SKALE Labs and contributors"},"license":"AGPL-3.0","_id":"@skalenetwork/filestorage@1.1.0-develop.6","maintainers":[{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},{"name":"dmitrytk","email":"dmitry.tkachuk@skalelabs.com"},{"name":"cstrange","email":"chadwick@skalelabs.com"},{"name":"skalelabsdev","email":"dev@skalelabs.com"},{"name":"theskyunicorn","email":"christine@skalelabs.com"},{"name":"stebaev","email":"dimastebaev@gmail.com"},{"name":"l_sergiy","email":"sergiy@skalelabs.com"}],"homepage":"https://github.com/skalenetwork/filestorage#readme","bugs":{"url":"https://github.com/skalenetwork/filestorage/issues"},"dist":{"shasum":"5f7b082bdeed06bb6f4c7607fc083a3b873aa5ba","tarball":"https://registry.npmjs.org/@skalenetwork/filestorage/-/filestorage-1.1.0-develop.6.tgz","fileCount":5,"integrity":"sha512-xd8eDbAEIYPxaWNEcmxN5gdtTCNYlmX7NLO7snqCs62IHZcw3dVI4fs1DNOj6l3JMw7+YZDdEEWplYZmNmQVaw==","signatures":[{"sig":"MEQCIHy9IDbr5pfi3SHBG1kuh4ittm/7EhpleMwgNe+uKHTtAiApf2a46rZ+xDyCTVmeQptk0J+NZBn5Zfn/NEd8KDa4kw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":68336,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjSHglACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqyFQ/9GtJteVRH+6QjrppQeFlkx8Vow14Dd41JguOEo2CEAGMYcKXl\r\nLVddzdrtwVIENfkXgwThOOlU0mcJ2cZprzz12GbeIPqoA6hrB2k82mx0j3Zb\r\n1xsh0jPqZ2cd8iroFa1L+Py2+PAdvQFF+zp4KAR/EGYT/GvXqjJ8hV3M8s+F\r\nQjTYPd81vwcj4FJDb1Eq/6UqNny1eWQkDdNGlkdbUHtRRSiA+9PLwWGHgGnn\r\nverE19EGh1idqfNaeC77m8LqFpTIxsfHRhIVPMzzgKtPX2XDGQVIuC2jrscs\r\nNXYIdfjyO1MgYvL5zazUjM+JnZPxqjx8lFnhE8a7eFfmbXxEq7eOxycqVmZd\r\n2+wvKRHZ0R0G8NljuTTmLaEtHhPlfAxf2WhkVAUgm/Bx/ElxfaW/m2zL5dsy\r\n/9E6TEVwefsM/dWOeI8H4bSbWPZiqwT7pjXQhaJVb+/LGaRPmUeiJAT/SoVt\r\ny4MtgJKw/aXqvhD2jpNbK9zZInBHIUYPS21eh7/W2RCVxH9Zn2chAktBPDJp\r\nYgymD5Nxqe7Wwt0n26YM7Kr9TKV316wGNkuS4iSns0GT8f8xJKN1Zt85Dhyy\r\n6T8yvr+ZAOuIRTvqI2ROAnPuSDl5BuXHkpIm8vprV6dxiCveL++GPLCena2H\r\npIpGVtdtzheH8rWXuTOVFm1kwBL3Ac8m0Hc=\r\n=8gUF\r\n-----END PGP SIGNATURE-----\r\n"},"main":"artifacts.json","readme":"# SKALE Filestorage\n\n[![Build Status](https://travis-ci.com/skalenetwork/filestorage.svg?token=HYnwEPctUzUdXVcsecA6&branch=develop)](https://travis-ci.com/skalenetwork/filestorage)\n[![codecov](https://codecov.io/gh/skalenetwork/filestorage/branch/develop/graph/badge.svg?token=2wkF3kZTXh)](https://codecov.io/gh/skalenetwork/filestorage)\n[![Discord](https://img.shields.io/discord/534485763354787851.svg)](https://discord.gg/vvUtWJB)\n\nFilestorage - smart contract, that controls decentralized file storage on SKALE chains.\n\n## Description\n\nFilestorage is a cost-effective storage layer within Ethereum capable of handling files up to 100MB. Filestorage uses UNIX-based filesystem of SKALE chains. Filestorage smart contract is a set of functions to interact with files on EVM. This contract may be predeployed on SKALE chains. It contains functions to work with Filestorage precompiled smart contracts. \n\nSmart contract language - Solidity 0.8.9\n\n## API Reference\n\n### Filestorage space handling \n\nTo start using Filestorage (upload/delete files and create/remove directories) the space should be allocated for specific account, it could be done from account that is given ALLOCATOR_ROLE. \nRules of occupying space in Filestorage:\n\n1. For directory **4096** bytes is taken\n2. File could be uploaded up to **100** MB (104857600 bytes)\n3. Occupying space for file is rounded up to the nearest multiple of **4096** bytes\n4. **Empty** file takes 4096 bytes of free space\n\nAfter deleting file/directory's amount of space is freed according to the rules above\n\n### FileStorage managing API\n#### reserveSpace\n\n```solidity\nfunction reserveSpace(address userAddress, uint reservedSpace)\n```\n\nReserves the Filestorage space for specific address. Could be called only with ALLOCATOR_ROLE\n\n**Parameters:**\n\n| Parameter             | Description                           |\n| --------------------- | ------------------------------------- |\n| `address` userAddress | Address to allocate space for         |\n| `uint` reservedSpace  | Amount of space to reserve in bytes   |\n\n#### Set version\n\n```solidity\nfunction setVersion(string newVersion)\n```\n\nSet the Filestorage version. Could be called only with DEFAULT_ADMIN_ROLE\n\n**Parameters:**\n\n| Parameter             | Description                           |\n| --------------------- | ------------------------------------- |\n| `string` newVersion   | New version of the Filestorage        |\n\n#### Get version\n\n```solidity\nfunction version()\n```\n\nGet the Filestorage version.\n\n**Parameters:**\n\n| Parameter             | Description                           |\n| --------------------- | ------------------------------------- |\n| `string`              | Version of the Filestorage            |\n\n#### getTotalStorageSpace\n\n```solidity\nfunction getTotalStorageSpace()\n```\n\nGets total space in Filestorage in bytes.\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Space in bytes                     |\n\n#### getTotalReservedSpace\n\n```solidity\nfunction getTotalStorageSpace()\n```\n\nGets total reserved space in Filestorage in bytes.\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Space in bytes                     |\n\n#### getReservedSpace\n\n```solidity\nfunction getReservedSpace(address owner)\n```\n\nGets reserved space for account.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `address` owner      | Account address                      |\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Size of reserved space for account |\n\n#### getOccupiedSpace\n\n```solidity\nfunction getOccupiedSpace(address owner)\n```\n\nGets occupied space for account.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `address` owner      | Account address                      |\n\n**Returns:**\n\n| Parameter       | Description                                 |\n| --------------- | ------------------------------------------- |\n| `uint`          | Size of occupied space for account in bytes |\n\n### File interaction methods\n\nTo begin the uploading process, the file should be broken into chunks of 1MB (&lt; 1MB for the last chunk) which are uploaded as separate transactions to FileStorage.sol. \nThe pipeline of the uploading file is:\n\n1.  creating empty file of fixed size on EVM by calling `startUpload`,\n2.  uploading data chunk by chunk with `uploadChunk`,\n3.  checking the file validity and finishing process with `finishUpload`.\n\n#### startUpload\n\n```solidity\nfunction startUpload(string memory filePath, uint256 fileSize)\n```\n\nCreates empty file on EVM with specific name and size. Owner of the file - message sender. \n\n-   Function is called by file owner\n-   Maximum amount of directories and files in one directory is **8196**\n-   Maximum filesize is **100,000,000** bytes\n-   Owner should have enough free space\n\n**Parameters:**\n\n| Parameter          | Description                           |\n| ------------------ | ------------------------------------- |\n| `string` filePath  | Path to the file in account directory |\n| `uint256` fileSize | Uploaded file size in bytes           |\n\n#### uploadChunk\n\n```solidity\nfunction uploadChunk(string memory filePath, uint position, bytes memory data)\n```\n\nUploads 1MB chunk of data from specific position in specific file by file owner.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n| `uint` position   | Uploaded chunk position               |\n| `bytes` data      | Uploaded chunk data                   |\n\n#### finishUpload\n\n```solidity\nfunction finishUpload(string memory filePath)\n```\n\nFinishes uploading of the file. Checks whether all chunks are uploaded correctly.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### deleteFile\n\n```solidity\nfunction deleteFile(string memory filePath)\n```\n\nDeletes file from Filestorage.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### readChunk\n\n```solidity\nfunction readChunk(string memory storagePath, uint position, uint length)\n        public\n        view\n        returns (bytes32[MAX_BLOCK_COUNT] memory out)\n```\n\nReads chunk from file from specific position with specific length. Returns `bytes32` array of fixed size with requested data.\n\n-   Maximum length of the chunk to read is 1Mb\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n| `uint` position      | First byte to read from              |\n| `uint` length        | Uploaded chunk length                |\n\n**Returns:**\n\n| Parameter       | Description                                       |\n| --------------- | ------------------------------------------------- |\n| `bytes32[]` out | Requested chunk data split across `bytes32` array |\n\n#### getFileSize\n\n```solidity\nfunction getFileSize(string memory storagePath) \n        public \n        view \n        returns (uint fileSize)\n```\n\nGets size of the requested file in bytes.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description            |\n| --------------- | ---------------------- |\n| `uint` fileSize | Size of requested file |\n\n#### getFileStatus\n\n```solidity\nfunction getFileStatus(string memory storagePath) \n        public \n        view \n        returns (int)\n```\n\nReturns status of the requested file:\n\n-   0 - file does not exist\n-   1 - file is created but has not finished uploading\n-   2 - file is fully uploaded\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter         | Description              |\n| ----------------- | ------------------------ |\n| `uint` fileStatus | Status of requested file |\n\n### Directory interaction methods\n\nFilestorage is represented with UNIX-based filesystem that consisted of files and directories. Directories are stored in `Directory` structure that contains information about its content in `ContentInfo` structure. Maximum amount of content in separate directory is **8196**.\n\n#### createDirectory\n\n```solidity\nfunction createDirectory(string memory directoryPath)\n```\n\nCreates directory in Filestorage. Owner of the directory - message sender. \n\n-   Function is called by directory owner\n-   Maximum amount of directories and files in one directory is **8196**\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### deleteDirectory\n\n```solidity\nfunction deleteDirectory(string memory directoryPath)\n```\n\nDeletes directory from Filestorage.\n\n-   Function is called by directory owner\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### listDirectory\n\n```solidity\nfunction listDirectory(string memory storagePath) \n        public \n        view \n        returns (ContentInfo[])\n```\n\nList information about content of the specific directory.\n\n**Parameters:**\n\n| Parameter            | Description                               |\n| -------------------- | ----------------------------------------- |\n| `string` storagePath | Full path of the directory in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description                          |\n| --------------- | ------------------------------------ |\n| `ContentInfo[]` | Array of content stored in directory |\n\nObject `ContentInfo` can be file or directory and contains:\n\n| Field                    | Description                                                                      |\n| ------------------------ | -------------------------------------------------------------------------------- |\n| `string` name            | Content name                                                                     |\n| `bool` isFile            | Whether content is file                                                          |\n| `uint` size              | File size, in bytes                                                              |\n| `int` status             | File uploading status                                                            |\n| `bool[]` isChunkUploaded | Array with statuses of each chunk (`true` - chunk uploaded, `false` - otherwise) |\n\n## Build\n\nCreate an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nPRIVATEKEY='Private key for test account'\n```\n\nCompile `FileStorage.sol`:\n\n```bash\ntruffle compile\n```\n\n## Test\n\nTests run only on SKALE chains. Create an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nSCHAIN_OWNER_PK='Private key of SKALE endpoint owner (or account with money)'\nPRIVATEKEY='Private key for test account'\n```\n\nRun tests:\n\n```bash\ntruffle test --network skaled\n```\n","gitHead":"48a8aec305a2b3c35d526ece662bd1721e7dc474","scripts":{"lint":"npx ethlint -d contracts","test":"npx truffle test test/unit/* --network skaled","build":"rm -r ./build; npx truffle build","compile":"npx truffle compile","slither":"slither . --filter-path strings --filter-path Migrations","version":"node -e \"console.log(require('./package.json').version);\"","coverage":"npx truffle run coverage --file=\"test/unit/*\"","lint-fix":"npm run lint -- --fix","compile-hardhat":"npx hardhat clean && npx hardhat compile","predeployed-test":"npx truffle test test/predeployed/* --network skaled"},"_npmUser":{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},"repository":{"url":"git+https://github.com/skalenetwork/filestorage.git","type":"git"},"_npmVersion":"6.14.17","description":"SKALE Filestorage contracts","directories":{},"_nodeVersion":"14.20.1","dependencies":{"@openzeppelin/contracts-upgradeable":"^4.3.2"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"chai":"^4.2.0","web3":"^1.2.1","dotenv":"^8.2.0","codecov":"^3.3.0","hardhat":"^2.6.4","truffle":"5.1.30","ts-node":"^10.2.1","typescript":"^4.4.3","randomstring":"^1.1.5","chai-as-promised":"^7.1.1","solidity-coverage":"^0.7.17","@truffle/hdwallet-provider":"^1.5.1"},"_npmOperationalInternal":{"tmp":"tmp/filestorage_1.1.0-develop.6_1665693733061_0.7230053266653422","host":"s3://npm-registry-packages"}},"1.1.0-beta.2":{"name":"@skalenetwork/filestorage","version":"1.1.0-beta.2","keywords":["SKALE","blockchain","ethereum"],"author":{"name":"SKALE Labs and contributors"},"license":"AGPL-3.0","_id":"@skalenetwork/filestorage@1.1.0-beta.2","maintainers":[{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},{"name":"dmitrytk","email":"dmitry.tkachuk@skalelabs.com"},{"name":"cstrange","email":"chadwick@skalelabs.com"},{"name":"skalelabsdev","email":"dev@skalelabs.com"},{"name":"theskyunicorn","email":"christine@skalelabs.com"},{"name":"stebaev","email":"dimastebaev@gmail.com"},{"name":"l_sergiy","email":"sergiy@skalelabs.com"}],"homepage":"https://github.com/skalenetwork/filestorage#readme","bugs":{"url":"https://github.com/skalenetwork/filestorage/issues"},"dist":{"shasum":"fa6d09b7e3e26b3ce375be0ffa73e2c31ba917d9","tarball":"https://registry.npmjs.org/@skalenetwork/filestorage/-/filestorage-1.1.0-beta.2.tgz","fileCount":5,"integrity":"sha512-Sc3dXkDt2/mt3zlphwggoFrtOtI66uIB3ARDd/Yt5Nbd8QVj+9y1REJF+lctcym1g2atUVsuhaMb8rVchymeHA==","signatures":[{"sig":"MEQCIHf/X2jOp6lkGdfrwsjOpwNZFKolV0+MxFi+uhampebpAiB8A6hEAY9OtZtou6Bit5vRWdbYas2EmSPgOkj9AMs2EQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":68333,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjTT7gACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmq6Bw/6A+6DrSJlWqIh+Ji7+ZLf+JzbXNklraKdu1P8P9Wn81+riueH\r\noazD5/gFScIi1vxAELJzIPWY4SYcIL9gDI0oYCKlBSsBj4BSK7VgKczFMv10\r\nObVv75KgJCezuKAE2eGxvQSHd5WqJIVuHlaO2X8nFXBmC+7mf+p6WvnncqdN\r\n1Aj+A92kdepvPvpUE6Wd3b8N5ExdcSzKQki4vndZ7/tZyXpKRE4LIw9IQCfc\r\nUVjGlLfGYi+4IgWhjqt70uFT5nwnmSPuZ62coFLLItmpKbhTiQFhZNQPUTVZ\r\nkJDEA7ov/igfP8CRx9W8GLajXd9LXL5ST1BLmlbyx1KWshciUs2G4MXnZVyL\r\noXcFAAXZAzbA8J+Q+YXptLcOg2gT4JAdF/ftu7WcGkl+xzL6FigZ9wXtjnpv\r\nbvd8sOT3KNnnBNq+jVG1RgZspA9JHUwDmjYnqanvofMWO2HKn7kJ3fxoC1HO\r\nisQ8C/rrcrT4Fp3LGGhHN/Lf2cNPgP8cMUu0DDRL9U6xGFzkuzcWqssh5pjC\r\nM+gUgndNn0J2Ny0OS7tSXqhI8a6aHuvNNCqHqmZ/CbXeHlZy0oLrogVxhoFY\r\nUJ9TeSUW8dggDYW0MlUeBXD7HRCc87IIPqgnFDcmHgtcJi0vaIoLQmjtJpRY\r\n1YnnEfZleryKk+VqOZohOS8q7ePTygljK8k=\r\n=rqm9\r\n-----END PGP SIGNATURE-----\r\n"},"main":"artifacts.json","readme":"# SKALE Filestorage\n\n[![Build Status](https://travis-ci.com/skalenetwork/filestorage.svg?token=HYnwEPctUzUdXVcsecA6&branch=develop)](https://travis-ci.com/skalenetwork/filestorage)\n[![codecov](https://codecov.io/gh/skalenetwork/filestorage/branch/develop/graph/badge.svg?token=2wkF3kZTXh)](https://codecov.io/gh/skalenetwork/filestorage)\n[![Discord](https://img.shields.io/discord/534485763354787851.svg)](https://discord.gg/vvUtWJB)\n\nFilestorage - smart contract, that controls decentralized file storage on SKALE chains.\n\n## Description\n\nFilestorage is a cost-effective storage layer within Ethereum capable of handling files up to 100MB. Filestorage uses UNIX-based filesystem of SKALE chains. Filestorage smart contract is a set of functions to interact with files on EVM. This contract may be predeployed on SKALE chains. It contains functions to work with Filestorage precompiled smart contracts. \n\nSmart contract language - Solidity 0.8.9\n\n## API Reference\n\n### Filestorage space handling \n\nTo start using Filestorage (upload/delete files and create/remove directories) the space should be allocated for specific account, it could be done from account that is given ALLOCATOR_ROLE. \nRules of occupying space in Filestorage:\n\n1. For directory **4096** bytes is taken\n2. File could be uploaded up to **100** MB (104857600 bytes)\n3. Occupying space for file is rounded up to the nearest multiple of **4096** bytes\n4. **Empty** file takes 4096 bytes of free space\n\nAfter deleting file/directory's amount of space is freed according to the rules above\n\n### FileStorage managing API\n#### reserveSpace\n\n```solidity\nfunction reserveSpace(address userAddress, uint reservedSpace)\n```\n\nReserves the Filestorage space for specific address. Could be called only with ALLOCATOR_ROLE\n\n**Parameters:**\n\n| Parameter             | Description                           |\n| --------------------- | ------------------------------------- |\n| `address` userAddress | Address to allocate space for         |\n| `uint` reservedSpace  | Amount of space to reserve in bytes   |\n\n#### Set version\n\n```solidity\nfunction setVersion(string newVersion)\n```\n\nSet the Filestorage version. Could be called only with DEFAULT_ADMIN_ROLE\n\n**Parameters:**\n\n| Parameter             | Description                           |\n| --------------------- | ------------------------------------- |\n| `string` newVersion   | New version of the Filestorage        |\n\n#### Get version\n\n```solidity\nfunction version()\n```\n\nGet the Filestorage version.\n\n**Parameters:**\n\n| Parameter             | Description                           |\n| --------------------- | ------------------------------------- |\n| `string`              | Version of the Filestorage            |\n\n#### getTotalStorageSpace\n\n```solidity\nfunction getTotalStorageSpace()\n```\n\nGets total space in Filestorage in bytes.\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Space in bytes                     |\n\n#### getTotalReservedSpace\n\n```solidity\nfunction getTotalStorageSpace()\n```\n\nGets total reserved space in Filestorage in bytes.\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Space in bytes                     |\n\n#### getReservedSpace\n\n```solidity\nfunction getReservedSpace(address owner)\n```\n\nGets reserved space for account.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `address` owner      | Account address                      |\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Size of reserved space for account |\n\n#### getOccupiedSpace\n\n```solidity\nfunction getOccupiedSpace(address owner)\n```\n\nGets occupied space for account.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `address` owner      | Account address                      |\n\n**Returns:**\n\n| Parameter       | Description                                 |\n| --------------- | ------------------------------------------- |\n| `uint`          | Size of occupied space for account in bytes |\n\n### File interaction methods\n\nTo begin the uploading process, the file should be broken into chunks of 1MB (&lt; 1MB for the last chunk) which are uploaded as separate transactions to FileStorage.sol. \nThe pipeline of the uploading file is:\n\n1.  creating empty file of fixed size on EVM by calling `startUpload`,\n2.  uploading data chunk by chunk with `uploadChunk`,\n3.  checking the file validity and finishing process with `finishUpload`.\n\n#### startUpload\n\n```solidity\nfunction startUpload(string memory filePath, uint256 fileSize)\n```\n\nCreates empty file on EVM with specific name and size. Owner of the file - message sender. \n\n-   Function is called by file owner\n-   Maximum amount of directories and files in one directory is **8196**\n-   Maximum filesize is **100,000,000** bytes\n-   Owner should have enough free space\n\n**Parameters:**\n\n| Parameter          | Description                           |\n| ------------------ | ------------------------------------- |\n| `string` filePath  | Path to the file in account directory |\n| `uint256` fileSize | Uploaded file size in bytes           |\n\n#### uploadChunk\n\n```solidity\nfunction uploadChunk(string memory filePath, uint position, bytes memory data)\n```\n\nUploads 1MB chunk of data from specific position in specific file by file owner.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n| `uint` position   | Uploaded chunk position               |\n| `bytes` data      | Uploaded chunk data                   |\n\n#### finishUpload\n\n```solidity\nfunction finishUpload(string memory filePath)\n```\n\nFinishes uploading of the file. Checks whether all chunks are uploaded correctly.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### deleteFile\n\n```solidity\nfunction deleteFile(string memory filePath)\n```\n\nDeletes file from Filestorage.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### readChunk\n\n```solidity\nfunction readChunk(string memory storagePath, uint position, uint length)\n        public\n        view\n        returns (bytes32[MAX_BLOCK_COUNT] memory out)\n```\n\nReads chunk from file from specific position with specific length. Returns `bytes32` array of fixed size with requested data.\n\n-   Maximum length of the chunk to read is 1Mb\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n| `uint` position      | First byte to read from              |\n| `uint` length        | Uploaded chunk length                |\n\n**Returns:**\n\n| Parameter       | Description                                       |\n| --------------- | ------------------------------------------------- |\n| `bytes32[]` out | Requested chunk data split across `bytes32` array |\n\n#### getFileSize\n\n```solidity\nfunction getFileSize(string memory storagePath) \n        public \n        view \n        returns (uint fileSize)\n```\n\nGets size of the requested file in bytes.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description            |\n| --------------- | ---------------------- |\n| `uint` fileSize | Size of requested file |\n\n#### getFileStatus\n\n```solidity\nfunction getFileStatus(string memory storagePath) \n        public \n        view \n        returns (int)\n```\n\nReturns status of the requested file:\n\n-   0 - file does not exist\n-   1 - file is created but has not finished uploading\n-   2 - file is fully uploaded\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter         | Description              |\n| ----------------- | ------------------------ |\n| `uint` fileStatus | Status of requested file |\n\n### Directory interaction methods\n\nFilestorage is represented with UNIX-based filesystem that consisted of files and directories. Directories are stored in `Directory` structure that contains information about its content in `ContentInfo` structure. Maximum amount of content in separate directory is **8196**.\n\n#### createDirectory\n\n```solidity\nfunction createDirectory(string memory directoryPath)\n```\n\nCreates directory in Filestorage. Owner of the directory - message sender. \n\n-   Function is called by directory owner\n-   Maximum amount of directories and files in one directory is **8196**\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### deleteDirectory\n\n```solidity\nfunction deleteDirectory(string memory directoryPath)\n```\n\nDeletes directory from Filestorage.\n\n-   Function is called by directory owner\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### listDirectory\n\n```solidity\nfunction listDirectory(string memory storagePath) \n        public \n        view \n        returns (ContentInfo[])\n```\n\nList information about content of the specific directory.\n\n**Parameters:**\n\n| Parameter            | Description                               |\n| -------------------- | ----------------------------------------- |\n| `string` storagePath | Full path of the directory in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description                          |\n| --------------- | ------------------------------------ |\n| `ContentInfo[]` | Array of content stored in directory |\n\nObject `ContentInfo` can be file or directory and contains:\n\n| Field                    | Description                                                                      |\n| ------------------------ | -------------------------------------------------------------------------------- |\n| `string` name            | Content name                                                                     |\n| `bool` isFile            | Whether content is file                                                          |\n| `uint` size              | File size, in bytes                                                              |\n| `int` status             | File uploading status                                                            |\n| `bool[]` isChunkUploaded | Array with statuses of each chunk (`true` - chunk uploaded, `false` - otherwise) |\n\n## Build\n\nCreate an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nPRIVATEKEY='Private key for test account'\n```\n\nCompile `FileStorage.sol`:\n\n```bash\ntruffle compile\n```\n\n## Test\n\nTests run only on SKALE chains. Create an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nSCHAIN_OWNER_PK='Private key of SKALE endpoint owner (or account with money)'\nPRIVATEKEY='Private key for test account'\n```\n\nRun tests:\n\n```bash\ntruffle test --network skaled\n```\n","gitHead":"f44d3a5f3dc0f46f0723649611e1642dfacfb8a3","scripts":{"lint":"npx ethlint -d contracts","test":"npx truffle test test/unit/* --network skaled","build":"rm -r ./build; npx truffle build","compile":"npx truffle compile","slither":"slither . --filter-path strings --filter-path Migrations","version":"node -e \"console.log(require('./package.json').version);\"","coverage":"npx truffle run coverage --file=\"test/unit/*\"","lint-fix":"npm run lint -- --fix","compile-hardhat":"npx hardhat clean && npx hardhat compile","predeployed-test":"npx truffle test test/predeployed/* --network skaled"},"_npmUser":{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},"repository":{"url":"git+https://github.com/skalenetwork/filestorage.git","type":"git"},"_npmVersion":"6.14.17","description":"SKALE Filestorage contracts","directories":{},"_nodeVersion":"14.20.1","dependencies":{"@openzeppelin/contracts-upgradeable":"^4.3.2"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"chai":"^4.2.0","web3":"^1.2.1","dotenv":"^8.2.0","codecov":"^3.3.0","hardhat":"^2.6.4","truffle":"5.1.30","ts-node":"^10.2.1","typescript":"^4.4.3","randomstring":"^1.1.5","chai-as-promised":"^7.1.1","solidity-coverage":"^0.7.17","@truffle/hdwallet-provider":"^1.5.1"},"_npmOperationalInternal":{"tmp":"tmp/filestorage_1.1.0-beta.2_1666006751878_0.538470887892341","host":"s3://npm-registry-packages"}},"1.1.0-develop.7":{"name":"@skalenetwork/filestorage","version":"1.1.0-develop.7","keywords":["SKALE","blockchain","ethereum"],"author":{"name":"SKALE Labs and contributors"},"license":"AGPL-3.0","_id":"@skalenetwork/filestorage@1.1.0-develop.7","maintainers":[{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},{"name":"dmitrytk","email":"dmitry.tkachuk@skalelabs.com"},{"name":"cstrange","email":"chadwick@skalelabs.com"},{"name":"skalelabsdev","email":"dev@skalelabs.com"},{"name":"theskyunicorn","email":"christine@skalelabs.com"},{"name":"stebaev","email":"dimastebaev@gmail.com"},{"name":"l_sergiy","email":"sergiy@skalelabs.com"}],"homepage":"https://github.com/skalenetwork/filestorage#readme","bugs":{"url":"https://github.com/skalenetwork/filestorage/issues"},"dist":{"shasum":"52cbada14087ee3b2f578fc952fc93e610d02f79","tarball":"https://registry.npmjs.org/@skalenetwork/filestorage/-/filestorage-1.1.0-develop.7.tgz","fileCount":5,"integrity":"sha512-sFek2uKMyqMJoOJF7YQsOrEkvd62ig+lCkYQ6wW4yswuXa/lbuEb8vBwuyvm3ANos0o3/3w8zMS3u9w8Ve3Ujg==","signatures":[{"sig":"MEUCIQDdg8OKfFSc8VoKzKPCJOWAmkxG58rkD9HdhWlXs0rIswIgPLb1t3SuLYJJqMko+RuYynryg1rRX29n7oKBuTCMPS8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":68336,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJje/QlACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpWNBAAmO5Bybae5I2f7MI2+EX/k+YKHZABT17viHV8g0dp3a/uh1U1\r\ngYvbMoYgaqbYDdsP627Dn5s+Z4eoi/lfkcSKx+NymCXN1QCaIaGMM+JbEAeS\r\nnDs67B8ZXJSVbfCrbYBmNgMFNjSQ1Z08Fk7OROBz3QYatKN0hRMWM1iXgzw6\r\n6JTWLdpWEPF/4hq7U5ybClY4VsgvMYjG7yLjrxVBebIW0OiGh3hv/J042pXD\r\nfWi3aIwdq7SIo24cYY/IN6X5st7s/luS/zxGCTa8CCa0L1znUf+xOv/P8SjL\r\n+DYY68d3YBetPWJZRaxvsCaiRNy0AwjG2LNxzwPMSTnuuYQCQMzAB2DsVo7d\r\nQlORe0i/GiYdqFJBLUgUM+LyD3SGdLQnz8IuoAXmnM6eg0kVM+qhHyzVwOkv\r\n9NnXA+ANBupuNXcQdieetv2yTsTw/dKjv9+0MNuAs6+QwO3pebvxUybtL4wJ\r\nswzElZmRlOQk3H2xtTzfhnuhYPUu89PAMwHvslBf/SosKO/8sbz15NnO8EVC\r\n9tnr5mmxIW7SQjqBEIExT7uu1pZLo2Wa1JZm2U9EY7hMpc0J7yK2VwubwykF\r\n+H3S1A9LuOOR4ngIV+BAT/rqyZeV8qb5mt6Vw9QgTnT9GwwA2iQ2v9hePUNp\r\nmwxJu0LH0B+R1mUd7fWqdTxxsdqmzHJZkQs=\r\n=g/5Y\r\n-----END PGP SIGNATURE-----\r\n"},"main":"artifacts.json","readme":"# SKALE Filestorage\n\n[![Build Status](https://travis-ci.com/skalenetwork/filestorage.svg?token=HYnwEPctUzUdXVcsecA6&branch=develop)](https://travis-ci.com/skalenetwork/filestorage)\n[![codecov](https://codecov.io/gh/skalenetwork/filestorage/branch/develop/graph/badge.svg?token=2wkF3kZTXh)](https://codecov.io/gh/skalenetwork/filestorage)\n[![Discord](https://img.shields.io/discord/534485763354787851.svg)](https://discord.gg/vvUtWJB)\n\nFilestorage - smart contract, that controls decentralized file storage on SKALE chains.\n\n## Description\n\nFilestorage is a cost-effective storage layer within Ethereum capable of handling files up to 100MB. Filestorage uses UNIX-based filesystem of SKALE chains. Filestorage smart contract is a set of functions to interact with files on EVM. This contract may be predeployed on SKALE chains. It contains functions to work with Filestorage precompiled smart contracts. \n\nSmart contract language - Solidity 0.8.9\n\n## API Reference\n\n### Filestorage space handling \n\nTo start using Filestorage (upload/delete files and create/remove directories) the space should be allocated for specific account, it could be done from account that is given ALLOCATOR_ROLE. \nRules of occupying space in Filestorage:\n\n1. For directory **4096** bytes is taken\n2. File could be uploaded up to **100** MB (104857600 bytes)\n3. Occupying space for file is rounded up to the nearest multiple of **4096** bytes\n4. **Empty** file takes 4096 bytes of free space\n\nAfter deleting file/directory's amount of space is freed according to the rules above\n\n### FileStorage managing API\n#### reserveSpace\n\n```solidity\nfunction reserveSpace(address userAddress, uint reservedSpace)\n```\n\nReserves the Filestorage space for specific address. Could be called only with ALLOCATOR_ROLE\n\n**Parameters:**\n\n| Parameter             | Description                           |\n| --------------------- | ------------------------------------- |\n| `address` userAddress | Address to allocate space for         |\n| `uint` reservedSpace  | Amount of space to reserve in bytes   |\n\n#### Set version\n\n```solidity\nfunction setVersion(string newVersion)\n```\n\nSet the Filestorage version. Could be called only with DEFAULT_ADMIN_ROLE\n\n**Parameters:**\n\n| Parameter             | Description                           |\n| --------------------- | ------------------------------------- |\n| `string` newVersion   | New version of the Filestorage        |\n\n#### Get version\n\n```solidity\nfunction version()\n```\n\nGet the Filestorage version.\n\n**Parameters:**\n\n| Parameter             | Description                           |\n| --------------------- | ------------------------------------- |\n| `string`              | Version of the Filestorage            |\n\n#### getTotalStorageSpace\n\n```solidity\nfunction getTotalStorageSpace()\n```\n\nGets total space in Filestorage in bytes.\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Space in bytes                     |\n\n#### getTotalReservedSpace\n\n```solidity\nfunction getTotalStorageSpace()\n```\n\nGets total reserved space in Filestorage in bytes.\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Space in bytes                     |\n\n#### getReservedSpace\n\n```solidity\nfunction getReservedSpace(address owner)\n```\n\nGets reserved space for account.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `address` owner      | Account address                      |\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Size of reserved space for account |\n\n#### getOccupiedSpace\n\n```solidity\nfunction getOccupiedSpace(address owner)\n```\n\nGets occupied space for account.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `address` owner      | Account address                      |\n\n**Returns:**\n\n| Parameter       | Description                                 |\n| --------------- | ------------------------------------------- |\n| `uint`          | Size of occupied space for account in bytes |\n\n### File interaction methods\n\nTo begin the uploading process, the file should be broken into chunks of 1MB (&lt; 1MB for the last chunk) which are uploaded as separate transactions to FileStorage.sol. \nThe pipeline of the uploading file is:\n\n1.  creating empty file of fixed size on EVM by calling `startUpload`,\n2.  uploading data chunk by chunk with `uploadChunk`,\n3.  checking the file validity and finishing process with `finishUpload`.\n\n#### startUpload\n\n```solidity\nfunction startUpload(string memory filePath, uint256 fileSize)\n```\n\nCreates empty file on EVM with specific name and size. Owner of the file - message sender. \n\n-   Function is called by file owner\n-   Maximum amount of directories and files in one directory is **8196**\n-   Maximum filesize is **100,000,000** bytes\n-   Owner should have enough free space\n\n**Parameters:**\n\n| Parameter          | Description                           |\n| ------------------ | ------------------------------------- |\n| `string` filePath  | Path to the file in account directory |\n| `uint256` fileSize | Uploaded file size in bytes           |\n\n#### uploadChunk\n\n```solidity\nfunction uploadChunk(string memory filePath, uint position, bytes memory data)\n```\n\nUploads 1MB chunk of data from specific position in specific file by file owner.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n| `uint` position   | Uploaded chunk position               |\n| `bytes` data      | Uploaded chunk data                   |\n\n#### finishUpload\n\n```solidity\nfunction finishUpload(string memory filePath)\n```\n\nFinishes uploading of the file. Checks whether all chunks are uploaded correctly.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### deleteFile\n\n```solidity\nfunction deleteFile(string memory filePath)\n```\n\nDeletes file from Filestorage.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### readChunk\n\n```solidity\nfunction readChunk(string memory storagePath, uint position, uint length)\n        public\n        view\n        returns (bytes32[MAX_BLOCK_COUNT] memory out)\n```\n\nReads chunk from file from specific position with specific length. Returns `bytes32` array of fixed size with requested data.\n\n-   Maximum length of the chunk to read is 1Mb\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n| `uint` position      | First byte to read from              |\n| `uint` length        | Uploaded chunk length                |\n\n**Returns:**\n\n| Parameter       | Description                                       |\n| --------------- | ------------------------------------------------- |\n| `bytes32[]` out | Requested chunk data split across `bytes32` array |\n\n#### getFileSize\n\n```solidity\nfunction getFileSize(string memory storagePath) \n        public \n        view \n        returns (uint fileSize)\n```\n\nGets size of the requested file in bytes.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description            |\n| --------------- | ---------------------- |\n| `uint` fileSize | Size of requested file |\n\n#### getFileStatus\n\n```solidity\nfunction getFileStatus(string memory storagePath) \n        public \n        view \n        returns (int)\n```\n\nReturns status of the requested file:\n\n-   0 - file does not exist\n-   1 - file is created but has not finished uploading\n-   2 - file is fully uploaded\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter         | Description              |\n| ----------------- | ------------------------ |\n| `uint` fileStatus | Status of requested file |\n\n### Directory interaction methods\n\nFilestorage is represented with UNIX-based filesystem that consisted of files and directories. Directories are stored in `Directory` structure that contains information about its content in `ContentInfo` structure. Maximum amount of content in separate directory is **8196**.\n\n#### createDirectory\n\n```solidity\nfunction createDirectory(string memory directoryPath)\n```\n\nCreates directory in Filestorage. Owner of the directory - message sender. \n\n-   Function is called by directory owner\n-   Maximum amount of directories and files in one directory is **8196**\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### deleteDirectory\n\n```solidity\nfunction deleteDirectory(string memory directoryPath)\n```\n\nDeletes directory from Filestorage.\n\n-   Function is called by directory owner\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### listDirectory\n\n```solidity\nfunction listDirectory(string memory storagePath) \n        public \n        view \n        returns (ContentInfo[])\n```\n\nList information about content of the specific directory.\n\n**Parameters:**\n\n| Parameter            | Description                               |\n| -------------------- | ----------------------------------------- |\n| `string` storagePath | Full path of the directory in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description                          |\n| --------------- | ------------------------------------ |\n| `ContentInfo[]` | Array of content stored in directory |\n\nObject `ContentInfo` can be file or directory and contains:\n\n| Field                    | Description                                                                      |\n| ------------------------ | -------------------------------------------------------------------------------- |\n| `string` name            | Content name                                                                     |\n| `bool` isFile            | Whether content is file                                                          |\n| `uint` size              | File size, in bytes                                                              |\n| `int` status             | File uploading status                                                            |\n| `bool[]` isChunkUploaded | Array with statuses of each chunk (`true` - chunk uploaded, `false` - otherwise) |\n\n## Build\n\nCreate an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nPRIVATEKEY='Private key for test account'\n```\n\nCompile `FileStorage.sol`:\n\n```bash\ntruffle compile\n```\n\n## Test\n\nTests run only on SKALE chains. Create an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nSCHAIN_OWNER_PK='Private key of SKALE endpoint owner (or account with money)'\nPRIVATEKEY='Private key for test account'\n```\n\nRun tests:\n\n```bash\ntruffle test --network skaled\n```\n","gitHead":"887f146dddd049d6ee02721f3e7dff77b9902481","scripts":{"lint":"npx ethlint -d contracts","test":"npx truffle test test/unit/* --network skaled","build":"rm -r ./build; npx truffle build","compile":"npx truffle compile","slither":"slither . --filter-path strings --filter-path Migrations","version":"node -e \"console.log(require('./package.json').version);\"","coverage":"npx truffle run coverage --file=\"test/unit/*\"","lint-fix":"npm run lint -- --fix","compile-hardhat":"npx hardhat clean && npx hardhat compile","predeployed-test":"npx truffle test test/predeployed/* --network skaled"},"_npmUser":{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},"repository":{"url":"git+https://github.com/skalenetwork/filestorage.git","type":"git"},"_npmVersion":"6.14.17","description":"SKALE Filestorage contracts","directories":{},"_nodeVersion":"14.20.1","dependencies":{"@openzeppelin/contracts-upgradeable":"^4.3.2"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"chai":"^4.2.0","web3":"^1.2.1","dotenv":"^8.2.0","codecov":"^3.3.0","hardhat":"^2.6.4","truffle":"5.1.30","ts-node":"^10.2.1","typescript":"^4.4.3","randomstring":"^1.1.5","chai-as-promised":"^7.1.1","solidity-coverage":"^0.7.17","@truffle/hdwallet-provider":"^1.5.1"},"_npmOperationalInternal":{"tmp":"tmp/filestorage_1.1.0-develop.7_1669067812791_0.704100569383344","host":"s3://npm-registry-packages"}},"1.1.0-develop.8":{"name":"@skalenetwork/filestorage","version":"1.1.0-develop.8","keywords":["SKALE","blockchain","ethereum"],"author":{"name":"SKALE Labs and contributors"},"license":"AGPL-3.0","_id":"@skalenetwork/filestorage@1.1.0-develop.8","maintainers":[{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},{"name":"dmitrytk","email":"dmitry.tkachuk@skalelabs.com"},{"name":"cstrange","email":"chadwick@skalelabs.com"},{"name":"skalelabsdev","email":"dev@skalelabs.com"},{"name":"theskyunicorn","email":"christine@skalelabs.com"},{"name":"stebaev","email":"dimastebaev@gmail.com"},{"name":"l_sergiy","email":"sergiy@skalelabs.com"}],"homepage":"https://github.com/skalenetwork/filestorage#readme","bugs":{"url":"https://github.com/skalenetwork/filestorage/issues"},"dist":{"shasum":"41f130299833062c24de989b639d69b4fc459934","tarball":"https://registry.npmjs.org/@skalenetwork/filestorage/-/filestorage-1.1.0-develop.8.tgz","fileCount":5,"integrity":"sha512-D69NNxFN2m1l/OVm/z6jkOGM2wtJ3CJa5TgDciNV595a496DmFEzYmQFJtiio0mlqSVmUYpEwY9R3S8xIxA2Ag==","signatures":[{"sig":"MEUCIQDheO1Hwux3DpSR0czgIIRheeByPMo1QqtWOjdmvEMoqgIgYfQCqAwHmbFwd5yFsYukMysHSV5J2lJTQolFKHt/Mhs=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":68336,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkNXHCACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqBBQ//aT3ug7I2LrrGb8pmsbh+Gi3S9C7H35OdtC3MUy5d4pJcJkOe\r\nC13vwGmIgg8iQwtRdS4FYtkDH9sdHaqmmVNP5ORB8RnyyHeLAWvj0OXYSqWB\r\n20PwNkEF1n3aLpdTuNOdsADAGHRFx+ZhRBGLhgagjO6poWCwor1GhOLLgb9d\r\nPFgfWXl18M1C3EheEBL1wwPeE8BvaZLE8BUgScwMshaeFRkQwYhQSW9zbgzD\r\nNQrRNL+52zq3RAWo1edsSXWHZanDfLRjc43MJuXJxr2E/P4iWnASRgqAmIyU\r\njbPKn1mHbzcjtdtpJmdwpQ+2k5j+weFPHeRpPNfe1u52cq/xiCJHQKHdHa1p\r\nKLsPoGbY23V7eE6y05gWVgOA1GXGaIY/Ff42F/XaBCC35iUwblX+Yh02AEiQ\r\n4+usum1NiscupsM1oZQC7+Pu5QDQtPPokYYgr4sdlbmUHmMtX8DZGNtcjHBS\r\nybWeJssKFKCqhz3So9YHfaPXZW8C7bbhLF4hDMgVsKVO+qMVl7vnr1X8Q2bY\r\nEsPFVl5OAhEndL7fxMo8QshL4sJ6Sk4ZZ2AEoDxyjfeakLjWgx61+HkJKGQ9\r\ncKfNIiEQ98bBK2sTvZ9xRuHPFbAGpG/VrZZo+Nfxar10Lt2lnDvarRcgYTJ3\r\nhWtSHQ5xGOayLAfQlQE+RIaFni2LavKmYLY=\r\n=VU8j\r\n-----END PGP SIGNATURE-----\r\n"},"main":"artifacts.json","readme":"# SKALE Filestorage\n\n[![Build Status](https://travis-ci.com/skalenetwork/filestorage.svg?token=HYnwEPctUzUdXVcsecA6&branch=develop)](https://travis-ci.com/skalenetwork/filestorage)\n[![codecov](https://codecov.io/gh/skalenetwork/filestorage/branch/develop/graph/badge.svg?token=2wkF3kZTXh)](https://codecov.io/gh/skalenetwork/filestorage)\n[![Discord](https://img.shields.io/discord/534485763354787851.svg)](https://discord.gg/vvUtWJB)\n\nFilestorage - smart contract, that controls decentralized file storage on SKALE chains.\n\n## Description\n\nFilestorage is a cost-effective storage layer within Ethereum capable of handling files up to 100MB. Filestorage uses UNIX-based filesystem of SKALE chains. Filestorage smart contract is a set of functions to interact with files on EVM. This contract may be predeployed on SKALE chains. It contains functions to work with Filestorage precompiled smart contracts. \n\nSmart contract language - Solidity 0.8.9\n\n## API Reference\n\n### Filestorage space handling \n\nTo start using Filestorage (upload/delete files and create/remove directories) the space should be allocated for specific account, it could be done from account that is given ALLOCATOR_ROLE. \nRules of occupying space in Filestorage:\n\n1. For directory **4096** bytes is taken\n2. File could be uploaded up to **100** MB (104857600 bytes)\n3. Occupying space for file is rounded up to the nearest multiple of **4096** bytes\n4. **Empty** file takes 4096 bytes of free space\n\nAfter deleting file/directory's amount of space is freed according to the rules above\n\n### FileStorage managing API\n#### reserveSpace\n\n```solidity\nfunction reserveSpace(address userAddress, uint reservedSpace)\n```\n\nReserves the Filestorage space for specific address. Could be called only with ALLOCATOR_ROLE\n\n**Parameters:**\n\n| Parameter             | Description                           |\n| --------------------- | ------------------------------------- |\n| `address` userAddress | Address to allocate space for         |\n| `uint` reservedSpace  | Amount of space to reserve in bytes   |\n\n#### Set version\n\n```solidity\nfunction setVersion(string newVersion)\n```\n\nSet the Filestorage version. Could be called only with DEFAULT_ADMIN_ROLE\n\n**Parameters:**\n\n| Parameter             | Description                           |\n| --------------------- | ------------------------------------- |\n| `string` newVersion   | New version of the Filestorage        |\n\n#### Get version\n\n```solidity\nfunction version()\n```\n\nGet the Filestorage version.\n\n**Parameters:**\n\n| Parameter             | Description                           |\n| --------------------- | ------------------------------------- |\n| `string`              | Version of the Filestorage            |\n\n#### getTotalStorageSpace\n\n```solidity\nfunction getTotalStorageSpace()\n```\n\nGets total space in Filestorage in bytes.\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Space in bytes                     |\n\n#### getTotalReservedSpace\n\n```solidity\nfunction getTotalStorageSpace()\n```\n\nGets total reserved space in Filestorage in bytes.\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Space in bytes                     |\n\n#### getReservedSpace\n\n```solidity\nfunction getReservedSpace(address owner)\n```\n\nGets reserved space for account.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `address` owner      | Account address                      |\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Size of reserved space for account |\n\n#### getOccupiedSpace\n\n```solidity\nfunction getOccupiedSpace(address owner)\n```\n\nGets occupied space for account.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `address` owner      | Account address                      |\n\n**Returns:**\n\n| Parameter       | Description                                 |\n| --------------- | ------------------------------------------- |\n| `uint`          | Size of occupied space for account in bytes |\n\n### File interaction methods\n\nTo begin the uploading process, the file should be broken into chunks of 1MB (&lt; 1MB for the last chunk) which are uploaded as separate transactions to FileStorage.sol. \nThe pipeline of the uploading file is:\n\n1.  creating empty file of fixed size on EVM by calling `startUpload`,\n2.  uploading data chunk by chunk with `uploadChunk`,\n3.  checking the file validity and finishing process with `finishUpload`.\n\n#### startUpload\n\n```solidity\nfunction startUpload(string memory filePath, uint256 fileSize)\n```\n\nCreates empty file on EVM with specific name and size. Owner of the file - message sender. \n\n-   Function is called by file owner\n-   Maximum amount of directories and files in one directory is **8196**\n-   Maximum filesize is **100,000,000** bytes\n-   Owner should have enough free space\n\n**Parameters:**\n\n| Parameter          | Description                           |\n| ------------------ | ------------------------------------- |\n| `string` filePath  | Path to the file in account directory |\n| `uint256` fileSize | Uploaded file size in bytes           |\n\n#### uploadChunk\n\n```solidity\nfunction uploadChunk(string memory filePath, uint position, bytes memory data)\n```\n\nUploads 1MB chunk of data from specific position in specific file by file owner.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n| `uint` position   | Uploaded chunk position               |\n| `bytes` data      | Uploaded chunk data                   |\n\n#### finishUpload\n\n```solidity\nfunction finishUpload(string memory filePath)\n```\n\nFinishes uploading of the file. Checks whether all chunks are uploaded correctly.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### deleteFile\n\n```solidity\nfunction deleteFile(string memory filePath)\n```\n\nDeletes file from Filestorage.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### readChunk\n\n```solidity\nfunction readChunk(string memory storagePath, uint position, uint length)\n        public\n        view\n        returns (bytes32[MAX_BLOCK_COUNT] memory out)\n```\n\nReads chunk from file from specific position with specific length. Returns `bytes32` array of fixed size with requested data.\n\n-   Maximum length of the chunk to read is 1Mb\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n| `uint` position      | First byte to read from              |\n| `uint` length        | Uploaded chunk length                |\n\n**Returns:**\n\n| Parameter       | Description                                       |\n| --------------- | ------------------------------------------------- |\n| `bytes32[]` out | Requested chunk data split across `bytes32` array |\n\n#### getFileSize\n\n```solidity\nfunction getFileSize(string memory storagePath) \n        public \n        view \n        returns (uint fileSize)\n```\n\nGets size of the requested file in bytes.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description            |\n| --------------- | ---------------------- |\n| `uint` fileSize | Size of requested file |\n\n#### getFileStatus\n\n```solidity\nfunction getFileStatus(string memory storagePath) \n        public \n        view \n        returns (int)\n```\n\nReturns status of the requested file:\n\n-   0 - file does not exist\n-   1 - file is created but has not finished uploading\n-   2 - file is fully uploaded\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter         | Description              |\n| ----------------- | ------------------------ |\n| `uint` fileStatus | Status of requested file |\n\n### Directory interaction methods\n\nFilestorage is represented with UNIX-based filesystem that consisted of files and directories. Directories are stored in `Directory` structure that contains information about its content in `ContentInfo` structure. Maximum amount of content in separate directory is **8196**.\n\n#### createDirectory\n\n```solidity\nfunction createDirectory(string memory directoryPath)\n```\n\nCreates directory in Filestorage. Owner of the directory - message sender. \n\n-   Function is called by directory owner\n-   Maximum amount of directories and files in one directory is **8196**\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### deleteDirectory\n\n```solidity\nfunction deleteDirectory(string memory directoryPath)\n```\n\nDeletes directory from Filestorage.\n\n-   Function is called by directory owner\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### listDirectory\n\n```solidity\nfunction listDirectory(string memory storagePath) \n        public \n        view \n        returns (ContentInfo[])\n```\n\nList information about content of the specific directory.\n\n**Parameters:**\n\n| Parameter            | Description                               |\n| -------------------- | ----------------------------------------- |\n| `string` storagePath | Full path of the directory in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description                          |\n| --------------- | ------------------------------------ |\n| `ContentInfo[]` | Array of content stored in directory |\n\nObject `ContentInfo` can be file or directory and contains:\n\n| Field                    | Description                                                                      |\n| ------------------------ | -------------------------------------------------------------------------------- |\n| `string` name            | Content name                                                                     |\n| `bool` isFile            | Whether content is file                                                          |\n| `uint` size              | File size, in bytes                                                              |\n| `int` status             | File uploading status                                                            |\n| `bool[]` isChunkUploaded | Array with statuses of each chunk (`true` - chunk uploaded, `false` - otherwise) |\n\n## Build\n\nCreate an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nPRIVATEKEY='Private key for test account'\n```\n\nCompile `FileStorage.sol`:\n\n```bash\ntruffle compile\n```\n\n## Test\n\nTests run only on SKALE chains. Create an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nSCHAIN_OWNER_PK='Private key of SKALE endpoint owner (or account with money)'\nPRIVATEKEY='Private key for test account'\n```\n\nRun tests:\n\n```bash\ntruffle test --network skaled\n```\n","gitHead":"961392b2e9a679c50bd408fe78fe92bdd9b2f49c","scripts":{"lint":"npx ethlint -d contracts","test":"npx truffle test test/unit/* --network skaled","build":"rm -r ./build; npx truffle build","compile":"npx truffle compile","slither":"slither . --filter-path strings --filter-path Migrations","version":"node -e \"console.log(require('./package.json').version);\"","coverage":"npx truffle run coverage --file=\"test/unit/*\"","lint-fix":"npm run lint -- --fix","compile-hardhat":"npx hardhat clean && npx hardhat compile","predeployed-test":"npx truffle test test/predeployed/* --network skaled"},"_npmUser":{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},"repository":{"url":"git+https://github.com/skalenetwork/filestorage.git","type":"git"},"_npmVersion":"6.14.18","description":"SKALE Filestorage contracts","directories":{},"_nodeVersion":"14.21.3","dependencies":{"@openzeppelin/contracts-upgradeable":"^4.3.2"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"chai":"^4.2.0","web3":"^1.2.1","dotenv":"^8.2.0","codecov":"^3.3.0","hardhat":"^2.6.4","truffle":"5.1.30","ts-node":"^10.2.1","typescript":"^4.4.3","randomstring":"^1.1.5","chai-as-promised":"^7.1.1","solidity-coverage":"^0.7.17","@truffle/hdwallet-provider":"^1.5.1"},"_npmOperationalInternal":{"tmp":"tmp/filestorage_1.1.0-develop.8_1681224130690_0.34489574555190927","host":"s3://npm-registry-packages"}},"1.1.0-beta.3":{"name":"@skalenetwork/filestorage","version":"1.1.0-beta.3","keywords":["SKALE","blockchain","ethereum"],"author":{"name":"SKALE Labs and contributors"},"license":"AGPL-3.0","_id":"@skalenetwork/filestorage@1.1.0-beta.3","maintainers":[{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},{"name":"dmitrytk","email":"dmitry.tkachuk@skalelabs.com"},{"name":"cstrange","email":"chadwick@skalelabs.com"},{"name":"skalelabsdev","email":"dev@skalelabs.com"},{"name":"theskyunicorn","email":"christine@skalelabs.com"},{"name":"stebaev","email":"dimastebaev@gmail.com"},{"name":"l_sergiy","email":"sergiy@skalelabs.com"}],"homepage":"https://github.com/skalenetwork/filestorage#readme","bugs":{"url":"https://github.com/skalenetwork/filestorage/issues"},"dist":{"shasum":"56ea594878084a3ec907ad8775e69ae0eea8359b","tarball":"https://registry.npmjs.org/@skalenetwork/filestorage/-/filestorage-1.1.0-beta.3.tgz","fileCount":5,"integrity":"sha512-kxCK3I45lbg9nIOjwPlJl823aRBJ33gLqqJ4vxggJQWzqAs8k2XmoJdMaWLH9MGKy5QuxWKH+NAjDRaoNcW6/A==","signatures":[{"sig":"MEUCIEKE2yxR5RJYehM/9u3m4C9KAzYT4dgGBy2GS9iSY5wdAiEAl37W3YBZA+pkF344mzfUWEiHqqdmKR2OZwd1tl0SfnQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":68333},"main":"artifacts.json","readme":"# SKALE Filestorage\n\n[![Build Status](https://travis-ci.com/skalenetwork/filestorage.svg?token=HYnwEPctUzUdXVcsecA6&branch=develop)](https://travis-ci.com/skalenetwork/filestorage)\n[![codecov](https://codecov.io/gh/skalenetwork/filestorage/branch/develop/graph/badge.svg?token=2wkF3kZTXh)](https://codecov.io/gh/skalenetwork/filestorage)\n[![Discord](https://img.shields.io/discord/534485763354787851.svg)](https://discord.gg/vvUtWJB)\n\nFilestorage - smart contract, that controls decentralized file storage on SKALE chains.\n\n## Description\n\nFilestorage is a cost-effective storage layer within Ethereum capable of handling files up to 100MB. Filestorage uses UNIX-based filesystem of SKALE chains. Filestorage smart contract is a set of functions to interact with files on EVM. This contract may be predeployed on SKALE chains. It contains functions to work with Filestorage precompiled smart contracts. \n\nSmart contract language - Solidity 0.8.9\n\n## API Reference\n\n### Filestorage space handling \n\nTo start using Filestorage (upload/delete files and create/remove directories) the space should be allocated for specific account, it could be done from account that is given ALLOCATOR_ROLE. \nRules of occupying space in Filestorage:\n\n1. For directory **4096** bytes is taken\n2. File could be uploaded up to **100** MB (104857600 bytes)\n3. Occupying space for file is rounded up to the nearest multiple of **4096** bytes\n4. **Empty** file takes 4096 bytes of free space\n\nAfter deleting file/directory's amount of space is freed according to the rules above\n\n### FileStorage managing API\n#### reserveSpace\n\n```solidity\nfunction reserveSpace(address userAddress, uint reservedSpace)\n```\n\nReserves the Filestorage space for specific address. Could be called only with ALLOCATOR_ROLE\n\n**Parameters:**\n\n| Parameter             | Description                           |\n| --------------------- | ------------------------------------- |\n| `address` userAddress | Address to allocate space for         |\n| `uint` reservedSpace  | Amount of space to reserve in bytes   |\n\n#### Set version\n\n```solidity\nfunction setVersion(string newVersion)\n```\n\nSet the Filestorage version. Could be called only with DEFAULT_ADMIN_ROLE\n\n**Parameters:**\n\n| Parameter             | Description                           |\n| --------------------- | ------------------------------------- |\n| `string` newVersion   | New version of the Filestorage        |\n\n#### Get version\n\n```solidity\nfunction version()\n```\n\nGet the Filestorage version.\n\n**Parameters:**\n\n| Parameter             | Description                           |\n| --------------------- | ------------------------------------- |\n| `string`              | Version of the Filestorage            |\n\n#### getTotalStorageSpace\n\n```solidity\nfunction getTotalStorageSpace()\n```\n\nGets total space in Filestorage in bytes.\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Space in bytes                     |\n\n#### getTotalReservedSpace\n\n```solidity\nfunction getTotalStorageSpace()\n```\n\nGets total reserved space in Filestorage in bytes.\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Space in bytes                     |\n\n#### getReservedSpace\n\n```solidity\nfunction getReservedSpace(address owner)\n```\n\nGets reserved space for account.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `address` owner      | Account address                      |\n\n**Returns:**\n\n| Parameter       | Description                        |\n| --------------- | ---------------------------------- |\n| `uint`          | Size of reserved space for account |\n\n#### getOccupiedSpace\n\n```solidity\nfunction getOccupiedSpace(address owner)\n```\n\nGets occupied space for account.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `address` owner      | Account address                      |\n\n**Returns:**\n\n| Parameter       | Description                                 |\n| --------------- | ------------------------------------------- |\n| `uint`          | Size of occupied space for account in bytes |\n\n### File interaction methods\n\nTo begin the uploading process, the file should be broken into chunks of 1MB (&lt; 1MB for the last chunk) which are uploaded as separate transactions to FileStorage.sol. \nThe pipeline of the uploading file is:\n\n1.  creating empty file of fixed size on EVM by calling `startUpload`,\n2.  uploading data chunk by chunk with `uploadChunk`,\n3.  checking the file validity and finishing process with `finishUpload`.\n\n#### startUpload\n\n```solidity\nfunction startUpload(string memory filePath, uint256 fileSize)\n```\n\nCreates empty file on EVM with specific name and size. Owner of the file - message sender. \n\n-   Function is called by file owner\n-   Maximum amount of directories and files in one directory is **8196**\n-   Maximum filesize is **100,000,000** bytes\n-   Owner should have enough free space\n\n**Parameters:**\n\n| Parameter          | Description                           |\n| ------------------ | ------------------------------------- |\n| `string` filePath  | Path to the file in account directory |\n| `uint256` fileSize | Uploaded file size in bytes           |\n\n#### uploadChunk\n\n```solidity\nfunction uploadChunk(string memory filePath, uint position, bytes memory data)\n```\n\nUploads 1MB chunk of data from specific position in specific file by file owner.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n| `uint` position   | Uploaded chunk position               |\n| `bytes` data      | Uploaded chunk data                   |\n\n#### finishUpload\n\n```solidity\nfunction finishUpload(string memory filePath)\n```\n\nFinishes uploading of the file. Checks whether all chunks are uploaded correctly.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### deleteFile\n\n```solidity\nfunction deleteFile(string memory filePath)\n```\n\nDeletes file from Filestorage.\n\n-   Function is called by file owner.\n\n**Parameters:**\n\n| Parameter         | Description                           |\n| ----------------- | ------------------------------------- |\n| `string` filePath | Path to the file in account directory |\n\n#### readChunk\n\n```solidity\nfunction readChunk(string memory storagePath, uint position, uint length)\n        public\n        view\n        returns (bytes32[MAX_BLOCK_COUNT] memory out)\n```\n\nReads chunk from file from specific position with specific length. Returns `bytes32` array of fixed size with requested data.\n\n-   Maximum length of the chunk to read is 1Mb\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n| `uint` position      | First byte to read from              |\n| `uint` length        | Uploaded chunk length                |\n\n**Returns:**\n\n| Parameter       | Description                                       |\n| --------------- | ------------------------------------------------- |\n| `bytes32[]` out | Requested chunk data split across `bytes32` array |\n\n#### getFileSize\n\n```solidity\nfunction getFileSize(string memory storagePath) \n        public \n        view \n        returns (uint fileSize)\n```\n\nGets size of the requested file in bytes.\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description            |\n| --------------- | ---------------------- |\n| `uint` fileSize | Size of requested file |\n\n#### getFileStatus\n\n```solidity\nfunction getFileStatus(string memory storagePath) \n        public \n        view \n        returns (int)\n```\n\nReturns status of the requested file:\n\n-   0 - file does not exist\n-   1 - file is created but has not finished uploading\n-   2 - file is fully uploaded\n\n**Parameters:**\n\n| Parameter            | Description                          |\n| -------------------- | ------------------------------------ |\n| `string` storagePath | Full path of the file in Filestorage |\n\n**Returns:**\n\n| Parameter         | Description              |\n| ----------------- | ------------------------ |\n| `uint` fileStatus | Status of requested file |\n\n### Directory interaction methods\n\nFilestorage is represented with UNIX-based filesystem that consisted of files and directories. Directories are stored in `Directory` structure that contains information about its content in `ContentInfo` structure. Maximum amount of content in separate directory is **8196**.\n\n#### createDirectory\n\n```solidity\nfunction createDirectory(string memory directoryPath)\n```\n\nCreates directory in Filestorage. Owner of the directory - message sender. \n\n-   Function is called by directory owner\n-   Maximum amount of directories and files in one directory is **8196**\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### deleteDirectory\n\n```solidity\nfunction deleteDirectory(string memory directoryPath)\n```\n\nDeletes directory from Filestorage.\n\n-   Function is called by directory owner\n\n**Parameters:**\n\n| Parameter              | Description                                     |\n| ---------------------- | ----------------------------------------------- |\n| `string` directoryPath | Path to the directory in account root directory |\n\n#### listDirectory\n\n```solidity\nfunction listDirectory(string memory storagePath) \n        public \n        view \n        returns (ContentInfo[])\n```\n\nList information about content of the specific directory.\n\n**Parameters:**\n\n| Parameter            | Description                               |\n| -------------------- | ----------------------------------------- |\n| `string` storagePath | Full path of the directory in Filestorage |\n\n**Returns:**\n\n| Parameter       | Description                          |\n| --------------- | ------------------------------------ |\n| `ContentInfo[]` | Array of content stored in directory |\n\nObject `ContentInfo` can be file or directory and contains:\n\n| Field                    | Description                                                                      |\n| ------------------------ | -------------------------------------------------------------------------------- |\n| `string` name            | Content name                                                                     |\n| `bool` isFile            | Whether content is file                                                          |\n| `uint` size              | File size, in bytes                                                              |\n| `int` status             | File uploading status                                                            |\n| `bool[]` isChunkUploaded | Array with statuses of each chunk (`true` - chunk uploaded, `false` - otherwise) |\n\n## Build\n\nCreate an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nPRIVATEKEY='Private key for test account'\n```\n\nCompile `FileStorage.sol`:\n\n```bash\ntruffle compile\n```\n\n## Test\n\nTests run only on SKALE chains. Create an .env file with following data:\n\n```bash\nENTRYPOINT='SKALE endpoint'\nSCHAIN_OWNER_PK='Private key of SKALE endpoint owner (or account with money)'\nPRIVATEKEY='Private key for test account'\n```\n\nRun tests:\n\n```bash\ntruffle test --network skaled\n```\n","gitHead":"01ed6574eac941cb10879f924f12762665587b64","scripts":{"lint":"npx ethlint -d contracts","test":"npx truffle test test/unit/* --network skaled","build":"rm -r ./build; npx truffle build","compile":"npx truffle compile","slither":"slither . --filter-path strings --filter-path Migrations","version":"node -e \"console.log(require('./package.json').version);\"","coverage":"npx truffle run coverage --file=\"test/unit/*\"","lint-fix":"npm run lint -- --fix","compile-hardhat":"npx hardhat clean && npx hardhat compile","predeployed-test":"npx truffle test test/predeployed/* --network skaled"},"_npmUser":{"name":"rikon","email":"dmytro.nazarenko@skalelabs.com"},"repository":{"url":"git+https://github.com/skalenetwork/filestorage.git","type":"git"},"_npmVersion":"6.14.18","description":"SKALE Filestorage contracts","directories":{},"_nodeVersion":"14.21.3","dependencies":{"@openzeppelin/contracts-upgradeable":"^4.3.2"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"chai":"^4.2.0","web3":"^1.2.1","dotenv":"^8.2.0","codecov":"^3.3.0","hardhat":"^2.6.4","truffle":"5.1.30","ts-node":"^10.2.1","typescript":"^4.4.3","randomstring":"^1.1.5","chai-as-promised":"^7.1.1","solidity-coverage":"^0.7.17","@truffle/hdwallet-provider":"^1.5.1"},"_npmOperationalInternal":{"tmp":"tmp/filestorage_1.1.0-beta.3_1686679207699_0.25854864352059037","host":"s3://npm-registry-packages"}}},"time":{"created":"2020-09-25T07:59:44.092Z","modified":"2025-07-09T16:51:21.069Z","0.4.0-develop.1":"2020-09-25T07:59:44.416Z","1.0.0-develop.0":"2021-03-30T10:53:06.290Z","1.0.0-develop.1":"2021-03-30T22:35:35.734Z","1.0.0-develop.2":"2021-08-30T12:06:01.720Z","1.0.0-develop.3":"2021-08-30T12:31:14.587Z","1.0.0-develop.4":"2021-09-09T11:01:15.380Z","1.0.0-develop.5":"2021-09-10T08:45:14.966Z","1.0.1-develop.0":"2021-09-22T17:30:33.524Z","1.0.1-develop.1":"2021-09-23T09:29:26.497Z","1.0.1-develop.2":"2021-10-29T12:26:22.451Z","1.0.1-develop.3":"2021-11-10T15:22:59.332Z","1.0.1-develop.5":"2021-11-10T15:33:23.890Z","1.0.1-develop.6":"2021-11-10T17:04:54.772Z","1.0.1-develop.7":"2021-11-10T17:20:26.625Z","1.0.1-develop.8":"2021-12-03T16:05:01.794Z","1.0.1-develop.9":"2021-12-23T13:25:28.848Z","1.0.1-develop.10":"2022-01-28T14:23:08.012Z","1.0.1-beta.0":"2022-03-21T14:59:43.282Z","1.0.1-develop.11":"2022-04-30T09:05:26.601Z","1.0.1-beta.1":"2022-04-30T11:37:57.971Z","1.0.1-develop.12":"2022-05-19T16:21:13.853Z","1.0.1-develop.13":"2022-05-19T16:31:28.713Z","1.0.1-beta.2":"2022-05-19T16:40:21.799Z","1.0.1-develop.14":"2022-05-19T18:33:43.621Z","1.0.1-beta.3":"2022-05-19T18:38:15.724Z","1.0.1":"2022-05-19T18:43:46.697Z","1.1.0-develop.1":"2022-07-07T19:03:01.335Z","1.1.0-develop.2":"2022-07-07T19:17:54.261Z","1.1.0-develop.3":"2022-08-01T14:39:51.254Z","1.1.0-beta.0":"2022-08-01T15:46:17.977Z","1.1.0-develop.4":"2022-08-26T19:28:29.263Z","1.1.0-develop.5":"2022-09-14T11:49:54.368Z","1.1.0-beta.1":"2022-09-22T11:53:21.946Z","1.1.0-develop.6":"2022-10-13T20:42:13.308Z","1.1.0-beta.2":"2022-10-17T11:39:12.052Z","1.1.0-develop.7":"2022-11-21T21:56:53.018Z","1.1.0-develop.8":"2023-04-11T14:42:10.846Z","1.1.0-beta.3":"2023-06-13T18:00:07.881Z"},"bugs":{"url":"https://github.com/skalenetwork/filestorage/issues"},"author":{"name":"SKALE Labs and contributors"},"license":"AGPL-3.0","homepage":"https://github.com/skalenetwork/filestorage#readme","keywords":["SKALE","blockchain","ethereum"],"repository":{"url":"git+https://github.com/skalenetwork/filestorage.git","type":"git"},"description":"SKALE Filestorage contracts","maintainers":[{"email":"dmytro.nazarenko@skalelabs.com","name":"rikon"},{"email":"dmitry.tkachuk@skalelabs.com","name":"dmitrytk"},{"email":"dimastebaev@gmail.com","name":"stebaev"}],"readme":"","readmeFilename":""}