
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
@metaplex-foundation/beet-solana
Advanced tools
Solana specific extension for beet, the borsh compatible de/serializer
@metaplex-foundation/beet-solana is a library designed to facilitate serialization and deserialization of data structures in the Solana blockchain ecosystem. It provides utilities to define and work with complex data types, making it easier to interact with Solana programs.
Serialization and Deserialization
This feature allows users to define data structures and serialize/deserialize them to/from buffers. The code sample demonstrates how to define a simple struct with two fields and serialize/deserialize it using the library.
const { u8, struct } = require('@metaplex-foundation/beet-solana');
const MyStruct = struct([
['field1', u8],
['field2', u8]
]);
const buffer = Buffer.alloc(MyStruct.byteSize);
MyStruct.write(buffer, 0, { field1: 1, field2: 2 });
const result = MyStruct.read(buffer, 0);
console.log(result); // { field1: 1, field2: 2 }
Complex Data Types
This feature supports complex data types, such as arrays within structs. The code sample shows how to define a struct with an array field and serialize/deserialize it.
const { u8, array, struct } = require('@metaplex-foundation/beet-solana');
const ComplexStruct = struct([
['field1', u8],
['field2', array(u8, 3)]
]);
const buffer = Buffer.alloc(ComplexStruct.byteSize);
ComplexStruct.write(buffer, 0, { field1: 1, field2: [2, 3, 4] });
const result = ComplexStruct.read(buffer, 0);
console.log(result); // { field1: 1, field2: [2, 3, 4] }
Borsh is a binary serialization format designed for speed and efficiency, commonly used in the Solana ecosystem. It provides similar functionality to @metaplex-foundation/beet-solana in terms of serialization and deserialization of data structures, but with a focus on performance and simplicity.
Buffer-layout is a library for describing and serializing binary data structures. It is used in the Solana ecosystem for defining data layouts in a flexible manner. Compared to @metaplex-foundation/beet-solana, buffer-layout offers a more low-level approach to defining data structures.
Solana specific extension for beet, the borsh compatible de/serializer
Please find the API docs here.
import { publicKey } from '@metaplex-foundation/beet-solana'
const generatedKey = Keypair.generate().publicKey
const buf = Buffer.alloc(publicKey.byteSize)
beet.write(buf, 0, generatedKey)
beet.read(buf, 0) // same as generatedKey
import * as web3 from '@solana/web3.js'
import * as beet from '@metaplex-foundation/beet'
import * as beetSolana from '@metaplex-foundation/beet-solana'
type InstructionArgs = {
authority: web3.PublicKey
}
const createStruct = new beet.BeetArgsStruct<InstructionArgs>(
[
['authority', beetSolana.publicKey]
],
'InstructionArgs'
)
Apache-2.0
FAQs
Solana specific extension for beet, the borsh compatible de/serializer
The npm package @metaplex-foundation/beet-solana receives a total of 135,954 weekly downloads. As such, @metaplex-foundation/beet-solana popularity was classified as popular.
We found that @metaplex-foundation/beet-solana demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 open source maintainers 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
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.