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 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.
  • Bitcoin A settlement chain canister that manages the logic on the bitcoin network, It is where assets are listed and it calls the bitcoin canister to check the status of any bitcoin address.
  • sICP A settlement chain canister which that manages on icp network.
  • eICP A execution chain canister that manages the logic on icp network.
  • EVM The evm route includes layer 2 evm-compatible instances as execution chains.

Use Cases

Code Examples

The APIs can be accessed using either Rust or TypeScript. Please refer the following basic code examples to utilize all the apis in Rust.

Rust (canister call)
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 (http call)
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_transport(ReqwestTransport::create(network).unwrap())
.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(())
}

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