Skip to content

Contract wallets

A contract wallet is a wallet whose address carries code, a Safe, a smart account, or an ordinary key that has delegated to code. Everything that is a transaction works from it as from any wallet, buying a listing, accepting an offer, the two approvals, a cancel, a transfer, a redemption. Three things differ. You sign a listing or an offer in the wallet’s own way, the wallet takes ETH when your listing sells and when you redeem, and it accepts the bond when you buy a listing. A signature from an ordinary wallet names its signer by itself, a contract wallet’s does not. So the contract asks the wallet’s code at the fill whether the signature is its own. The mechanism is on How trading works.

A contract wallet signs the same typed message as any wallet, the seven fields of the message, in its own way. Your wallet’s own address is one of the fields, so the signature counts for that wallet alone and not for another account behind the same key. Several owners may have to confirm. A Safe with three owners returns a signature of 195 bytes, and a Safe whose owners approved the message’s hash on chain returns none at all.

At the fill the contract asks your wallet’s code whether the signature is its own, with all the gas the taker gave the fill, and moves nothing until the answer is yes. A no costs the taker their gas and nothing else, and leaves your message live for the next taker. The answer can change after you sign, when an owner rotates or a delegation moves for example, and a later yes makes the message fillable again. When a holder accepts your offer, the bond goes to your wallet without a question to its code, since the offer you signed already names the bond. When you buy a listing, the bond comes to your wallet through a transfer that asks your wallet’s code whether it accepts the token, and a wallet that does not say yes fails the purchase.

When a buyer fills your listing, the ask goes to your wallet in ETH with all the gas the fill has left. If your wallet’s code refuses the ETH or runs out of gas taking it, the whole fill fails, nothing moves, and your listing stays live. A wallet that cannot take ETH sells through an offer instead, which pays in WETH. It cannot redeem a bond itself either, because a redemption pays ETH to the wallet that holds the bond, so it moves the bond to a wallet that can take ETH first.

A fill runs code the maker controls at two points, the signature check and, on a listing, the seller’s wallet taking the ETH. That code can burn gas and fail the fill, and it cannot change the terms, since the signature binds every field of the message and a failed fill reverts everything, the nonce included. The most it can cost the taker is the gas limit the taker submitted.