Skip to content

Commit

Permalink
Replaced EthSigner with Web3Signer
Browse files Browse the repository at this point in the history
Signed-off-by: madelinemurray <[email protected]>
  • Loading branch information
MadelineMurray committed Nov 15, 2023
1 parent f1a130d commit ea113df
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 82 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ tags:

# Configure client and server TLS

Hyperledger Besu supports TLS for client and server communication. For example, you can configure TLS for communication between [EthSigner](https://docs.ethsigner.consensys.net/en/latest/Concepts/TLS/) and Besu, and Besu and [Tessera](https://docs.tessera.consensys.net/HowTo/Configure/TLS/).
Hyperledger Besu supports TLS for client and server communication. For example, you can configure TLS for communication between [Web3Signer](https://docs.web3signer.consensys.net/concepts/tls) and Besu, and Besu and [Tessera](https://docs.tessera.consensys.net/HowTo/Configure/TLS/).

The following diagram displays an example client and server TLS configuration.

Expand All @@ -22,7 +22,7 @@ Configure TLS communication from the command line.

## Configure client TLS

Allow clients (for example a dapp, curl, or EthSigner) to send and receive secure HTTP JSON-RPCs.
Allow clients (for example a dapp, curl, or Web3Signer) to send and receive secure HTTP JSON-RPCs.

**Client prerequisites**:

Expand All @@ -39,7 +39,7 @@ Create a file (in this example, `knownClients`) that lists one or more trusted c
- `<hex-string>` is the SHA-256 fingerprint of the client certificate.

```bash title="Example"
ethsigner 8E:E0:85:9F:FC:2E:2F:21:31:46:0B:82:4C:A6:88:AB:30:34:9A:C6:EA:4F:04:31:ED:0F:69:A7:B5:C2:2F:A7
web3signer 8E:E0:85:9F:FC:2E:2F:21:31:46:0B:82:4C:A6:88:AB:30:34:9A:C6:EA:4F:04:31:ED:0F:69:A7:B5:C2:2F:A7
curl FC:18:BF:39:45:45:9A:15:46:76:A6:E7:C3:94:64:B8:34:84:A3:8E:B8:EA:67:DC:61:C0:29:E6:38:B8:B7:99
```

Expand Down Expand Up @@ -115,5 +115,5 @@ The command line:

<!-- Links -->

[Configure the client for TLS]: https://docs.ethsigner.consensys.net/en/latest/HowTo/Configure-TLS/#server-tls-connection
[Configure the client for TLS]: https://docs.web3signer.consensys.net/how-to/configure-tls
[Configure the server to allow TLS communication]: https://docs.tessera.consensys.net/HowTo/Configure/TLS/
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ tags:
Create and send [private transactions](../../concepts/privacy/index.md) using:

- [web3js-quorum client library](../use-privacy/web3js-quorum.md) or [web3j client library](https://github.com/web3j/web3j)
- [`eea_sendTransaction` with EthSigner](https://docs.ethsigner.consensys.net/Reference/API-Methods#eea_sendtransaction)
- [`eea_sendRawTransaction`](#eea_sendrawtransaction)
- [`priv_distributeRawTransaction`](#priv_distributerawtransaction).

Expand Down
6 changes: 1 addition & 5 deletions docs/private-networks/reference/api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -322,10 +322,6 @@ For production systems requiring private transactions, use a network with a cons

Using private transactions with [pruning](../../../public-networks/concepts/data-storage-formats.md#pruning) or [fast sync](../../../public-networks/reference/cli/options.md#sync-mode) isn't supported.

Besu doesn't implement [`eea_sendTransaction`](../../how-to/send-transactions/private-transactions.md).

[EthSigner](https://docs.ethsigner.consensys.net/en/latest/) provides transaction signing and implements [`eea_sendTransaction`](https://docs.ethsigner.consensys.net/Reference/API-Methods#eea_sendtransaction).

:::

#### Parameters
Expand Down Expand Up @@ -1617,7 +1613,7 @@ Returns the private transaction if you are a participant, otherwise, `null`.
#### Parameters
`transaction`: _string_ - transaction hash returned by [`eea_sendRawTransaction`](#eea_sendrawtransaction) or [`eea_sendTransaction`](https://docs.ethsigner.consensys.net/Reference/API-Methods#eea_sendtransaction).
`transaction`: _string_ - transaction hash returned by [`eea_sendRawTransaction`](#eea_sendrawtransaction).
#### Returns
Expand Down
60 changes: 3 additions & 57 deletions docs/private-networks/tutorials/contracts/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,9 @@ This example code creates the transaction `tx`, signs it with the private key of

## Use `eth_sendTransaction`

You can use [`eth_sendTransaction`](https://ethereum.github.io/execution-apis/api-documentation) as an alternative to `eth_sendSignedTransaction`. However, Hyperledger Besu does not support the `eth_sendTransaction` API call and keeps account management separate for stronger security. Configure [EthSigner](https://docs.ethsigner.consensys.net/en/stable/) with your Besu node to make the `eth_sendTransaction` API call.
You can use [`eth_sendTransaction`](https://ethereum.github.io/execution-apis/api-documentation) as an alternative to `eth_sendSignedTransaction`. However, Hyperledger Besu does not support the `eth_sendTransaction` API call and keeps account management separate for stronger security. Configure [Web3Signer](https://docs.web3signer.consensys.net/) with your Besu node to make the `eth_sendTransaction` API call.

An example can be found in the [Developer Quickstart](../quickstart.md) where the RPC node is paired with EthSigner. Refer to the [EthSigner documentation](https://docs.ethsigner.consensys.net/) for configuration details.

Pass the following parameters to the [`eth_sendTransaction`](https://docs.ethsigner.consensys.net/Reference/API-Methods/#eth_sendtransaction) call to EthSigner; EthSigner then converts the request to an [`eth_sendRawTransaction`](../../../public-networks/reference/api/index.md#eth_sendrawtransaction) call that Besu uses:
Pass the following parameters to the [`eth_sendTransaction`](https://docs.web3signer.consensys.net/reference/api/json-rpc#eth_sendtransaction) call to Web3Signer. Web3Signer converts the request to an [`eth_sendRawTransaction`](../../../public-networks/reference/api/index.md#eth_sendrawtransaction) call that Besu uses:

- `to` - address of the receiver. To deploy a contract, set to `null`.
- `from` - address of the sender account. For example `0x9b790656b9ec0db1936ed84b3bea605873558198`.
Expand Down Expand Up @@ -220,56 +218,4 @@ This example doesn't use a privacy group and makes a simple node-to-node transac

The Developer Quickstart provides an [example of a private transaction with a privacy group](https://github.com/ConsenSys/quorum-dev-quickstart/blob/b72a0f64d685c851bf8be399a8e33bbdf0e09982/files/besu/smart_contracts/privacy/scripts/private_tx_privacy_group.js).

:::

## Use `eea_sendRawTransaction` for private contracts with web3js-eea

:::warning

This web3js-eea library will be deprecated on December 31, 2021. Please use the [web3js-quorum](https://www.npmjs.com/package/web3js-quorum) library instead and refer to the previous section.

:::

To deploy a private contract to another [privacy group](../../concepts/privacy/privacy-groups.md) member, use the [web3js-quorum](https://consensys.github.io/web3js-quorum/latest/index.html) library and the [`eea_sendRawTransaction`](../../../public-networks/reference/api/index.md#eea_sendrawtransaction) API call. You must use this API call instead of [`eth_sendTransaction`](https://ethereum.github.io/execution-apis/api-documentation) because Hyperledger Besu keeps account management separate for stronger security.

The Developer Quickstart provides an [example of a private transaction script](https://github.com/ConsenSys/quorum-dev-quickstart/blob/1e8cc281098923802845cd829ec20c88513c2e1c/files/besu/smart_contracts/privacy/scripts/private_tx.js).

This example uses the [web3js](https://www.npmjs.com/package/web3) library to make the API calls.

Use `eea_sendRawTransaction` by running the following commands in a JavaScript console, or by including them in a `private_tx.js` file and running `node private_tx.js`:

```js title="'private_tx.js' using 'eea_sendRawTransaction'"
const Web3 = require("web3");
const EEAClient = require("web3-eea");

const bytecode =
"608060405234801561001057600080fd5b5060405161014d38038061014d8339818101604052602081101561003357600080fd5b8101908080519060200190929190505050806000819055505060f38061005a6000396000f3fe6080604052348015600f57600080fd5b5060043610603c5760003560e01c80632a1afcd914604157806360fe47b114605d5780636d4ce63c146088575b600080fd5b604760a4565b6040518082815260200191505060405180910390f35b608660048036036020811015607157600080fd5b810190808035906020019092919050505060aa565b005b608e60b4565b6040518082815260200191505060405180910390f35b60005481565b8060008190555050565b6000805490509056fea2646970667358221220e6966e446bd0af8e6af40eb0d8f323dd02f771ba1f11ae05c65d1624ffb3c58264736f6c63430007060033";
// initialize the default constructor with a value `47 = 0x2F`; this value is appended to the bytecode
const contractConstructorInit =
"000000000000000000000000000000000000000000000000000000000000002F";

const web3 = new Web3(clientUrl);
const web3eea = new EEAClient(web3, 1337);
const txOptions = {
data: "0x" + bytecode + contractConstructorInit,
privateKey: fromPrivateKey,
privateFrom: fromPublicKey,
privateFor: [toPublicKey],
};
console.log("Creating contract...");
const txHash = await web3eea.eea.sendRawTransaction(txOptions);
console.log("Getting contractAddress from txHash: ", txHash);

const privateTxReceipt = await web3.priv.getTransactionReceipt(
txHash,
fromPublicKey,
);
// console.log("Private Transaction Receipt: ", privateTxReceipt);
return privateTxReceipt;
```

`txOptions` contains the following field:

- `data` - compiled code of the contract (in this example there's also a constructor initialization value, so we append that to the bytecode).

The deployment process includes creating the client as in the previous examples, but rather than deploying the contract with `to: null`, it instead sends the transaction with `privateFor: [memberPublicKey/s]`. Once you make the API call, you receive a `transactionHash`, which you can use to get a `transactionReceipt` containing the contract's address.
:::
2 changes: 1 addition & 1 deletion docs/private-networks/tutorials/contracts/interact.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ async function getValueAtAddress(

### 2. Perform a write operation

To perform a write operation, send a transaction to update the stored value. As with the [`get` call](#1-perform-a-read-operation), you need to use the address that the contract was deployed to and the contract's ABI. The account address must correspond to an actual account with some ETH in it to perform the transaction. Because Besu doesn't manage accounts, this address is the address you use in [EthSigner](https://docs.ethsigner.consensys.net/en/stable/) (or equivalent) to manage your accounts.
To perform a write operation, send a transaction to update the stored value. As with the [`get` call](#1-perform-a-read-operation), you need to use the address that the contract was deployed to and the contract's ABI. The account address must correspond to an actual account with some ETH in it to perform the transaction. Because Besu doesn't manage accounts, this address is the address you use in [Web3Signer](https://docs.web3signer.consensys.net/) (or equivalent) to manage your accounts.

Make the `set` call passing in your account address, `value` as the updated value of the contract, and the amount of gas you are willing to spend for the transaction:

Expand Down
6 changes: 2 additions & 4 deletions docs/private-networks/tutorials/contracts/transfer-funds.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,9 @@ A [full example](https://github.com/ConsenSys/quorum-dev-quickstart/blob/1e8cc28

## Use `eth_sendTransaction`

An alternative to using `eth_sendSignedTransaction` is [`eth_sendTransaction`](https://web3js.readthedocs.io/en/v1.2.11/web3-eth.html#sendtransaction). However, Hyperledger Besu does not support the `eth_sendTransaction` API call and keeps account management separate for stronger security. Instead, Besu uses [EthSigner](https://docs.ethsigner.consensys.net/en/stable/) to make the `eth_sendTransaction` API call.
An alternative to using `eth_sendSignedTransaction` is [`eth_sendTransaction`](https://web3js.readthedocs.io/en/v1.2.11/web3-eth.html#sendtransaction). However, Hyperledger Besu does not support the `eth_sendTransaction` API call and keeps account management separate for stronger security. Instead, Besu uses [Web3Signer](https://docs.web3signer.consensys.net/) to make the `eth_sendTransaction` API call.

An example can be found in the [Developer Quickstart](../quickstart.md) where the RPC node is paired with EthSigner. Refer to the [EthSigner documentation](https://docs.ethsigner.consensys.net/en/stable/) configuration details.

Use `eth_sendTransaction` similarly to [using `eth_sendSignedTransaction`](#use-eth_sendsignedtransaction) (without the signing step which is done by EthSigner):
Use `eth_sendTransaction` similarly to [using `eth_sendSignedTransaction`](#use-eth_sendsignedtransaction) (without the signing step which is done by Web3Signer):

```js
const web3 = new Web3(host);
Expand Down
10 changes: 2 additions & 8 deletions docs/public-networks/how-to/send-transactions.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Don't use the accounts from the examples on Mainnet or any public network except

All accounts and private keys in the examples are from the `dev.json` genesis file in the [`/besu/config/src/main/resources`](https://github.com/hyperledger/besu/tree/master/config/src/main/resources) directory.

In production environments avoid exposing your private keys by creating signed transactions offline, or use [EthSigner](https://docs.ethsigner.consensys.net/) to isolate your private keys and sign transactions with [`eth_sendTransaction`](https://docs.ethsigner.consensys.net/Reference/API-Methods#eth_sendtransaction).
In production environments avoid exposing your private keys by creating signed transactions offline, or use [Web3Signer](https://docs.web3signer.consensys.net/) to isolate your private keys and sign transactions with [`eth_sendTransaction`](https://docs.web3signer.consensys.net/reference/api/json-rpc#eth_sendtransaction).

:::

Expand Down Expand Up @@ -55,11 +55,5 @@ You can interact with contracts using [`eth_call`](../reference/api/index.md#eth

Besu doesn't support key management inside the client. Use:

- [EthSigner](http://docs.ethsigner.consensys.net/en/latest/) with Besu to provide access to your key store and sign transactions.
- [Web3Signer](https://docs.web3signer.consensys.net/) with Besu to provide access to your key store and sign transactions.
- Third-party tools (for example, [MetaMask](https://metamask.io/) and [web3j](https://web3j.io/)) for creating accounts.

:::tip

[EthSigner](http://docs.ethsigner.consensys.net/en/latest/) implements [`eth_sendTransaction`](https://docs.ethsigner.consensys.net/Reference/API-Methods#eth_sendtransaction) and [`eea_sendTransaction`](https://docs.ethsigner.consensys.net/Reference/API-Methods#eea_sendtransaction).

:::
4 changes: 2 additions & 2 deletions docs/public-networks/reference/api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -1788,7 +1788,7 @@ Returns a list of account addresses a client owns.
This method returns an empty object because Besu [doesn't support key management](../../how-to/send-transactions.md) inside the client.
To provide access to your key store and and then sign transactions, use [EthSigner](http://docs.ethsigner.consensys.net/en/latest/) with Besu.
To provide access to your key store and and then sign transactions, use [Web3Signer](https://docs.web3signer.consensys.net/) with Besu.
:::
Expand Down Expand Up @@ -5028,7 +5028,7 @@ To avoid exposing your private key, create signed transactions offline and send
Besu doesn't implement [`eth_sendTransaction`](../../how-to/send-transactions.md).
[EthSigner](https://docs.ethsigner.consensys.net/) provides transaction signing and implements [`eth_sendTransaction`](https://docs.ethsigner.consensys.net/Reference/API-Methods#eth_sendtransaction).
[Web3Signer](https://docs.web3signer.consensys.net/) provides transaction signing and implements [`eth_sendTransaction`](https://docs.web3signer.consensys.net/reference/api/json-rpc#eth_sendtransaction).
:::
Expand Down

0 comments on commit ea113df

Please sign in to comment.