https://github.com/joticajulian/kondor-js
library to interact with kondor extension
https://github.com/joticajulian/kondor-js
Last synced: 20 days ago
JSON representation
library to interact with kondor extension
- Host: GitHub
- URL: https://github.com/joticajulian/kondor-js
- Owner: joticajulian
- License: mit
- Created: 2022-05-07T21:05:32.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2025-02-17T08:07:25.000Z (3 months ago)
- Last Synced: 2025-04-18T00:59:13.590Z (about 1 month ago)
- Language: TypeScript
- Size: 788 KB
- Stars: 2
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Kondor JS
Library to interact with Kondor, the browser extension for Koinos blockchain.
## Table of Contents
1. [Install](#install)
2. [Usage](#usage)
3. [Documentation](#documentation)
4. [License](#license)## Install
Install the package from NPM
```sh
npm install kondor-js
```You can also load it directly to the browser by downloading the bunble file located at `dist/kondor.min.js`, or its non-minified version `dist/kondor.js` (useful for debugging).
## Usage
### Vanilla JS
```html
My App
(async () => {
const accounts = await kondor.getAccounts();
const userAddress = accounts[0].address;const koinContract = new Contract({
id: "1EdLyQ67LW6HVU1dWoceP4firtyz77e37Y",
abi: utils.tokenAbi,
provider: kondor.getProvider("harbinger"),
signer: kondor.getSigner(userAddress),
});
const koin = koinContract.functions;// Get balance
const { result } = await koin.balanceOf({
owner: userAddress,
});
console.log(balance.result);
})();
```
NOTE: For koilib check https://github.com/joticajulian/koilib
### Using a framework
```ts
import * as kondor from "kondor-js";
import { Contract, utils } from "koilib";(async () => {
const accounts = await kondor.getAccounts();
const userAddress = accounts[0].address;const koinContract = new Contract({
id: "1EdLyQ67LW6HVU1dWoceP4firtyz77e37Y",
abi: utils.tokenAbi,
provider: kondor.getProvider("harbinger"),
signer: kondor.getSigner(userAddress),
});
const koin = koinContract.functions;// Get balance
const { result } = await koin.balanceOf({
owner: userAddress,
});
console.log(balance.result);
})();
```### KondorSigner
You can also import the `KoinosSigner`:
```ts
import { KondorSigner } from "kondor-js";
import { Contract, utils } from "koilib";(async () => {
const accounts = await kondor.getAccounts();
const userAddress = accounts[0].address;const provider = new Provider("https://api.koinos.io");
const signer = new KoinosSigner({
address: userAddress,
provider,
});const koinContract = new Contract({
id: "1EdLyQ67LW6HVU1dWoceP4firtyz77e37Y",
abi: utils.tokenAbi,
provider,
signer,
});
const koin = koinContract.functions;// Get balance
const { result } = await koin.balanceOf({
owner: userAddress,
});
console.log(balance.result);
})();
```## Test
Run `yarn serve` and open in the browser `http://localhost:8081/test.html`. This page contains a basic example to get accounts and make a transfer using Kondor.
## Acknowledgments
Many thanks to the sponsors of this library: @levineam, @Amikob, @motoeng, @isaacdozier, @imjwalker, and the private sponsors.
If you would like to contribute to the development of this library consider becoming a sponsor in https://github.com/sponsors/joticajulian.
## License
MIT License
Copyright (c) 2021 Julián González
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.