Prerequisites
- A deployed PolicyClient contract (see Smart Contract Integration)
- A Newton API key (see Dashboard & API Keys)
- Node.js >= 20
Step 1: Create the Project
Step 2: Environment Variables
Create.env.local:
NEXT_PUBLIC_POLICY_CONTRACT_ADDRESS is the Newton Policy contract (fixed on Sepolia). NEXT_PUBLIC_POLICY_WALLET_ADDRESS is YOUR deployed PolicyClient. These are different contracts.Step 3: Create Configuration
Createsrc/const/config.ts:
Step 4: Create the Newton Client
Createsrc/lib/use-newton-client.ts:
Step 5: Submit an Evaluation Request
Createsrc/lib/evaluation-request.ts:
Step 6: Execute an Attested Transaction
UseevaluateIntentDirect to get an attestation, then submit the attested transaction on-chain:
Step 7: Run the Application
Troubleshooting
| Issue | Cause | Fix |
|---|---|---|
GATEWAY_ERROR | Invalid API key or network issue | Verify NEWTON_API_KEY and network connectivity |
InvalidAttestation on-chain | Task Manager mismatch or expired attestation | Verify contract was initialized with correct Task Manager address |
| WebSocket connection failed | Wrong WS URL or Alchemy plan limits | Verify SEPOLIA_ALCHEMY_WS_URL format (wss://...) |
TIMEOUT | Operator network slow or unavailable | Increase timeout or retry |
Next Steps
SDK Reference
Full TypeScript SDK documentation
RPC API
Underlying JSON-RPC methods