
Research
Two Malicious Rust Crates Impersonate Popular Logger to Steal Wallet Keys
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
@fuels/streams
Advanced tools
The @fuels/streams
library provides a simple and robust TypeScript SDK for connecting to and consuming real-time data from the Fuel blockchain. It enables developers to subscribe to blockchain events with type-safe interfaces and powerful filtering capabilities.
npm install @fuels/streams
# or
yarn add @fuels/streams
# or
pnpm add @fuels/streams
# or
bun install @fuels/streams
import { Client, FuelNetwork } from "@fuels/streams";
async function main() {
// Connect to the Fuel network with your API key
const connection = await Client.connect(FuelNetwork.Mainnet, "your_api_key");
console.log("Connected to Fuel Network");
}
main().catch(console.error);
import {
BlocksSubject,
Client,
DeliverPolicy,
FuelNetwork,
} from "@fuels/streams";
async function main() {
const connection = await Client.connect(FuelNetwork.Mainnet, "your_api_key");
// Create a subject for all blocks
const subjects = [BlocksSubject.build()];
// Subscribe to blocks with new deliver policy
const stream = await connection.subscribe(subjects, DeliverPolicy.new());
for await (const message of stream) {
console.log("Block:", message.payload);
}
}
main().catch(console.error);
import {
Client,
DeliverPolicy,
FuelNetwork,
TransactionStatus,
TransactionType,
TransactionsSubject,
} from "@fuels/streams";
async function main() {
const connection = await Client.connect(FuelNetwork.Mainnet, "your_api_key");
// Create a filtered subject for successful script transactions
const subjects = [
TransactionsSubject.build({
txType: TransactionType.Script,
status: TransactionStatus.Success,
}),
];
// Subscribe from a specific block height
const stream = await connection.subscribe(
subjects,
DeliverPolicy.fromBlock(1000000),
);
for await (const message of stream) {
console.log("Transaction:", message.payload);
}
}
main().catch(console.error);
import {
Client,
DeliverPolicy,
FuelNetwork,
ReceiptsLogDataSubject,
} from "@fuels/streams";
// Import your contract ABI
import contractAbi from "./contract_abi.json";
async function main() {
// Pass the ABI when connecting
const connection = await Client.connect(FuelNetwork.Mainnet, "your_api_key", {
abi: contractAbi,
});
// Filter log data from a specific contract
const subjects = [
ReceiptsLogDataSubject.build({
contract:
"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
}),
];
const stream = await connection.subscribe(subjects, DeliverPolicy.new());
for await (const message of stream) {
console.log("Event:", message.payload);
// The payload will be automatically decoded using the provided ABI
}
}
main().catch(console.error);
import {
BlocksSubject,
Client,
DeliverPolicy,
FuelNetwork,
} from "@fuels/streams";
async function main() {
const connection = await Client.connect(FuelNetwork.Mainnet, "your_api_key");
const subjects = [BlocksSubject.build()];
const stream = await connection.subscribe(subjects, DeliverPolicy.new());
// Use event handlers instead of async iteration
const unsubscribe = stream.onMessage((message) => {
console.log("New block:", message.payload);
});
// Handle errors
stream.onMessageError((error) => {
console.error("Stream error:", error);
});
// Later, when you want to stop receiving events
// unsubscribe();
}
main().catch(console.error);
The library provides various subject types for different blockchain data:
Each subject type supports specific filter criteria. For a complete list of available filters, see the Filters List in the main repository README.
Control how you receive data with delivery policies:
The library is organized into several key components:
Contributions are welcome! Please see the Contributing Guide for more information.
This project is licensed under the MIT License - see the LICENSE file for details.
FAQs
Official data streaming Typescript library for Fuel Network
We found that @fuels/streams demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.