Conditional Payment Smart Contract Development

We design and develop full-cycle blockchain solutions: from smart contract architecture to launching DeFi protocols, NFT marketplaces and crypto exchanges. Security audits, tokenomics, integration with existing infrastructure.
Showing 1 of 1All 1305 services
Conditional Payment Smart Contract Development
Medium
~3-5 days
Frequently Asked Questions

Blockchain Development Services

Blockchain Development Stages

Latest works

  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1251
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1189
  • image_logo-advance_0.webp
    B2B Advance company logo design
    646
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    929
  • image_logo-aider_0.webp
    AIDER company logo development
    859
  • image_crm_chasseurs_493_0.webp
    CRM development for Chasseurs
    974

We develop escrow contracts that lock funds and release them only when predefined conditions are met. No intermediaries, full on-chain transparency. With over 50 successful projects, we know that the key is choosing the right verification mechanism and building defenses against typical attacks. Get a consultation — we will help determine the optimal architecture for your scenario.

A conditional payment is escrow on steroids. Funds are locked in the contract and released only when predetermined conditions are met. Sounds simple, but the devil is in the details: who verifies condition fulfillment, what happens in a dispute, how does the contract know about off-chain events? The last question makes this task non-trivial — a blockchain contract is isolated and cannot check 'task completed' or 'KPI achieved' by itself. It needs an oracle.

Why conditional payment requires an oracle?

The contract has no access to the outside world. If the condition is 'goods delivered' or 'result from a server', a trusted data source is needed by both parties. There are three options: centralized arbitrator, decentralized oracle (Chainlink), or cryptographic signature from a pre-agreed verifier. Each dictates the architecture and trust level.

How to choose a verification mechanism?

Mechanism Trust Complexity Use Case Example
Arbitrator (trusted third party) Centralized Low B2B contracts, freelance payments
Chainlink Oracle (Price Feed / Functions) Decentralized Medium DeFi options, KPI payments
Cryptographic signature Decentralized (key) Low Payments with off-chain confirmation
Multi-party verification (2-of-3) Distributed High Auctions, high-risk scenarios

Arbitrator (trusted third party)

Classic escrow: buyer, seller, arbitrator. The arbitrator is an address with the right to call release() or refund(). The simplest implementation suitable for most B2B cases. Problem: the arbitrator is centralized — if it's a single address, it's a single point of failure and trust. Solution: use a multisig or DAO as the arbitrator.

Oracle (Chainlink or custom)

For conditions that can be obtained on-chain: asset price, event result, on-chain data from another protocol. Chainlink AnyAPI allows requesting any HTTP data and delivering it to the contract.

// Request data via Chainlink Functions
function requestVerification(bytes32 jobId, string calldata apiUrl) external {
    Chainlink.Request memory req = buildChainlinkRequest(
        jobId, address(this), this.fulfill.selector
    );
    req.add("get", apiUrl);
    req.add("path", "result.completed");
    sendChainlinkRequest(req, fee);
}

function fulfill(bytes32 requestId, bool completed) external recordChainlinkFulfillment(requestId) {
    if (completed) {
        _releaseFunds();
    }
}

For simple numeric conditions (price threshold) — Chainlink Price Feeds without additional integration.

Recipient's signature (cryptographic proof)

The condition is confirmed by a digital signature from a trusted party. For example, a payment system signs a transaction confirmation, and the contract verifies the signature via ecrecover. This works without an on-chain oracle — the signature contains all necessary information.

function releaseWithSignature(
    uint256 paymentId,
    bytes memory signature
) external {
    bytes32 hash = keccak256(abi.encodePacked(paymentId, address(this)));
    bytes32 ethHash = hash.toEthSignedMessageHash();
    address signer = ethHash.recover(signature);
    require(signer == trustedVerifier, "Invalid signature");
    _release(paymentId);
}

Multi-party verification

Combination: 2-of-3 between buyer, seller, and arbitrator. Any two of three can release funds. This reduces the risk of collusion between one party and the arbitrator.

Dispute resolution mechanism

We implement a dispute mechanism with evidence storage (IPFS hashes in the contract). Each party can upload a hash of their claim, and the arbitrator (or DAO) decides based on this data. The dispute window is limited — for example, 7 days.

Basic contract structure

struct Payment {
    address payer;
    address payee;
    uint256 amount;
    address token;          // address(0) for ETH
    uint256 deadline;       // timestamp expiry
    PaymentState state;     // Pending, Released, Refunded, Disputed
    bytes32 conditionHash;  // hash of condition (off-chain document)
}

enum PaymentState { Pending, Released, Refunded, Disputed }

