Skip to content

A set of library to ease blockchain agnostic communication and ease financial communication

License

Notifications You must be signed in to change notification settings

castframework/gba

Repository files navigation

Generic Blockchain Adapter

drawing

Typescript libraries to provide blockchain agnostic tools for interacting with Smart Contracts.

Coverage Release status Pre-release status Latest version Next version Dependencies state License

Description

The CAST Framework is composed of market standards designed for digital blockchain-based securities. We aspire to promote innovation in capital markets with a set of open standards and technologies anyone can use to develop mutually compatible and interoperable digital financial services.

The CAST Framework enables the creation of an integrated financial ecosystem across blockchain-native and legacy systems.
It is intended to give issuers, investors, financial institutions and other service providers easy, trustworthy and seamless access to the developing market of tokenized securities.
Minimizing integration risk will give actors throughout the financial industry the ability to transition to a new model for financial markets without prohibitive cost overheads.

Features

  • Send blockchain transaction
  • Read state of blockchain transaction
  • Read blockchain state
  • Listen to blockchain events
  • Boost blockchain transaction (Ethereum only)
  • Cancel blockchain transaction (Ethereum only)

Note: We do not support TZIP-16 for reading blockchain state. See more details here.
We also use conventions for Tezos events as Events mechanic do not exist in Tezos at the time of writing.

Packages

See packages documentation

Usage

We build some examples of how to use the Transaction Manager and Drivers in examples package

# This may vary depending of the blockchain you want to support
npm install @castframework/transaction-manager @castframework/blockchain-driver-tz @castframework/blockchain-driver-eth

Note: to run the examples, you should follow the setup procedure

Prepare a transaction manager and the driver

import { EthereumBlockchainDriver, PrivateKeySigner } from '@castframework/blockchain-driver-eth';
import { TransactionManager } from '@castframework/transaction-manager';

const driver = new EthereumBlockchainDriver({
  config: {
    // Config here
  },
  signer: new PrivateKeySigner('your private key'),
  nodeURL: 'your node url',
});

const transactionManager = new TransactionManager({
  driver: driver,
});

See Ethereum driver configuration reference See Tezos driver configuration reference

Reading blockchain state

Example of reading blockchain state on Ethereum and Tezos.

// With a Ethereum configured transactionManager

const balance = await transactionManager.call({
  methodName: 'balanceOf',
  methodParameters: ['0x71660c4005ba85c37ccec55d0c4493e66fe775d3'], // Coinbase address
  to: '0xdAC17F958D2ee523a2206206994597C13D831ec7', // Tether USD smart contract address
  blockchainSpecificParams: {
    abi, // ERC20 abi
  },
});

Sending blockchain transaction

Example of sending blockchain transaction on Ethereum and Tezos.

// With a Ethereum configured transactionManager

const transactionId = transactionManager.send({
  methodName: 'transfer',
  methodParameters: [
    '0x71660c4005ba85c37ccec55d0c4493e66fe775d3', // Recipient: coinbase address
    10 // Number of tokens to send
  ],
  to: '0xdAC17F958D2ee523a2206206994597C13D831ec7', // Tether USD address on mainnet
  blockchainSpecificParams: {
    abi, // ERC20 abi
  },
});

More examples

See more examples in the examples package

Run locally

Setup

# Clone repo locally
git clone https://github.com/castframework/gba.git && cd cast 

# Install lerna
npm i -g lerna

# Install dependencies
lerna bootstrap --hoist --strict && lerna run build

# Start local blockchains
docker-compose up -d

# Deploy sample smart contracts to local blockchains
./bin/iter-all

After this setup, you can run the different examples or the integration tests

Run on your own network

If you want to run your tests on another blockchain network that the one we deployed with docker-compose you can add a new network and use it this way:

./bin/iter-all --network-folder ./networks/yournetwork

Deploy to other networks

See Add network

License

Apache 2.0

About

A set of library to ease blockchain agnostic communication and ease financial communication

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages