renounceOwnership
The renounceOwnership
method allows the current owner of a smart contract to relinquish their ownership rights. Once executed, the contract will have no owner, and certain functionalities that are typically restricted to the owner might become inaccessible. This operation is irreversible, and extreme caution should be exercised before using this method. This method is often found in contracts that implement the Ownable
pattern.
Method Signature
async renounceOwnership(signer: WalletSigner): Promise<string>
Parameters
Parameter | Type | Description |
---|---|---|
signer | WalletSigner | The wallet signer instance accountable for signing the transaction. It must represent the current owner of the contract for the operation to succeed. |
Returns
- A
Promise
that resolves to astring
, typically the transaction hash indicating that the ownership renouncement was successful.
Usage Example
Before invoking the renounceOwnership
method, ensure that you have a signer instance that corresponds to the current owner of the contract:
const signer = edexaClient.createWalletSigner("current owner's private key");
Then, call the renounceOwnership
method:
const transactionHash = await contractInstance.renounceOwnership(signer);
console.log(`Ownership Renounced! Transaction Hash: ${transactionHash}`);
Notes
Irreversible Action: Once ownership is renounced, it cannot be reclaimed. Ensure you've considered all implications before executing this action.
The
signer
provided must correspond to the current owner of the contract. If not, the transaction will likely fail.This method is usually found in contracts implementing the
Ownable
pattern or similar ownership patterns.Always handle the
signer
securely. Avoid exposing private keys in client-side or insecure environments.