Skip to content
This repository has been archived by the owner on Jul 12, 2022. It is now read-only.

Commit

Permalink
Merge branch 'master' into v0.17-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
shumkov committed Dec 30, 2020
2 parents fa71f5c + a915e2a commit 70c63b9
Show file tree
Hide file tree
Showing 12 changed files with 230 additions and 177 deletions.
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# [3.17.0](https://github.com/dashevo/DashJS/compare/v3.16.1...v3.17.0) (2020-12-30)
# [3.17.0](https://github.com/dashevo/DashJS/compare/v3.16.2...v3.17.0) (2020-12-30)


### Features
Expand All @@ -20,6 +20,15 @@



## [3.16.2](https://github.com/dashevo/DashJS/compare/v3.16.1...v3.16.2) (2020-11-17)


### Bug Fixes

* cannot read property 'getBinaryProperties' of undefined ([#158](https://github.com/dashevo/DashJS/issues/158))



## [3.16.1](https://github.com/dashevo/DashJS/compare/v3.16.0...v3.16.1) (2020-10-30)


Expand Down
61 changes: 30 additions & 31 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
## Dash SDK
# Dash SDK

[![Package Version](https://img.shields.io/github/package-json/v/dashevo/dashjs.svg?&style=flat-square)](https://www.npmjs.org/package/dash)
[![Build Status](https://img.shields.io/travis/com/dashevo/dashjs.svg?branch=master&style=flat-square)](https://travis-ci.com/dashevo/dashjs)
[![NPM Version](https://img.shields.io/npm/v/dash)](https://www.npmjs.org/package/dash)
[![Build Status](https://img.shields.io/travis/com/dashevo/js-dash-sdk)](https://travis-ci.com/dashevo/js-dash-sdk)
[![Release Date](https://img.shields.io/github/release-date/dashevo/js-dash-sdk)](https://github.com/dashevo/js-dash-sdk/releases/latest)
[![standard-readme compliant](https://img.shields.io/badge/readme%20style-standard-brightgreen)](https://github.com/RichardLitt/standard-readme)

> Client-side library for wallet payment/signing and application development with Dash. (Wallet, DAPI, Primitives, BLS, ...)
Dash library for JavaScript/TypeScript ecosystem (Wallet, DAPI, Primitives, BLS, ...)

---

Dash SDK is intended to provide, in a single entry-point all the different features, classes & utils you might need to interface with the Dash network.
Dash library allows you to connect to DAPI and receive or broadcast payments on the Dash Network, manage identifies, register data contracts, retrieve or submit documents on the Dash Platform, all within a single library.

## Install

## Browser
### Browser

```html
<script src="https://unpkg.com/dash"></script>
```

## Node
### Node

In order to use this library, you will need to add our [NPM package](https://www.npmjs.com/dash) to your project.

Expand All @@ -27,57 +27,56 @@ Having [NodeJS](https://nodejs.org/) installed, just type :
npm install dash
```

### Usage
## Usage

```js
const Dash = require("dash");
const Dash = require('dash');

const client = new Dash.Client({
network: "testnet",
network: 'evonet',
wallet: {
mnemonic: "arena light cheap control apple buffalo indicate rare motor valid accident isolate",
mnemonic: 'arena light cheap control apple buffalo indicate rare motor valid accident isolate',
},
});

// Accessing an account allow you to transact with the Dash Network
// Accessing an account allows you to transact with the Dash Network
client.getWalletAccount().then(async (account) => {
console.log("Funding address", account.getUnusedAddress().address);
console.log('Funding address', account.getUnusedAddress().address);

const balance = account.getConfirmedBalance();
console.log("Confirmed Balance", balance);
console.log('Confirmed Balance', balance);

if(balance > 0){
if (balance > 0) {
// Creating an identity is the basis of all interactions with the Dash Platform
const identity = await client.platform.identities.register()
const identity = await client.platform.identities.register();

// Prepare a new document containing a simple hello world sent to a hypothetical tutorial contract
const document = await platform.documents.create(
const document = await client.platform.documents.create(
'tutorialContract.note',
identity,
{ message: 'Hello World' },
);

// Broadcast the document into a new state transition
await platform.documents.broadcast({create:[document]}, identity);
await client.platform.documents.broadcast({ create: [document] }, identity);
}
});
```


### Use-cases examples
- [Generate a mnemonic](/examples/generate-a-new-mnemonic.md)
- [Receive money and display balance](/examples/receive-money-and-check-balance.md)
- [Pay to another address](/examples/pay-to-another-address.md)
- [Use a local evonet](/examples/use-local-evonet.md)
- [Publishing a new contract](/examples/publishing-a-new-contract.md)
- [Use another BIP44 account](/examples/use-different-account.md)


- [Generate a mnemonic](/examples/generate-a-new-mnemonic.md)
- [Receive money and display balance](/examples/receive-money-and-check-balance.md)
- [Pay to another address](/examples/pay-to-another-address.md)
- [Use a local evonet](/examples/use-local-evonet.md)
- [Publishing a new contract](/examples/publishing-a-new-contract.md)
- [Use another BIP44 account](/examples/use-different-account.md)

### Tutorial

- [Register an identity](https://dashplatform.readme.io/docs/tutorial-register-an-identity)
- [Register a Name for an Identity](https://dashplatform.readme.io/docs/tutorial-register-a-name-for-an-identity)


## Licence

[MIT](https://github.com/dashevo/dashjs/blob/master/LICENCE.md) © Dash Core Group, Inc.

4 changes: 2 additions & 2 deletions docs/getting-started/about-schemas.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## About Schemas

Schemas represents the application data structure, a JSON Schema language based set of rules that is allow the creation of a Data Contract.
Schemas represents the application data structure, a JSON Schema language based set of rules that allows the creation of a Data Contract.

You can read more on the [Dash Platform Documentation - Data contract section](https://dashplatform.readme.io/docs/explanation-platform-protocol-data-contract).
You can read more in the [Dash Platform Documentation - Data contract section](https://dashplatform.readme.io/docs/explanation-platform-protocol-data-contract).
23 changes: 10 additions & 13 deletions docs/getting-started/core-concepts.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,28 @@
## Core concepts

The [Dash Core Developer Guide](https://dashcore.readme.io/docs/core-guide-introduction) will answer most of the questions about the fundamentals of Dash.

However, some elements provided by the SDK need to be grasped, so we will quickly cover some of those.
The [Dash Core Developer Guide](https://dashcore.readme.io/docs/core-guide-introduction) will answer most of questions about the fundamentals of Dash. However, some elements provided by the SDK need to be grasped, so we will quickly cover some of those.

## Wallet

At the core of Dash is the Payment Chain, in order to be able to transact on it, one needs to have a set of [UTXO](https://dashcore.readme.io/docs/core-guide-block-chain-transaction-data) that is controlled by a Wallet instance.
At the core of Dash is the Payment Chain. In order to be able to transact on it, one needs to have a set of [UTXOs](https://dashcore.readme.io/docs/core-guide-block-chain-transaction-data) that are controlled by a Wallet instance.

In order to access your UTXO, you will have to provide a valid mnemonic that will unlock the Wallet and automatically fetch the associated UTXOs.

When a SDK instance is created, you can access your wallet via the `client.wallet` variable, with the [wallet-lib Wallet doc](https://dashevo.github.io/wallet-lib/#/usage/wallet)
When an SDK instance is created, you can access your wallet via the `client.wallet` variable, with the [wallet-lib Wallet doc](https://dashevo.github.io/wallet-lib/#/usage/wallet)

## Account

Since the introduction of deterministic wallet ([BIP44](https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki)), a Wallet is a representation of multiple account.
Since the introduction of deterministic wallets ([BIP44](https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki)), a Wallet is a representation of multiple accounts.

It is the instance you will use most of the time for receiving or broadcasting payments.
It is the instance you will use most of the time for receiving or broadcasting payments.

You can access your account with `client.account` and see [how to use a different account](/examples/use-different-account) if you need to get a specific account index.
You can access your account with `client.getWalletAccount()` and see [how to use a different account](/examples/use-different-account) if you need to get a specific account index.

## App Schema and Contracts

The Dash Platform Application Chain, provides to developers the ability to create application.
That application requires a set of rules and conditions describe in a portable document in the form of a JSON names : Application Schema.
The Dash Platform Chain, provides to developers the ability to create applications. Each application requires a set of rules and conditions describe in a portable document in the form of a JSON Schema.

When registered, those app schema are called contracts and contains a contractId (namespace : `client.contracts`).
By default, this library supports DPNS (to attach a name to an identity), under the namespace `client.names` for testnet.
When registered, those applications schemas are called contracts and contains a contractId (namespace : `client.platform.contracts`).
By default, this library supports Dash Platform Name Service (DPNS) (to attach a name to an identity), under the namespace `client.platform.names` for testnet.

You can read more on [how to use DPNS on a local evonet](/examples/use-local-evonet.md) or [how to use multiple apps](/getting-started/multiple-apps.md)
You can read more on [how to use DPNS on a local Evonet devnet](/examples/use-local-evonet.md) or [how to use multiple apps](/getting-started/multiple-apps.md).
9 changes: 2 additions & 7 deletions docs/getting-started/dash-platform-applications.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
## DPNS

DPNS is handled in Dash SDK's Client under the namespace `client.names.*'`. [Read more here](/platform/names)
DPNS is handled in the Dash SDK Client under the namespace `client.platform.names.*'`. [Read more here](/platform/names)

## DashPay

Soon. Registration of the contract on public evonet should happen in Q1 2020, we will update the doc shortly after.


## Memo.dash

Soon. Registration of the contract on public evonet should happen in Q1 2020, we will update the doc shortly after.
Registration of the contract on Evonet occurred in Q4 2020. Its functionality is not incorporated with the Dash SDK at this time.
12 changes: 6 additions & 6 deletions docs/getting-started/multiple-apps.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Working with multiple apps

When working with other registered contracts, you will need to know their `contractId` and reference it on the SDK constructor.
When working with other registered contracts, you will need to know their `contractId` and reference it in the SDK constructor.

Assuming a contract DashPay and having a following `contractId: "77w8Xqn25HwJhjodrHW133aXhjuTsTv9ozQaYpSHACE3"`.
You can then pass it as an options.
Assuming a contract DashPay has the following `contractId: "77w8Xqn25HwJhjodrHW133aXhjuTsTv9ozQaYpSHACE3"`.
You can then pass it as an option.

```js
const client = new Dash.Client({
Expand All @@ -15,9 +15,9 @@ const client = new Dash.Client({
});
```

This allow the methods `client.platform.documents.fetch` to provide you field selection.
Therefore, if the dashpay contract have a `profile` field that you wish to access, DashJS will allow you to do dot-syntax access :
This allow the method `client.platform.documents.get` to provide you field selection.
Therefore, if the contract has a `profile` field that you wish to access, the SDK will allow you to use dot-syntax for access :

```js
const bobProfile = await client.platform.documents.fetch('dashpay.profile', {name:'bob'})
const bobProfile = await client.platform.documents.get('dashpay.profile', { name: 'bob' });
```
47 changes: 23 additions & 24 deletions docs/getting-started/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,58 +7,57 @@ Having [NodeJS](https://nodejs.org/) installed, just type :
```bash
npm install dash
```

## Initialization

Let's create a Dash SDK client instance specifying both our mnemonic and the schema we wish to work with.

```js
const Dash = require("../src");
const Dash = require('dash');
const opts = {
network: 'testnet',
apps: {
dashpay: {
contractId:1234,
schema: require('schema.json')
contractId: '77w8Xqn25HwJhjodrHW133aXhjuTsTv9ozQaYpSHACE3',
},
},
wallet: {
mnemonic: "arena light cheap control apple buffalo indicate rare motor valid accident isolate",
},
};
const client = new Dash.Client(opts);
client.isReady().then(()=>{
const {account} = client;
// Do something
});
client.getWalletAccount().then(async (account) => {
// Do something
})
```

Quick note :
- If no mnemonic is provided, the subinstance `client.Wallet` will not be initiated (write function for platforms won't be usable).

If you do not have any mnemonic, you can pass `null` to get one generated or omit that parameter to only use Dash.Client in `read-only`.
- If no mnemonic is provided, the sub-instance `client.Wallet` will not be initialized (writing capabilities of Dash Platform won't be usable).

If you do not have a mnemonic, you can pass `null` to have one generated or omit that parameter to only use Dash.Client for `read-only` operations.

## Make a payment

```js
client.isReady().then(()=>{
const {account} = client;

account
.createTransaction({
recipient:{address:'yLptqWxjgTxtwKJuLHoGY222NnoeqYuN8h', amount:0.12}
})
.then(account.broadcastTransaction);
client.getWalletAccount().then(async (account) => {
const transaction = account.createTransaction({
recipient: 'yixnmigzC236WmTXp9SBZ42csyp9By6Hw8',
amount: 0.12,
});
account.broadcastTransaction(transaction);
});
```

## Read a document
## Read a document

At time of writing, you will need to have registered dashpay yourself, see on [publishing a new contract](/examples/publishing-a-new-contract.md).
At the time of writing, you will need to have registered a data contract yourself. See [publishing a new contract](/examples/publishing-a-new-contract.md).

```js
client.isReady().then(async ()=>{
const {account} = client;
const bobProfile = await account.platform.documents.fetch('dashpay.profile', {name:'bob'})
});

client.platform.documents.get(
'tutorialContract.note',
{ limit: 1 }, // Only retrieve 1 document
).then(async (documents) => {
console.log(documents);
});
```
7 changes: 4 additions & 3 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
<script>
window.$docsify = {
alias: {
'.*?/changelog': 'https://raw.githubusercontent.com/dashevo/dashjs/master/CHANGELOG.md',
'.*?/changelog': 'https://raw.githubusercontent.com/dashevo/js-dash-sdk/master/CHANGELOG.md',
},
name: 'DashJS',
repo: 'https://github.com/dashevo/DashJS',
name: 'Dash SDK',
repo: 'https://github.com/dashevo/js-dash-sdk',
loadSidebar: "_sidebar.md",
maxLevel: 4,
subMaxLevel: 2,
Expand All @@ -33,6 +33,7 @@
// search: 'auto',
formatUpdated: '{MM}/{DD} {HH}:{mm}',
themeColor: '#008de4',
auto2top: true,
}
</script>
<script src="https://cdn.jsdelivr.net/npm/docsify@4"></script>
Expand Down
Loading

0 comments on commit 70c63b9

Please sign in to comment.