I'm trying to create a token contract using openzeppelin. I managed to create the token using the ownable contract from ownable.sol, which let me transfer the ownership of the token contract.
However, I need to transfer the token contract ownership to a crowdsale contract. I'm wondering if there is a way to reclaim/transfer the token contract ownership to another address.
Here's at a glance what I'm trying to do.
- Token contract created [solved]
- Crowdsale contract created [solved]
- Token contract ownership transferred to the crowdsale contract address [solved]
- Transfer the Token contract ownership to another address. [NEED SOLUTION]
Any suggestion?
Best Answer
Ownable.sol has the following method:
If you want to transfer ownership of the token contract (and assuming the token is Ownable) you can call
transferOwnership(address_of_new_owner)
using the account that currently owns the token contract.Have in mind that unless the crowdsale contract that now owns the token also implements a function that can call this function, you won't be able to transfer ownership back again if you wanted so.
Here's an example.
You have the token contract with the
transferOwnership()
function above. The current owner is your own account.You call that function passing the address of the crowdsale. Now the owner = (the crowdsale).
If you now wanted to transfer ownership from the crowdsale to another account, the only one that can do so is the actual crowdsale contract as it is the current owner.
For that to be possible, the crowdsale contract would have to have the following code: