{"_id":"@0glabs/0g-storage-contracts","_rev":"3-fff8205292cb652a746a743f55a4a03d","name":"@0glabs/0g-storage-contracts","dist-tags":{"latest":"0.0.1"},"versions":{"0.0.1":{"name":"@0glabs/0g-storage-contracts","version":"0.0.1","author":{"name":"Zero Gravity Labs"},"license":"Unlicense","_id":"@0glabs/0g-storage-contracts@0.0.1","maintainers":[{"name":"0g-peterzhang","email":"peter@0g.ai"}],"dist":{"shasum":"e3a19239b5da46761fc9325301a1ca44d1f13b32","tarball":"https://registry.npmjs.org/@0glabs/0g-storage-contracts/-/0g-storage-contracts-0.0.1.tgz","fileCount":88,"integrity":"sha512-0gaxRI9zYwYXhn++LXoshSOPfdYOwDSFkDwmvravw/VVDXiLxDehXYK6mlcJV+s+VCCFOyNvaQIevfwxsoctHQ==","signatures":[{"sig":"MEUCIEbY6rARNB4daZD2p0X2DykFU/jJDa/RgHUiRaAoiNXeAiEAgI1aEzDWMSDn3TK5KXlGZukOYqYIZwNTRuX3ylPL5v8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":278241},"gitHead":"4d27648db555edff9553f2e8300bea47e590f711","scripts":{"lint":"yarn lint:sol && yarn lint:ts","test":"hardhat test","build":"hardhat compile","fmt:ts":"prettier 'src/**/*.ts' 'test/**/*.ts' '*.ts' -w","fmt:sol":"prettier 'contracts/**/*.sol' -w","lint:ts":"eslint 'src/**/*.ts' '*.ts' --max-warnings 0 --fix","coverage":"hardhat coverage","lint:sol":"solhint 'contracts/**/*.sol'","postinstall":"patch-package","deploy-no-market":"hardhat deploy --tags no-market --network","deploy-market-enabled":"hardhat deploy --tags market-enabled --network"},"_npmUser":{"name":"0g-peterzhang","email":"peter@0g.ai"},"_npmVersion":"10.8.1","description":"## Introduction","directories":{},"_nodeVersion":"20.14.0","_hasShrinkwrap":false,"packageManager":"yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e","devDependencies":{"chai":"4.3.7","dotenv":"^16.4.5","eslint":"8.34.0","ethers":"^6.11.1","hardhat":"^2.22.2","solhint":"^4.5.4","ts-node":"^10.9.2","prettier":"2.8.4","hash-wasm":"^4.9.0","typechain":"^8.3.2","typescript":"4.9.5","@types/mocha":"^10.0.6","patch-package":"^8.0.0","hardhat-deploy":"^0.12.2","solidity-coverage":"^0.8.12","@typechain/hardhat":"^9.1.0","@typechain/ethers-v6":"^0.5.1","hardhat-abi-exporter":"^2.10.1","hardhat-gas-reporter":"^2.1.1","hardhat-deploy-ethers":"^0.4.1","eslint-config-prettier":"8.6.0","eslint-plugin-prettier":"4.2.1","@openzeppelin/contracts":"4.8.3","solhint-plugin-prettier":"0.0.5","prettier-plugin-solidity":"1.1.2","@typescript-eslint/parser":"6.21.0","eslint-plugin-no-only-tests":"3.1.0","hardhat-interface-generator":"^0.0.6","@clrfund/waffle-mock-contract":"^0.0.11","@nomicfoundation/ignition-core":"^0.15.5","@openzeppelin/hardhat-upgrades":"^3.0.5","@nomicfoundation/hardhat-ethers":"^3.0.5","@nomicfoundation/hardhat-verify":"^2.0.8","@nomicfoundation/hardhat-toolbox":"^5.0.0","@typescript-eslint/eslint-plugin":"6.21.0","prettier-plugin-organize-imports":"3.2.4","@nomicfoundation/hardhat-ignition":"^0.15.5","@openzeppelin/contracts-upgradeable":"^4.1.0","@nomicfoundation/hardhat-chai-matchers":"^2.0.6","@nomicfoundation/hardhat-ignition-ethers":"^0.15.5","@nomicfoundation/hardhat-network-helpers":"^1.0.11"},"_npmOperationalInternal":{"tmp":"tmp/0g-storage-contracts_0.0.1_1726640813582_0.8765390193772009","host":"s3://npm-registry-packages"},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info."}},"time":{"created":"2024-09-18T06:26:53.488Z","modified":"2026-04-30T11:23:14.472Z","0.0.1":"2024-09-18T06:26:53.762Z"},"author":{"name":"Zero Gravity Labs"},"license":"Unlicense","description":"## Introduction","maintainers":[{"name":"0g-jiahao","email":"jiahao@0g.ai"},{"name":"0g-peterzhang","email":"peter@0g.ai"}],"readme":"# 0G Storage Contract \n\n## Introduction\n\nThe 0g-storage-contracts system is tasked with the management of data submission for 0g storage, Proof of Random Access (PoRA) mining, and the economic model associated with these processes. It features a modular design that allows for various implementations of its components, including:\n\n### Flow\n\nThe Flow module is responsible for receiving user storage requests along with their metadata, maintaining the overall storage Merkle root, and generating mining tasks in period.\n\n### Market\n\nUpon receiving a submission from a user, the Flow module notifies the Market contract. If the Market contract determines that the user has not paid sufficient fees, it will revert the entire transaction.\n\nIt is important to note that the payment of fees and the submission of data are independent steps. The Flow does not automatically pay the Market when submitting data. This design allows for more flexible Market logic, such as multi-currency payments. Some contracts, like FixedPriceFlow, merge these two steps into a single transaction.\n\nImplementations of the Market include:\n- **Cashier**: An early design with extensive features, may not be suitable for current systems.\n- **FixedPrice**: Charges a fixed price for submissions. Users can voluntarily pay a tip to incentivize more miners for storage.\n\n### Reward\n\nThe Market can transfer a portion of the balance to the Reward module and inform it about which segment of data the fees are for.\n\nBesides, after a mining task is verified, the Flow informs the Reward about the pricing chunk hit by the miner's PoRA and requests the reward. The specific amount of the reward is determined by the Reward contract.\n\nImplementations of the Reward include:\n- **ChunkDecayReward**: The earliest economic model design, where each pricing chunk has a separate reward pool composed of various fees paid by users during data submission. The fees are released at a half-life rate of 25 years, allowing miners to extract half of the remaining unlocked rewards with each mining hit.\n- **ChunkLinearReward**: A variation of the previous design that changes the release method to a fixed-time linear release, aiming to address the issue of low capital utilization.\n- **OnePoolReward**: Maintains a single reward pool within a mining time window (e.g., only data submitted in the last three months is eligible for mining). This design focuses on a singular, consolidated reward pool for the specified time window.\n\n### Mine\n\nResponsible for validating mining submissions and distributing rewards.\n\n## Compile\n\n```shell\nyarn\nyarn build\n```\n\n## Deploy contract\n\nIf the economic model is not enabled, data submissions and mining will not involve token transfers. If enabled, `FixedPrice` will be selected as the market, and `OnePoolReward` as the Reward.\n\nUse the following command for deployment with economic model:\n\n```\nyarn deploy-market-enabled <network>\n```\n\nFor deployment without economic model:\n\n```\nyarn deploy-no-market <network>\n```\n\nTo export all contract addresses of a deployment into a single file:\n```\nyarn hardhat export --network <network> --export <filename>\n``` \n\n### Deployment Configurations\n\nYou can create a custom configuration file for a network under [networks](src/networks/) folder, then put the network name and the configuration struct as entry in `GlobalConfig` mapping in [config.ts](src/config.ts).\n\nSee configuration for [zg](src/networks/zerog_contract_config.ts) network as reference.\n\n### targetnetwork\n\nYou have several options for the target network, which you can modify in `hardhat.config.ts`:\n\n- **localtest**: For local testing environments.\n- **zg**: For deploying on Zero Gravity network.\n\nWhen deploying, ensure that your environment is properly configured with the necessary variables and network settings to match your deployment goals. This modular and flexible approach allows for tailored deployments that fit the specific needs of your project.\n","readmeFilename":"README.md"}