The deadline is critical. If the condition is not met by deadline, the payer must be able to reclaim funds. Without it, funds can be stuck forever.

How to implement a conditional payment: 5 steps

  1. Scenario analysis. Identify participants, condition, and verification mechanism. For example, a KPI payment needs an oracle; freelance needs an arbitrator.
  2. Contract design. Choose the pattern (arbitrator, oracle, signature) and set parameters: deadline, token, amount.
  3. Implementation. Write Solidity code using Foundry or Hardhat. Include tests with >95% coverage.
  4. Security audit. Check for reentrancy, oracle manipulation, front-running. Use Slither and Echidna.
  5. Deployment and monitoring. Deploy to testnet, run integration tests, then mainnet.

Typical cases and their specifics

From our practice:

  • Freelance payment. Condition: client confirmation. Arbitrator: DAO or multisig. Term: 14-30 days. Specifics: needs a dispute mechanism with evidence storage.
  • DeFi option. Condition: price level reached. Oracle: Chainlink Price Feed. Term: option expiry. Specifics: oracle manipulation risk — a flash loan can briefly change price. Solution: TWAP instead of spot price. On a recent DeFi options platform, we replaced spot price oracles with Chainlink TWAP. This reduced the risk of price manipulation by over 90% and lowered operational costs by 30%.
  • Vendor payment with KPI. Condition: on-chain data (TVL, transaction volume). Oracle: The Graph + custom oracle. Term: quarterly. Specifics: data from The Graph is pull, not push — the contract requests it via Chainlink.
  • Gaming achievements. Condition: on-chain event in a game contract. Verification: direct call from the game contract.

How to protect against attacks?

Reentrancy on release. _release() transfers ETH or tokens. If the recipient is a contract, it can call _release() again. Protection: ReentrancyGuard from OpenZeppelin + checks-effects-interactions pattern (change state first, then transfer).

Oracle manipulation. An attacker uses a flash loan to manipulate the price on a DEX in one block — the oracle reads the manipulated price → condition met → funds released. For price conditions: use only Chainlink with TWAP, not DEX spot price.

Front-running on fulfill. MEV bots see a fulfillment transaction in the mempool and insert their transaction before it. For escrow this is usually not critical (the recipient is predetermined), but in auction schemes a commit-reveal mechanism is needed.

Deadline expiry with valid condition. The condition is met, but the confirmation transaction gets stuck and the deadline passes. We implement a reasonable grace period or off-chain monitoring with alerts.

What's included in the deliverables

  • Requirements audit and refinement for your business scenario.
  • Smart contract source code in Solidity (Foundry/Hardhat) with unit and integration tests (>95% coverage).
  • API documentation and interaction diagrams.
  • Deployment to testnet (Sepolia, Goerli), full test round.
  • Operation and maintenance instructions.
  • Code review by our senior engineer (extensive blockchain experience).

We support projects after deployment: monitoring, contract upgrades if needed. We will assess your project within 24 hours. Contact us for a consultation. Order development — we will discuss details. Get a consultation to determine the architecture and budget estimate.

Timelines

Stage Duration
Basic escrow (ETH/ERC-20, arbitrator, deadline) 2 days
Adding Chainlink Price Feed +1 day
Adding Chainlink Functions +2 days
Multi-party dispute mechanism with IPFS +2 days
Full system with frontend +3-5 business days

Exact timeline is determined after analyzing your scenario.

Smart Contract Development

We faced a situation: a contract was deployed, two weeks later a message arrives—the pool drained for $800k. Looked at the transaction in Tenderly: attacker called deposit(), inside an ERC-777 callback re-called withdraw()—balance only updated after the second exit. Classic reentrancy, but not via ETH transfer—through an ERC-777 hook. ReentrancyGuard was only on withdraw().

Such cases are not rare. A smart contract is financial logic with no possibility to patch it overnight. Our team develops turnkey contracts, embedding protection against reentrancy, MEV, and gas attacks from the early stages.

How We Develop Smart Contracts Turnkey

We start with business logic audit and stack selection. Solidity 0.8.x is the standard for EVM-compatible chains: Ethereum, Arbitrum, Optimism, Polygon, BSC, Avalanche C-Chain. For Solana, we use Rust and Anchor: the account and program model requires explicit declaration of all resources. For projects requiring formal verification, Move (Aptos, Sui) fits—linear types eliminate resource copying at the compiler level. Vyper is chosen for contracts where audit simplicity is critical (Curve Finance).

