> For the complete documentation index, see [llms.txt](https://etherlime.gitbook.io/etherlime/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://etherlime.gitbook.io/etherlime/developer-documentation/etherlime-library-api/wrappers.md).

# Deployed Contract Wrapper

## Wrappers

One of the advancements of the etherlime is the result of the deployment

* the `DeployedContractWrapper`

The `DeployedContractWrapper` is a powerful object that provides you with `ethers.Contract` amongst other functionalities. This allows you to start using your deployed contract right away as part of your deployment sequence (f.e. you can call initialization methods)

In addition it exposes you `verboseWaitForTransaction(transaction, transactionLabel)` function. This function can be used to wait for transaction to be mined while giving you verbose output of the state. In addition it allows you to specify a label for the transaction you are waiting for, so that you can get a better understanding of what transaction is being waited for. This comes in handy when deployment scripts start to grow.

```javascript
    const contractWrapper = await deployer.deploy(ICOTokenContract);
    const transferTransaction = await contractWrapper.transferOwnership(randomAddress);
    const result = await contractWrapper.verboseWaitForTransaction(transferTransaction,
         'Transfer Ownership');
```

Тhe address of the contract can be accessed by `contractWrapper.contractAddress`. It has also utils property that gives you the option to get easy the contract's balance.

```javascript
    let balance = await contractWrapper.utils.getBalance();
```

If you are working with EtherlimeGanacheDeployer you will have the `from` method at your disposal. It will allow you to call certain methods from other default accounts.

```javascript
    const deployer = new etherlime.EtherlimeGanacheDeployer();
    const contractWrapper = await deployer.deploy(SomeContract);
    const tx = await contractWrapper
        .from(0 /* could be string address or ethers.Wallet instance*/).someFunction(params);
    const result = await contractWrapper.verboseWaitForTransaction(tx);
```

## Working with previously deployed contracts

Sometimes you want to work with already deployed contract. You can do this two ways:

### etherlime.ContractAt

`etherlime.ContractAt(contract, contractAddress, [signer], [providerOrPort])`

Etherlime has a convenience method allowing you to quickly wrap contracts. Passing the contract descriptor and the address it is deployed `ContractAt` will wire up an instance of the wrapper connected to etherlime ganache on the default port and default account. Optionally you can provide an account and port to connect to etherlime ganache. Alternatively if you want to connect to another provider you can pass it as last parameter, but then you must pass a signer too which is already connected to the same provider.

```javascript
    const deployedContract = etherlime.ContractAt(ContractDescriptor,
         deployedContractAddress);

    const tx = await deployedContract.someMethod(randomParam);
    const result = await deployedContract.verboseWaitForTransaction(tx);
```

### The deployer instance

The deployer object allows you to wrap such an deployed contract by it's address and continue using the power of the wrapper object. The function you can use to achieve this is `wrapDeployedContract(contract, contractAddress)`.

```javascript
    const deployedContractWrapper = deployer
        .wrapDeployedContract(SomeContractWithInitMethod, alreadyDeployedContractAddress);

    const initTransaction = await deployedContractWrapper.init(randomParam, defaultConfigs);
    const result = await deployedContractWrapper.verboseWaitForTransaction(initTransaction,
         'Init Contract');
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://etherlime.gitbook.io/etherlime/developer-documentation/etherlime-library-api/wrappers.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
