> For the complete documentation index, see [llms.txt](https://yuga.gitbook.io/zkyuga-whitepaper/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://yuga.gitbook.io/zkyuga-whitepaper/developer-guide/stablecoin/transferownership.md).

# transferOwnership

The `transferOwnership` function in StableCoin Contracts is a crucial governance tool that allows the current owner of a contract to transfer control to another Ethereum address. This function is typically used in scenarios like transitioning to a decentralized governance model, delegating control to a new entity, or in contract upgrades. The new owner gains the ability to execute functions that are restricted to the owner.

## Method Signature

```typescript
async transferOwnership(to: string, signer: any): Promise<string>
```

## Parameters

* `to: string`: The Ethereum address that will receive ownership of the contract. This can be a standard Ethereum address or an ENS name.
* `signer: any`: An object representing the signer of the transaction, often provided by a wallet interface like MetaMask or ethers.js.

## Function Logic

1. **Resolve ENS Name**: Converts the `to` address from an ENS name to its corresponding Ethereum address if necessary.
2. **Get Contract Instance**: Obtains a contract instance using the `signer` for blockchain interactions.
3. **Execute Transfer of Ownership**: Performs the `transferOwnership` method on the contract, passing the resolved `to` address.
4. **Return Result**: The result of the ownership transfer, typically a transaction hash, is returned as a string.

## Example Usage

```typescript
const newOwnerAddress = "newOwner.eth";
const signer = ethersProvider.getSigner();

stableCoinContract.transferOwnership(newOwnerAddress, signer)
    .then(result => 
        // add your logic here 
    )
    .catch(error => 
        // add your logic here
    );
```

## Notes

* The `transferOwnership` function is a significant and impactful operation, often signaling a change in governance or operational control.
* Ensuring the correct and intended recipient address is crucial due to the irreversible nature of this operation.
