This project includes a complete 1inch protocol implementation with near intents
The 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.
The system consists of several main components:
Smart Contracts
solver-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 Server
TypeScript SDK
tee-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
Due 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
"
# Standard compilation
rustup target add wasm32-unknown-unknown
cargo build --target wasm32-unknown-unknown --release
# 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
"
# Create a new NEAR account
near create-account <your-account>.testnet --masterAccount <master-account>.testnet
# Or use existing account
near login
# 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>.testnet
# Deploy to Sepolia testnet
npx hardhat deploy --network sepolia
# Deploy to Mumbai testnet
npx hardhat deploy --network mumbai
Use the provided deployment script:
# Make script executable
chmod +x quick-start.sh
# Run automated deployment
./quick-start.sh
Error: 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:
Status: Under investigation - affects all contracts, not just 1inch implementation.
Error: relocation R_WASM_MEMORY_ADDR_SLEB cannot be used against symbol ... recompile with -fPIC
Description: WASM cross-compilation fails on Apple Silicon due to architecture differences.
Solution: Use Docker compilation (see Docker Compilation Setup above).
Error: 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 file
Description: Docker image has outdated Cargo version.
Solution: Use rust:1.86.0
Docker image (already specified in commands above).
Issue: node_modules
directory being tracked in git.
Solution: Updated .gitignore
to exclude build artifacts and dependencies.
# Run all tests
cargo test
# Run specific contract tests
cargo test -p limit-order-protocol
cargo test -p cross-chain-escrow
# Test SDK functionality
cd sdk
pnpm test
# Run demo script
node demo.js
# Deploy to testnet and run integration tests
./scripts/test-integration.sh
import { 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'
});
const 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
});
const escrowId = await escrow.createEscrow({
makerAsset: 'token-a.testnet',
takerAsset: '0x1234567890123456789012345678901234567890', // EVM address
makingAmount: '1000000000000000000000000',
takingAmount: '2000000000000000000000000',
timelocks: {
finalityPeriod: 3600,
withdrawalPeriod: 7200,
cancellationPeriod: 1800
}
});
# Build all contracts
make all
# Build specific contract
make limit-order-protocol
make cross-chain-escrow
cd sdk
pnpm install
pnpm build
cd server
pnpm install
pnpm dev
This 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.
The project is inspired by the incredible design of Shade Agent and the 1inch protocol architecture.
This project is licensed under the MIT License - see the LICENSE file for details.
A complete implementation of the 1inch protocol on NEAR blockchain, featuring cross-chain swaps, limit orders, and enhanced resolver functionality using NEAR Intents technology.
All contracts have been successfully deployed to NEAR testnet:
| Contract | Address | Transaction ID |
|----------|---------|----------------|
| Limit Order Protocol | limit-order-protocol.testnet
| ZqhQv8FdtBXMm88CPvdvE9JwWXWSBrXQw1PtoRqUn3G |
| Cross-Chain Bridge | cross-chain-bridge.testnet
| 9QZALfnY3YbWPkqXepdwNq6UfW3gmHiLfjougYUUAZ3K |
| Enhanced Resolver | enhanced-resolver.testnet
| F9f8y175aaqb1QG7J2HTa9yRt878HPJhUBYYL5CTzKyv |
The 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.
The system consists of several main components:
Smart Contracts
solver-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 Server
TypeScript SDK
tee-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
Due 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
"
# Standard compilation
rustup target add wasm32-unknown-unknown
cargo build --target wasm32-unknown-unknown --release
# 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
"
# Create a new NEAR account
near create-account <your-account>.testnet --masterAccount <master-account>.testnet
# Or use existing account
near login
# 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>.testnet
# Deploy to Sepolia testnet
npx hardhat deploy --network sepolia
# Deploy to Mumbai testnet
npx hardhat deploy --network mumbai
Use the provided deployment script:
# Make script executable
chmod +x quick-start.sh
# Run automated deployment
./quick-start.sh
Error: 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:
Status: Under investigation - affects all contracts, not just 1inch implementation.
Error: relocation R_WASM_MEMORY_ADDR_SLEB cannot be used against symbol ... recompile with -fPIC
Description: WASM cross-compilation fails on Apple Silicon due to architecture differences.
Solution: Use Docker compilation (see Docker Compilation Setup above).
Error: 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 file
Description: Docker image has outdated Cargo version.
Solution: Use rust:1.86.0
Docker image (already specified in commands above).
Issue: node_modules
directory being tracked in git.
Solution: Updated .gitignore
to exclude build artifacts and dependencies.
# Run all tests
cargo test
# Run specific contract tests
cargo test -p limit-order-protocol
cargo test -p cross-chain-escrow
# Test SDK functionality
cd sdk
pnpm test
# Run demo script
node demo.js
# Deploy to testnet and run integration tests
./scripts/test-integration.sh
import { 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'
});
const 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
});
const escrowId = await escrow.createEscrow({
makerAsset: 'token-a.testnet',
takerAsset: '0x1234567890123456789012345678901234567890', // EVM address
makingAmount: '1000000000000000000000000',
takingAmount: '2000000000000000000000000',
timelocks: {
finalityPeriod: 3600,
withdrawalPeriod: 7200,
cancellationPeriod: 1800
}
});
# Build all contracts
make all
# Build specific contract
make limit-order-protocol
make cross-chain-escrow
cd sdk
pnpm install
pnpm build
cd server
pnpm install
pnpm dev
This 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.
The project is inspired by the incredible design of Shade Agent and the 1inch protocol architecture.
This project is licensed under the MIT License - see the LICENSE file for details.
A complete implementation of the 1inch protocol on NEAR blockchain, featuring cross-chain swaps, limit orders, and enhanced resolver functionality using NEAR Intents technology.
All contracts have been successfully deployed to NEAR testnet:
| Contract | Address | Transaction ID |
|----------|---------|----------------|
| Limit Order Protocol | limit-order-protocol.testnet
| ZqhQv8FdtBXMm88CPvdvE9JwWXWSBrXQw1PtoRqUn3G |
| Cross-Chain Bridge | cross-chain-bridge.testnet
| 9QZALfnY3YbWPkqXepdwNq6UfW3gmHiLfjougYUUAZ3K |
| Enhanced Resolver | enhanced-resolver.testnet
| F9f8y175aaqb1QG7J2HTa9yRt878HPJhUBYYL5CTzKyv |