Giter Club home page Giter Club logo

web3js-quorum's Introduction

Website npm Known Vulnerabilities

This repository is not actively maintained by Consensys and is provided as-is. It is open-source and contributions are welcome.

web3js-quorum

Web3js-Quorum is an Ethereum JavaScript library extending web3.js that adds supports for GoQuorum and Hyperledger Besu specific JSON-RPC APIs and features. In particular it enables to use web3.js with private transactions.

Web3js-Quorum gather all features from quorum.js and web3js-eea in a single library.

Please read the documentation for more.

Features

  • Supports GoQuorum and Besu JSON-RPC APIs
  • Create and send private transactions
  • Privacy group management

Installation

npm install web3 web3js-quorum

Quickstart

The Quorum client APIs methods provided by web3js-quorum are accessed like so:

Extending web3 object

const Web3 = require("web3");
const Web3Quorum = require("web3js-quorum");
const web3 = new Web3Quorum(new Web3("http://localhost:22000"));
web3.priv.generateAndSendRawTransaction(options);

Documentation

For full usage and API details see the documentation.

Examples

The example directory contains examples of web3js-quorum usage with Besu as a Quorum client.
The 7nodes-test directory contains examples of web3js-quorum usage with GoQuorum as a Quorum client.

Migrations

  • To migrate from web3js-eea refer to this
  • To migrate from quorum.js refer to this

Contributing

Please follow the Contribution Guidelines and Review Guidelines.

web3js-quorum's People

Contributors

0xigor avatar achraf17 avatar akuanti avatar antonydenyer avatar bmcd avatar cruzmolina avatar ekellstrand avatar fixanoid avatar gbarcomu avatar iikirilov avatar josh-richardson avatar joshuafernandes avatar lucassaldanha avatar macfarla avatar madelinemurray avatar magooster avatar namtruong avatar nicksneo avatar nicolae-leonte-go avatar nicolasmassart avatar nmvalera avatar non-fungible-nelson avatar petermetz avatar prd-fox avatar puneetha17 avatar rojotek avatar satpalsandhu61 avatar snyk-bot avatar timbeiko avatar vgloic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

web3js-quorum's Issues

method handler crashed error when sending private transaction.

System information

Client type: GoQuorum

Client version: v21.4.2

OS & Version: MAC

Expected behaviour

Private transaction is suppose to go through, essentially calling a function on. a smart contract.

Actual behaviour

get the following error, method handler crashed

Steps to reproduce the behaviour

Steps listed here : https://docs.goquorum.consensys.net/tutorials/quorum-dev-quickstart/using-the-quickstart#private-transactions

Backtrace

[backtrace]

fix(typescript): make enclaveOptions and isQuorum optional args

The implementation [1] has the 2nd and 3rd parameters as optional with default values, but the Typescript types are forcing the programmer to provide values due to the typings [2] not mirroring the implementation:

[1]

