Sahara Documentation
Blockchain Developer Docs
Blockchain Developer Docs
  • Overview
    • Introduction
    • Core Concepts
    • Sahara Protocols
  • Basics
    • Get Started
    • Technical Reference
    • Sahara Blockchain Validator Guide
    • Resources & Support
    • FAQ
    • Glossary
    • Github Repository
Powered by GitBook
On this page
  • Overview
  • Prerequisites
  • Network Details
  • Step-by-Step Setup
  • Common Issues & Solutions
  1. Basics

Get Started

Overview

Welcome to the Sahara Blockchain developer quickstart guide. This guide will walk you through setting up your development environment and deploying your first smart contract on the Sahara Testnet.

Prerequisites

Before starting, ensure you have:

  • Node.js v16 or higher

  • A code editor (VS Code recommended)

  • MetaMask or another Web3 wallet

  • Basic Solidity knowledge

  • Git installed

Network Details

The Sahara Testnet is our development environment with the following specifications:

Network Configuration:

Network Name: Sahara Testnet
RPC URL: https://testnet.saharalabs.ai
Chain ID: 313313
Currency Symbol: SAHARA
Block Explorer: https://testnet-explorer.saharalabs.ai

Chain Specifications:

Cosmos Chain ID: sahara-test-1
Ethereum Chain ID: 313313
Native Token: SAHARA
Bech32 Prefix: sah

Step-by-Step Setup

1. Create Project Directory

First, create and initialize your project:

mkdir my-sahara-project
cd my-sahara-project
npm init -y

2. Install Dependencies

Install Hardhat and required packages:

npm install --save-dev hardhat @nomiclabs/hardhat-ethers ethers dotenv

3. Configure Hardhat

Create a .env file in your project root:

PRIVATE_KEY=your_private_key_here 
SAHARA_TESTNET_API_KEY=your_api_key_here

Create hardhat.config.js with the following configuration:

require("@nomiclabs/hardhat-ethers");
require("dotenv").config();

const config = {
  solidity: "0.8.24",
  networks: {
    saharaTestnet: {
      chainId: 313313,
      url: "https://testnet.saharalabs.ai",
      accounts: [process.env.PRIVATE_KEY],
      timeout: 60000
    }
  },
  etherscan: {
    apiKey: {
      saharaTestnet: process.env.SAHARA_TESTNET_API_KEY
    },
    customChains: [
      {
        chainId: 313313,
        network: "saharaTestnet",
        urls: {
          apiURL: "https://testnet-explorer.saharalabs.ai/api",
          browserURL: "https://testnet-explorer.saharalabs.ai/"
        }
      }
    ]
  }
};

module.exports = config;

4. Create Sample Contract

Create contracts/HelloSahara.sol:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

contract HelloSahara {
    string public message;
   
    constructor(string memory _message) {
        message = _message;
    }
   
    function updateMessage(string memory _newMessage) public {
        message = _newMessage;
    }
}

5. Create Deployment Contract

Create scripts/deploy.js:

async function main() {
    const HelloSahara = await ethers.getContractFactory("HelloSahara");
    const hello = await HelloSahara.deploy("Hello, Sahara AI!");
    await hello.waitForDeployment();
   
    console.log("HelloSahara deployed to:", await hello.getAddress());

    // Wait for confirmations for verification
    await hello.deploymentTransaction().wait(5);

    // Verify contract
    await hre.run("verify:verify", {
        address: await hello.getAddress(),
        constructorArguments: ["Hello, Sahara AI!"],
    });
}

main()
    .then(() => process.exit(0))
    .catch((error) => {
        console.error(error);
        process.exit(1);
    });

6. Get Testnet Tokens

7. Deploy Contract

Run the deployment script:

npx hardhat run scripts/deploy.js --network sahara_testnet

Common Issues & Solutions

Timeout Errors

// Increase timeout in your config
networks: {
  sahara_testnet: {
    timeout: 120000 // 2 minutes
  }
}

Transaction Failures

  • Double-check gas settings

  • Ensure proper nonce management

  • Verify RPC endpoint status

Verification Errors

  • Wait for sufficient block confirmations

  • Ensure constructor arguments match exactly

  • Double-check API key configuration

Next Steps

After successful deployment:

  1. Interact with your contract through the block explorer

  2. Test different contract interactions

  3. Begin integrating AI assets using Sahara's specialized features

PreviousSahara ProtocolsNextTechnical Reference

Last updated 2 months ago

Visit and request test SAHARA tokens for deployment.

Need help? Join our or email

https://faucet.saharalabs.ai
Discord
support@saharalabs.ai