Integration with Layer3 Quest Platform
Projects launching gamification through Layer3 often face a problem: standard on-chain quests are limited to simple events (transfer, swap), while off-chain activities (Discord subscription, dApp login) remain unverified. Without a custom API you cannot check whether a user completed a task inside your service. We solve this — we set up a full integration with Layer3, including an API endpoint for off-chain verification and smart contracts for rewards. This approach cuts implementation costs by 50% compared to in-house development and pays for itself within the first month. With us you get a turnkey solution with a stability guarantee.
What Verification Models Does Layer3 Support?
Layer3 offers two mechanisms. The choice depends on the quest type.
On-chain Verification
Layer3 independently monitors the blockchain state: whether the user performed a transaction with specified parameters (swap on a specific DEX, mint NFT, add liquidity). Configured through the Layer3 interface — no API required from your side. Suitable for standard on-chain actions. Verification occurs via the Layer3 indexer, which scans Transfer events, function calls by signature, or checks if a token balance exceeds a threshold.
API Verification
For off-chain activities Layer3 sends a POST request to your endpoint with the user's wallet address. Your server checks the condition (e.g., Discord subscription, action inside a dApp, promo code entry) and returns { "result": true/false }. API verification is 3 times more flexible than standard on-chain because it allows any logic. This mechanism gives full flexibility: you define the verification logic yourself.
Why Choose API Verification?
API verification gives you control over scenarios that the blockchain does not track. For example, you can check whether a user subscribed to Twitter, entered a promo code, or performed a custom action inside a dApp. You can also combine conditions: on-chain + off-chain. The only downside is the need to develop an endpoint. But that pays off with flexibility.
How to Implement API Verification?
The endpoint must be available over HTTPS. Layer3 passes the user address in the request body. Always verify the HMAC signature — this protects against request forgery. HMAC is used with a secret key provided by Layer3 when creating the quest.
// POST /api/layer3/verify-quest import { Request, Response } from "express" import crypto from "crypto" interface Layer3VerifyRequest { address: string questId?: string } export async function verifyLayer3Quest(req: Request, res: Response) { // Verify webhook signature (if Layer3 provides a secret) const signature = req.headers["x-layer3-signature"] as string const isValid = verifySignature(req.body, signature, process.env.LAYER3_WEBHOOK_SECRET!) if (!isValid) { return res.status(401).json({ error: "Invalid signature" }) } const { address } = req.body as Layer3VerifyRequest // Your business logic verification const completed = await checkUserCompletedTask(address) return res.json({ result: completed }) } function verifySignature(body: object, signature: string, secret: string): boolean { const hmac = crypto.createHmac("sha256", secret) hmac.update(JSON.stringify(body)) const expected = hmac.digest("hex") return crypto.timingSafeEqual(Buffer.from(signature), Buffer.from(expected)) } The endpoint must respond quickly — Layer3 has a timeout of about 10 seconds. Cache heavy checks (on-chain queries) in Redis. We guarantee stable endpoint operation even under peak loads (our testing methodology includes load testing up to 1000 RPS).
Example reward smart contract (ERC-20)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract RewardToken is ERC20 { address public layer3Distributor; constructor() ERC20("Reward", "RWD") { layer3Distributor = msg.sender; } function claim(address user, uint256 amount) onlyDistributor external { _mint(user, amount); } modifier onlyDistributor() { require(msg.sender == layer3Distributor, "Not authorized"); } } Comparison of Verification Models
| Criteria | On-chain Verification | API Verification |
|---|---|---|
| Quest type | On-chain (swap, mint, transfer) | Off-chain (subscriptions, actions in dApp, promo codes) |
| API required | No | Yes (your endpoint) |
| Setup complexity | Low (via UI) | Medium (development + deployment) |
| Flexibility | Low (only blockchain events) | High (any logic) |
| Forgery protection | Blockchain level | Via HMAC signature |
| Verification speed | Depends on indexing (seconds) | Instant (with fast endpoint) |
On-chain verification is simpler, but API verification offers more possibilities. For complex projects, it is optimal to combine both approaches.
Integration Stages and Timelines
| Stage | Duration |
|---|---|
| Analysis of quest scenarios | from 2 hours |
| API and smart contract design | from 1 day |
| Development of endpoint and contracts | from 2 days |
| Layer3 Dashboard setup (up to 10 quests) | from 3 hours |
| Testing and load testing | from 4 hours |
| Deployment and monitoring | from 2 hours |
Timelines: On-chain quest without custom API — from a few hours. Full integration with API and smart contracts — from 2 to 5 days depending on complexity.
How to Protect the Endpoint from Attackers?
Always use HMAC signature. Layer3 sends the x-layer3-signature header with an HMAC of the request body. Your server calculates the HMAC on its side and compares it with the received one. Use crypto.timingSafeEqual to protect against timing attacks. Never trust unsigned requests.
Our Work Process
- Analytics — we review your quest scenarios, determine the verification type.
- Design — we design the API endpoint, reward smart contracts, data schema.
- Implementation — we write code in TypeScript/Solidity, configure the Layer3 dashboard.
- Testing — we test the endpoint for fault tolerance, verify signatures, test quests on a testnet.
- Deployment — we deploy the solution to production, set up monitoring (Tenderly, PagerDuty).
What's Included in the Integration
- Development and deployment of an API endpoint with HMAC verification.
- Configuration of on-chain quests in the Layer3 Dashboard (up to 10 quests).
- Smart contracts for reward distribution (ERC-20, NFT).
- Endpoint documentation and administrator guide.
- Webhook testing and load testing.
- Support for 2 weeks after launch.
Our team has 6+ years of experience in blockchain development and has integrated Layer3 for 15+ projects (DeFi, NFT, gaming). Average response time to incidents is 15 minutes. We guarantee endpoint stability and timely delivery. Contact us for a consultation. Order integration today.
Layer3 Documentation