function Web3Quorum(web3, enclaveOptions = {}, isQuorum = false) {

[2]

export default function Web3Quorum(web3: Web3, enclaveOptions: EnclaveOptions, isQuorum: boolean): IWeb3Quorum;

Update Flexible Privacy Group

Summary:
Besu have updated the JSON-RPC method privx_findOnChainPrivacyGroup which got replaced with a call to the pre-compiled smart contract, leading to few failing tests with error Method not found.

Acceptance Tests:

  • remove the json rpc method privx_findOnChainPrivacyGroup
  • Add the new find flexible privacy group contract call (pre-compiled contract)
  • Update the unit tests
  • Update the integration tests
  • Pump the besu version to latest to make sure all changes are working fine

How to send private transaction with custom generated account?

System information

Client type: GoQuorum / quorum-dev-quickstart

Client version: v21.4.2

OS & Version: Windows

Expected behaviour

Generated Account/address with HD wallet and added to wallet via "web3.eth.accounts.wallet.add(privateKey)". Address is used to create private transaction.

Actual behaviour

Transaction is executed without producing an error, but state of private smart contract is not changed (also no events are created). Anyhow, when using the default account of node 0, the transaction processed correctly.

So my question is: how can I add accounts to web3js-quorum to execute private transactions?

Transaction with default account:
....
​blockHash: "0x4b126620e53c7c55a7e8bae38a4dd5b3706df19ba00faadf7fac4ff9993e5c57"
​blockNumber: 37998
​from: "0xf0E2Db6C8dC6c681bB5D6aD121A107f300e9B2b5"
​gas: 3000000
​gasPrice: "0"
​hash: "0x143fa97f62d952bbb70cd3b8eaa73ab53bfcb6690285363e535f3976d7ee4f7b"
​input: "0xb2c49a3352eb4d5cb508fa0aaedef437f38138aaa64231113ad0dbb4c2d4a16bbdd1b69ac335c4ea1329b9f02a5830b28430b4874abb73b820a95c8f0076cfeb"
​nonce: 1568
​r: "0xa5dbe9b212ad260028d8ec36c456b83f28ecfaa68b5556d24f0c99ebb31c1861"
​s: "0x65766021f2697da9de43b1f265283870d3c20a95c153125b11179448d18ebe21"
​to: "0x2d41EF825ACD66332F8A208a97eA2B7E2547bae9"
​transactionIndex: 0
​type: "0x0"
​v: "0x26"
​value: "0"

Transaction with custom generated account:
blockHash: "0x1561cb3a5279c5fc708ee0382c29685c9e7710f5a1cc3720fc7bd1cdd6f7d77f"
​blockNumber: 38043
​from: "0x6858DC3A3E1c2F4de7dA740bb0257ED8A0aE582b"
​gas: 3000000
​gasPrice: "0"
​hash: "0x09a8f112ae72fc7f395adba0aaf28867bd10b30fa1a61c2ca368c42885dc2f50"
​input: "0x08ed3144737373000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000639903f000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000063a23e70000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005444548414d0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005534753494e000000000000000000000000000000000000000000000000000000"
​nonce: 304
​r: "0xb8409b4f2e012a0054424ae98c5948f6ec26d3ec8e98a36f9428011658d5b5c6"
​s: "0x39413af0c423bdc1344aeb5fe43a31c776e0533e1c13900d3acff061ef3d0c54"
​to: "0x2d41EF825ACD66332F8A208a97eA2B7E2547bae9"
​transactionIndex: 0
​type: "0x0"
​v: "0xa95"
​value: "0

Large bundle size

Having import Web3Quorum from "web3js-quorum"; increases bundle size by a lot.

In my project, before importing it, bundle size was 396.68 KiB / gzip: 115.09 KiB.
After importing it, bundle size increased to 1649.67 KiB / gzip: 472.42 KiB.

System information

Client type: Besu
Bundler: Rollup

Expected behaviour

Bundle size shouldn't increase that much.

Actual behaviour

Bundle size increases by ~1.2MB uncompressed.

Steps to reproduce the behaviour

In any example project, try building it with and without importing web3-quorum.

Failing url dependency in the browser

When I pass a privateUrl to the Web3Quorum constructor in the browser, the url dependency fails here.

I checked the dependencies of web3js-quorum and there is no "url" defined.

After checking my project's dependencies, I see that it react-scripts transitively adds [email protected].
This is probably not the dependency Web3Quorum should be using because it does not have any constructor (you should use Url.parse() instead).

I see different solutions:

  • Adding the original dependency to Web3Quorum.

  • Using [email protected] and explicitly defining it as Web3Quorum's dependency

- const { URL } = require("url");
+ const Url = require("url");
...
-    const { protocol } = new URL(privateEndpoint);
+    const { protocol } = Url.parse(privateEndpoint);
  • Use a package like universal-url or iso-url to rely on browser's URL implementation whenever it is possible and to use a different implementation on NodeJS. For example:
- const { URL } = require("url");
+ require('universal-url').shim();
...
    const { protocol } = new URL(privateEndpoint);

fix(typescript): correct type for IDistributeRawTransaction.privateFor

readonly privateFor: string;

  export interface IDistributeRawTransaction {
    readonly privateKey: string;
    readonly privateFrom: string;
    readonly privateFor: string;
    readonly privacyGroupId: string;
    readonly nonce: string;
    readonly to: string;
    readonly data: string;
  }

Shouldn't this privateFor be an array of keys rather than a single string? If you can confirm that this is the case, then I can send a PR fixing it.

Same question about this interface:

  export interface IPtmSend extends IOptions {
    readonly privateFor: string;
  }

https://github.com/Consensys/web3js-quorum/blob/eff69e832c6ac1528899d8f969641ff203fa1c4d/src/typescript/index.d.ts#L82C1-L84C4

rename orion variables

Summary

in keys.js and wherever this is used. Orion deprecated in favour of tessera - but maybe we should just use "enclave" to be agnostic.
There are two keys.js file:

  • integration-tests/support/keys.js used for integration tests
  • example/keys.js used in the examples provided in web3js-quorum

Acceptance tests

  • Rename the orion varibale in the keys.js files to enclave (for example)
  • Update the source code that uses that

Cannot find eea_sendTransaction

Hello,

I'm trying to use this library to send private transactions to Besu, but using EthSigner. However, I cannot find a method to send an "eea_sendTransaction" request.
Isn't it supported?

Thanks in advance

chore(npm): publish current code to the registry

Expected behaviour

The current code (which has the Typescript typings included) is on npm under an rc2 or some other version (doesn't matter to me what version)

Actual behaviour

Currently a 9 months old version of the code is the only one that's published on npm which does NOT contain the Typescript typings which we want to use in the Cactus Quorum/Besu connector plugins.

Steps to reproduce the behaviour

Go to https://www.npmjs.com/package/web3js-quorum
Click versions and on that tab observe that there's only one release from 9 months ago.

Unable to add privateFrom for named resident group for MPS enanbled quorum node v21.7.1

System information

Client type: GoQuorum

Client version: v21.7.1

OS & Version: Ubuntu 18.04

Expected behaviour

Client node running example from :
https://github.com/ConsenSys/web3js-quorum/blob/master/7nodes-test/deployContractViaHttp.js
to be able to interact with MPS enabled quorum node v21.7.1

Actual behaviour

The below error occurs when I am trying to connect to named (PS1) resident group as the privateFrom as evident in the example provided in this repository.
error :>> Error: Returned error: The PrivateFrom address does not match the specified private state (private)

Backtrace

I have set up a MPS enable private quorum network of v21.7.1 with tessera v21.7.2 and am able to push transactions from and to my MPS enabled node with 2 keys passed onto tessera and connecting to geth with :
geth attach https://10.16.2.6:22000?PSI=PS1

But I tried to push a new transaction with the example code present at
https://github.com/ConsenSys/web3js-quorum/blob/master/7nodes-test/deployContractViaHttp.js
as directed from:
https://consensys.github.io/web3js-quorum/latest/index.html

where there is no mention of how to pass the Private State information nor is there any mention of how to connect to a multitenant quorum node where we can connect via RPC like:

geth attach https://10.16.2.6:22000?PSI=$PSI --rpcclitls.insecureskipverify --rpcclitoken "bearer $accessToken"

Please help me get this figured out.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.