Before You Build
You've completed the Getting Started guide and built a workflow that fetches offchain data, reads from a smart contract, performs calculations, and writes results onchain. You're ready to build your own workflows.
Before you do, take two minutes to understand how CRE differs from typical development. These tips will save you debugging time.
Library compatibility
Your TypeScript code compiles to WebAssembly and runs in a QuickJS environment, not Node.js. Some NPM packages won't work if they rely on Node.js-specific APIs like node:crypto or node:fs.
Before using a third-party package:
- Check if it relies on Node.js built-in modules
- Test with
cre workflow simulate— simulation uses the same WASM environment as production, so compatibility issues surface immediately
Working with Solidity integers
When sending values to smart contracts, always use bigint (with the n suffix) in your workflow code. JavaScript number loses precision for large values, causing silent precision loss.
// WRONG - silent precision loss
const amount = 10000000000000001 // 10 quadrillion + 1
// Silently becomes 10000000000000000 (the +1 vanishes)
// CORRECT - use bigint
const amount = 10000000000000001n // Stays exactly 10000000000000001
Working with time
If your workflow uses timestamps (e.g., for API authentication or time-based queries), use runtime.now() instead of Date.now(). This ensures all nodes in the DON use the same timestamp and can reach consensus.
What's next?
Here are resources to help you go from simulation to production.
Learn from examples
- Run the Custom Data Feed Demo — A starter template you can run locally and customize
- Browse all Templates — Building blocks for specific patterns (secrets, HTTP auth, streams) and starter templates
- AI-Powered Prediction Market — Full end-to-end demo integrating CRE with Gemini AI and Firebase
Deploy to production
- Link a Wallet Key — Connect your wallet to your organization
- Deploy Your Workflow — Push your workflow live
- Monitor Your Workflow — Watch it execute and debug issues
Explore different triggers
You used a Cron trigger. Most production workflows react to events:
- HTTP Trigger — Trigger via API calls
- EVM Log Trigger — React to onchain events
Add secrets
Real workflows need API keys and sensitive data:
- Using Secrets in Simulation — Local development
- Using Secrets with Deployed Workflows — Store secrets in the Vault DON for production
- Managing Secrets with 1Password — Best practice: inject secrets at runtime
Build your own consumer contract
- Building Consumer Contracts — Create contracts that receive CRE data
Reference
Dive deeper into concepts from this guide:
| Topic | Resources |
|---|---|
| Workflow structure | Core SDK, Triggers Overview |
| HTTP & offchain data | API Interactions, Consensus & Aggregation |
| EVM interactions | EVM Client Overview, Onchain Read, Onchain Write |
| Configuration | Project Configuration, Secrets Guide |
| All capabilities | Capabilities Overview |