Typescript Library for encoding and decoding data according to the Oracle Binary Interface (OBI) specification.
npm install @bandprotocol/obi-ts
# or
yarn add @bandprotocol/obi-tsimport { Obi } from '@bandprotocol/obi-ts'
// Create OBI object
const obi = new Obi(
`{symbols:[string],minimum_source_count:u8}/{responses:[{symbol:string,response_code:u8,rate:u64}]}`
)
// Encode input
const input = { symbol: 'BTC', minimum_source_count: 10 }
const encodedInput = obi.encodeInput(input)
// Decode output
const output = obi.decodeOutput(encodedBytes)
console.log(output)OBI supports the following data types:
string: UTF-8 encoded stringbytes: Raw bytesu8,u16,u32,u64,u128,u256: Unsigned integersi8,i16,i32,i64,i128,i256: Signed integersbool: Booleanvector<T>: Array of elements of typeTstruct: Object with named fields
- Type-safe data encoding/decoding
- Support for complex nested structures
- Compatible with Band Protocol oracle scripts
- Language-agnostic specification
For detailed documentation, please visit:
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
This project is licensed under the MIT License
For support and questions, please join our Discord community or open an issue in this repository.