An enterprise-grade Java-based, Apache 2.0 licensed Ethereum client https://wiki.hyperledger.org/display/besu
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
besu/docs/Privacy/Private-Transactions/eeajs.md

2.0 KiB

description: web3.js-eea Client Library

web3.js-eea Client Library

The web3.js-eea library adds an additional property to your web3 instance by extending web3. Use the library to create and send RLP-encoded transactions using JSON-RPC.

!!! note web3.js-eea supports JSON-RPC over HTTP only.

Prerequisites

Add web3.js-eea to Project

npm install web3-eea

Initialize EEA Client

Initilize your EEA client where:

  • <JSON-RPC HTTP endpoint> is the JSON-RPC HTTP endpoint of your Pantheon node. Specified by the --rpc-http-host and --rpc-http-port command line options.
  • <chain_id> is the chain ID of your network.

!!! example js tab="Syntax" const EEAClient = require("web3-eea"); const web3 = new EEAClient(new Web3("<JSON-RPC HTTP endpoint>", <chain_id>);

```js tab="Example"
const EEAClient = require("web3-eea");
const web3 = new EEAClient(new Web3("http://localhost:8545", 2018);
```

Deploying a Contract with sendRawTransaction

To deploy a private contract, you need the contract binary. You can use Solidity to get the contract binary.

!!! example "Deploying a Contract with sendRawTransaction"
js const contractOptions = { data: `0x123`, // contract binary privateFrom: "orionNode1PublicKey", privateFor: ["orionNode3PublicKey"], privateKey: "pantheonNode1PrivateKey" }; return web3.eea.sendRawTransaction(contractOptions);

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