← Back to home

1inchtents- near

This project includes a complete 1inch protocol implementation with near intents

Problem Statement

NEAR Intents TEE Solver Registry with 1inch IntegrationThe NEAR Intents TEE Solver Registry is a protocol that enables secure and private execution of NEAR Intents solvers using Trusted Execution Environment (TEE) technology. This project includes a complete 1inch protocol implementation (Limit Order Protocol and Cross-chain Escrow) integrated with NEAR Intents for cross-chain atomic swaps.This protocol allows liquidity pools creation for NEAR Intents. Liquidity providers can transfer funds into the pools' smart contracts. Only the solvers who're running within TEE with the approved Docker images can be registered and authorized to operate against the pools' assets.🚀 1inch Implementation FeaturesLimit Order Protocol: Complete NEAR implementation of 1inch's limit order functionalityCross-chain Escrow: Atomic swap mechanism for NEAR ↔ EVM chainsTypeScript SDK: Full client-side library with type safetyDocker Build System: Cross-platform compilation for Apple Silicon and x86_64Automated Deployment: Scripts for NEAR testnet and EVM testnet deploymentComprehensive Testing: End-to-end testing frameworkOverviewThe system consists of several main components:Smart Contractssolver-registry: Support liquidity pools creation. Manage registration and verification of TEE solvers for each liquidity pool.intents-vault: The vault contract that manage the pool's asset within NEAR Intents.limit-order-protocol: 1inch Limit Order Protocol implementation for NEARcross-chain-escrow: Cross-chain atomic swap escrow contractSolver Management ServerA TypeScript-based server that manages the lifecycle of TEE solversHandles solver deployment and monitoring for each liquidity poolTypeScript SDKClient-side library for interacting with all contractsFull type safety and comprehensive error handlingPrerequisitesRust and Cargo (latest stable version)Node.js (v20 or later)pnpm package managerDocker and Docker ComposeNEAR CLIA NEAR account with sufficient NEAR tokens for funding the ephemeral accounts in each TEE solverProject Structuretee-solver/ ├── contracts/ # Smart contracts │ ├── solver-registry/ # Solver registry contract │ ├── intents-vault/ # NEAR Intents vault contract │ ├── mock-intents/ # Mock NEAR Intents contract for testing │ ├── mock-ft/ # Mock fungible token for testing │ ├── limit-order-protocol/ # 1inch Limit Order Protocol │ └── cross-chain-escrow/ # Cross-chain atomic swap escrow ├── sdk/ # TypeScript SDK │ ├── src/ # Source code │ ├── dist/ # Compiled JavaScript │ └── package.json # SDK dependencies ├── server/ # TEE Solver management server ├── scripts/ # Deployment and utility scripts ├── demo.js # Demo script for testing ├── quick-start.sh # Quick setup script └── docs/ # Documentation🐳 Docker Compilation SetupApple Silicon (M1/M2) UsersDue to WASM compilation issues on Apple Silicon, we use Docker for consistent builds:# Build all contracts using Docker docker run --rm -v $(pwd):/code -w /code --platform=linux/amd64 rust:1.86.0 bash -c " rustup target add wasm32-unknown-unknown && cargo clean && cargo build --target wasm32-unknown-unknown --release -p limit-order-protocol && cargo build --target wasm32-unknown-unknown --release -p cross-chain-escrow && cargo build --target wasm32-unknown-unknown --release -p solver-registry "x86_64 Users# Standard compilation rustup target add wasm32-unknown-unknown cargo build --target wasm32-unknown-unknown --releaseBuild Individual Contracts# Build Limit Order Protocol docker run --rm -v $(pwd):/code -w /code --platform=linux/amd64 rust:1.86.0 bash -c " rustup target add wasm32-unknown-unknown && cargo build --target wasm32-unknown-unknown --release -p limit-order-protocol " # Build Cross-chain Escrow docker run --rm -v $(pwd):/code -w /code --platform=linux/amd64 rust:1.86.0 bash -c " rustup target add wasm32-unknown-unknown && cargo build --target wasm32-unknown-unknown --release -p cross-chain-escrow "🚀 Deployment Instructions1. NEAR Testnet DeploymentCreate NEAR Account# Create a new NEAR account near create-account <your-account>.testnet --masterAccount <master-account>.testnet # Or use existing account near loginDeploy Contracts# Deploy Limit Order Protocol near deploy <your-account>.testnet target/wasm32-unknown-unknown/release/limit_order_protocol.wasm # Initialize the contract near call <your-account>.testnet new '{"owner_id": "<your-account>.testnet"}' --accountId <your-account>.testnet # Deploy Cross-chain Escrow near deploy <your-account>.testnet target/wasm32-unknown-unknown/release/cross_chain_escrow.wasm # Initialize the contract near call <your-account>.testnet new '{"owner_id": "<your-account>.testnet"}' --accountId <your-account>.testnet2. EVM Testnet Deployment# Deploy to Sepolia testnet npx hardhat deploy --network sepolia # Deploy to Mumbai testnet npx hardhat deploy --network mumbai3. Automated DeploymentUse the provided deployment script:# Make script executable chmod +x quick-start.sh # Run automated deployment ./quick-start.sh⚠️ Known Issues and Solutions1. NEAR SDK Deserialization ErrorError:CompilationError(PrepareError(Deserialization))Description: This error occurs during contract initialization on NEAR testnet, affecting all contracts including known-working ones.Root Cause: NEAR SDK v5.14.0 compatibility issue with testnet RPC.Solutions:Try downgrading to NEAR SDK v4.xUse different RPC endpointsTest with mainnet deploymentCheck NEAR CLI version compatibilityStatus: Under investigation - affects all contracts, not just 1inch implementation.2. Apple Silicon WASM CompilationError:relocation R_WASM_MEMORY_ADDR_SLEB cannot be used against symbol ... recompile with -fPICDescription: WASM cross-compilation fails on Apple Silicon due to architecture differences.Solution: Use Docker compilation (see Docker Compilation Setup above).3. Cargo Lock File VersionError:error: failed to parse lock file at: /code/Cargo.lock lock file version '4' was found, but this version of Cargo does not understand this lock fileDescription: Docker image has outdated Cargo version.Solution: Userust:1.86.0Docker image (already specified in commands above).4. Node Modules TrackingIssue:node_modulesdirectory being tracked in git.Solution: Updated.gitignoreto exclude build artifacts and dependencies.🧪 TestingUnit Tests# Run all tests cargo test # Run specific contract tests cargo test -p limit-order-protocol cargo test -p cross-chain-escrowIntegration Tests# Test SDK functionality cd sdk pnpm test # Run demo script node demo.jsEnd-to-End Testing# Deploy to testnet and run integration tests ./scripts/test-integration.sh📚 SDK UsageInitialize SDKimport { LimitOrderProtocol, CrossChainEscrow } from './sdk'; const limitOrder = new LimitOrderProtocol({ contractId: 'limit-order-protocol.testnet', network: 'testnet' }); const escrow = new CrossChainEscrow({ contractId: 'cross-chain-escrow.testnet', network: 'testnet' });Create Limit Orderconst orderId = await limitOrder.createOrder({ makerAsset: 'token-a.testnet', takerAsset: 'token-b.testnet', makingAmount: '1000000000000000000000000', // 1 token takingAmount: '2000000000000000000000000', // 2 tokens expiration: Date.now() + 3600000 // 1 hour });Create Cross-chain Escrowconst escrowId = await escrow.createEscrow({ makerAsset: 'token-a.testnet', takerAsset: '0x1234567890123456789012345678901234567890', // EVM address makingAmount: '1000000000000000000000000', takingAmount: '2000000000000000000000000', timelocks: { finalityPeriod: 3600, withdrawalPeriod: 7200, cancellationPeriod: 1800 } });🔧 DevelopmentBuilding Contracts# Build all contracts make all # Build specific contract make limit-order-protocol make cross-chain-escrowBuilding SDKcd sdk pnpm install pnpm buildRunning Development Servercd server pnpm install pnpm dev📖 DocumentationQS1D🛠️ Toolsc- NEAR smart contract development toolkit for Rustn- Interact with NEAR blockchain from command lineNSecurityThis project uses TEE (Trusted Execution Environment) to ensure secure and private execution of NEAR Intents solvers. The 1inch implementation includes comprehensive security measures for cross-chain atomic swaps.AcknowledgementThe project is inspired by the incredible design ofSand the 1inch protocol architecture.LicenseThis project is licensed under the MIT License - see the LICENSE file for details.1inch Protocol Implementation on NEARA complete implementation of the 1inch protocol on NEAR blockchain, featuring cross-chain swaps, limit orders, and enhanced resolver functionality using NEAR Intents technology.🚀Deployed Contracts (NEAR Testnet)All contracts have been successfully deployed to NEAR testnet:| Contract | Address | Transaction ID | |----------|---------|----------------| |Limit Order Protocol|limit-order-protocol.testnet|Z| |Cross-Chain Bridge|cross-chain-bridge.testnet|9| |Enhanced Resolver|enhanced-resolver.testnet|F|📋Contract Status✅All contracts deployed successfully✅WASM files generated and verified⚠️Initialization pending(due to NEAR testnet RPC compatibility issue)✅SDK ready for integration

