Skip to content

Commit

Permalink
feat(MPC-2011): initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg May committed Oct 17, 2024
1 parent 7c0deef commit c17331d
Show file tree
Hide file tree
Showing 67 changed files with 11,849 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
BLOCKDAEMON_RPC_URL="https://svc.blockdaemon.com/native/v1/ethereum/holesky?apiKey=zpka_..."
BUILDERVAULT_PLAYER0_URL="http://localhost:8500"
BUILDERVAULT_PLAYER0_APIKEY="..."
BUILDERVAULT_PLAYER1_URL="http://localhost:8501"
BUILDERVAULT_PLAYER1_APIKEY="..."
BUILDERVAULT_MASTERKEY_ID="Ap7..."
BUILDERVAULT_ACCOUNT_ID=0
BUILDERVAULT_ADDRESS_INDEX=0
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
*.crt
*.key
.vscode
init
**/key.txt
**/.env
**/node_modules
102 changes: 102 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# Blockdaemon BuilderVault Web3 Provider

Blockdaemon BuilderVault [EIP-1193](https://eips.ethereum.org/EIPS/eip-1193) Compatible Ethereum JavaScript Provider

## Installation
```bash
npm config set @sepior:registry=https://gitlab.com/api/v4/projects/56306653/packages/npm/ # Builder Vault nodejsSDK repository
npm install @blockdaemon/buildervault-web3-provider
```

## Setup
```js
import { BuildervaultWeb3Provider } from "@blockdaemon/buildervault-web3-provider";

const eip1193Provider = new BuildervaultWeb3Provider({
rpcUrl: "https://svc.blockdaemon.com/native/v1/ethereum/holesky?apiKey=zpka_8...",
player0Url: "http://localhost:8500",
player0ApiKey: "apikey0",
player1Url: "http://localhost:8501",
player1ApiKey: "apikey1",
masterKeyId: "Ap7fC2YPwBKbRXwVHEBVUkHYF37G",
accountId: 0, // account of BIP44 m/44/60/account/0/address_index
addressIndex: 0, // address_index of BIP44 m/44/60/account/0/address_index
logRequestsAndResponses: false, // Verbose logging
})
```

## Usage with ethers.js
```sh
npm install ethers@5
```

```js
import * as ethers from "ethers"

const provider = new ethers.providers.Web3Provider(eip1193Provider);
// const provider = new ethers.BrowserProvider(eip1193Provider); // For ethers v6
```

## Usage with web3.js
```sh
npm install web3
```

```js
import Web3 from "web3";

const web3 = new Web3(eip1193Provider);
```

## API Documentation

### new BuildervaultWeb3Provider(config)

- `config` [BuildervaultProviderConfig](#BuildervaultProviderConfig)

This class is an [EIP-1193](https://eips.ethereum.org/EIPS/eip-1193) Compatible Ethereum JavaScript Provider powered by the [Blockdaemon API](https://docs.fireblocks.com/api/)

### BuildervaultProviderConfig

```ts
type BuildervaultProviderConfig = {
// ------------- Mandatory fields -------------
/**
* Set the RPC API URL endpoint for JSON-RPC over HTTP access to the blockchain data
*/
rpcUrl?: string,
/**
* Set the URL of the BuilderVault player0 and player1 endpoints
*/
player0Url?: string,
player1Url?: string,
/**
* Set the BuilderVault TSM API keys
*/
player0ApiKey?: string,
player1ApiKey?: string,
/**
* BuilderVault Master Key ID. This ID represents all the private Master Key shares and must be generated outside if the web3 provider using the BuilderVault SDK
*/
masterKeyId?: string,
/**
* It is recommended to provide the account id explicitly.
* This represents the <account> in the BIP44 chain path m/44/60/account/0/address_index
*/
accountId?: number,
/**
* By default, the first 5 addresses are derived from the master key
* It is recommended to provide the address index explicitly.
* This represents the <address_index> in the BIP44 chain path m/44/60/account/0/address_index
*/
addressIndex?: number,

// ------------- Optional fields --------------
/**
* Default: false
* By setting to true, every request and response processed by the provider will be logged to the console
* Same as setting env var `DEBUG=buildervault-web3-provider:req_res`
*/
logRequestsAndResponses?: boolean
}
```
Loading

0 comments on commit c17331d

Please sign in to comment.