Band Chain Oracle Binary Interface (OBI)

Typescript Library for encoding and decoding data according to the Oracle Binary Interface (OBI) specification.
Installation
npm install @bandprotocol/obi-ts
yarn add @bandprotocol/obi-ts
Usage
Basic Example
import { Obi } from '@bandprotocol/obi-ts'
const obi = new Obi(
`{symbols:[string],minimum_source_count:u8}/{responses:[{symbol:string,response_code:u8,rate:u64}]}`
)
const input = { symbol: 'BTC', minimum_source_count: 10 }
const encodedInput = obi.encodeInput(input)
const output = obi.decodeOutput(encodedBytes)
console.log(output)
Data Types
OBI supports the following data types:
string: UTF-8 encoded string
bytes: Raw bytes
u8, u16, u32, u64, u128, u256: Unsigned integers
i8, i16, i32, i64, i128, i256: Signed integers
bool: Boolean
vector<T>: Array of elements of type T
struct: Object with named fields
Features
- Type-safe data encoding/decoding
- Support for complex nested structures
- Compatible with Band Protocol oracle scripts
- Language-agnostic specification
Documentation
For detailed documentation, please visit:
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature)
- Commit your changes (
git commit -m 'Add some amazing feature')
- Push to the branch (
git push origin feature/amazing-feature)
- Open a Pull Request
License
This project is licensed under the MIT License
Support
For support and questions, please join our Discord community or open an issue in this repository.