# /smart-contract (alpha)

## Generate solidity code from a prompt.

<mark style="color:green;">`POST`</mark> `https://api.brianknows.org/api/v0/agent/smart-contract`

Allows you to send a prompt to Brian and generate a Solidity Smart Contract. The code is encapsulated in a markdown code tag. You can also request the ABI and bytecode of the compiled smart contract in the same API call.

#### Headers

| Name                                              | Type             | Description        |
| ------------------------------------------------- | ---------------- | ------------------ |
| x-brian-api-key<mark style="color:red;">\*</mark> | String           | Brian API key.     |
| Content-Type<mark style="color:red;">\*</mark>    | application/json | Body content type. |

#### Request Body

<table><thead><tr><th width="205">Name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td>prompt<mark style="color:red;">*</mark></td><td>String</td><td>User input prompt.</td></tr><tr><td>compile</td><td>Boolean</td><td>If true, it compiles the contract and returns the ABI and bytecode</td></tr><tr><td>messages</td><td>array object[]</td><td>messages exchanged between the user and Brian (conversation history).</td></tr></tbody></table>

#### Requesting information

{% code overflow="wrap" %}

```bash
curl https://api.brianknows.org/api/v0/agent/smart-contract \
  --request POST \
  --header 'Content-Type: application/json' \
  --header 'X-Brian-Api-Key: ' \
  --data '{
  "prompt": "",
  "compile": true,
}'
```

{% endcode %}

{% tabs %}
{% tab title="200: OK OK." %}
{% code title="Response" overflow="wrap" fullWidth="true" %}

````json

{
  "result": "```solidity\nCODE_HERE```",
  "abi": "abi_here",
  "bytecode": "bytecode_here"
}
````

{% endcode %}
{% 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://docs.brianknows.org/brian-api/apis/smart-contract-alpha.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.
