# Contract Module

Contract module handles interactions related to smart contracts, such as fetching contract ABI and bytecode.

#### 5.1 Get Contract Code

Fetches the bytecode of a smart contract.

{% tabs %}
{% tab title="Python" %}
Function Name

```python
get_contract_code
```

{% tabs %}
{% tab title="Query" %}

* Arguments

  ```python
  contract_address (str): The address of the smart contract.
  ```
* Example Code

  ```python
  from crypto_com_developer_platform_client import Contract

  code = Contract.get_contract_code('example-contract')
  print(code)
  ```

{% endtab %}

{% tab title="Response" %}

* Returns

  ```python
  The bytecode of the smart contract.
  ```
* Errors

  ```python
  ValueError: If the Contract class is not initialized with a Client instance.
  ```
* Example Return

  ```python
  {'status': 'Success', 'data': {'code': 'example-code'}}
  ```

{% endtab %}
{% endtabs %}
{% endtab %}

{% tab title="TypeScript" %}
Function Name

```typescript
getContractCode
```

{% tabs %}
{% tab title="Query" %}

* Arguments

  ```typescript
  {string} {string} contractAddress: The smart contract address.
  ```
* Example Code

  ```typescript
  import { Contract } from '@crypto.com/developer-platform-client';

  try {
    const bytecode = await Contract.getContractCode('example-address');
    console.log(bytecode);
  }
    catch(err) {
    console.log(err);
  }
  ```

{% endtab %}

{% tab title="Response" %}

* Returns

  ```typescript
  {Promise<ApiResponse<ContractCode>>}: A promise that resolves to the bytecode of the contract.
  ```
* Errors

  ```typescript
  {Error} If the bytecode retrieval fails.
  ```
* Example Return

  ```typescript
  {
    status: 'Success',
    data: {
      code: 'example-byte-code'
    }
  }
  ```

{% endtab %}
{% endtabs %}
{% endtab %}
{% endtabs %}


---

# Agent Instructions: 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:

```
GET https://ai-agent-sdk-docs.crypto.com/crypto.com-developer-platform/on-chain-developer-platform-client-sdk/contract-module.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
