Contract suite to faciliate counterfactual vault creation and management.
A CounterfactualVaultController is deployed for an EOA (0xA
) funded with ETH.
ERC20/721 and Ether can be sent to any counterfactual addresses associated with this contract. These can be calculated using the function computeAddress(vaultId)
where vaultId
is a nonce of choice. This address is communicated out of bands to a counterparty.
Later, 0xA
can sweep the funds received at these counterfactual addresses to a destination of their choice.
For example:
0xA
calculates counterfactual address0xA1
withvaultId
= 10xA1
sends this address to counter party B (address0xB
)0xB
sends 100 USDC to0xA1
0xA
sweeps0xA1
to a destination address0xZ
by callingexecuteVaultCalls(vaultId = 1, to = 0xZ, value = =0 data = [erc20 = usdc address, amount = 100])
This pattern does seem to introduce some level of ephemeral unlinkability similar to that gained in a16z's sneaky auction https://a16zcrypto.com/hidden-in-plain-sight-a-sneaky-solidity-implementation-of-a-sealed-bid-auction/
If the vaultId's are random enough, then it is hard to index sufficiently so that you can identify a transaction sent to a related CounterfactualVaultController address.
A minimal proxy factory is used to create (CREATE2) a CounterfactualWallet which is then swept for ERC20, ERC721 or Ether to a target address specifed. The contract is then destroyed within the same transaction.
An ERC20 transfer which usually costs 50k gas now costs 130k (:()
Inspired by PoolTogether's Lootbox (https://github.com/pooltogether/loot-box) and a16z's sneaky auction (https://a16zcrypto.com/hidden-in-plain-sight-a-sneaky-solidity-implementation-of-a-sealed-bid-auction/).
This project uses Foundry. See the book for instructions on how to install and use Foundry.
Run forge test