Skip to content
This repository was archived by the owner on Dec 21, 2021. It is now read-only.

Commit 76b01a3

Browse files
authored
Merge pull request #231 from streamr-dev/README-improvement-deployment-options
Added a section about deployment options to README
2 parents dcb9ab2 + cb1aa04 commit 76b01a3

File tree

1 file changed

+49
-6
lines changed

1 file changed

+49
-6
lines changed

README.md

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ All the below functions return a Promise which gets resolved with the result.
349349

350350
This library provides functions for working with Data Unions.
351351

352-
To deploy a new DataUnion:
352+
To deploy a new DataUnion with default [deployment options](#deployment-options):
353353
```js
354354
const dataUnion = await client.deployDataUnion()
355355
```
@@ -380,7 +380,7 @@ These DataUnion-specific options can be given to `new StreamrClient` options:
380380
| withdrawAllToMember(memberAddress\[, [options](#withdraw-options)\]) | Transaction receipt | Send all withdrawable earnings to the member's address |
381381
| 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)) |
382382

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:
384384

385385
```js
386386
import { StreamrClient } from 'streamr-client'
@@ -389,8 +389,14 @@ const client = new StreamrClient({
389389
auth: { privateKey },
390390
})
391391

392-
const dataUnion = await client.deployDataUnion()
393-
const receipt = await dataUnion.setAdminFee(0.3)
392+
const dataUnion = await client.deployDataUnion({
393+
adminFee: 0.3,
394+
})
395+
const receipt = await dataUnion.addMembers([
396+
"0x1234567890123456789012345678901234567890",
397+
"0x1234567890123456789012345678901234567891",
398+
"0x1234567890123456789012345678901234567892",
399+
])
394400
```
395401

396402
### Member functions
@@ -454,7 +460,7 @@ const withdrawableWei = await dataUnion.getWithdrawableEarnings(memberAddress)
454460

455461
### Withdraw options
456462

457-
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:
458464

459465
| Name | Default | Description |
460466
| :---------------- | :-------------------- | :---------------------------------------------------------------------------------- |
@@ -464,6 +470,40 @@ The functions `withdrawAll`, `withdrawAllTo`, `withdrawAllToMember`, `withdrawAl
464470

465471
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.
466472

473+
### Deployment options
474+
475+
`deployDataUnion` can take an options object as the argument. It's an object that can contain the following parameters:
476+
477+
| Name | Type | Default | Description |
478+
| :------------------------ | :-------- | :-------------------- | :------------------------------------------------------------------------------------ |
479+
| 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+
467507
## Utility functions
468508

469509
| Name | Returns | Description |
@@ -472,7 +512,10 @@ These withdraw transactions are sent to the sidechain, so gas price shouldn't be
472512
| getTokenBalance(address) | `BigNumber` | Mainnet DATA token balance |
473513
| getSidechainTokenBalance(address) | `BigNumber` | Sidechain DATA token balance |
474514

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.
476519

477520
## Events
478521

0 commit comments

Comments
 (0)