Language Execution Model Typical Domain Risks
Solidity 0.8.x EVM, sequential DeFi, NFT, tokens Reentrancy, overflow (unchecked)
Rust (Anchor) Solana, parallel High-throughput DEX, games Incorrect account declaration
Move Aptos/Sui, resource Large protocols Ecosystem complexity
Vyper EVM, limited syntax Critical contracts (Curve) Compiler stability dependency

Gas optimization is not premature optimization—it is an architectural decision. On Ethereum mainnet, deploying a poorly designed contract can cost a significant amount of ETH due to suboptimal storage layout. Repacking a Proposal structure from 7 slots to 4 saved thousands of gas per vote—substantial savings when scaled across thousands of votes per day.

Typical gas mistakes: passing arrays via memory instead of calldata in external functions (2–3x more expensive); using require with long strings instead of custom errors like error InsufficientBalance(...). Custom errors are cheaper on revert and pass structured data to the frontend.

Why Smart Contract Audit Is Critical for Security

Audit is not a one-time check—it is a built-in development stage. We use three levels:

  1. Static analysisSlither (30 seconds in CI) detects reentrancy, uninitialized variables, dangerous delegatecall.
  2. Fuzzing and invariant testsFoundry with --fuzz-runs 50000 finds edge cases missed by hundreds of unit tests. Real case: an AMM contract with custom math passed 150 Hardhat tests; Foundry found an integer division truncation that allowed a dust attack to accumulate dust on the contract. Echidna checks invariants ("sum of all balances ≤ totalSupply").
  3. Manual code review—our engineers with 10+ years in blockchain identify logic errors that tools miss. For protocols with TVL > $1M, external audit from Trail of Bits, Consensys Diligence, or OpenZeppelin is mandatory. Timeline: 2–4 weeks.

Any upgradeable protocol must have a timelock. TimelockController from OpenZeppelin: operation proposed → wait minimum delay (48–72 hours) → executed. Without timelock, one compromised deployer wallet means losing the entire pool.

What Upgrade Patterns Do We Choose?

Pattern Mechanism Risk When to Use Our Experience
Transparent Proxy (OZ) admin vs user separation Storage collision, centralization Standard projects 15+ implementations
UUPS Upgrade logic in implementation Forget _authorizeUpgrade → contract permanently broken Gas-optimized projects 7 projects
Diamond (EIP-2535) Multiple facets Audit complexity Large protocols with 10+ contracts 3 deployments
Beacon Proxy One beacon for multiple proxies Beacon = single point of failure Factories of identical contracts 5 factories

Storage collision is the main danger of proxies. Implementation v2 must not add variables before existing ones. OpenZeppelin Upgrades plugin for Hardhat and Foundry checks this automatically, but only when using its API.

How to Protect a Contract from MEV and Front-Running

On Ethereum mainnet, transactions in the mempool are visible to all. MEV bots execute sandwich attacks on DEX, front-run mints and governance. Solution: commit-reveal scheme for auctions, private submission via Flashbots PROTECT RPC. EIP-7702 and PBS (proposer-builder separation) are changing the landscape but not yet widespread.

What Is the Development Process?

  1. Analysis—functional specification, call diagram, edge case analysis. Without this, coding starts in vain.
  2. Development—Solidity/Rust with tests in parallel. Test → code → refactoring. Use Foundry for fuzz and invariant tests.
  3. Internal audit—Slither + Echidna + manual code review. Foundry invariant tests for protocol invariants.
  4. External audit—for projects with real money. Timeline: 2–4 weeks.
  5. Deployment—Foundry scripts or Hardhat Ignition with verification on Etherscan. Gnosis Safe for ownership transfer immediately after deployment.
  6. Monitoring—Tenderly alerts, OpenZeppelin Defender, Forta Network.

What Is Included

  • Architecture documentation and contract specification (NatSpec).
  • Source code with repository and CI (Slither, Foundry, coverage).
  • Deployed contract with verification on blockchain explorer.
  • Audit results (internal and external upon request).
  • Access to monitoring and management (Gnosis Safe).
  • Code warranty: critical bug fixes within one month after deployment.
  • Consultation on web integration (wagmi, RainbowKit).

Estimated Timelines

  • ERC-20 token with basic functions: 1–2 weeks
  • Vesting contract with cliff/linear schedule: 2–3 weeks
  • NFT ERC-721/1155 with marketplace: 4–6 weeks
  • AMM or lending protocol: 2–4 months
  • Multichain protocol with bridge: 4–7 months

Audit adds 3–6 weeks and runs in parallel with final testing where possible. Cost is calculated individually—contact us for a free project evaluation.

Order smart contract development—get consultation on architecture and protection against reentrancy, MEV, and gas attacks. Want to discuss details? Write to us—we will select the optimal stack for your task.