# Conditional Shipment

### Conditional On-Chain Package Shipment

As an example, we can create a wrapper contract that will only allow users to ship a package if more than 1,000,000 USDC is included.

```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.15;

import "./PostOffice.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

contract MillionDollarShipmentService {
    using SafeERC20 for IERC20;

    PostOffice public postOffice;
    IERC20 public usdcToken;

    uint8 public constant USDC_DECIMALS = 6;
    uint256 public constant MIN_PACKAGE_VALUE = 1_000_000 * 10 ** USDC_DECIMALS;

    constructor(address _postOfficeAddress, address _usdcTokenAddress) {
        postOffice = PostOffice(_postOfficeAddress);
        usdcToken = IERC20(_usdcTokenAddress);
    }

    function createMillionDollarPackage(
        CapsuleData.CapsuleContent calldata packageContent_,
        PostOffice.SecurityInfo calldata securityInfo_,
        address receiver_,
        uint256 usdcAmount_
    ) external returns (uint256) {
        require(usdcAmount_ >= MIN_PACKAGE_VALUE, "Package value is below 1 million USDC");

        usdcToken.safeTransferFrom(msg.sender, address(this), usdcAmount_);

        return postOffice.shipPackage(packageContent_, securityInfo_, receiver_);
    }

    function pickup(
        uint256 packageId_,
        string calldata rawPassword_,
        string calldata salt_,
        bool shouldRedeem_
    ) external {
        postOffice.pickup(packageId_, rawPassword_, salt_, shouldRedeem_);
    }
}
```

`MillionDollarShipmentService` allows users to create a unique shipment by providing more than 1,000,000 USDC tokens. The `createMillionDollarPackage` method creates the package by transferring the USDC tokens from the sender to the contract if the million dollar criteria is met, and then invokes the `shipPackage` method from the `PostOffice` contract to initiate the shipment process.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.capsulelabs.xyz/protocol-overview/developer-walkthroughs/code-examples/conditional-shipment.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
