Conditional Shipment
Conditional On-Chain Package Shipment
// 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_);
}
}Last updated