# 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="https://554649953-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsngyalOv1KZFtumkXhNU%2Fuploads%2FHFHwM3hwZF3RvCJbxq0i%2FScreenshot%202025-05-14%20at%2015.37.45.png?alt=media&#x26;token=98507c33-4f33-4e08-9924-a2645f39e2d7" 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](https://docs.k3-labs.com/introduction/integrations/cubist-wallet) for more details.&#x20;
* **Network**: By defaul **Mainnet** is selected. You can opt-in for **Testnet** using a checkmark below.

<figure><img src="https://554649953-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsngyalOv1KZFtumkXhNU%2Fuploads%2FVZq11NtNRozxFf76aosA%2Fimage.png?alt=media&#x26;token=befd73d3-7eb3-4348-ad69-28d0d554d6b3" 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="https://554649953-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsngyalOv1KZFtumkXhNU%2Fuploads%2FrhGIkLGLkmhjxTK0fBSn%2Fimage.png?alt=media&#x26;token=ea908f27-db70-4517-af3e-708099ffef55" 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="https://554649953-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsngyalOv1KZFtumkXhNU%2Fuploads%2F9lQECjIDH8uCCz0xP9xG%2FScreenshot%202025-05-14%20at%2015.31.16.png?alt=media&#x26;token=cb582fde-05e2-4466-84f6-897749ca841d" alt="" width="353"><figcaption></figcaption></figure>

***

#### 3. Visual Example:

<figure><img src="https://554649953-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsngyalOv1KZFtumkXhNU%2Fuploads%2FiUDyHLfrIRBTAubO02pv%2FScreenshot%202025-05-14%20at%2015.31.25.png?alt=media&#x26;token=17cdfd63-656f-489e-b3c2-65f1e20b1047" 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
