dash 3.23.0-dev.1 → 3.23.0-dev.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +57 -14
- package/build/src/SDK/Client/Client.spec.js +2 -4
- package/build/src/SDK/Client/Client.spec.js.map +1 -1
- package/build/src/SDK/Client/Platform/Platform.js +12 -0
- package/build/src/SDK/Client/Platform/Platform.js.map +1 -1
- package/build/src/SDK/Client/Platform/broadcastStateTransition.js +16 -9
- package/build/src/SDK/Client/Platform/broadcastStateTransition.js.map +1 -1
- package/build/src/SDK/Client/Platform/createAssetLockTransaction.js +8 -4
- package/build/src/SDK/Client/Platform/createAssetLockTransaction.js.map +1 -1
- package/build/src/SDK/Client/Platform/methods/contracts/publish.js +1 -1
- package/build/src/SDK/Client/Platform/methods/contracts/publish.js.map +1 -1
- package/build/src/SDK/Client/Platform/methods/contracts/update.js +1 -1
- package/build/src/SDK/Client/Platform/methods/contracts/update.js.map +1 -1
- package/build/src/SDK/Client/Platform/methods/documents/broadcast.js +1 -1
- package/build/src/SDK/Client/Platform/methods/documents/broadcast.js.map +1 -1
- package/build/src/SDK/Client/Platform/methods/identities/internal/createAssetLockProof.js +8 -4
- package/build/src/SDK/Client/Platform/methods/identities/internal/createAssetLockProof.js.map +1 -1
- package/build/src/SDK/Client/Platform/methods/identities/internal/createIdentityCreateTransition.js +42 -17
- package/build/src/SDK/Client/Platform/methods/identities/internal/createIdentityCreateTransition.js.map +1 -1
- package/build/src/SDK/Client/Platform/methods/identities/internal/createIdnetityTopUpTransition.js +8 -4
- package/build/src/SDK/Client/Platform/methods/identities/internal/createIdnetityTopUpTransition.js.map +1 -1
- package/build/src/SDK/Client/Platform/methods/identities/internal/waitForCoreChainLockedHeight.js +7 -3
- package/build/src/SDK/Client/Platform/methods/identities/internal/waitForCoreChainLockedHeight.js.map +1 -1
- package/build/src/SDK/Client/Platform/methods/identities/register.js +31 -8
- package/build/src/SDK/Client/Platform/methods/identities/register.js.map +1 -1
- package/build/src/SDK/Client/Platform/methods/identities/topUp.js +5 -7
- package/build/src/SDK/Client/Platform/methods/identities/topUp.js.map +1 -1
- package/build/src/SDK/Client/Platform/methods/identities/update.js +34 -5
- package/build/src/SDK/Client/Platform/methods/identities/update.js.map +1 -1
- package/build/src/SDK/SDK.js +10 -0
- package/build/src/SDK/SDK.js.map +1 -1
- package/build/src/test/fixtures/createIdentityFixtureInAccount.js +13 -3
- package/build/src/test/fixtures/createIdentityFixtureInAccount.js.map +1 -1
- package/build/src/test/fixtures/createTransactionFixtureInAccount.js +2 -2
- package/build/src/test/fixtures/createTransactionFixtureInAccount.js.map +1 -1
- package/build/src/test/mocks/createAndAttachTransportMocksToClient.js +2 -2
- package/build/src/test/mocks/createAndAttachTransportMocksToClient.js.map +1 -1
- package/build/tests/fixtures/contracts.json +1 -1
- package/build-utils/ws.js +15 -0
- package/dist/dash.min.js +9 -0
- package/dist/dash.min.js.LICENSE.txt +80 -0
- package/dist/dash.min.js.map +1 -0
- package/dist/src/SDK/Client/Platform/Platform.d.ts +7 -0
- package/dist/src/SDK/Client/Platform/broadcastStateTransition.d.ts +6 -1
- package/dist/src/SDK/Client/Platform/createAssetLockTransaction.d.ts +3 -2
- package/dist/src/SDK/Client/Platform/methods/identities/internal/createAssetLockProof.d.ts +3 -2
- package/dist/src/SDK/Client/Platform/methods/identities/internal/createIdentityCreateTransition.d.ts +3 -2
- package/dist/src/SDK/Client/Platform/methods/identities/internal/createIdnetityTopUpTransition.d.ts +3 -2
- package/dist/src/SDK/Client/Platform/methods/identities/internal/waitForCoreChainLockedHeight.d.ts +2 -1
- package/dist/src/SDK/Client/Platform/methods/identities/update.d.ts +4 -0
- package/dist/src/SDK/SDK.d.ts +9 -0
- package/docs/README.md +11 -52
- package/docs/_sidebar.md +0 -17
- package/docs/examples/fetch-an-identity-from-its-name.md +5 -9
- package/docs/examples/generate-a-new-mnemonic.md +1 -1
- package/docs/examples/pay-to-another-address.md +16 -13
- package/docs/examples/receive-money-and-check-balance.md +55 -39
- package/docs/examples/sign-and-verify-messages.md +19 -9
- package/docs/examples/use-different-account.md +5 -17
- package/docs/getting-started/core-concepts.md +6 -5
- package/docs/getting-started/dash-platform-applications.md +1 -1
- package/docs/getting-started/quickstart.md +7 -24
- package/docs/getting-started/with-typescript.md +5 -2
- package/docs/index.html +2 -2
- package/docs/platform/about-platform.md +5 -5
- package/docs/platform/contracts/about-contracts.md +2 -2
- package/docs/platform/contracts/create.md +5 -5
- package/docs/platform/contracts/get.md +1 -1
- package/docs/platform/contracts/publish.md +3 -3
- package/docs/platform/contracts/update.md +1 -4
- package/docs/platform/documents/broadcast.md +15 -15
- package/docs/platform/documents/create.md +5 -5
- package/docs/platform/documents/get.md +6 -5
- package/docs/platform/identities/about-identity.md +1 -1
- package/docs/platform/identities/get.md +1 -1
- package/docs/platform/identities/register.md +1 -1
- package/docs/platform/identities/topUp.md +2 -2
- package/docs/platform/names/about-dpns.md +1 -1
- package/docs/platform/names/register.md +9 -9
- package/docs/platform/names/resolve.md +1 -1
- package/docs/platform/names/resolveByRecord.md +9 -8
- package/docs/platform/names/search.md +1 -1
- package/docs/usage/dashcorelib-primitives.md +48 -37
- package/docs/wallet/about-wallet-lib.md +3 -3
- package/docs/wallet/accounts.md +11 -7
- package/docs/wallet/signing-encrypt.md +12 -6
- package/package.json +19 -15
- package/src/SDK/Client/Client.spec.ts +2 -4
- package/src/SDK/Client/Platform/Platform.ts +21 -0
- package/src/SDK/Client/Platform/broadcastStateTransition.ts +15 -6
- package/src/SDK/Client/Platform/createAssetLockTransaction.ts +5 -2
- package/src/SDK/Client/Platform/methods/contracts/publish.ts +1 -1
- package/src/SDK/Client/Platform/methods/contracts/update.ts +1 -1
- package/src/SDK/Client/Platform/methods/documents/broadcast.ts +1 -1
- package/src/SDK/Client/Platform/methods/identities/internal/createAssetLockProof.ts +5 -2
- package/src/SDK/Client/Platform/methods/identities/internal/createIdentityCreateTransition.ts +38 -7
- package/src/SDK/Client/Platform/methods/identities/internal/createIdnetityTopUpTransition.ts +5 -2
- package/src/SDK/Client/Platform/methods/identities/internal/waitForCoreChainLockedHeight.ts +4 -3
- package/src/SDK/Client/Platform/methods/identities/register.ts +33 -9
- package/src/SDK/Client/Platform/methods/identities/topUp.ts +5 -8
- package/src/SDK/Client/Platform/methods/identities/update.ts +35 -1
- package/src/SDK/SDK.ts +34 -21
- package/src/test/fixtures/createIdentityFixtureInAccount.ts +14 -3
- package/src/test/fixtures/createTransactionFixtureInAccount.ts +2 -2
- package/src/test/mocks/createAndAttachTransportMocksToClient.ts +2 -2
- package/tests/fixtures/contracts.json +1 -1
- package/tests/fixtures/ratePlatform.schema.json +1 -1
- package/webpack.base.config.js +14 -0
- package/webpack.config.js +6 -2
- package/docs/examples/publishing-a-new-contract.md +0 -68
- package/docs/examples/updating-a-contract.md +0 -55
- package/docs/examples/use-local-evonet.md +0 -19
- package/examples/node/create-and-fund-wallet.js +0 -28
- package/examples/node/register-contract.js +0 -34
- package/examples/node/register-identity.js +0 -23
- package/examples/node/register-name.js +0 -19
- package/examples/node/retrieve-contract.js +0 -20
- package/examples/node/retrieve-documents.js +0 -22
- package/examples/node/retrieve-identity.js +0 -20
- package/examples/node/retrieve-name.js +0 -14
- package/examples/node/sign-and-verify-messages.js +0 -29
- package/examples/schema.json +0 -58
- package/examples/web/usage.web.html +0 -12
- package/examples/web/usage.web.js +0 -28
|
@@ -39,6 +39,13 @@ interface Identities {
|
|
|
39
39
|
register: Function;
|
|
40
40
|
topUp: Function;
|
|
41
41
|
update: Function;
|
|
42
|
+
utils: {
|
|
43
|
+
createAssetLockTransaction: Function;
|
|
44
|
+
createAssetLockProof: Function;
|
|
45
|
+
createIdentityCreateTransition: Function;
|
|
46
|
+
createIdentityTopUpTransition: Function;
|
|
47
|
+
waitForCoreChainLockedHeight: Function;
|
|
48
|
+
};
|
|
42
49
|
}
|
|
43
50
|
interface DataContracts {
|
|
44
51
|
update: Function;
|
|
@@ -2,6 +2,11 @@ import { Platform } from "./Platform";
|
|
|
2
2
|
import { IStateTransitionResult } from "./IStateTransitionResult";
|
|
3
3
|
/**
|
|
4
4
|
* @param {Platform} platform
|
|
5
|
+
* @param {Object} [options]
|
|
6
|
+
* @param {boolean} [options.skipValidation=false]
|
|
7
|
+
*
|
|
5
8
|
* @param stateTransition
|
|
6
9
|
*/
|
|
7
|
-
export default function broadcastStateTransition(platform: Platform, stateTransition: any
|
|
10
|
+
export default function broadcastStateTransition(platform: Platform, stateTransition: any, options?: {
|
|
11
|
+
skipValidation?: boolean;
|
|
12
|
+
}): Promise<IStateTransitionResult | void>;
|
|
@@ -2,13 +2,14 @@ import { PrivateKey, Transaction } from "@dashevo/dashcore-lib";
|
|
|
2
2
|
import { Platform } from "./Platform";
|
|
3
3
|
/**
|
|
4
4
|
* Creates a funding transaction for the platform identity and returns one-time key to sign the state transition
|
|
5
|
-
* @param {Platform}
|
|
5
|
+
* @param {Platform} this
|
|
6
6
|
* @param {number} fundingAmount - amount of dash to fund the identity's credits
|
|
7
7
|
* @return {Promise<{transaction: Transaction, privateKey: PrivateKey}>} - transaction and one time private key
|
|
8
8
|
* that can be used to sign registration/top-up state transition
|
|
9
9
|
*/
|
|
10
|
-
export
|
|
10
|
+
export declare function createAssetLockTransaction(this: Platform, fundingAmount: any): Promise<{
|
|
11
11
|
transaction: Transaction;
|
|
12
12
|
privateKey: PrivateKey;
|
|
13
13
|
outputIndex: number;
|
|
14
14
|
}>;
|
|
15
|
+
export default createAssetLockTransaction;
|
|
@@ -2,10 +2,11 @@ import { Transaction } from "@dashevo/dashcore-lib";
|
|
|
2
2
|
import { Platform } from "../../../Platform";
|
|
3
3
|
/**
|
|
4
4
|
* Creates a funding transaction for the platform identity and returns one-time key to sign the state transition
|
|
5
|
-
* @param {Platform}
|
|
5
|
+
* @param {Platform} this
|
|
6
6
|
* @param {Transaction} assetLockTransaction
|
|
7
7
|
* @param {number} outputIndex - index of the funding output in the asset lock transaction
|
|
8
8
|
* @return {AssetLockProof} - asset lock proof to be used in the state transition
|
|
9
9
|
* that can be used to sign registration/top-up state transition
|
|
10
10
|
*/
|
|
11
|
-
export
|
|
11
|
+
export declare function createAssetLockProof(this: Platform, assetLockTransaction: Transaction, outputIndex: number): Promise<any>;
|
|
12
|
+
export default createAssetLockProof;
|
package/dist/src/SDK/Client/Platform/methods/identities/internal/createIdentityCreateTransition.d.ts
CHANGED
|
@@ -2,14 +2,15 @@ import { PrivateKey } from "@dashevo/dashcore-lib";
|
|
|
2
2
|
import { Platform } from "../../../Platform";
|
|
3
3
|
/**
|
|
4
4
|
* Creates a funding transaction for the platform identity and returns one-time key to sign the state transition
|
|
5
|
-
* @param {Platform}
|
|
5
|
+
* @param {Platform} this
|
|
6
6
|
* @param {AssetLockProof} assetLockProof - asset lock transaction proof for the identity create transition
|
|
7
7
|
* @param {PrivateKey} assetLockPrivateKey - private key used in asset lock
|
|
8
8
|
* @return {{identity: Identity, identityCreateTransition: IdentityCreateTransition}} - identity, state transition and index of the key used to create it
|
|
9
9
|
* that can be used to sign registration/top-up state transition
|
|
10
10
|
*/
|
|
11
|
-
export
|
|
11
|
+
export declare function createIdentityCreateTransition(this: Platform, assetLockProof: any, assetLockPrivateKey: PrivateKey): Promise<{
|
|
12
12
|
identity: any;
|
|
13
13
|
identityCreateTransition: any;
|
|
14
14
|
identityIndex: number;
|
|
15
15
|
}>;
|
|
16
|
+
export default createIdentityCreateTransition;
|
package/dist/src/SDK/Client/Platform/methods/identities/internal/createIdnetityTopUpTransition.d.ts
CHANGED
|
@@ -2,11 +2,12 @@ import { PrivateKey } from "@dashevo/dashcore-lib";
|
|
|
2
2
|
import { Platform } from "../../../Platform";
|
|
3
3
|
/**
|
|
4
4
|
* Creates a funding transaction for the platform identity and returns one-time key to sign the state transition
|
|
5
|
-
* @param {Platform}
|
|
5
|
+
* @param {Platform} this
|
|
6
6
|
* @param {AssetLockProof} assetLockProof - asset lock transaction proof for the identity create transition
|
|
7
7
|
* @param {PrivateKey} assetLockPrivateKey - private key used in asset lock
|
|
8
8
|
* @param {string|Buffer|Identifier} identityId
|
|
9
9
|
* @return {{identity: Identity, identityCreateTransition: IdentityCreateTransition}} - identity, state transition and index of the key used to create it
|
|
10
10
|
* that can be used to sign registration/top-up state transition
|
|
11
11
|
*/
|
|
12
|
-
export
|
|
12
|
+
export declare function createIdentityTopUpTransition(this: Platform, assetLockProof: any, assetLockPrivateKey: PrivateKey, identityId: any): Promise<any>;
|
|
13
|
+
export default createIdentityTopUpTransition;
|
package/dist/src/SDK/Client/Platform/methods/identities/internal/waitForCoreChainLockedHeight.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Platform } from "../../../Platform";
|
|
2
|
-
export
|
|
2
|
+
export declare function waitForCoreChainLockedHeight(this: Platform, expectedCoreHeight: number): Promise<{
|
|
3
3
|
promise: Promise<any>;
|
|
4
4
|
cancel: Function;
|
|
5
5
|
}>;
|
|
6
|
+
export default waitForCoreChainLockedHeight;
|
|
@@ -7,11 +7,15 @@ import IdentityPublicKey from "@dashevo/dpp/lib/identity/IdentityPublicKey";
|
|
|
7
7
|
* @param {Platform} this - bound instance class
|
|
8
8
|
* @param {Identity} identity - identity to update
|
|
9
9
|
* @param {{add: IdentityPublicKey[]; disable: IdentityPublicKey[]}} publicKeys - public keys to add
|
|
10
|
+
* @param {Object<string, any>} privateKeys - public keys to add
|
|
10
11
|
*
|
|
11
12
|
* @returns {boolean}
|
|
12
13
|
*/
|
|
13
14
|
export declare function update(this: Platform, identity: Identity, publicKeys: {
|
|
14
15
|
add?: IdentityPublicKey[];
|
|
15
16
|
disable?: IdentityPublicKey[];
|
|
17
|
+
}, privateKeys: {
|
|
18
|
+
string: any;
|
|
19
|
+
any: any;
|
|
16
20
|
}): Promise<any>;
|
|
17
21
|
export default update;
|
package/dist/src/SDK/SDK.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { Client as _Client } from './Client';
|
|
3
3
|
import { Platform as _Platform } from './Platform';
|
|
4
|
+
import { StateTransitionBroadcastError } from '../errors/StateTransitionBroadcastError';
|
|
4
5
|
import { Wallet as _Wallet, Account as _Account, DerivableKeyChain as _KeyChain } from '@dashevo/wallet-lib';
|
|
5
6
|
export declare namespace SDK {
|
|
6
7
|
let DAPIClient: any;
|
|
@@ -62,6 +63,7 @@ export declare namespace SDK {
|
|
|
62
63
|
UNKNOWN: string;
|
|
63
64
|
};
|
|
64
65
|
STORAGE: {
|
|
66
|
+
version: number;
|
|
65
67
|
autosaveIntervalTime: number;
|
|
66
68
|
};
|
|
67
69
|
TXIN_OUTPOINT_TXID_BYTES: number;
|
|
@@ -185,5 +187,12 @@ export declare namespace SDK {
|
|
|
185
187
|
};
|
|
186
188
|
};
|
|
187
189
|
};
|
|
190
|
+
let PlatformProtocol: any;
|
|
191
|
+
let Essentials: {
|
|
192
|
+
Buffer: typeof Buffer;
|
|
193
|
+
};
|
|
194
|
+
let Errors: {
|
|
195
|
+
StateTransitionBroadcastError: typeof StateTransitionBroadcastError;
|
|
196
|
+
};
|
|
188
197
|
}
|
|
189
198
|
export { SDK as default };
|
package/docs/README.md
CHANGED
|
@@ -1,81 +1,40 @@
|
|
|
1
1
|
# Dash SDK
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.org/package/dash)
|
|
4
|
-
[](https://github.com/dashevo/platform/actions/workflows/release.yml)
|
|
5
|
+
[](https://github.com/dashevo/platform/releases/latest)
|
|
6
6
|
[](https://github.com/RichardLitt/standard-readme)
|
|
7
7
|
|
|
8
8
|
Dash library for JavaScript/TypeScript ecosystem (Wallet, DAPI, Primitives, BLS, ...)
|
|
9
9
|
|
|
10
|
-
Dash library
|
|
10
|
+
Dash library provides access via [DAPI](https://dashplatform.readme.io/docs/explanation-dapi) to use both the Dash Core network and Dash Platform on [supported networks](https://github.com/dashevo/platform/#supported-networks). The Dash Core network can be used to broadcast and receive payments. Dash Platform can be used to manage identities, register data contracts for applications, and submit or retrieve application data via documents.
|
|
11
11
|
|
|
12
12
|
## Install
|
|
13
13
|
|
|
14
|
-
###
|
|
15
|
-
|
|
16
|
-
```html
|
|
17
|
-
<script src="https://unpkg.com/dash"></script>
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
### Node
|
|
21
|
-
|
|
14
|
+
### From NPM
|
|
22
15
|
In order to use this library, you will need to add our [NPM package](https://www.npmjs.com/dash) to your project.
|
|
23
16
|
|
|
24
|
-
Having [NodeJS](https://nodejs.org/) installed, just type
|
|
17
|
+
Having [NodeJS](https://nodejs.org/) installed, just type:
|
|
25
18
|
|
|
26
19
|
```bash
|
|
27
20
|
npm install dash
|
|
28
21
|
```
|
|
29
22
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const Dash = require('dash');
|
|
34
|
-
|
|
35
|
-
const client = new Dash.Client({
|
|
36
|
-
network: 'evonet',
|
|
37
|
-
wallet: {
|
|
38
|
-
mnemonic: 'arena light cheap control apple buffalo indicate rare motor valid accident isolate',
|
|
39
|
-
},
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
// Accessing an account allows you to transact with the Dash Network
|
|
43
|
-
client.getWalletAccount().then(async (account) => {
|
|
44
|
-
console.log('Funding address', account.getUnusedAddress().address);
|
|
45
|
-
|
|
46
|
-
const balance = account.getConfirmedBalance();
|
|
47
|
-
console.log('Confirmed Balance', balance);
|
|
48
|
-
|
|
49
|
-
if (balance > 0) {
|
|
50
|
-
// Creating an identity is the basis of all interactions with the Dash Platform
|
|
51
|
-
const identity = await client.platform.identities.register();
|
|
52
|
-
|
|
53
|
-
// Prepare a new document containing a simple hello world sent to a hypothetical tutorial contract
|
|
54
|
-
const document = await client.platform.documents.create(
|
|
55
|
-
'tutorialContract.note',
|
|
56
|
-
identity,
|
|
57
|
-
{ message: 'Hello World' },
|
|
58
|
-
);
|
|
59
|
-
|
|
60
|
-
// Broadcast the document into a new state transition
|
|
61
|
-
await client.platform.documents.broadcast({ create: [document] }, identity);
|
|
62
|
-
}
|
|
63
|
-
});
|
|
23
|
+
### From unpkg
|
|
24
|
+
```html
|
|
25
|
+
<script src="https://unpkg.com/dash"></script>
|
|
64
26
|
```
|
|
65
27
|
|
|
66
|
-
###
|
|
28
|
+
### Usage examples
|
|
67
29
|
|
|
68
30
|
- [Generate a mnemonic](examples/generate-a-new-mnemonic.md)
|
|
69
31
|
- [Receive money and display balance](examples/receive-money-and-check-balance.md)
|
|
70
32
|
- [Pay to another address](examples/pay-to-another-address.md)
|
|
71
|
-
- [Use a local evonet](examples/use-local-evonet.md)
|
|
72
|
-
- [Publishing a new contract](examples/publishing-a-new-contract.md)
|
|
73
33
|
- [Use another BIP44 account](examples/use-different-account.md)
|
|
74
34
|
|
|
75
|
-
###
|
|
35
|
+
### Dash Platform Tutorials
|
|
76
36
|
|
|
77
|
-
|
|
78
|
-
- [Register a Name for an Identity](https://dashplatform.readme.io/docs/tutorial-register-a-name-for-an-identity)
|
|
37
|
+
See the [Tutorial section](https://dashplatform.readme.io/docs/tutorials-introduction) of the Dash Platform documentation for examples.
|
|
79
38
|
|
|
80
39
|
## Licence
|
|
81
40
|
|
package/docs/_sidebar.md
CHANGED
|
@@ -4,32 +4,15 @@
|
|
|
4
4
|
- [Working with multiple apps](getting-started/multiple-apps.md)
|
|
5
5
|
- [Dash Platform Applications](getting-started/dash-platform-applications.md)
|
|
6
6
|
- [About Schemas](getting-started/about-schemas.md)
|
|
7
|
-
- [With TypeScript](getting-started/with-typescript.md)
|
|
8
7
|
|
|
9
8
|
- Examples
|
|
10
9
|
- [Generate a mnemonic](/examples/generate-a-new-mnemonic.md)
|
|
11
10
|
- [Receive money and display balance](/examples/receive-money-and-check-balance.md)
|
|
12
11
|
- [Pay to another address](/examples/pay-to-another-address.md)
|
|
13
|
-
- [Use a local evonet](/examples/use-local-evonet.md)
|
|
14
12
|
- [Fetch an identity from its name](/examples/fetch-an-identity-from-its-name.md)
|
|
15
|
-
- [Publishing new contract](/examples/publishing-a-new-contract.md)
|
|
16
|
-
- [Updating an existing contract](/examples/updating-a-contract.md)
|
|
17
13
|
- [Use another BIP44 account](/examples/use-different-account.md)
|
|
18
14
|
- [Sign and verify messages](/examples/sign-and-verify-messages.md)
|
|
19
15
|
|
|
20
|
-
- Tutorial
|
|
21
|
-
- [Register an identity](https://dashplatform.readme.io/docs/tutorial-register-an-identity)
|
|
22
|
-
- [Register a Name for an Identity](https://dashplatform.readme.io/docs/tutorial-register-a-name-for-an-identity)
|
|
23
|
-
|
|
24
|
-
- Snippets
|
|
25
|
-
- [Create and fund wallet](https://github.com/dashevo/DashJS/tree/master/examples/node/create-and-fund-wallet.js)
|
|
26
|
-
- [Register identity](https://github.com/dashevo/DashJS/tree/master/examples/node/register-identity.js)
|
|
27
|
-
- [Register name](https://github.com/dashevo/DashJS/tree/master/examples/node/register-name.js)
|
|
28
|
-
- [Retrieve Contract](https://github.com/dashevo/DashJS/tree/master/examples/node/retrieve-contract.js)
|
|
29
|
-
- [Retrieve Documents](https://github.com/dashevo/DashJS/tree/master/examples/node/retrieve-documents.js)
|
|
30
|
-
- [Retrieve Identity](https://github.com/dashevo/DashJS/tree/master/examples/node/retrieve-identity.js)
|
|
31
|
-
- [Retrieve Name](https://github.com/dashevo/DashJS/tree/master/examples/node/retrieve-name.js)
|
|
32
|
-
|
|
33
16
|
- Usage
|
|
34
17
|
- [DAPI](usage/dapi.md)
|
|
35
18
|
- [Platform](platform/about-platform.md)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
## Fetching an identity from
|
|
1
|
+
## Fetching an identity from its name
|
|
2
2
|
|
|
3
|
-
Assuming you have created an identity and attached a name to it (see how to [register an identity](https://dashplatform.readme.io/docs/tutorial-register-an-identity) and how to [attach it to a name](https://dashplatform.readme.io/docs/tutorial-register-a-name-for-an-identity)
|
|
4
|
-
|
|
3
|
+
Assuming you have created an identity and attached a name to it (see how to [register an identity](https://dashplatform.readme.io/docs/tutorial-register-an-identity) and how to [attach it to a name](https://dashplatform.readme.io/docs/tutorial-register-a-name-for-an-identity)),
|
|
4
|
+
you will then be able to directly recover an identity from its names. See below:
|
|
5
5
|
|
|
6
6
|
```js
|
|
7
7
|
const client = new Dash.Client({
|
|
@@ -12,11 +12,7 @@ const client = new Dash.Client({
|
|
|
12
12
|
|
|
13
13
|
// This is the name previously registered in DPNS.
|
|
14
14
|
const identityName = 'alice';
|
|
15
|
-
client.isReady().then(getIdentity);
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const identityId = (await names.get(identityName)).data.records.dashIdentity;
|
|
20
|
-
const identity = await identities.get(identityId);
|
|
21
|
-
}
|
|
16
|
+
const nameDocument = await client.platform.names.resolve(`${identityName}.dash`);
|
|
17
|
+
const identity = await client.platform.identities.get(nameDocument.ownerId);
|
|
22
18
|
```
|
|
@@ -4,22 +4,25 @@ In order to pay, you need to have an [existing balance](../examples/receive-mone
|
|
|
4
4
|
The below code will allow you to pay to a single address a specific amount of satoshis.
|
|
5
5
|
|
|
6
6
|
```js
|
|
7
|
-
const Dash = require(
|
|
8
|
-
|
|
7
|
+
const Dash = require('dash');
|
|
8
|
+
|
|
9
|
+
const mnemonic = ''; // your mnemonic here.
|
|
9
10
|
const client = new Dash.Client({
|
|
10
|
-
|
|
11
|
+
wallet: {
|
|
12
|
+
mnemonic,
|
|
13
|
+
},
|
|
11
14
|
});
|
|
12
15
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
satoshis:10000
|
|
20
|
-
});
|
|
21
|
-
const transactionId = await account.broadcastTransaction(transaction);
|
|
16
|
+
async function payToRecipient(account) {
|
|
17
|
+
const transaction = account.createTransaction({
|
|
18
|
+
recipient: 'yNPbcFfabtNmmxKdGwhHomdYfVs6gikbPf',
|
|
19
|
+
satoshis: 10000,
|
|
20
|
+
});
|
|
21
|
+
const transactionId = await account.broadcastTransaction(transaction);
|
|
22
22
|
}
|
|
23
|
+
|
|
24
|
+
client.wallet.getAccount().then(payToRecipient);
|
|
25
|
+
|
|
23
26
|
```
|
|
24
27
|
|
|
25
|
-
See more on create [transaction options here](https://dashevo.github.io/
|
|
28
|
+
See more on create [transaction options here](https://dashevo.github.io/platform/Wallet-library/account/createTransaction/).
|
|
@@ -1,76 +1,92 @@
|
|
|
1
1
|
## Receive money and display balance
|
|
2
2
|
|
|
3
|
-
Initialize the SDK Client with your [generated mnemonic](../examples/generate-a-new-mnemonic.md) passed as an option.
|
|
4
|
-
By default, the SDK Client will work on Evonet, the only network having DAPI at the time of writing.
|
|
3
|
+
Initialize the SDK Client with your [generated mnemonic](../examples/generate-a-new-mnemonic.md) passed as an option.
|
|
5
4
|
|
|
6
5
|
```js
|
|
7
6
|
const Dash = require("dash");
|
|
8
7
|
const mnemonic = ''// your mnemonic here.
|
|
9
8
|
const client = new Dash.Client({
|
|
10
|
-
|
|
9
|
+
wallet: {
|
|
10
|
+
mnemonic,
|
|
11
|
+
}
|
|
11
12
|
});
|
|
13
|
+
|
|
14
|
+
async function showBalance() {
|
|
15
|
+
const account = await client.wallet.getAccount();
|
|
16
|
+
const totalBalance = account.getTotalBalance();
|
|
17
|
+
console.log(`Account's total balance: ${totalBalance} duffs`);
|
|
18
|
+
}
|
|
12
19
|
```
|
|
13
20
|
|
|
14
|
-
Having
|
|
21
|
+
Having your `client` instance set up, you will be able to access the `account` and `wallet` instance generated from your mnemonic.
|
|
15
22
|
|
|
16
|
-
|
|
23
|
+
By default `getAccount()` returns the first BIP44 account.
|
|
24
|
+
You can read more on [how to use a different account](../examples/use-different-account.md).
|
|
17
25
|
|
|
18
26
|
|
|
19
27
|
## Generate a receiving address
|
|
20
28
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
29
|
+
Dash wallet supports two different types of addresses:
|
|
30
|
+
- `external` addresses used for receiving funds from other addresses
|
|
31
|
+
- `internal` addresses used for change outputs of outgoing transactions
|
|
32
|
+
-
|
|
33
|
+
For your privacy, you might want to generate a new address for each payment:
|
|
24
34
|
|
|
25
35
|
```js
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
36
|
+
async function generateUnusedAddress() {
|
|
37
|
+
const account = await client.wallet.getAccount();
|
|
38
|
+
const { address } = account.getUnusedAddress();
|
|
39
|
+
console.log(`Unused external address: ${address}`);
|
|
40
|
+
}
|
|
31
41
|
```
|
|
32
42
|
|
|
33
43
|
This above code will generate a new unique (never used) address.
|
|
34
44
|
|
|
35
|
-
##
|
|
45
|
+
## Displaying your balance
|
|
46
|
+
|
|
47
|
+
_Dash Wallet returns the balance in duffs (1 Dash is equal to 100.000.000 duffs)_
|
|
36
48
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
Value is in satoshis (smallest unit).
|
|
49
|
+
`getTotalBalance()` function takes into account `confirmed` and `unconfirmed` transactions (not included in a block).
|
|
50
|
+
It is recommended to check the confirmed balance before making a payment:
|
|
40
51
|
|
|
41
52
|
```js
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
53
|
+
async function showBalance() {
|
|
54
|
+
const account = await client.wallet.getAccount();
|
|
55
|
+
const totalBalance = account.getTotalBalance();
|
|
56
|
+
const confirmedBalance = account.getConfirmedBalance();
|
|
57
|
+
const unconfirmedBalance = account.getUnconfirmedBalance();
|
|
58
|
+
console.log(`Account balance:
|
|
59
|
+
Confirmed: ${confirmedBalance}
|
|
60
|
+
Unconfirmed: ${unconfirmedBalance}
|
|
61
|
+
Total: ${totalBalance}
|
|
62
|
+
`);
|
|
63
|
+
}
|
|
47
64
|
```
|
|
48
|
-
|
|
49
|
-
Or you might want to look-up for the `.getUnconfirmedBalance()` to have only the unconfirmed amount.
|
|
65
|
+
|
|
50
66
|
|
|
51
67
|
## Listen for event on received transaction
|
|
52
68
|
|
|
53
|
-
When a new unconfirmed transaction is received, you can receive
|
|
69
|
+
When a new unconfirmed transaction is received, you can receive an event, and then validate the address or perform an action if needed.
|
|
54
70
|
|
|
55
71
|
```js
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
72
|
+
// FETCHED/UNCONFIRMED_TRANSACTION event is currently disabled
|
|
73
|
+
|
|
74
|
+
async function listenUnconfirmedTransaction() {
|
|
75
|
+
const account = await client.wallet.getAccount();
|
|
76
|
+
account.on('FETCHED/UNCONFIRMED_TRANSACTION', (data) => {
|
|
77
|
+
console.dir(data);
|
|
59
78
|
});
|
|
79
|
+
}
|
|
60
80
|
```
|
|
61
81
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
## Get an address
|
|
65
|
-
|
|
66
|
-
In case you want to retrieve a specific address index :
|
|
67
|
-
|
|
68
|
-
```js
|
|
69
|
-
const {address} = client.account.getAddress(2);
|
|
70
|
-
```
|
|
82
|
+
## Get address at specific index
|
|
71
83
|
|
|
72
|
-
|
|
84
|
+
In case you want to retrieve an address at specific index:
|
|
73
85
|
|
|
74
86
|
```js
|
|
75
|
-
|
|
87
|
+
async function getAddressAtIndex() {
|
|
88
|
+
const account = await client.wallet.getAccount();
|
|
89
|
+
const { address: externalAddress } = account.getAddress(2);
|
|
90
|
+
const { address: internalAddress } = account.getAddress(2, 'internal');
|
|
91
|
+
}
|
|
76
92
|
```
|
|
@@ -1,14 +1,24 @@
|
|
|
1
1
|
## Sign and verify messages
|
|
2
2
|
|
|
3
|
-
Dash SDK exports the Message constructor inside the Core namespace `new Dash.Core.Message
|
|
4
|
-
|
|
5
|
-
You can refer to its documentation : https://github.com/dashevo/dashcore-message/blob/master/README.md
|
|
3
|
+
Dash SDK exports the Message constructor inside the Core namespace `new Dash.Core.Message`
|
|
6
4
|
|
|
7
5
|
```js
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
const verify = message.verify(pk.toAddress().toString(), signed.toString());
|
|
12
|
-
```
|
|
6
|
+
const Dash = require('dash');
|
|
7
|
+
|
|
8
|
+
const mnemonic = '';
|
|
13
9
|
|
|
14
|
-
|
|
10
|
+
const client = new Dash.Client({
|
|
11
|
+
wallet: {
|
|
12
|
+
mnemonic,
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
async function signAndVerify() {
|
|
17
|
+
const account = await client.wallet.getAccount();
|
|
18
|
+
|
|
19
|
+
const pk = new Dash.Core.PrivateKey();
|
|
20
|
+
const message = new Dash.Core.Message('hello, world');
|
|
21
|
+
const signed = account.sign(message, pk);
|
|
22
|
+
const verified = message.verify(pk.toAddress().toString(), signed.toString());
|
|
23
|
+
}
|
|
24
|
+
```
|
|
@@ -1,23 +1,11 @@
|
|
|
1
1
|
## Using a different account
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Clients initialized with a mnemonic support multiple accounts as defined in [BIP44](https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki).
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
By default, accessing to `client.account` is equivalent of `client.wallet.getAccount({index:0})`.
|
|
7
|
-
Therefore usage might varies if you need to deal with platform or not.
|
|
5
|
+
By default `client.wallet.getAccount()` returns the account at index `0`.
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
### Access to account without platform
|
|
11
|
-
```js
|
|
12
|
-
const account = await client.getWalletAccount({index:1});
|
|
7
|
+
To access other accounts, pass the `index` option:
|
|
13
8
|
```
|
|
9
|
+
const secondAccount = await client.wallet.getAccount({ index: 1 })
|
|
10
|
+
```
|
|
14
11
|
|
|
15
|
-
### Access to account with platform.
|
|
16
|
-
|
|
17
|
-
When calling `getWalletAccount`, the client will locally store the index options you have passed to it, which will be used for your platform related calls.
|
|
18
|
-
|
|
19
|
-
```js
|
|
20
|
-
async function changeAccount(){
|
|
21
|
-
await client.getWalletAccount({index:2});
|
|
22
|
-
}
|
|
23
|
-
```
|
|
@@ -8,21 +8,22 @@ At the core of Dash is the Payment Chain. In order to be able to transact on it,
|
|
|
8
8
|
|
|
9
9
|
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.
|
|
10
10
|
|
|
11
|
-
When an SDK instance is created, you can access your wallet via the `client.wallet` variable
|
|
11
|
+
When an SDK instance is created, you can access your wallet via the `client.wallet` variable. (Check [wallet-lib documentation](https://dashevo.github.io/platform/Wallet-library/) for more details)
|
|
12
12
|
|
|
13
13
|
## Account
|
|
14
14
|
|
|
15
|
-
Since the introduction of deterministic wallets ([BIP44](https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki)), a
|
|
15
|
+
Since the introduction of deterministic wallets ([BIP44](https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki)), a wallet is represented by multiple accounts.
|
|
16
16
|
|
|
17
17
|
It is the instance you will use most of the time for receiving or broadcasting payments.
|
|
18
18
|
|
|
19
|
-
You can access your account with `client.getWalletAccount()
|
|
19
|
+
You can access your account with `client.getWalletAccount()`. See [how to use a different account](../examples/use-different-account.md) if you need to get an account at a specific index.
|
|
20
20
|
|
|
21
21
|
## App Schema and Contracts
|
|
22
22
|
|
|
23
|
-
The Dash Platform Chain
|
|
23
|
+
The Dash Platform Chain provides developers with the ability to create applications.
|
|
24
|
+
Each application requires a set of rules and conditions described as a portable document in the form of a JSON Schema.
|
|
24
25
|
|
|
25
26
|
When registered, those applications schemas are called contracts and contains a contractId (namespace : `client.platform.contracts`).
|
|
26
27
|
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.
|
|
27
28
|
|
|
28
|
-
|
|
29
|
+
See: [how to use multiple apps](../getting-started/multiple-apps.md)
|
|
@@ -4,4 +4,4 @@ DPNS is handled in the Dash SDK Client under the namespace `client.platform.name
|
|
|
4
4
|
|
|
5
5
|
## DashPay
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
The DashPay contract is registered on testnet under contract id `Bwr4WHCPz5rFVAD87RqTs3izo4zpzwsEdKPWUT1NS1C7`. Its functionality is not incorporated with the Dash SDK at this time.
|