Coder Social home page Coder Social logo

ckb_sdk_dart's Introduction

CKB SDK Dart

License Pub CircleCI Github Actions CI Platform codecov

Dart SDK for Nervos CKB

Prerequisites

  • Dart 2.5 or later

Installation

You should install dart firstly through Dart.

Usage

JSONRPC

A simple usage example of jsonrpc request which in example/rpc.dart:

main() async {
  Api api = Api('http://localhost:8114', hasLogger: false);
  String blockHash = await api.getBlockHash('0x2');
  Block block = await api.getBlock(blockHash);
  print(block.transactions[0].outputs[0].lock.toJson());
}

Simple Wallet example

A simple usage example of sendTransaction which is in example/wallet.dart:

main() async {
    api = Api(NODE_URL);

    print('Before transferring, sender\'s balance: ${await getBalance(TestAddress)} CKB');

    print('Before transferring, first receiver\'s balance: ${await getBalance(ReceiveAddresses[0])} CKB');

    print('Before transferring, change address\'s balance: ${await getBalance(changeAddress)} CKB');

    var hash = await sendCapacity(receivers, changeAddress);
    print('Transaction hash: $hash');

    // waiting transaction into block, sometimes you should wait more seconds
    sleep(Duration(seconds: 30));

    print('After transferring, sender\'s balance: ${await getBalance(TestAddress)} CKB');

    print('After transferring, receiver\'s balance: ${await getBalance(ReceiveAddresses[0])} CKB');

    print('After transferring, change address\'s balance: ${await getBalance(changeAddress)} CKB');
}

Development

If you want to develop by yourself, you can download this project to your local.

git clone https://github.com/duanyytop/ckb_sdk_dart.git
cd ckb_sdk_dart

pub get                       // download and install dependence
pub run test                  // run sdk unit tests

dart ./example/main.dart       // rpc request example
dart ./example/single_key_single_sig_tx_example.dart    // single key and single signature transaction 
dart ./example/multi_key_single_sig_tx_example.dart     // multi keys and single signature transaction 
dart ./example/dao_deposit.dart                         // Nervos DAO deposit example
dart ./example/dao_withdraw.dart                        // Nervos DAO withdraw phase1 and phase2 example
dart ./example/carrot_contract.dart                     // simple contract(with carrot string) example
dart ./example/udt.contract.dart                        // simple udt contract example

Features and bugs

Please create pull requests or issues in this GitHub repo if you want to contribute new features or find bugs.

Welcome to join us. Thanks.

ckb_sdk_dart's People

Contributors

duanyytop avatar renovate-bot avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

bluewatson jjyr

ckb_sdk_dart's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • chore(deps): update codecov/codecov-action action to v1.5.2
  • chore(deps): update actions/checkout action to v4
  • chore(deps): update codecov/codecov-action action to v4
  • chore(deps): update dependency dart to v3
  • ๐Ÿ” Create all rate-limited PRs at once ๐Ÿ”

Edited/Blocked

These updates have been manually edited so Renovate will no longer make changes. To discard all commits and start over, click on a checkbox.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

circleci
.circleci/config.yml
github-actions
.github/workflows/dart.yml
  • actions/checkout v1
  • codecov/codecov-action v1.0.2
pub
pubspec.yaml
  • dio ^3.0.8
  • pointycastle ^1.0.2
  • pinenacl ^0.1.3-dev.1
  • bip_bech32 ^0.1.3
  • test_coverage ^0.4.0
  • http ^0.12.0+4
  • hex ^0.1.2
  • json_annotation ^3.0.1
  • pedantic ^1.9.0
  • test ^1.6.0
  • build_runner ^1.7.4
  • json_serializable ^3.2.5
  • dart >=2.4.0 <3.0.0

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.