GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - kinecosystem/kin.js: A typescript/javascript implementation of the Kin sdk

This repository was archived by the owner on May 14, 2021. It is now read-only.
BranchesTags
Open more actions menu

Latest commit

 

History

48 Commits
48 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
scripts
scripts
 
 
.gitignore
.gitignore
 
 
CHANGELOG.md
CHANGELOG.md
 
 
README.md
README.md
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 

Repository files navigation

kin.js

A typescript/javascript implementation of the Kin sdk.
The sdk is meant to run in both node based apps as well as in the browser.

Current state

This is still a work in progress and is not ready for use.
Currently it's only possible to load an existing funded wallets.

Client

The sdk offers a client which allows to check for payments (earn and spend transactions) and to create new payments.
The client interface:

interface Payment {
	readonly id: string;
	readonly hash: string;
	readonly amount: number;
	readonly sender: string;
	readonly recipient: string;
	readonly timestamp: string;
	readonly memo: string | undefined;
}

type Address = string;
type OnPaymentListener = (payment: Payment) => void;

interface KinWallet {
	getPayments(): Promise<Payment[]>;
	onPaymentReceived(listener: OnPaymentListener): void;
	pay(recipient: Address, amount: number, memo?: string): Promise<Payment>;
}

In order to create a wallet:

import { KinWallet, createWallet, KinNetwork, Keypair } from "@kinecosystem/kin.js";

async function createKinWallet(): Promise<KinWallet> {
	const keys = Keypair.random();
	const network = KinNetwork.Testnet;
	
	return await createWallet(network, keys);
}

Or using promises (without async/await):

import { KinWallet, createWallet, KinNetwork, Keypair } from "@kinecosystem/kin.js";

const keys = Keypair.random();
const network = KinNetwork.Testnet;
	
let wallet: KinWallet | undefined;
createWallet(network, keys).then(w => wallet = w);

For production use the appropriate network:

import { KinNetwork } from "@kinecosystem/kin.js";

const network = KinNetwork.Production;

Or you can create your own:

import { KinNetwork } from "@kinecosystem/kin.js";

const network = KinNetwork.from(
	"network passphrase",
	"asset issuer",
	"horizon url");

To get the Kin balance from a wallet:

const wallet = getWallet(); // get the wallet somehow
let balance = wallet.balance.cached();

Or to get the current balance:

let balance = await wallet.balance.update();

The update() method will also update the cached value.

About

A typescript/javascript implementation of the Kin sdk

www.kinecosystem.com

Topics

blockchainjavascriptkinnodejssdktypescript

Resources

Readme

Contributing

Contributing
Activity
Custom properties

Stars

11 stars

Watchers

0 watching

Forks

4 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.