JSPM

cowcare-sdk

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 10
  • Score
    100M100P100Q71836F
  • License MIT

JavaScript/TypeScript SDK for the CowCare MilkSupplyChain contract on Celo

Package Exports

  • cowcare-sdk

Readme

cowcare-sdk

npm npm downloads

JavaScript/TypeScript SDK for the CowCare MilkSupplyChain contract on Celo.

Install

npm install cowcare-sdk

Usage

import { getBatchCount, getBatch, getRecentBatches, formatCelo } from "cowcare-sdk";

// Total batches on-chain
const count = await getBatchCount();

// Fetch a single batch
const batch = await getBatch(1);
console.log(batch.productName, batch.stage);

// Latest 5 batches
const recent = await getRecentBatches(5);

// Format price
console.log(formatCelo(batch.pricePerUnit)); // "0.0010 CELO"

API

Function Description
getBatchCount(rpc?) Total batches on-chain
getBatch(id, rpc?) Fetch one batch by ID
getRecentBatches(n?, rpc?) Latest N batches
formatCelo(wei) Format wei as CELO string
shortAddr(addr) Shorten address for display
celoScanAddr(addr) Celoscan URL for address

Contract

0x337b04f40036bfb48f22ae58fcf92d2f1f5cc4a8 on Celo Mainnet

License

MIT