A modular toolkit for deploying smart contracts with optional Chainlink services integration. This tool automates the process of:
- Deploying your smart contract
- Optionally integrating Chainlink Functions
- Optionally setting up Chainlink Automation
-
Contract Requirements: If using Chainlink Automation, your contract must implement a
setForwarderAddressfunction:function setForwarderAddress(address forwarderAddress) external { // Your implementation to set the forwarder address // This is required for Chainlink Automation integration }
-
Update your contract's deploy script path:
# In .env file SCRIPT_PATH=path/to/your/DeployContract.s.sol -
Choose your deployment type:
make deploy # Deploy contract only make deploy-functions # Deploy + Chainlink Functions make deploy-automation # Deploy + Chainlink Automation make deploy-all # Deploy + Both services
- 🤖 Chainlink Automation support
- 🔮 Chainlink Functions integration
- 🛠️ Modular deployment system
- 🔐 Secure configuration management
- 📝 Comprehensive logging
- 🔄 Automatic retries and error handling
. ├── deploy/ │ ├── config/ # Configuration files │ │ ├── .env.example # Environment variables template │ │ └── validation.js # Configuration validation │ ├── automation/ # Automation-specific scripts │ ├── function/ # Functions-specific scripts │ ├── helpers/ # Utility functions │ │ ├── executeCommand.js # Command execution │ │ ├── extractAddress.js # Address extraction │ │ ├── log.js # Logging utility │ │ └── updateEnvFile.js # Environment variable management (dotenv-based) │ ├── modules/ # Core service modules │ │ ├── automation.js # Automation module │ │ └── functions.js # Functions module │ └── deploy.js # Main deployment script
-
Clone the repository: ```bash git clone https://github.com/ashleychandy/Chainlink-Plug-and-Play.git cd Chainlink-Plug-and-Play ```
-
Install dependencies: ```bash npm install ```
-
Configure environment: ```bash cp deploy/config/.env.example .env
```
Deploy your contract without any Chainlink services: ```bash node deploy/deploy.js ```
Deploy and set up Chainlink Functions: ```bash node deploy/deploy.js --functions ```
Deploy and set up Chainlink Automation: ```bash node deploy/deploy.js --automation ```
Deploy with both Chainlink Functions and Automation: ```bash node deploy/deploy.js --functions --automation ```
- `PRIVATE_KEY`: Your wallet private key
- `RPC_URL`: RPC endpoint URL
- `CHAIN_ID`: Network chain ID
- `ETHERSCAN_API_KEY`: API key for contract verification
- `AUTOMATION_REGISTRAR_ADDRESS`: Automation registrar address
- `LINK_TOKEN_ADDRESS`: LINK token address
- `AUTOMATION_GAS_LIMIT`: Maximum gas limit for upkeep
- `AUTOMATION_LINK_AMOUNT`: LINK payment for registration
- `AUTOMATION_TRIGGER_TYPE`: Automation trigger type
- `AUTOMATION_UPKEEP_NAME`: Display name for upkeep
- `FUNCTIONS_ROUTER_ADDRESS`: Chainlink Functions Router contract address
- `FUNCTIONS_SUBSCRIPTION_ID`: Functions subscription ID
The system can generate upkeep names with timestamps in your local timezone. Set the `TIMEZONE` environment variable to customize this:
```bash
export TIMEZONE=Asia/Kolkata # India Standard Time export TIMEZONE=America/New_York # Eastern Time export TIMEZONE=Europe/London # Greenwich Mean Time export TIMEZONE=America/Los_Angeles # Pacific Time export TIMEZONE=Asia/Tokyo # Japan Standard Time export TIMEZONE=Australia/Sydney # Australian Eastern Time ```
Upkeep Name Format: `Test hr:min_day/month`
- With `TIMEZONE=Asia/Kolkata`: `"Test 15:30_18/9"` (3:30 PM on Sept 18th)
- With `TIMEZONE=America/New_York`: `"Test 06:00_18/9"` (6:00 AM on Sept 18th)
- If not set: Uses system timezone (usually UTC on servers)
- `AUTOMATION_UPKEEP_NAME`: Custom upkeep name (auto-generated with timestamp if empty)
- `USDC_TOKEN_ADDRESS`: USDC token address for testing
- `ALPACA_API_KEY` / `ALPACA_SECRET_KEY`: For stock price feeds
The system includes comprehensive error handling and retry mechanisms:
- Automatic Retries: Failed operations automatically retry with exponential backoff
- Validation Checks: Input parameters are validated before execution
- Status Verification: Deployment status is verified after each operation
- Detailed Logging: Comprehensive logs help diagnose issues
-
Transaction Failures
- Check gas settings in .env
- Verify network stability
- Ensure sufficient LINK balance
-
Automation Registration Fails
- Verify LINK allowance
- Check upkeep parameters
- Confirm contract implements required interface
-
Functions Setup Issues
- Verify subscription status
- Check DON hosting configuration
- Validate consumer contract
```javascript const functions = require('./deploy/modules/functions');
// Setup Functions await functions.setupFunctions();
// Add consumer await functions.addFunctionsConsumer(contractAddress, { consumerAddress, subId, privateKey, rpcUrl });
// Verify consumer status const isValid = await functions.verifyConsumer(contractAddress, config); ```
```javascript const automation = require('./deploy/modules/automation');
// Register for automation const upkeepId = await automation.registerAutomation(contractAddress, { name: "Custom Upkeep", adminAddress: "0x..." });
// Set forwarder address await automation.setForwarderAddress(forwarderAddress, upkeepId);
// Verify registration const isRegistered = await automation.verifyRegistration(contractAddress); ```
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a new Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
For support, please open an issue in the GitHub repository.