Upload File to 0G Storage
Facilitates file uploads to 0G decentralized storage, ensuring data integrity with Merkle tree organization and secure retrieval.
Install this skill
Security score
The Upload File to 0G Storage skill was audited on Feb 25, 2026 and we found 30 security issues across 2 threat categories. Review the findings below before installing.
Categories Tested
Security Issues
Template literal with variable interpolation in command context
| 66 | if (err) throw new Error(`Merkle tree error: ${err}`); |
Template literal with variable interpolation in command context
| 72 | if (uploadErr) throw new Error(`Upload failed: ${uploadErr.message}`); |
Template literal with variable interpolation in command context
| 102 | const tempPath = path.join(os.tmpdir(), `0g-upload-${Date.now()}-${filename}`); |
Template literal with variable interpolation in command context
| 108 | if (err) throw new Error(`Merkle tree error: ${err}`); |
Template literal with variable interpolation in command context
| 112 | if (uploadErr) throw new Error(`Upload failed: ${uploadErr.message}`); |
Template literal with variable interpolation in command context
| 140 | if (!fs.existsSync(filePath)) throw new Error(`File not found: ${filePath}`); |
Template literal with variable interpolation in command context
| 144 | console.log(`Uploading ${filePath} (${stats.size} bytes)...`); |
Template literal with variable interpolation in command context
| 159 | if (err) throw new Error(`Merkle tree generation failed: ${err}`); |
Template literal with variable interpolation in command context
| 166 | if (uploadErr) throw new Error(`Upload failed: ${uploadErr.message}`); |
Access to .env file
| 20 | - `.env` with `PRIVATE_KEY`, `RPC_URL`, `STORAGE_INDEXER` |
Access to .env file
| 24 | 1. Initialize ethers provider and wallet from `.env` |
Access to .env file
| 59 | const provider = new ethers.JsonRpcProvider(process.env.RPC_URL); |
Access to .env file
| 60 | const wallet = new ethers.Wallet(process.env.PRIVATE_KEY!, provider); |
Access to .env file
| 61 | const indexer = new Indexer(process.env.STORAGE_INDEXER!); |
Access to .env file
| 71 | const [tx, uploadErr] = await indexer.upload(file, process.env.RPC_URL!, wallet); |
Access to .env file
| 97 | const provider = new ethers.JsonRpcProvider(process.env.RPC_URL); |
Access to .env file
| 98 | const wallet = new ethers.Wallet(process.env.PRIVATE_KEY!, provider); |
Access to .env file
| 99 | const indexer = new Indexer(process.env.STORAGE_INDEXER!); |
Access to .env file
| 111 | const [, uploadErr] = await indexer.upload(file, process.env.RPC_URL!, wallet); |
Access to .env file
| 135 | if (!process.env.PRIVATE_KEY) throw new Error('PRIVATE_KEY not set in .env'); |
Access to .env file
| 136 | if (!process.env.RPC_URL) throw new Error('RPC_URL not set in .env'); |
Access to .env file
| 137 | if (!process.env.STORAGE_INDEXER) throw new Error('STORAGE_INDEXER not set in .env'); |
Access to .env file
| 146 | const provider = new ethers.JsonRpcProvider(process.env.RPC_URL); |
Access to .env file
| 147 | const wallet = new ethers.Wallet(process.env.PRIVATE_KEY!, provider); |
Access to .env file
| 153 | const indexer = new Indexer(process.env.STORAGE_INDEXER!); |
Access to .env file
| 165 | const [tx, uploadErr] = await indexer.upload(file, process.env.RPC_URL!, wallet); |
Access to .env file
| 182 | await indexer.upload(file, process.env.RPC_URL!, wallet); |
Access to .env file
| 187 | await indexer.upload(file, process.env.RPC_URL!, wallet); // May fail or produce invalid upload |
Access to .env file
| 194 | await indexer.upload(file, process.env.RPC_URL!, wallet); // Root hash lost! |
Access to .env file
| 206 | | `indexer not available` | Wrong indexer URL | Check `STORAGE_INDEXER` in `.env` | |
Install this skill with one command
/learn @0gfoundation/upload-file