API Reference
Actions
ZG_UPLOAD
Uploads files to the 0G network with automatic handling of file processing and network communication.Aliases
TheZG_UPLOAD action can be triggered using any of these aliases:
UPLOAD_FILE_TO_ZGSTORE_FILE_ON_ZGSAVE_FILE_TO_ZGUPLOAD_TO_ZERO_GRAVITYSTORE_ON_ZERO_GRAVITYSHARE_FILE_ON_ZGPUBLISH_FILE_TO_ZG
Input Content
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
filePath | string | Yes | Path to the file to upload (absolute or relative) |
Response
Response Fields
| Field | Type | Description |
|---|---|---|
success | boolean | Whether the upload was successful |
fileHash | string | IPFS hash of the uploaded file |
accessUrl | string | URL to access the file |
error | string | Error message if upload failed |
transactionHash | string | Blockchain transaction hash |
Example Usage
Plugin Configuration
Plugin Registration
Environment Variables
The plugin requires these environment variables:Error Codes
File Access Errors
| Code | Description | Solution |
|---|---|---|
FILE_NOT_FOUND | File doesn’t exist at specified path | Check file path and existence |
PERMISSION_DENIED | Insufficient file permissions | Verify read permissions |
PATH_INVALID | Invalid file path format | Use valid absolute or relative path |
Network Errors
| Code | Description | Solution |
|---|---|---|
RPC_CONNECTION_FAILED | Cannot connect to 0G RPC | Check network and RPC endpoint |
TRANSACTION_FAILED | Blockchain transaction failed | Verify gas and account balance |
UPLOAD_TIMEOUT | Upload operation timed out | Retry with smaller file or check network |
Configuration Errors
| Code | Description | Solution |
|---|---|---|
MISSING_CONFIG | Required environment variable missing | Set all required environment variables |
INVALID_PRIVATE_KEY | Private key format invalid | Verify private key format |
CONTRACT_NOT_FOUND | Flow contract address invalid | Check contract address |