Quick Start

This guide walks you through building and submitting your first Soroban contract invocation with Colibri.

Setup

First, make sure you have installed the core package:

deno add jsr:@colibri/core

Your First Contract Call

Let's invoke a simple contract method on TestNet using the Contract class:

import {
  NetworkConfig,
  LocalSigner,
  Contract,
  initializeWithFriendbot,
} from "@colibri/core";

// 1. Configure the network
const network = NetworkConfig.TestNet();

// 2. Create a new random signer (or use an existing secret key)
const signer = LocalSigner.generateRandom();
console.log("Public Key:", signer.publicKey());

// 3. Fund the account on TestNet using Friendbot
await initializeWithFriendbot(network.friendbotUrl, signer.publicKey());
console.log("Account funded!");

// 4. Create a contract instance
const contract = Contract.create({
  networkConfig: network,
  contractConfig: {
    contractId: "CDLZFC3SYJYDZT7K67VZ75HPJVIEUVNIXF47ZG2FB2RMQQVU2HHGCYSC",
  },
});

// 5. Invoke a contract method
const result = await contract.invoke({
  method: "hello",
  methodArgs: { to: "World" },
  config: {
    source: signer.publicKey(),
    fee: "100000",
    signers: [signer],
  },
});

// 6. Handle the result
console.log("✅ Transaction successful!");
console.log("   Hash:", result.hash);
console.log("   Return Value:", result.returnValue);

Using Pipelines Directly

For more control, use the pipeline API directly:

Reading Contract State

To read data from a contract without submitting a transaction:

Streaming Events

To listen for contract events in real-time:

Understanding Error Handling

Colibri uses typed errors that extend ColibriError. Each error includes:

  • code — Unique error code (e.g., BTX_003, SIM_001)

  • message — Human-readable message

  • details — Additional context

  • diagnostic — Suggestions and references (when available)

  • meta.cause — Original error if wrapped

Next Steps

  • Architecture Overview — Understand pipelines, processes, and error handling

  • Contract — Deep dive into contract interactions

  • Pipelines — Learn about transaction pipelines

  • Events — Learn about event parsing and streaming

Last updated