Skip to content

yacswap/chainabstractionlayer

 
 

Repository files navigation

Chain Abstraction Layer

Test Status Coverage Status Standard Code Style MIT License Gitter Telegram Greenkeeper badge

⚠️ This project is under heavy development. Expect bugs & breaking changes.

Query different blockchains with account management using a single and simple interface.

Packages

Package Version
@yac-swap/bitcoin-js-wallet-provider ChainAbstractionLayer
@yac-swap/bitcoin-ledger-provider ChainAbstractionLayer
@yac-swap/bitcoin-networks ChainAbstractionLayer
@yac-swap/bitcoin-rpc-provider ChainAbstractionLayer
@yac-swap/bitcoin-wallet-node-provider ChainAbstractionLayer
@yac-swap/bitcoin-swap-provider ChainAbstractionLayer
@yac-swap/bitcoin-esplora-api-provider ChainAbstractionLayer
@yac-swap/bitcoin-esplora-swap-find-provider ChainAbstractionLayer
@yac-swap/bitcoin-utils ChainAbstractionLayer
@yac-swap/client ChainAbstractionLayer
@yac-swap/crypto ChainAbstractionLayer
@yac-swap/debug ChainAbstractionLayer
@yac-swap/errors ChainAbstractionLayer
@yac-swap/ethereum-erc20-provider ChainAbstractionLayer
@yac-swap/ethereum-erc20-swap-provider ChainAbstractionLayer
@yac-swap/ethereum-ledger-provider ChainAbstractionLayer
@yac-swap/ethereum-wallet-api-provider ChainAbstractionLayer
@yac-swap/ethereum-networks ChainAbstractionLayer
@yac-swap/ethereum-rpc-provider ChainAbstractionLayer
@yac-swap/ethereum-js-wallet-provider ChainAbstractionLayer
@yac-swap/ethereum-swap-provider ChainAbstractionLayer
@yac-swap/ethereum-scraper-swap-find-provider ChainAbstractionLayer
@yac-swap/ethereum-utils ChainAbstractionLayer
@yac-swap/jsonrpc-provider ChainAbstractionLayer
@yac-swap/ledger-provider ChainAbstractionLayer
@yac-swap/provider ChainAbstractionLayer
@yac-swap/schema ChainAbstractionLayer
@yac-swap/utils ChainAbstractionLayer
@yac-swap/wallet-provider ChainAbstractionLayer

Usage

import { Client } from '@yac-swap/client'
import { BitcoinRpcProvider } from '@yac-swap/bitcoin-rpc-provider'
import { EthereumRpcProvider } from '@yac-swap/ethereum-rpc-provider'

import { BitcoinLedgerProvider } from '@yac-swap/bitcoin-ledger-provider'
import { EthereumLedgerProvider } from '@yac-swap/ethereum-ledger-provider'

import { BitcoinNetworks } from '@yac-swap/bitcoin-networks'
import { EthereumNetworks } from '@yac-swap/ethereum-networks'

const bitcoin = new Client()
const ethereum = new Client()

bitcoin.addProvider(new BitcoinRpcProvider(
  'https://liquality.io/bitcointestnetrpc/', 'bitcoin', 'local321'
))
ethereum.addProvider(new EthereumRpcProvider(
  'https://rinkeby.infura.io/v3/xxx'
))

bitcoin.addProvider(new BitcoinLedgerProvider(
  { network: BitcoinNetworks.bitcoin_testnet }
))
ethereum.addProvider(new EthereumLedgerProvider(
  { network: EthereumNetworks.rinkeby }
))

// Fetch addresses from Ledger wallet using a single-unified API
const [ bitcoinAddress ] = await bitcoin.wallet.getAddresses(0, 1)
const [ ethereumAddress ] = await ethereum.wallet.getAddresses(0, 1)

// Sign a message
const signedMessageBitcoin = await bitcoin.wallet.signMessage(
  'The Times 3 January 2009 Chancellor on brink of second bailout for banks', bitcoinAddress
)
const signedMessageEthereum = await ethereum.wallet.signMessage(
  'The Times 3 January 2009 Chancellor on brink of second bailout for banks', ethereumAddress
)

// Send a transaction
await bitcoin.chain.sendTransaction(<to>, 1000)
await ethereum.chain.sendTransaction(<to>, 1000)

Development

npm install
npm run bootstrap
npm run watch

Production

npm run build

Publish

npm run new:version # prepare
npm run publish:all # publish

License

MIT

About

Blockchain abstraction layer

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 98.4%
  • Other 1.6%