https://github.com/fireblocks/solana-web3-adapter
Fireblocks Solana Web3.js Connection Adapter
https://github.com/fireblocks/solana-web3-adapter
Last synced: about 1 month ago
JSON representation
Fireblocks Solana Web3.js Connection Adapter
- Host: GitHub
- URL: https://github.com/fireblocks/solana-web3-adapter
- Owner: fireblocks
- License: mit
- Created: 2024-04-24T17:08:05.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-10T13:10:59.000Z (2 months ago)
- Last Synced: 2025-03-25T20:21:23.997Z (about 2 months ago)
- Language: TypeScript
- Size: 42 KB
- Stars: 7
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![]()
[Fireblocks Developer Portal](https://developers.fireblocks.com)
[Fireblocks Sandbox Sign-up](https://www.fireblocks.com/developer-sandbox-sign-up/)
Fireblocks Solana Web3 Connection Adapter
## Introduction
The Fireblocks Solana Web3 Connection Adapter facilitates interactions between the Fireblocks API and the Solana blockchain, simplifying the process of sending transactions through Fireblocks by handling complex authentication and transaction signing procedures.
The Solana Web3 Connection Adapter utilizes Fireblocks Program Call API to process and sign all transactions, providing a seamless integration with the Solana blockchain.
> **Note**: This Web3 Connection Adapter is currently in Beta. We welcome your feedback and pull requests to help improve the package!
> **Important**: The Program Call API is currently in Early Availability. Please contact your Customer Success Manager (CSM) to enable this feature for your workspace.
## Installation
Clone the repository and install dependencies:
```bash
git clone https://github.com/fireblocks/solana-web3-provider.git
cd solana-web3-provider
npm install -g typescript ts-node
npm install
```## Configuration
Configure the adapter with your Fireblocks API credentials and Solana connection details (See .env.example for reference):
```js
import { FireblocksConnectionAdapter } from './path_to_adapter';const config = {
apiKey: process.env.FIREBLOCKS_API_KEY,
apiSecretPath: process.env.FIREBLOCKS_SECRET_KEY_PATH,
vaultAccountId: process.env.FIREBLOCKS_VAULT_ACCOUNT_ID
};const solanaEndpoint = 'https://api.devnet.solana.com'; // Use appropriate Solana RPC endpoint
```
## Usage
Creating an Adapter Instance:
```js
const connection = await FireblocksConnectionAdapter.create(solanaEndpoint, config);
```Sending a Transaction:
```js
const { Transaction, SystemProgram, sendAndConfirmTransaction} = require('@solana/web3.js');const fromMyAccount = new PublicKey(connection.getAccount());
let transaction = new Transaction().add(
SystemProgram.transfer({
fromPubkey: fromMyAccount,
toPubkey: new PublicKey('destination_address'),
lamports: 1000
})
);const txHash = await connection.sendTransaction(transaction);
// OR
const txHash = await sendAndConfirmTransaction(connection, transaction, []);console.log('Transaction sent with hash:', txHash);
```## Examples
See the [examples](https://github.com/fireblocks/solana-web3-provider/tree/main/examples) directory in this repository for more detailed examples.
## Connection Configuration
```js
apiKey: string - Your Fireblocks API Key
apiSecretPath: string - Path to your Fireblocks API Secret Key
apiBaseUrl?: ApiBaseUrl | string - Base URL for the Fireblocks API (optional, defaults to US production environment)
vaultAccountId: string | number - The ID of the vault account to use for transactions
devnet?: boolean - Whether to use the Devnet environment (optional, defaults to false)
pollingInterval?: number - Fireblocks API polling interval for tx status updates
feeLevel?: FeeLevel - Fee level to use for transactions (optional, defaults to MEDIUM)
silent?: boolean - Whether to suppress logging (optional, defaults to false)
```## Extended methods
Fireblocks Solana Web3 Connection Adapter introduces a few extended methods for better user experience:
Set a transaction note:
```js
connection.setTxNote(txNote: string)
```Set an external transaction identifier:
```js
connection.setExternalTxId(externalTxId: string | null)
```Get the address of the current account (the address of the SOL/SOL_TEST wallet in the configured vault account):
```js
connection.getAccount()
```