# Deploying & Writing to a Stellar Smart Contract (Oracle Example)

With K3 Labs, you can deploy a Stellar smart contract from GitHub and create workflows to write data to it, like updating price feeds for oracles. This guide walks you through the entire process.

***

#### 1. Deploy a Stellar Smart Contract

**Step 1: Open Deploy Page**

* Go to **Deploy > Deploy Stellar Contract**.

<figure><img src="/files/MQpZTu1MLxLofigJWCuh" alt=""><figcaption></figcaption></figure>

**Step 2: Fill in Deployment Details**

* **GitHub Repository URL**: Paste your smart contract repo. Example:\
  `https://github.com/k3-labs/stellar-data-contract`\
  (This example creates a contract to store and update data like prices.)
* **Wallet**: Select your Stellar wallet to pay for gas.

  > You can create a Stellar wallet using our **Cubist integration** if needed. See [Cubist integration page](/introduction/integrations/cubist-wallet.md) for more details.&#x20;
* **Network**: By defaul **Mainnet** is selected. You can opt-in for **Testnet** using a checkmark below.

<figure><img src="/files/51WBL6q78r9Un6Sq8yab" alt=""><figcaption></figcaption></figure>

**Step 3: Deploy**

* Click **Deploy**.
* After a few seconds, you’ll receive a confirmation message with your **Smart Contract Address**.

<figure><img src="/files/VueElXhhqsgWlO0AFqJK" alt=""><figcaption></figcaption></figure>

***

#### 2. Create a Workflow to Update Oracle Data

Now, let’s create an automation to periodically update this contract with BTC prices.

**Example Workflow:**

| Step                           | Function                                                                                                                                                            | Setup                                                        |
| ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------ |
| **1. Trigger**                 | **Schedule**                                                                                                                                                        | Run every **1 Hour**                                         |
| **2. Market Data**             | **Read BTC Price**                                                                                                                                                  | Source: Market Data API or eOracle contract                  |
| **3. Write to Smart Contract** | <p>- Blockchain: Stellar<br>- Contract Address: <em>(Your Deployed Contract Address)</em><br>- Method: <code>Write</code><br>- Value: Use BTC price from Step 2</p> |                                                              |
| **4. Alerts**                  | **Email**                                                                                                                                                           | Send yourself a confirmation with price and transaction hash |

See an example of the Write to Smart Contract set up below.

<figure><img src="/files/4pMJ8pG9Tit4uZAMe3eN" alt="" width="353"><figcaption></figcaption></figure>

***

#### 3. Visual Example:

<figure><img src="/files/khIZ8LIkCKXZzPBYRmmU" alt=""><figcaption></figcaption></figure>

***

#### 4. Notes:

* Your Stellar wallet must have enough XLM to cover transaction fees.
* This example uses a simple `Write` method. You can adapt it for other data types or use cases.
* Works with **both Mainnet and Testnet**.

***

#### Benefits:

✅ Deploy & manage custom Stellar contracts in minutes\
✅ Automate data updates like prices, indexes, and metrics\
✅ Secure wallet integration & gas management via Cubist\
✅ Scalable for DeFi, Oracles, and Data Publishing


---

# 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.k3-labs.com/introduction/stellar-blockchain/deploying-and-writing-to-a-stellar-smart-contract-oracle-example.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.
