New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@stellar/js-xdr

Package Overview
Dependencies
Maintainers
8
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stellar/js-xdr

Read/write XDR encoded data structures (RFC 4506)

  • 3.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
186K
increased by0.16%
Maintainers
8
Weekly downloads
 
Created

What is @stellar/js-xdr?

@stellar/js-xdr is a JavaScript library for working with XDR (External Data Representation) data structures, specifically tailored for the Stellar network. It allows developers to encode and decode XDR data, which is used extensively in the Stellar protocol for defining data structures and messages.

What are @stellar/js-xdr's main functionalities?

Encoding XDR Data

This feature allows you to encode data into XDR format. The code sample demonstrates creating a data structure and encoding it into XDR, which is then output as a base64 string.

const xdr = require('@stellar/js-xdr');

const myData = new xdr.MyDataStructure({
  field1: 'value1',
  field2: 1234
});

const encoded = myData.toXDR();
console.log(encoded.toString('base64'));

Decoding XDR Data

This feature allows you to decode XDR data back into a JavaScript object. The code sample shows how to take a base64 encoded XDR string, decode it, and access the resulting data structure.

const xdr = require('@stellar/js-xdr');

const encodedData = Buffer.from('base64encodedstring', 'base64');
const myData = xdr.MyDataStructure.fromXDR(encodedData);

console.log(myData);

Defining Custom XDR Types

This feature allows you to define custom XDR types using the library's API. The code sample demonstrates defining a custom structure with specific fields and encoding it into XDR.

const xdr = require('@stellar/js-xdr');

const MyCustomType = xdr.struct([['field1', xdr.string()], ['field2', xdr.int()]]);

const myData = new MyCustomType({
  field1: 'example',
  field2: 42
});

console.log(myData.toXDR().toString('base64'));

Other packages similar to @stellar/js-xdr

FAQs

Package last updated on 18 Jul 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc