Smart Contract Design

Smart Contract Design

The Signex smart contract is responsible for executing trustless peer-to-peer swaps between two wallets. It enforces atomic execution, verifies signed trade agreements, and guarantees that either both assets transfer successfully or the entire trade reverts.

The contract does not store user funds, does not custody assets, and does not allow partial execution.


Design Principles

Atomic Execution

  • Both sides of a trade execute in a single transaction.

  • If any transfer fails, the entire swap fails.

  • Eliminates first-send risk.

Off-Chain Order Signing

  • Trades are signed using EIP-712 typed structured data.

  • Reduces gas costs by keeping order creation off-chain.

  • Ensures cryptographic verification of trade intent.

Explicit Counterparty Model

  • Every trade specifies both maker and taker addresses.

  • Prevents third-party front-running.

  • Guarantees private 1-to-1 trading.

Replay Protection

  • Each trade contains a unique nonce.

  • Used trades cannot be executed again.

Expiry Enforcement

  • Trades include an expiration timestamp.

  • Prevents execution of outdated orders.

No Custody / No Escrow Storage

  • Assets remain in user wallets until execution.

  • Transfers happen directly wallet-to-wallet inside the atomic transaction.


Security Enforcement

The contract validates the following before execution:

  • Maker and taker signatures are valid.

  • Trade is not expired.

  • Trade nonce has not been used.

  • Token addresses are valid.

  • Maker and taker are different wallets.

  • Transfer approvals exist (ERC20 allowance).

  • Tokens are standard ERC20 (rejects fee-on-transfer tokens).

  • Trade parameters match signed data.

If any validation fails → transaction reverts.


Trade Structure (Token ↔ Token)

Each trade contains:

  • Maker wallet address

  • Taker wallet address

  • Token offered by maker

  • Token offered by taker

  • Amount offered by maker

  • Amount offered by taker

  • Unique nonce

  • Expiry timestamp


Token ↔ Token Contract Functions (ABI)

Below are the core public/external functions used for token-to-token swaps.

Execute Trade

Executes a signed atomic swap between maker and taker.


Cancel Trade

Allows either participant to invalidate a signed trade before execution.


Check Trade Status

Returns whether a trade nonce has already been executed or cancelled.


Domain Separator (EIP-712 Helper)

Allows frontend and external tools to verify signature domain consistency.


Events

Events allow indexing services and frontends to track trade activity.

Trade Executed


Trade Cancelled


Allowance Requirements

Before executing a trade:

  • Maker must approve contract to spend makerToken.

  • Taker must approve contract to spend takerToken.

No approval = trade execution fails.


The smart contract is designed to support additional swap types:

  • NFT ↔ NFT swaps

  • Token ↔ NFT swaps

  • Multi-asset swaps

  • Cross-chain swap routing

These features extend the same atomic execution model and will be available soon.


Smart Contract Address (Token<->Token): 0xc04038114Fe5D8B838055ab77136544fF5881eb6arrow-up-right

Last updated