Solution

NEAR Intents TEE Solver Registry with 1inch IntegrationThe NEAR Intents TEE Solver Registry is a protocol that enables secure and private execution of NEAR Intents solvers using Trusted Execution Environment (TEE) technology. This project includes a complete 1inch protocol implementation (Limit Order Protocol and Cross-chain Escrow) integrated with NEAR Intents for cross-chain atomic swaps.This protocol allows liquidity pools creation for NEAR Intents. Liquidity providers can transfer funds into the pools' smart contracts. Only the solvers who're running within TEE with the approved Docker images can be registered and authorized to operate against the pools' assets.🚀 1inch Implementation FeaturesLimit Order Protocol: Complete NEAR implementation of 1inch's limit order functionalityCross-chain Escrow: Atomic swap mechanism for NEAR ↔ EVM chainsTypeScript SDK: Full client-side library with type safetyDocker Build System: Cross-platform compilation for Apple Silicon and x86_64Automated Deployment: Scripts for NEAR testnet and EVM testnet deploymentComprehensive Testing: End-to-end testing frameworkOverviewThe system consists of several main components:Smart Contractssolver-registry: Support liquidity pools creation. Manage registration and verification of TEE solvers for each liquidity pool.intents-vault: The vault contract that manage the pool's asset within NEAR Intents.limit-order-protocol: 1inch Limit Order Protocol implementation for NEARcross-chain-escrow: Cross-chain atomic swap escrow contractSolver Management ServerA TypeScript-based server that manages the lifecycle of TEE solversHandles solver deployment and monitoring for each liquidity poolTypeScript SDKClient-side library for interacting with all contractsFull type safety and comprehensive error handlingPrerequisitesRust and Cargo (latest stable version)Node.js (v20 or later)pnpm package managerDocker and Docker ComposeNEAR CLIA NEAR account with sufficient NEAR tokens for funding the ephemeral accounts in each TEE solverProject Structuretee-solver/ ├── contracts/ # Smart contracts │ ├── solver-registry/ # Solver registry contract │ ├── intents-vault/ # NEAR Intents vault contract │ ├── mock-intents/ # Mock NEAR Intents contract for testing │ ├── mock-ft/ # Mock fungible token for testing │ ├── limit-order-protocol/ # 1inch Limit Order Protocol │ └── cross-chain-escrow/ # Cross-chain atomic swap escrow ├── sdk/ # TypeScript SDK │ ├── src/ # Source code │ ├── dist/ # Compiled JavaScript │ └── package.json # SDK dependencies ├── server/ # TEE Solver management server ├── scripts/ # Deployment and utility scripts ├── demo.js # Demo script for testing ├── quick-start.sh # Quick setup script └── docs/ # Documentation🐳 Docker Compilation SetupApple Silicon (M1/M2) UsersDue to WASM compilation issues on Apple Silicon, we use Docker for consistent builds:# Build all contracts using Docker docker run --rm -v $(pwd):/code -w /code --platform=linux/amd64 rust:1.86.0 bash -c " rustup target add wasm32-unknown-unknown && cargo clean && cargo build --target wasm32-unknown-unknown --release -p limit-order-protocol && cargo build --target wasm32-unknown-unknown --release -p cross-chain-escrow && cargo build --target wasm32-unknown-unknown --release -p solver-registry "x86_64 Users# Standard compilation rustup target add wasm32-unknown-unknown cargo build --target wasm32-unknown-unknown --releaseBuild Individual Contracts# Build Limit Order Protocol docker run --rm -v $(pwd):/code -w /code --platform=linux/amd64 rust:1.86.0 bash -c " rustup target add wasm32-unknown-unknown && cargo build --target wasm32-unknown-unknown --release -p limit-order-protocol " # Build Cross-chain Escrow docker run --rm -v $(pwd):/code -w /code --platform=linux/amd64 rust:1.86.0 bash -c " rustup target add wasm32-unknown-unknown && cargo build --target wasm32-unknown-unknown --release -p cross-chain-escrow "🚀 Deployment Instructions1. NEAR Testnet DeploymentCreate NEAR Account# Create a new NEAR account near create-account <your-account>.testnet --masterAccount <master-account>.testnet # Or use existing account near loginDeploy Contracts# Deploy Limit Order Protocol near deploy <your-account>.testnet target/wasm32-unknown-unknown/release/limit_order_protocol.wasm # Initialize the contract near call <your-account>.testnet new '{"owner_id": "<your-account>.testnet"}' --accountId <your-account>.testnet # Deploy Cross-chain Escrow near deploy <your-account>.testnet target/wasm32-unknown-unknown/release/cross_chain_escrow.wasm # Initialize the contract near call <your-account>.testnet new '{"owner_id": "<your-account>.testnet"}' --accountId <your-account>.testnet2. EVM Testnet Deployment# Deploy to Sepolia testnet npx hardhat deploy --network sepolia # Deploy to Mumbai testnet npx hardhat deploy --network mumbai3. Automated DeploymentUse the provided deployment script:# Make script executable chmod +x quick-start.sh # Run automated deployment ./quick-start.sh⚠️ Known Issues and Solutions1. NEAR SDK Deserialization ErrorError:CompilationError(PrepareError(Deserialization))Description: This error occurs during contract initialization on NEAR testnet, affecting all contracts including known-working ones.Root Cause: NEAR SDK v5.14.0 compatibility issue with testnet RPC.Solutions:Try downgrading to NEAR SDK v4.xUse different RPC endpointsTest with mainnet deploymentCheck NEAR CLI version compatibilityStatus: Under investigation - affects all contracts, not just 1inch implementation.2. Apple Silicon WASM CompilationError:relocation R_WASM_MEMORY_ADDR_SLEB cannot be used against symbol ... recompile with -fPICDescription: WASM cross-compilation fails on Apple Silicon due to architecture differences.Solution: Use Docker compilation (see Docker Compilation Setup above).3. Cargo Lock File VersionError:error: failed to parse lock file at: /code/Cargo.lock lock file version '4' was found, but this version of Cargo does not understand this lock fileDescription: Docker image has outdated Cargo version.Solution: Userust:1.86.0Docker image (already specified in commands above).4. Node Modules TrackingIssue:node_modulesdirectory being tracked in git.Solution: Updated.gitignoreto exclude build artifacts and dependencies.🧪 TestingUnit Tests# Run all tests cargo test # Run specific contract tests cargo test -p limit-order-protocol cargo test -p cross-chain-escrowIntegration Tests# Test SDK functionality cd sdk pnpm test # Run demo script node demo.jsEnd-to-End Testing# Deploy to testnet and run integration tests ./scripts/test-integration.sh📚 SDK UsageInitialize SDKimport { LimitOrderProtocol, CrossChainEscrow } from './sdk'; const limitOrder = new LimitOrderProtocol({ contractId: 'limit-order-protocol.testnet', network: 'testnet' }); const escrow = new CrossChainEscrow({ contractId: 'cross-chain-escrow.testnet', network: 'testnet' });Create Limit Orderconst orderId = await limitOrder.createOrder({ makerAsset: 'token-a.testnet', takerAsset: 'token-b.testnet', makingAmount: '1000000000000000000000000', // 1 token takingAmount: '2000000000000000000000000', // 2 tokens expiration: Date.now() + 3600000 // 1 hour });Create Cross-chain Escrowconst escrowId = await escrow.createEscrow({ makerAsset: 'token-a.testnet', takerAsset: '0x1234567890123456789012345678901234567890', // EVM address makingAmount: '1000000000000000000000000', takingAmount: '2000000000000000000000000', timelocks: { finalityPeriod: 3600, withdrawalPeriod: 7200, cancellationPeriod: 1800 } });🔧 DevelopmentBuilding Contracts# Build all contracts make all # Build specific contract make limit-order-protocol make cross-chain-escrowBuilding SDKcd sdk pnpm install pnpm buildRunning Development Servercd server pnpm install pnpm dev📖 DocumentationQS1D🛠️ Toolsc- NEAR smart contract development toolkit for Rustn- Interact with NEAR blockchain from command lineNSecurityThis project uses TEE (Trusted Execution Environment) to ensure secure and private execution of NEAR Intents solvers. The 1inch implementation includes comprehensive security measures for cross-chain atomic swaps.AcknowledgementThe project is inspired by the incredible design ofSand the 1inch protocol architecture.LicenseThis project is licensed under the MIT License - see the LICENSE file for details.1inch Protocol Implementation on NEARA complete implementation of the 1inch protocol on NEAR blockchain, featuring cross-chain swaps, limit orders, and enhanced resolver functionality using NEAR Intents technology.🚀Deployed Contracts (NEAR Testnet)All contracts have been successfully deployed to NEAR testnet:| Contract | Address | Transaction ID | |----------|---------|----------------| |Limit Order Protocol|limit-order-protocol.testnet|Z| |Cross-Chain Bridge|cross-chain-bridge.testnet|9| |Enhanced Resolver|enhanced-resolver.testnet|F|📋Contract Status✅All contracts deployed successfully✅WASM files generated and verified⚠️Initialization pending(due to NEAR testnet RPC compatibility issue)✅SDK ready for integration

Hackathon

ETHGlobal Unite

2025

Contributors