> ## Documentation Index
> Fetch the complete documentation index at: https://docs.oumla.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Contract Templates

> SDK methods for managing smart contract templates

Manage smart contract templates and deploy contracts from templates.

## Methods

### `getContracts()`

Get a paginated list of contract templates.

**Signature:**

```typescript theme={null}
getContracts(
  request?: GetContractsRequest,
  requestOptions?: RequestOptions
): Promise<ContractTemplatesResponse>
```

**Example:**

```typescript theme={null}
const templates = await client.contractTemplates.getContracts({
  skip: 0,
  take: 25
});

console.log('Templates:', templates.data);
```

***

### `getContractById()`

Get details for a specific contract template.

**Signature:**

```typescript theme={null}
getContractById(
  templateId: string,
  requestOptions?: RequestOptions
): Promise<ContractTemplateResponse>
```

**Example:**

```typescript theme={null}
const template = await client.contractTemplates.getContractById('template-id');

console.log('Template:', template.data.result);
console.log('Name:', template.data.result?.name);
console.log('Type:', template.data.result?.type);
```

***

### `getContractConstructorById()`

Get constructor information for a template.

**Signature:**

```typescript theme={null}
getContractConstructorById(
  templateId: string,
  requestOptions?: RequestOptions
): Promise<ConstructorInfoResponse>
```

**Example:**

```typescript theme={null}
const constructorInfo = await client.contractTemplates.getContractConstructorById('template-id');

console.log('Constructor inputs:', constructorInfo.data.contractConstructor?.inputs);
```

***

### `getContractFunctionById()`

Get function information for a template.

**Signature:**

```typescript theme={null}
getContractFunctionById(
  templateId: string,
  requestOptions?: RequestOptions
): Promise<FunctionInfoResponse>
```

**Example:**

```typescript theme={null}
const functions = await client.contractTemplates.getContractFunctionById('template-id');

console.log('Available functions:', functions.data.contractFunction);
```

***

### `deployContract()`

Deploy a contract from a template. Returns a workflow ID for async processing.

**Signature:**

```typescript theme={null}
deployContract(
  templateId: string,
  request: DeployContractRequest,
  requestOptions?: RequestOptions
): Promise<DeployContractResponse>
```

**Parameters:**

| Parameter                       | Type     | Required | Description                                                           |
| ------------------------------- | -------- | -------- | --------------------------------------------------------------------- |
| `templateId`                    | `string` | Yes      | Template ID                                                           |
| `request.networkId`             | `string` | Yes      | Network ID (from `getNetworks()`)                                     |
| `request.addressId`             | `string` | Yes      | Address ID for deployment                                             |
| `request.clientShare`           | `string` | Yes      | Client share for signing                                              |
| `request.constructorParameters` | `array`  | No       | Array of constructor parameter objects `[{ name, type, value }, ...]` |

**Example Request:**

```typescript theme={null}
const deployment = await client.contractTemplates.deployContract('template-id', {
  networkId: 'your-network-id',
  addressId: 'address-id',
  clientShare: 'your-client-share',
  constructorParameters: [
    { name: 'name', type: 'string', value: 'MyToken' },
    { name: 'symbol', type: 'string', value: 'MTK' },
    { name: 'initialSupply', type: 'uint256', value: '1000000' }
  ]
});
```

**Example Response:**

```typescript theme={null}
{
  data: {
    workflowResult: {
      workflowId: 'workflow-id-here',
      operationId: 'deployment-id-here',
      status: 'started',
      message: 'Deploy contract workflow started'
    }
  }
}
```

**Response Fields:**

| Field                             | Type                             | Required | Description                                  |
| --------------------------------- | -------------------------------- | -------- | -------------------------------------------- |
| `data.workflowResult.workflowId`  | `string`                         | Yes      | Workflow ID for tracking contract deployment |
| `data.workflowResult.operationId` | `string`                         | Yes      | Operation ID (e.g. `deploymentId`)           |
| `data.workflowResult.status`      | `'started' \| 'already_running'` | Yes      | Workflow status                              |
| `data.workflowResult.message`     | `string`                         | Yes      | Human-readable status message                |

```typescript theme={null}
console.log('Deployment Workflow ID:', deployment.data.workflowResult.workflowId);
```

***

### `createContract()`

Create a new contract template.

**Signature:**

```typescript theme={null}
createContract(
  request: CreateContractRequest,
  requestOptions?: RequestOptions
): Promise<ContractTemplateResponse>
```

***

### `deleteContract()`

Delete a contract template.

**Signature:**

```typescript theme={null}
deleteContract(
  templateId: string,
  requestOptions?: RequestOptions
): Promise<void>
```
