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:

  1. Check if it relies on Node.js built-in modules
  2. 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

Deploy to production

  1. Link a Wallet Key — Connect your wallet to your organization
  2. Deploy Your Workflow — Push your workflow live
  3. Monitor Your Workflow — Watch it execute and debug issues

Explore different triggers

You used a Cron trigger. Most production workflows react to events:

Add secrets

Real workflows need API keys and sensitive data:

Build your own consumer contract

Reference

Dive deeper into concepts from this guide:

Get the latest Chainlink content straight to your inbox.