You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 21, 2021. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+49-6Lines changed: 49 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -349,7 +349,7 @@ All the below functions return a Promise which gets resolved with the result.
349
349
350
350
This library provides functions for working with Data Unions.
351
351
352
-
To deploy a new DataUnion:
352
+
To deploy a new DataUnion with default [deployment options](#deployment-options):
353
353
```js
354
354
constdataUnion=awaitclient.deployDataUnion()
355
355
```
@@ -380,7 +380,7 @@ These DataUnion-specific options can be given to `new StreamrClient` options:
380
380
| withdrawAllToMember(memberAddress\[, [options](#withdraw-options)\]) | Transaction receipt | Send all withdrawable earnings to the member's address |
381
381
| withdrawAllToSigned(memberAddress, recipientAddress, signature\[, [options](#withdraw-options)\]) | Transaction receipt | Send all withdrawable earnings to the address signed off by the member (see [example below](#member-functions)) |
382
382
383
-
Here's how to deploy a Data Union contract and set the admin fee to 30%:
383
+
Here's how to deploy a Data Union contract with 30% Admin fee and add some members:
384
384
385
385
```js
386
386
import { StreamrClient } from'streamr-client'
@@ -389,8 +389,14 @@ const client = new StreamrClient({
The functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned` all take an extra "options" argument. It's an object that can contain the following parameters:
463
+
The functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAllToSigned` all can take an extra "options" argument. It's an object that can contain the following parameters:
@@ -464,6 +470,40 @@ The functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAl
464
470
465
471
These withdraw transactions are sent to the sidechain, so gas price shouldn't be manually set (fees will hopefully stay very low), but a little bit of [sidechain native token](https://www.xdaichain.com/for-users/get-xdai-tokens) is nonetheless required.
466
472
473
+
### Deployment options
474
+
475
+
`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters:
| owner | Address |`*`you | Owner / admin of the newly created Data Union |
480
+
| joinPartAgents | Address[]|`*`you, Streamr Core | Able to add and remove members to/from the Data Union |
481
+
| dataUnionName | string | Generated | NOT stored anywhere, only used for address derivation |
482
+
| adminFee | number | 0 (no fee) | Must be between 0...1 (inclusive) |
483
+
| sidechainPollingIntervalMs| number | 1000 (1 second) | How often requests are sent to find out if the deployment has completed |
484
+
| sidechainRetryTimeoutMs | number | 60000 (1 minute) | When to give up when waiting for the deployment to complete |
485
+
| confirmations | number | 1 | Blocks to wait after Data Union mainnet contract deployment to consider it final |
486
+
| gasPrice | BigNumber | network estimate | Ethereum Mainnet gas price to use when deploying the Data Union mainnet contract |
487
+
488
+
`*`you here means the address of the authenticated StreamrClient
489
+
(that corresponds to the `auth.privateKey` given in constructor)
490
+
491
+
Streamr Core is added as a `joinPartAgent` by default
492
+
so that joining with secret works using the [member function](#member-functions)`join`.
493
+
If you don't plan to use `join` for "self-service joining",
494
+
you can leave out Streamr Core agent by calling `deployDataUnion`
495
+
e.g. with your own address as the sole joinPartAgent:
496
+
```
497
+
const dataUnion = await client.deployDataUnion({
498
+
joinPartAgents: [yourAddress],
499
+
adminFee,
500
+
})
501
+
```
502
+
503
+
`dataUnionName` option exists purely for the purpose of predicting the addresses of Data Unions not yet deployed.
504
+
Data Union deployment uses the [CREATE2 opcode](https://eips.ethereum.org/EIPS/eip-1014) which means
505
+
a Data Union deployed by a particular address with particular "name" will have a predictable address.
506
+
467
507
## Utility functions
468
508
469
509
| Name | Returns | Description |
@@ -472,7 +512,10 @@ These withdraw transactions are sent to the sidechain, so gas price shouldn't be
472
512
| getTokenBalance(address) |`BigNumber`| Mainnet DATA token balance |
473
513
| getSidechainTokenBalance(address) |`BigNumber`| Sidechain DATA token balance |
474
514
475
-
`*` The static function `StreamrClient.generateEthereumAccount()` generates a new Ethereum private key and returns an object with fields `address` and `privateKey`. Note that this private key can be used to authenticate to the Streamr API by passing it in the authentication options, as described earlier in this document.
515
+
`*` The static function `StreamrClient.generateEthereumAccount()` generates a new
516
+
Ethereum private key and returns an object with fields `address` and `privateKey`.
517
+
Note that this private key can be used to authenticate to the Streamr API
518
+
by passing it in the authentication options, as described earlier in this document.
0 commit comments