🖤

Creating Projects

Solana Synq empowers developers to create AI-driven blockchain workflows, tools, and intelligent dApps seamlessly integrated into the Solana ecosystem. Whether you're building trading bots, sentiment analysis systems, or custom on-chain workflows, Solana Synq simplifies the process through its solSynq framework.

This guide will walk you through creating your first project using Solana Synq.

Step 1: Prerequisites

Before starting your project, ensure you have:

API Key: Register at api.solSynq.xyz to obtain your API key.

Framework Installed:

For Python: pip install solSynq

For JavaScript/TypeScript: npm install solSynq

Step 2: Setting Up a New Project

For Python

Create a project directory:

bashCopy codemkdir solSynq-project

cd solSynq-project

python -m venv venv

source venv/bin/activate

Install Solana Synapse:

bashCopy codepip install solSynq

Create a starter script:

bashCopy codetouch main.py

For JavaScript/TypeScript

Create a project directory:

bashCopy codemkdir solSynq-project

cd solSynq-project

npm init -y

Install Solana Synapse:

bashCopy codenpm install solSynq

Create a starter script:

bashCopy codetouch index.js

Step 3: Initializing the Project

Python Example

Add the following to main.py:

pythonCopy codefrom solSynq import SynqClient

# Initialize Solana Synq Client

client = SynqClient(api_key="your_api_key")

# Verify connection

print("Project initialized. Synq Client ready to use.")

Run the script:

bashCopy codepython main.py

JavaScript Example

Add the following to index.js:

javascriptCopy codeconst { SynqClient } = require('solSynq');

// Initialize Solana Synq Client

const client = new SynapseClient({ apiKey: 'your_api_key' });

// Verify connection

console.log('Project initialized. Synapse Client ready to use.');

Run the script:

bashCopy codenode index.js

Step 4: Adding AI Models

To create an AI-powered workflow, start by loading a pre-trained model.

Example: Sentiment Analysis

Python

pythonCopy code# Load the sentiment analysis model

model = client.load_model("sentiment-analysis")

# Fetch on-chain data and analyze sentiment

transactions = client.fetch_chain_data("recent_transactions", chain="Solana")

results = model.infer(transactions)

print("Sentiment Analysis Results:", results)

JavaScript

javascriptCopy code// Load the sentiment analysis model

const sentimentModel = client.loadModel('sentiment-analysis');

// Fetch on-chain data and analyze sentiment

client.fetchChainData('recent_transactions', 'Solana').then((data) => {

const results = sentimentModel.infer(data);

console.log('Sentiment Analysis Results:', results);

});

Step 5: Creating a Custom Workflow

Use Solana Synapse to automate workflows. For example, let's create a trading alert system based on transaction sentiment.

Python Example

pythonCopy code# Define a function to trigger alerts for negative sentiment

def alert_on_negative(results):

for result in results:

if result["sentiment"] == "negative":

print("⚠️ Negative Sentiment Alert:", result)

# Automate workflow

client.workflow_automator.add_task(

task_name="NegativeSentimentAlert",

model=model,

data_source="recent_transactions",

callback=alert_on_negative,

)

# Start the workflow

client.workflow_automator.run()

JavaScript Example

javascriptCopy code// Define a function to trigger alerts for negative sentiment

const alertOnNegative = (results) => {

results.forEach((result) => {

if (result.sentiment === 'negative') {

console.log('⚠️ Negative Sentiment Alert:', result);

}

});

};

// Automate workflow

client.workflowAutomator.addTask({

taskName: 'NegativeSentimentAlert',

model: sentimentModel,

dataSource: 'recent_transactions',

callback: alertOnNegative,

});

// Start the workflow

client.workflowAutomator.run();

Step 6: Deploy and Test

Deploy: Use Solana Synq in a live project or integrate it into your existing dApp.

Test: Ensure all models and workflows are running as expected.

Best Practices

Use Environment Variables: Store your API key securely using environment variables instead of hardcoding it in your scripts.

Python Example:

pythonCopy codeimport os

api_key = os.getenv("SOLYNAPSE_API_KEY")

client = SynqClient(api_key=api_key)

JavaScript Example:

javascriptCopy coderequire('dotenv').config();

const client = new SynqClient({ apiKey: process.env.SOLSYNAPSE_API_KEY });

Monitor Performance: Use logging and debugging tools to track workflow performance.

Iterate: Start with basic workflows and refine them over time.

Next Steps

Explore More Models: Use trading bots or data visualization models to expand your project.

Learn Advanced Features: Check out the documentation for advanced capabilities like custom model deployment and data manipulation.

Prepare for the GUI: Once the GUI launches in March 2025, you’ll be able to import and manage your existing workflows visually.