Skip to main content

Overview

Omnity API hosts a library of fundamental apis for app developers to plug and play into their codebases.

See the architecture / codebase for more details. It includes:

  • Hub A canister (smart contract) on icp that handles chain and token registration and ticket (transaction) execution, and it also lists settlement chains and execution chains.
  • ICP(Settlement) A settlement chain canister that manages on icp network.
  • Solana(Settlement) A settlement chain canister that manages the logic on solana network.
  • Dogecoin(Settlement) A settlement chain canister that manages the logic on the dogecoin network.
  • Bitcoin Runes(Settlement) A settlement chain canister that manages the logic on the bitcoin network, it is where runes assets are listed and it calls the bitcoin canister to check the status of any bitcoin address.
  • Ton(Execution) A execution chain canister that manages the logic on ton network.
  • ICP(Execution) A execution chain canister that manages the logic on icp network.
  • Solana(Execution) A execution chain canister that manages the logic on solana network.
  • EVM(Execution) The evm route includes layer 2 evm-compatible instances and ethereum as execution chains.
  • Cosmwasm(Execution) CosmWasm Route is the component of the system that interfaces with the execution chains supporting CosmWasm.

Use Cases

Code Examples

The APIs can be accessed using Rust | TypeScript.

Please refer the following basic code examples to utilize all the apis in Rust.

Rust (call via canister)
use candid::Principal;
use ic_cdk::update;

#[update]
pub async fn cross_chain_function() -> Result<(), ErrorType> {
let cycles = 1_000_000_000;

let bitcoin_canister_id = Principal::from_text(BTC_CANISTER_ID.to_string()).unwrap();

let ret: (Result<(), ErrorType>,) = ic_cdk::api::call::call_with_payment128(
bitcoin_canister_id,
"API_METHOD",
(args,),
cycles,
)
.await
.map_err(|err| ErrorType)?;
ret.0
}
Rust (call via http)
use candid::{Decode, Encode};
use ic_agent::{agent::http_transport::ReqwestTransport, export::Principal, identity::Secp256k1Identity, Agent};
use std::error::Error;
use candid::CandidType;
use thiserror::Error;
use serde::Deserialize;

#[tokio::main]
pub async fn main() -> Result<(), Box<dyn Error>> {
let network = "https://ic0.app".to_string();

let agent_identity = Secp256k1Identity::from_pem(
"-----BEGIN EC PRIVATE KEY-----
YOURPRIVATEKEY
-----END EC PRIVATE KEY-----".as_bytes(),
)?;

let agent = Agent::builder()
.with_url(network)
.with_identity(agent_identity)
.build()
.map_err(|e| format!("{:?}", e))?;

let canister_id = Principal::from_text(DAPP_CANISTER_ID.to_string())?;

let arg: Vec<u8> = Encode!(&api_input)?;
let ret = agent
.query(&canister_id, "API_METHOD")
.with_arg(arg)
.call()
.await?;

let result = Decode!(&ret, API_RETURN)??;
Ok(())
}

Please refer the following basic code examples to utilize all the apis in Typescript.

omnityHub.ts
import { Actor, HttpAgent } from "@dfinity/agent";
import { IDL } from "@dfinity/candid";
import {
idlFactory as OmnityHubInterfaceFactory,
_SERVICE as OmnityHubService,
} from "./OmnityHub.did";

export const OMNITY_HUB_CANISTER_ID = "7wupf-wiaaa-aaaar-qaeya-cai";

const createActor = <T>(
canisterId: string,
interfaceFactory: IDL.InterfaceFactory,
) => {
const agent = new HttpAgent({
host: "https://icp0.io/",
});
return Actor.createActor<T>(interfaceFactory, {
canisterId,
agent,
});
};

export const OmnityHub = createActor<OmnityHubService>(
OMNITY_HUB_CANISTER_ID,
OmnityHubInterfaceFactory,
);
App.tsx
import { useEffect, useState } from "react";
import { OmnityHub } from "./omnitHub";

function App() {
const [totalTx, setTotalTx] = useState<number>();

useEffect(() => {
function getOmnityAnalysis() {
OmnityHub.get_total_tx().then((res:any) => {
if ("Ok" in res) {
const total = Number(res.Ok.toString());
setTotalTx((prev) => {
if (Number.isInteger(prev) && prev !== total) {
// new tx
}
return total;
});
}
});
}
const tick = setInterval(getOmnityAnalysis, 5000);
return () => {
clearInterval(tick);
};
}, []);

return (
<div >Total Txs : {totalTx}</div>
);
}

export default App;

Can't find what you need? let us know on OpenChat.

Last updated on May 26, 2025