StealthGiveStealthGive
Smart Contracts

StealthGive Contracts

What each contract does, the public surface area, and how they compose.

A working manual,

edited & set
by Ezra Nahumury

StealthGiveDollar (SGD)

A vanilla ERC-20 with a faucet. claim() mints 1,000 SGD per call; a 24-hour cooldown per address acts as anti-Sybil. SGD has 6 decimals so it lines up with USDC conventions.

StandardERC-20
Decimals6
Drip1,000 SGD
Cooldown24 hours per address
── StealthGiveDollar.sol ──solidity
function claim() external {
    require(block.timestamp >= lastClaim[msg.sender] + COOLDOWN, "cooldown");
    lastClaim[msg.sender] = uint64(block.timestamp);
    _mint(msg.sender, DRIP);
}

ConfidentialSGD (cSGD)

A concrete instance of iExec's ERC20ToERC7984Wrapper. Calling wrap(donor, amount) locks SGD and mints encrypted cSGD; unwrap reverses the operation.

── ConfidentialSGD.sol ──solidity
contract ConfidentialSGD is ERC20ToERC7984Wrapper {
    constructor(IERC20 underlying)
        ERC7984("Confidential StealthGive Dollar", "cSGD", "")
        ERC20ToERC7984Wrapper(underlying) {}
}

Factory & Registry

↳ StealthGiveFactory

Deploys a fresh Campaign instance per fundraiser. Public method:

── solidity ──
function createCampaign(
    string  calldata metadataURI,    // data:application/json;base64,...
    uint256 goal,                    // target in cSGD (6 dec)
    uint256 deadline,                // unix timestamp
    address recipient                // who can withdraw
) external returns (address campaign);

↳ CampaignRegistry

A view-only indexer. The frontend uses two methods to render the /campaigns page without any backend service:

── solidity ──
function paginate(uint256 offset, uint256 limit)
    external view returns (address[] memory campaigns, uint256 total);

function summariseMany(address[] calldata campaigns)
    external view returns (Summary[] memory);

Campaign Contract

Each campaign is a small state machine. Donations stay in Active; anyone can settle() after the deadline; the recipient withdraws during the grace window or donors refund afterwards.

Fig. iii — the campaign, as a small machine.
plate · 03
  1. state · 01
    Active

    Donations accepted. Encrypted aggregate updated on each donate.

    ActsAnyone
  2. state · 02
    Settling

    Deadline reached. Recipient has 7 days to withdraw funds.

    ActsRecipient
  3. state · 03
    Withdrawn

    Funds delivered to recipient. Terminal state.

    Acts—
  4. state · 04
    Refunding

    Recipient missed window. Each donor may refund individually.

    ActsEach donor
── Campaign.sol ──solidity
enum State { Active, Settling, Withdrawn, Refunding }

function donate(bytes32 handle, bytes calldata handleProof) external;
function settle() external;                 // anyone, after deadline
function withdraw() external;                // recipient only
function refund() external;                  // donor, after grace
Refund grace7 days post-settle
Receiver hookImplements IERC7984Receiver for confidentialTransferAndCall

ConfidentialEscrow

The abstract base every Campaign inherits from. It owns the encrypted state and is the single place that calls into the Nox SDK — making contract audits much easier.

── solidity ──
euint256 internal _encryptedTotal;
mapping(address => euint256) internal _encryptedContrib;

function _credit(address donor, bytes32 handle, bytes calldata proof) internal {
    euint256 amount = Nox.toEuint256(handle, proof);
    _encryptedContrib[donor] = Nox.add(_encryptedContrib[donor], amount);
    _encryptedTotal           = Nox.add(_encryptedTotal, amount);
    Nox.allowThis(_encryptedTotal);
    Nox.allowPublicDecryption(_encryptedTotal);
}