> For the complete documentation index, see [llms.txt](https://docs.brianknows.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.brianknows.org/brian-api/apis/smart-contract-alpha.md).

# /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 %}
