Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
@hapi.one/solana-client
Advanced tools
This library provides three types of clients of HAPI smart contract on Solana:
import { ReaderClient, u64 } from '@hapi.one/solana-client';
// Create a client that connects to a Solana API endpoint
const reader = new ReaderClient({ endpoint: "https://api.mainnet-beta.solana.com" });
// Fetch info on "hapi.one" community
const communityInfo = await reader.getCommunity("hapi.one");
// Fetch info on "solana" network in "hapi.one" community
const networkInfo1 = await reader.getNetwork("solana", "hapi.one");
// You can set a contextual community
reader.switchCommunity("hapi.one");
// Alternatively, you can initialize the client with default community name specified
const reader2 = new ReaderClient({ endpoint: "https://api.mainnet-beta.solana.com", communityName: "hapi.one" });
// This and next calls to methods will use "hapi.one" community implicitly
const networkInfo2 = await reader.getNetwork("bitcoin");
const reporterAccount = new PublicKey("GNNtJU2WCuk1q8uLW6aXHwFcZvrgbzRrtwuQqYkaCKSY");
// You can get info on a particular reporter in the community by their public key
const reporterInfo = await reader.getReporter(reporterAccount);
// You can fetch info of a case in the community by it's ID
const caseInfo = await reader.getCase(new u64(420));
// You can get information about a particular address using a string representation of it's public key (for Solana blockchain)
const addressInfo1 = await reader.getAddress("9Y9eHFk6tyadkz3e4zpYxvAuTumkLHSXV2tZQhxjb6xf", "solana-mainnet");
// You'll have to convert addresses in other blockchains to a buffer and pad it to 32 bytes
const buffer = Buffer.alloc(32);
const pizzaTransactionAddress = Buffer.from("0046af3fb481837fadbb421727f9959c2d32a3682971c823e7", "hex");
buffer.set(pizzaTransactionAddress);
// ... then you can get that address info
const addressInfo2 = await reader.getAddress(buffer, "bitcoin-mainnet");
ReporterClient
extends ReaderClient
, so all the getter methods are the same.
import { Keypair, PublicKey, Connection } from '@solana/web3.js';
import { ReporterClient, u64, Category } from '@hapi.one/solana-client';
// You'll need a keypair to operate reporter client
const payer = Keypair.generate();
// Payer should be passed to the client on instantiation
const reporter = new ReporterClient({ endpoint: "https://api.mainnet-beta.solana.com", payer });
// You can set community name contextually, as in ReaderClient
reporter.switchCommunity("hapi.one");
// Create a new case with a name and a category
const resultCase = await reporter.createCase("Exchange hack 2021-10-08", [Category.Theft]);
// Create a new address record for an address exposed in this case
const resultAddress = await reporter.createAddress(
"solana",
new PublicKey("vwiVuBCPvFW5GJTM9Z2CbAuard5xP4Cyjn8gFjnUxy4"),
resultCase.meta.caseId,
Category.Theft,
5,
);
// Alternatively, you can set up a client with only a public key of the payer,
// but you'll need to sign transactions externally (e.g. via wallet)
const payer2 = new PublicKey("9Y9eHFk6tyadkz3e4zpYxvAuTumkLHSXV2tZQhxjb6xf");
const reporter2 = new ReporterClient({ endpoint: "https://api.mainnet-beta.solana.com", payer: payer2 });
// You can create an unsigned transaction so you can sign it with a connected wallet and
const transaction = await reporter2.createCaseTransaction("Rug pull", [Category.Scam]);
// ...sign transaction here
// Send signed transaction via @solana/web3.js
const conn = new Connection("https://api.mainnet-beta.solana.com");
await conn.sendRawTransaction(transaction.serialize());
FAQs
Client library for Solana smart contract for #HAPI
The npm package @hapi.one/solana-client receives a total of 2 weekly downloads. As such, @hapi.one/solana-client popularity was classified as not popular.
We found that @hapi.one/solana-client demonstrated a not healthy version release cadence and project activity because the last version was released 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.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.