Deploy KASEscrow Contract

Deploy the escrow contract to Kasplex L2 Mainnet or Testnet

Mainnet

Production
Chain ID
202555
RPC URL
https://evmrpc.kasplex.org

Testnet

Testing
Chain ID
202555
RPC URL
https://evmrpc-testnet.kasplex.org

Deployment Steps

1

Copy Contract Code

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract KASEscrow {
    struct Trade {
        address payable seller;
        address payable buyer;
        uint256 kasAmount;
        uint256 fiatAmount;
        string paymentMethod;
        string paymentDetails;
        bool buyerConfirmed;
        bool sellerConfirmed;
        bool isActive;
        bool isDisputed;
    }

    mapping(uint256 => Trade) public trades;
    uint256 public tradeCounter;
    address public owner;

    event TradeCreated(uint256 indexed tradeId, address indexed seller, uint256 kasAmount, uint256 fiatAmount);
    event TradeAccepted(uint256 indexed tradeId, address indexed buyer);
    event PaymentConfirmedBySeller(uint256 indexed tradeId);
    event PaymentConfirmedByBuyer(uint256 indexed tradeId);
    event TradeCompleted(uint256 indexed tradeId);
    event TradeCancelled(uint256 indexed tradeId);
    event DisputeRaised(uint256 indexed tradeId);

    constructor() {
        owner = msg.sender;
    }

    function createTrade(
        uint256 _fiatAmount,
        string memory _paymentMethod,
        string memory _paymentDetails
    ) external payable returns (uint256) {
        require(msg.value > 0, "Must deposit KAS");
        require(_fiatAmount > 0, "Fiat amount must be positive");

        uint256 tradeId = tradeCounter++;
        trades[tradeId] = Trade({
            seller: payable(msg.sender),
            buyer: payable(address(0)),
            kasAmount: msg.value,
            fiatAmount: _fiatAmount,
            paymentMethod: _paymentMethod,
            paymentDetails: _paymentDetails,
            buyerConfirmed: false,
            sellerConfirmed: false,
            isActive: true,
            isDisputed: false
        });

        emit TradeCreated(tradeId, msg.sender, msg.value, _fiatAmount);
        return tradeId;
    }

    function acceptTrade(uint256 _tradeId) external {
        Trade storage trade = trades[_tradeId];
        require(trade.isActive, "Trade not active");
        require(trade.buyer == address(0), "Trade already accepted");
        require(msg.sender != trade.seller, "Seller cannot accept own trade");

        trade.buyer = payable(msg.sender);
        emit TradeAccepted(_tradeId, msg.sender);
    }

    function confirmPaymentSent(uint256 _tradeId) external {
        Trade storage trade = trades[_tradeId];
        require(trade.isActive, "Trade not active");
        require(msg.sender == trade.buyer, "Only buyer can confirm");
        require(!trade.buyerConfirmed, "Already confirmed");

        trade.buyerConfirmed = true;
        emit PaymentConfirmedByBuyer(_tradeId);
    }

    function confirmPaymentReceived(uint256 _tradeId) external {
        Trade storage trade = trades[_tradeId];
        require(trade.isActive, "Trade not active");
        require(msg.sender == trade.seller, "Only seller can confirm");
        require(trade.buyerConfirmed, "Buyer must confirm first");
        require(!trade.sellerConfirmed, "Already confirmed");

        trade.sellerConfirmed = true;
        trade.isActive = false;

        // Release KAS to buyer
        trade.buyer.transfer(trade.kasAmount);

        emit PaymentConfirmedBySeller(_tradeId);
        emit TradeCompleted(_tradeId);
    }

    function cancelTrade(uint256 _tradeId) external {
        Trade storage trade = trades[_tradeId];
        require(trade.isActive, "Trade not active");
        require(
            msg.sender == trade.seller || msg.sender == trade.buyer,
            "Only participants can cancel"
        );

        trade.isActive = false;

        // Refund KAS to seller
        trade.seller.transfer(trade.kasAmount);

        emit TradeCancelled(_tradeId);
    }

    function raiseDispute(uint256 _tradeId) external {
        Trade storage trade = trades[_tradeId];
        require(trade.isActive, "Trade not active");
        require(
            msg.sender == trade.seller || msg.sender == trade.buyer,
            "Only participants can raise dispute"
        );

        trade.isDisputed = true;
        emit DisputeRaised(_tradeId);
    }
}
2

Open Remix IDE

Go to Remix IDE and create a new file called KASEscrow.sol

Open Remix IDE
3

Compile Contract

In Remix, go to the "Solidity Compiler" tab and click "Compile KASEscrow.sol"

4

Deploy Contract

• Go to "Deploy & Run Transactions" tab

• Select "Injected Provider - MetaMask" as environment

• Make sure you're on the correct network (Mainnet or Testnet)

• Click "Deploy"

• Approve the transaction in MetaMask

5

Copy Contract Address

After deployment, copy the contract address from Remix

For Mainnet:

Set CONTRACT_ADDRESS in environment variables

For Testnet:

Set TESTNET_CONTRACT_ADDRESS in environment variables

Then set ENVIRONMENT='testnet' to use testnet

Kaspa runs at 10 BPS — live! 🔷