The Cross-Chain Portal is a Clarity smart contract that enables secure cross-chain asset transfers between Stacks and other blockchain networks (Ethereum, BSC, Polygon). It implements a multi-signature validation system to ensure transfer security and integrity.
- Multi-Chain Support: Transfer assets to/from Ethereum (chain ID: 1), BSC (56), and Polygon (137)
- Multi-Signature Validation: Requires multiple verifier approvals before finalizing transfers
- Configurable Limits: Adjustable minimum/maximum transfer amounts and fees
- Emergency Controls: Admin can pause the portal and perform emergency withdrawals
- Duplicate Prevention: Prevents processing the same transaction multiple times
- Transaction Tracking: Complete audit trail of all movements
ADMIN_ADDRESS: Contract owner with administrative privileges- Error Codes: (u100-u109) for various failure scenarios
| Variable | Default Value | Description |
|---|---|---|
portal-suspended |
false | Portal operational status |
minimum-movement-amount |
1,000,000 μSTX (1 STX) | Minimum transfer amount |
maximum-movement-amount |
100,000,000,000 μSTX (1,000 STX) | Maximum transfer amount |
portal-charge |
10,000 μSTX (0.01 STX) | Fee per transfer |
needed-approvals |
3 | Required verifier signatures |
Adds a new verifier to the multi-signature system.
- Access: Admin only
- Returns:
(ok true)on success
Removes a verifier from the system.
- Access: Admin only
- Returns:
(ok true)on success
Pauses or resumes portal operations.
- Access: Admin only
- Use Case: Emergency situations or maintenance
Sets transfer limits.
- Access: Admin only
- Constraints:
- min > 0
- max > min
- max ≤ 10,000 STX
Updates the transfer fee.
- Access: Admin only
- Maximum: 1 STX
Changes required verifier approvals.
- Access: Admin only
- Range: 1-10 signatures
Adds support for a new blockchain.
- Access: Admin only
- Valid Range: 1-1,000,000
Initiates a cross-chain transfer.
Parameters:
amount: Transfer amount in μSTXtarget-chain: Destination blockchain IDrecipient: Destination address (max 32 bytes)
Process:
- Validates amount is within limits
- Checks target chain is supported
- Transfers STX + fee to contract
- Creates pending movement record
- Returns unique movement ID
Example:
(begin-movement u5000000 u1 0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb)
;; Transfers 5 STX to Ethereum addressVerifier approves a pending transfer.
Process:
- Validates caller is a registered verifier
- Records approval
- If threshold reached, finalizes transfer
- Returns
trueif finalized,falseif more approvals needed
Example:
(approve-movement u42)
;; Verifier approves transfer #42Completes an incoming transfer from another blockchain.
Parameters:
amount: Amount in μSTXrecipient: Stacks address to receive fundssource-chain: Origin blockchain IDtx-hash: Transaction hash from source chain (32 bytes)
Access: Verifiers only
Process:
- Validates transaction hasn't been processed
- Marks transaction as completed
- Transfers STX to recipient
- Updates locked amount tracker
Emergency withdrawal of contract funds.
- Access: Admin only
- Use Case: Critical situations requiring fund recovery
Returns complete information about a pending movement.
Returns:
{
sender: principal,
amount: uint,
target-chain: uint,
recipient: (buff 32),
block-height: uint
}Returns number of verifier approvals for a transfer.
Checks if an address is a registered verifier.
Checks if a blockchain is supported.
Returns current portal configuration.
Returns:
{
bridge-paused: bool,
min-transfer: uint,
max-transfer: uint,
bridge-fee: uint,
required-sigs: uint,
total-locked: uint
}Checks if a transaction has been processed.
Returns total STX held by contract.
Returns the next movement ID.
Checks if a specific verifier has approved a transfer.
-
User Initiates:
(begin-movement u10000000 u1 0xRecipientAddress) ;; Returns movement ID: u123
-
Verifiers Approve (3 required):
(approve-movement u123) ;; Verifier 1 (approve-movement u123) ;; Verifier 2 (approve-movement u123) ;; Verifier 3 - Finalizes
-
Off-chain relayer completes transfer on Ethereum
- User locks tokens on Ethereum bridge
- Verifier detects and finalizes:
(finalize-arriving-movement u10000000 'SP2J6ZY48GV1EZ5V2V5RB9MP66SW86PYKKNRV9EJ7 u1 0xEthereumTxHash)
- Configurable threshold (default: 3 signatures)
- Prevents single point of failure
- Each verifier can only approve once per transfer
- Tracks processed transactions by chain ID + tx hash
- Prevents replay attacks
- Verifiers cannot sign same transfer twice
- Minimum: 1 STX (prevents spam)
- Maximum: 1,000 STX (limits risk exposure)
- Adjustable by admin
- Portal suspension capability
- Emergency withdrawal function
- Admin-only critical functions
- Balance verification before transfers
- Chain support validation
- Input sanitization (buffer lengths, numeric ranges)
- Authorization checks on all privileged functions
| Code | Constant | Description |
|---|---|---|
| u100 | ERROR_NOT_AUTHORIZED | Caller lacks permission |
| u101 | ERROR_AMOUNT_INVALID | Amount outside allowed range |
| u102 | ERROR_PORTAL_SUSPENDED | Portal is paused |
| u103 | ERROR_BALANCE_TOO_LOW | Insufficient STX balance |
| u104 | ERROR_CHAIN_NOT_SUPPORTED | Invalid target blockchain |
| u105 | ERROR_TRANSACTION_DUPLICATE | Transaction already processed |
| u106 | ERROR_VERIFIER_ALREADY_EXISTS | Verifier already registered |
| u107 | ERROR_NOT_A_VERIFIER | Caller is not a verifier |
| u108 | ERROR_APPROVALS_INSUFFICIENT | Not enough signatures yet |
| u109 | ERROR_INPUT_INVALID | Invalid input parameters |
- Ethereum: Chain ID
1 - BSC: Chain ID
56 - Polygon: Chain ID
137
Additional chains can be added via register-permitted-blockchain.
Upon deployment:
- Admin address is set to deployer (
tx-sender) - Admin is automatically registered as first verifier
- Default chains (Ethereum, BSC, Polygon) are activated
- Default configuration values are set
-
For Admins:
- Maintain at least 3-5 trusted verifiers
- Set
needed-approvalsto at least 60% of verifier count - Regularly review and update verifiers
- Use
update-portal-suspensionduring upgrades
-
For Users:
- Verify target chain ID before transfer
- Ensure recipient address is correct (irreversible)
- Account for portal fees in transfer amount
- Save movement ID for tracking
-
For Verifiers:
- Verify off-chain transaction proof before approving
- Never approve without independent verification
- Monitor for unusual patterns