npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@57block/stellar-autoaction-sdk

v0.0.2

Published

stellar autoaction sdk

Downloads

18

Readme

Stellar-AutoAction-sdk

Provides a sign transaction function for users to replace the sign function of the steller SDK.

Install

npm install @57block/stellar-autoaction-sdk

Usage

The following example demonstrates signing a transaction using the stellar autoaction-sdk on the Stellar blockchain.

const {
  Horizon,
  Networks,
  Asset,
  Operation,
  TransactionBuilder,
  Keypair,
  xdr,
} = require("@stellar/stellar-sdk");
const { sign } = require("@57block/stellar-autoaction-sdk");

const submitTx = async (
  sourcePublicKey,
  destinationPublicKey,
  account,
  org
) => {
  // Configure the server to the Horizon instance hosted by Stellar.org
  // To use the live network, set the hostname to 'horizon.stellar.org'
  const server = new Horizon.Server('https://horizon-testnet.stellar.org');

  console.log("Building transaction...");
  // Transactions require a valid sequence number that is specific to this account.
  // We can fetch the current sequence number for the source account from Horizon.
  const sourceAccount = await server.loadAccount(sourcePublicKey);
  // Right now, there's one function that fetches the base fee.
  const fee = await server.fetchBaseFee();
  const tx = new TransactionBuilder(sourceAccount, {
    fee,
    // Uncomment the following line to build transactions for the live network. Be
    // sure to also change the horizon hostname.
    // networkPassphrase: StellarSdk.Networks.PUBLIC,
    networkPassphrase: Networks.TESTNET
  })
  // Add a payment operation to the transaction
  .addOperation(Operation.payment({
    destination: destinationPublicKey,
    // The term native asset refers to lumens
    asset: Asset.native(),
    amount: '10',
  }))
  // Make this transaction valid for the next 30 seconds only
  .setTimeout(30)
  // Uncomment to add a memo (https://developers.stellar.org/docs/glossary/transactions/)
  // .addMemo(Memo.text('Hello world!'))
  .build();

  console.log("Signing transaction...");
  // get the signature from sdk sign server
  const signature = await sign({
    txHash: tx.hash().toString('base64'),
    sourcePublicKey,
    account,
    org,
  });
  // use the signature to sign the transaction
  tx.addDecoratedSignature(
    new xdr.DecoratedSignature({
      signature,
      hint: Keypair.fromPublicKey(sourcePublicKey).signatureHint(),
    })
  );
  console.log("Submiting transaction...");
  // Submit the transaction to the Horizon server. The Horizon server will then
  // submit the transaction into the network for us.
  const transactionResult = await server.submitTransaction(tx);
  console.log(`Transaction successful! Tx hash: ${transactionResult.hash}`);
};