Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

Added privacy group methods for web3.js-eea #1761

Merged
merged 32 commits into from
Jul 27, 2019
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
0ed474b
WIP
MadelineMurray Jun 13, 2019
0cd240a
WIP
MadelineMurray Jun 15, 2019
0bb7329
WIP:
MadelineMurray Jun 16, 2019
8e1cc0e
WIP
MadelineMurray Jun 29, 2019
3329412
Merge branch 'master' of https://github.com/PegaSysEng/pantheon into …
MadelineMurray Jun 29, 2019
d9d7716
Ready for review
MadelineMurray Jun 29, 2019
4edbf16
WIP
MadelineMurray Jul 12, 2019
3bd6f8d
WIP
MadelineMurray Jul 13, 2019
236afe8
Merge branch 'master' of https://github.com/PegaSysEng/pantheon into …
MadelineMurray Jul 15, 2019
7f58702
Merge branch 'master' of https://github.com/PegaSysEng/pantheon into …
MadelineMurray Jul 21, 2019
0787fe8
Added overview of privacy methods
MadelineMurray Jul 21, 2019
e99111d
Added method overviews
MadelineMurray Jul 21, 2019
c46761a
Reorganised privacy section
MadelineMurray Jul 21, 2019
e261569
Moved files
MadelineMurray Jul 22, 2019
12c3568
Rework
MadelineMurray Jul 22, 2019
a5ffe15
Merge branch 'privacyReorg' of https://github.com/MadelineMurray/pant…
MadelineMurray Jul 22, 2019
9834dde
Merge branch 'MadelineMurray-privacyReorg'
MadelineMurray Jul 22, 2019
f55ff08
Merge branch 'master' of https://github.com/PegaSysEng/pantheon into …
MadelineMurray Jul 22, 2019
da054a5
Merge branch 'MadelineMurray-privacyReorg'
MadelineMurray Jul 22, 2019
1ca598f
Merge branch 'managingPrivateTransactions' of https://github.com/Made…
MadelineMurray Jul 22, 2019
7e1f705
rework
MadelineMurray Jul 22, 2019
4acf168
Merge branch 'MadelineMurray-managingPrivateTransactions'
MadelineMurray Jul 22, 2019
2058cbd
Merge branch 'master' of https://github.com/PegaSysEng/pantheon
MadelineMurray Jul 23, 2019
1a86c07
Merge branch 'eeajsMethods' of https://github.com/MadelineMurray/pant…
MadelineMurray Jul 24, 2019
9319b04
Merge branch 'MadelineMurray-eeajsMethods'
MadelineMurray Jul 24, 2019
fcd5f38
fix conflict
MadelineMurray Jul 24, 2019
6d4f152
Merge branch 'master' of https://github.com/PegaSysEng/pantheon
MadelineMurray Jul 25, 2019
7c80061
Added priv group methods
MadelineMurray Jul 25, 2019
c7d3d2a
Merge branch 'master' into privGroupweb3jsEEA
MadelineMurray Jul 25, 2019
af90e99
Merge branch 'master' into privGroupweb3jsEEA
MadelineMurray Jul 26, 2019
2a90cd1
Merge branch 'master' into privGroupweb3jsEEA
MadelineMurray Jul 27, 2019
fd30c56
Merge branch 'master' into privGroupweb3jsEEA
MadelineMurray Jul 27, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/Privacy/How-To/eeajs.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,7 @@ to get the contract binary.
```

The transaction hash is returned. To get the private transaction receipt, use `web3.eea.getTransactionReceipt(txHash)`.

## web3.js-eea Methods

Refer to the [web3.js-eea reference documentation](../../Reference/web3js-eea-Methods.md).
144 changes: 144 additions & 0 deletions docs/Reference/web3js-eea-Methods.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
description: web3js-eea methods reference
<!--- END of page meta data -->

Use the [web3.js-eea library](https://github.com/PegaSysEng/eeajs) to [create and send
private transactions](../Privacy/Private-Transactions/eeajs.md).

## Options Parameter

The Options parameter is used by:

* [`generatePrivacyGroup`](#generateprivacygroup)
* [`getTransactionCount`](#gettransactioncount)
* [`sendRawParameter`](#sendrawtransaction)

The Options parameter has the following properties:

* `privateKey`: Ethereum private key with which to sign the transaction
* `privateFrom` : Orion public key
* `privateFor` : Orion public keys of recipients
* `nonce` : Optional. If not provided, calculated using [`eea_getTransctionCount`](../Reference/Pantheon-API-Methods.md).
* `to` : Optional. Contract address to which to send the transaction. Do not specify for contract deployment transactions
* `data` : Transaction data

## generatePrivacyGroup

Generates the privacy group ID. The privacy group ID is the RLP-encoded `privateFor` and `privateFrom` keys.

**Parameters**

[Transaction options](#options-parameter)

**Returns**

`string` : Privacy group ID

!!! example
```bash
const privacyGroupId = web3.eea.generatePrivacyGroup({
privateFrom: "A1aVtMxLCUHmBVHXoZzzBgPbW/wj5axDpW9X8l91SGo=",
privateFor: ["Ko2bVqD+nNlNYL5EE7y3IdOnviftjiizpjRt+HTuFBs="]
});
```

## getMarkerTransaction

Gets the [privacy marker transaction](../Privacy/Private-Transaction-Processing.md) transaction receipt.

**Parameters**

`txHash` - `string` : Transaction hash of the private transaction

`retries` - `int` : Number of attempts to make to get the private marker transaction receipt

`delay` - `int` : Delay between retries in milliseconds

**Returns**

Privacy marker transaction receipt

!!! example
```bash
const privateMarkerTransacion = web3.eea.getMarkerTransaction("0x9c41b3d44ed73511c82a9e2b1ef581eb797475c82f318ca2802358d3ba4a8274", 5, 100);
```

## getTransactionCount

Returns the number of transactions sent from the specified address for the privacy group.

**Parameters**

[Transaction options](#options-parameter)

**Returns**

`int` : Transaction count for that account (`privateKey`) and privacy group

!!! example
```bash
return web3.eea
.getTransactionCount({
privateKey: pantheon.node1.privateKey,
privateFrom: orion.node1.publicKey,
privateFor: [orion.node2.publicKey],
})
```

## getTransactionReceipt

Gets the private transaction receipt using [`eea_getTransactionReceipt`](../Reference/Pantheon-API-Methods.md#eea_gettransactionreceipt).

**Parameters**

`txHash` - `string` : Transaction hash of the private transaction

`enclavePublicKey` - `string` : [`privateFrom` key for the transaction](#options-parameter)

`retries` - `int` : Optional. Number of attempts to make to get the private marker transaction receipt. Default is `300`.

`delay` - `int` : Optional. Delay between retries in milliseconds. Optional. Default is `1000`.

**Returns**

Private transaction receipt

!!! example
```bash
const privateTxReceipt = web3.eea.getTransactionReceipt("0x9c41b3d44ed73511c82a9e2b1ef581eb797475c82f318ca2802358d3ba4a8274", "A1aVtMxLCUHmBVHXoZzzBgPbW/wj5axDpW9X8l91SGo=");
```

## sendRawTransaction

Signs and sends a RLP-encoded private transaction to Pantheon using [`eea_sendRawTransaction`](Pantheon-API-Methods.md#eea_sendrawtransaction).

**Parameters**

[Transaction options](#options-parameter)

**Returns**

`string` : Transaction hash of the [`privacy marker transaction`](../Privacy/Private-Transaction-Processing.md)

!!! example
```bash tab="Contract Deployment"
const createPrivateEmitterContract = () => {
const contractOptions = {
data: `0x${binary}`,
privateFrom: orion.node1.publicKey,
privateFor: [orion.node2.publicKey],
privateKey: pantheon.node1.privateKey
};
return web3.eea.sendRawTransaction(contractOptions);
};
```

```bash tab="Contract Invocation"
const functionCall = {
to: address,
data: functionAbi.signature + functionArgs,
privateFrom: orion.node1.publicKey,
privateFor: [orion.node2.publicKey],
privateKey: pantheon.node1.privateKey
};
return web3.eea.sendRawTransaction(functionCall);
```
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ nav:
- Pantheon Command Line: Reference/Pantheon-CLI-Syntax.md
- Pantheon API Methods: Reference/Pantheon-API-Methods.md
- Pantheon API Objects: Reference/Pantheon-API-Objects.md
- web3.js-eaa Methods: Reference/web3js-eea-Methods.md
- Resources:
- Blog Posts and Webinars: Resources/Resources.md

Expand Down