Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding gunz-test to chain list #28

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
90 changes: 49 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,48 +3,56 @@
</p>
<div align="center">

[![npm version](https://badge.fury.io/js/@fireblocks%2Ffireblocks-web3-provider.svg)](https://badge.fury.io/js/@fireblocks%2Ffireblocks-web3-provider) </br>
[<ins>Fireblocks Web3 Provider Documentation</ins>](https://developers.fireblocks.com/docs/ethereum-development)
</div>
[![npm version](https://badge.fury.io/js/@fireblocks%2Ffireblocks-web3-provider.svg)](https://badge.fury.io/js/@fireblocks%2Ffireblocks-web3-provider) </br>
[<ins>Fireblocks Web3 Provider Documentation</ins>](https://developers.fireblocks.com/docs/ethereum-development)

</div>

# Fireblocks Web3 Provider

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

## Installation

```bash
npm install @fireblocks/fireblocks-web3-provider
```

## Setup

```js
import { FireblocksWeb3Provider, ChainId, ApiBaseUrl } from "@fireblocks/fireblocks-web3-provider";
import {
FireblocksWeb3Provider,
ChainId,
ApiBaseUrl,
} from "@fireblocks/fireblocks-web3-provider";

const eip1193Provider = new FireblocksWeb3Provider({
// apiBaseUrl: ApiBaseUrl.Sandbox // If using a sandbox workspace
privateKey: process.env.FIREBLOCKS_API_PRIVATE_KEY_PATH,
apiKey: process.env.FIREBLOCKS_API_KEY,
vaultAccountIds: process.env.FIREBLOCKS_VAULT_ACCOUNT_IDS,
chainId: ChainId.GOERLI,

logTransactionStatusChanges: true, // Verbose logging
})
// apiBaseUrl: ApiBaseUrl.Sandbox // If using a sandbox workspace
privateKey: process.env.FIREBLOCKS_API_PRIVATE_KEY_PATH,
apiKey: process.env.FIREBLOCKS_API_KEY,
vaultAccountIds: process.env.FIREBLOCKS_VAULT_ACCOUNT_IDS,
chainId: ChainId.SEPOLIA,

logTransactionStatusChanges: true, // Verbose logging
});
```

## Usage with ethers.js

```sh
npm install ethers@5
```

```js
import * as ethers from "ethers"
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
```
Expand All @@ -68,96 +76,96 @@ This class is an [EIP-1193](https://eips.ethereum.org/EIPS/eip-1193) Compatible
```ts
type FireblocksProviderConfig = {
// ------------- Mandatory fields -------------
/**
* Learn more about creating API users here:
/**
* Learn more about creating API users here:
* https://developers.fireblocks.com/docs/quickstart#api-user-creation
*/

/**
/**
* Fireblocks API key
*/
apiKey: string,
apiKey: string;

/**
/**
* Fireblocks API private key for signing requests
*/
privateKey: string,
privateKey: string;

// Either chainId or rpcUrl must be provided
/**
* If not provided, it is inferred from the rpcUrl
/**
* If not provided, it is inferred from the rpcUrl
*/
chainId?: ChainId,
/**
* If not provided, it is inferred from the chainId
chainId?: ChainId;
/**
* If not provided, it is inferred from the chainId
*/
rpcUrl?: string,
rpcUrl?: string;

// ------------- Optional fields --------------

/**
/**
* By default, the first 20 vault accounts are dynamically loaded from the Fireblocks API
* It is recommended to provide the vault account ids explicitly because it helps avoid unnecessary API calls
*/
vaultAccountIds?: number | number[] | string | string[],
/**
vaultAccountIds?: number | number[] | string | string[];
/**
* By default, it uses the Fireblocks API production endpoint
* When using a sandbox workspace, you should provide the ApiBaseUrl.Sandbox value
*/
apiBaseUrl?: ApiBaseUrl | string,
apiBaseUrl?: ApiBaseUrl | string;
/**
* By default, the fallback fee level is set to FeeLevel.MEDIUM
*/
fallbackFeeLevel?: FeeLevel,
fallbackFeeLevel?: FeeLevel;
/**
* By default, the note is set to "Created by Fireblocks Web3 Provider"
*/
note?: string,
note?: string;
/**
* By default, the polling interval is set to 1000ms (1 second)
* It is the interval in which the Fireblocks API is queried to check the status of transactions
*/
pollingInterval?: number,
pollingInterval?: number;
/**
* By default, it is assumed that one time addresses are enabled in your workspace
* If they're not, set this to false
*/
oneTimeAddressesEnabled?: boolean,
oneTimeAddressesEnabled?: boolean;
/**
* By default, no externalTxId is associated with transactions
* If you want to set one, you can either provide a function that returns a string, or provide a string directly
*/
externalTxId?: (() => string) | string,
externalTxId?: (() => string) | string;
/**
* If you want to prepend an additional product string to the User-Agent header, you can provide it here
*/
userAgent?: string,
userAgent?: string;
/**
* If you are using a private/custom EVM chain, you can provide its Fireblocks assetId here
*/
assetId?: string,
assetId?: string;
/**
* Default: false
* By setting to true, every transaction status change will be logged to the console
* Same as setting env var `DEBUG=fireblocks-web3-provider:status`
*/
logTransactionStatusChanges?: boolean,
logTransactionStatusChanges?: boolean;
/**
* 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=fireblocks-web3-provider:req_res`
*/
logRequestsAndResponses?: boolean,
logRequestsAndResponses?: boolean;
/**
* Default: true
* By setting to true, every failed transaction will print additional information
* helpful for debugging, such as a link to simulate the transaction on Tenderly
* Same as setting env var `DEBUG=fireblocks-web3-provider:error`
*/
enhancedErrorHandling?: boolean,
enhancedErrorHandling?: boolean;
/**
* Proxy path in the format of `http(s)://user:pass@server`
*/
proxyPath?: string
}
proxyPath?: string;
};
```
Loading
Loading