omni-box

Crates.ioomni-box
lib.rsomni-box
version
sourcesrc
created_at2024-12-10 17:32:01.832302
updated_at2024-12-12 19:21:36.01821
descriptionMultichain testing environment for developing chain abstracted applications on NEAR
homepage
repositoryhttps://github.com/near/omni-box
max_upload_size
id1478801
Cargo.toml error:TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
Edson Alcalá (EdsonAlcala)

documentation

README

OmniBox

An opinionated testing environment for chain abstracted applications.

OmniBox contains a set of utilities and encapsulates multiple test environments into a unified framework that makes developing chain abstracted applications easier than ever.

Join our Telegram chat for support and community discussions.

Features

  • Support for EVM Chains, Bitcoin and NEAR
  • Pre configured accounts for easy development
  • Account creation
  • Easy compile and deploy to testnet
  • Utilities for account derivation and signature construction
  • Utilities to interact with the NEAR contract via a friendly NEAR JSON RPC client
  • Utilities to assert transaction propagations
  • Utilities to interact easily with your deployed contracts
  • Automatic compilation and deployment
  • Automatic contract changes detection to avoid redeploy the same contract

The OmniBox Way

You are developing a smart contract that interacts with the MPC signer and require to propagate signed transactions to an EVM chain, Bitcoin network or NEAR.

The typical workflow would be as follows:

  • Develop a smart contract that integrates the MPC Signer, optionally using the Omni-transaction-rs library to create the payload
  • Deploy it to the NEAR testnet
  • Interact with your contract by executing a transaction (this means you are calling the MPC Signer)
  • Get a signed transaction
  • Propagate to the destination chain

Since this process is common among developers, the OmniBox provides an opinionated way to develop these type of applications.

OmniBox assumes your main goal as developer is to ensure that your integration with the MPC Signer and the propagation to the destination chain works seamlessly. This is only possible by following a test driven development approach and creating integration tests since the beginning.

Pre Requisites

Note: Although the OmniBox could have automatically download them, we believe it is more secure to avoid that and ensure you install these pre requisites from trusted sources.

Installation

Add dependency

[dev_dependencies]
omni-box = "0.0.1"

or via cargo

cargo add omni-box --dev

Usage

To get started with the OmniBox, we simply create an OmniBox instance:

let omni_box = OmniBox::new().await;

The OmniBox provides high-level abstractions through contexts, which encapsulate interactions with specific blockchains.

Each context includes utilities and features like pre-configured accounts, transaction propagation, and more.

Contexts

Bitcoin Context

The Bitcoin context allows you to interact with your local Bitcoin node, where you can propagate signed transactions for testing.

// Access the btc context
let btc_context = omni_box.btc_context;

// Use pre-configured accounts
let alice_legacy = btc_context.alice_legacy;
let alice_segwit = btc_context.alice_segwit;
let bob_legacy = btc_context.bob_legacy;
let bob_segwit = btc_context.bob_segwit;

// Create custom accounts
let new_account_legacy = btc_context.create_account(AddressType.Legacy);
//or
let new account_segwit = btc_context.create_account(AddressType.Bech32);

EVM Context

The EVM context lets you interact with your local Anvil instance, where you can propagate signed transactions for testing.

// Access the evm context
let evm_context = omni_box.evm_context;

// Use pre-configured accounts
let alice = evm_context.alice;
let bob = evm_context.bob;

// Create custom accounts
let new_account = evm_context.create_account();

NEAR Context

The NEAR context helps you deploy and interact with a local [Near] instance, where you can propagate signed transactions for testing.

// Access the near context
let near_context = omni_box.near_context;

// Use pre-configured accounts
let alice = near_context.alice;
let bob = near_context.bob;

// Create custom accounts
let new_account = near_context.create_account();

Configuration

Since OmniBox deploys your smart contract to the NEAR testnet, it requires a deployer account. This account must be configured in a deployer.json file located in the root of your project.

Example deployer.json:

{
    "account_id": "your-account-id.testnet",
    "public_key": "your-public-key",
    "private_key": "your-private-key"
}

Advanced Usage

In addition to the pre-configured contexts, OmniBox supports advanced configurations and workflows. Examples include custom RPC endpoints and dynamic account generation.

Stay tuned for more detailed examples and features in future updates.

Commit count: 0

cargo fmt