Contract for exchanging the DEFAULT_ADMIN_ROLE of a contract for some amount of Ether.
The happy case process is:
- Buyer and seller agree off-line about terms.
- Buyer deploys
SafeExchange, indicating contract to be purchased, and the new admin to be giveDEFAULT_ADMIN_ROLE, and an offer amount. The amount sent with the transaction is this offer amount plus an optional bonus amount. - Seller adds the safeExchange contract as a
DEFAULT_ADMIN_ROLEfor the contract being sold. - Seller renounces their
DEFAULT_ADMIN_ROLErole for the contract being sold. - Seller calls
exchangeto sell the contract.
Optional additional steps to pay a bonus payment (which can be repeated multiple times):
- Buyer calls
payBonusPaymentto send the bonus payment to the address that calledexchangein the steps above.
If the exchange function fails, or the seller changes their mind after switching ownership of the contract to be sold to the SafeExchange contract, they can regain control of the contract being sold by calling:
regainOwnership
The test plan for the code is here.
To run the tests:
foundry test