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.

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 for more details.

  • Network: By defaul Mainnet is selected. You can opt-in for Testnet using a checkmark below.

Step 3: Deploy

  • Click Deploy.

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


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

- Blockchain: Stellar - Contract Address: (Your Deployed Contract Address) - Method: Write - Value: Use BTC price from Step 2

4. Alerts

Email

Send yourself a confirmation with price and transaction hash

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


3. Visual Example:


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

Last updated