Managing your Extendable Contract

Understanding how to continue managing your Extendable after deployment and basic extending.

Now that you've created your Extendable contract and extended it with a custom Extension, how do you configure it with more control?

Removing Extensions

Your Extendable contract can be extended, but what if you want to remove some Extensions because an implementation is outdated or because you want to remove the ability for your contract to perform some functions?

Extend your Extendable with the RetractLogic extension to allow it to be able to retract an extension that is has.

YourContract.extend(retractLogicAddress)

If the network your contract is deployed to does not have an instance of RetractLogic deployed to it, you will first need to deploy it yourself before attempting to extend your contract with it. Our reference implementation exists here.

Now your contract can be retracted.

YourContract.retract(oldExtension)

Replacing Extensions

Now that you've learnt how to add and remove Extensions, we can actually combine both methods to replace Extensions too; a retraction of an old Extension and a subsequent extend of a new Extension.

Extend your Extendable with the ReplaceLogic extension to allow it to be able to replace an extension.

YourContract.extend(replaceLogicAddress)

If the network your contract is deployed to does not have an instance of ReplaceLogic deployed to it, you will first need to deploy it yourself before attempting to extend your contract with it. Additionally, ReplaceLogic uses references to both RetractLogic and ExtendLogic to perform a replacement, which means both of those Extensions must be deployed and attached to your contract.

Our reference implementation is called ReplaceLogic.sol and can be found here.

YourContract.replace(oldExtensionAddress, newExtensionAddress)

Changing Permissions

The default implementation of ExtendLogic that is used on the base Extendable contract uses an owner pattern to control who has permissions to extend the contract. This is also used for retracting and replacing.

To change owner you must give your contract the ability to control these permissions by extending your contract with the PermissioningLogic extension. Our reference implementation can be found here.

YourContract.extend(permissioningLogicAddress)

Once extended, your contract will have access to numerous functions to allow you to control ownership.

YourContract.getOwner()

YourContract.updateOwner(newOwner)

Last updated