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

soroban-toolkit

v0.1.5

Published

Soroban Toolkit is a powerful library designed to simplify interactions with Stellar’s Soroban smart contracts. It provides tools for deploying, invoking, and managing smart contracts while handling complex blockchain interactions with ease.

Downloads

405

Readme

Soroban Toolkit

Soroban Toolkit is a powerful library designed to simplify interactions with Stellar’s Soroban smart contracts. It provides tools for deploying, invoking, and managing smart contracts while handling complex blockchain interactions with ease.

Features

  • Smart Contract Deployment: Streamline the deployment of Soroban smart contracts.
  • Transaction Management: Simplify transaction creation and execution.
  • Address Book: Keep track of deployed contracts and WASM hashes.
  • Verbose Logging: Customizable verbosity levels (none, some, full) to tailor logs.
  • Airdrop Utility: Easy access to funding accounts on test networks.

Getting Started

Installation

  1. Clone the repository:
git clone https://github.com/paltalabs/soroban-toolkit.git
cd soroban-toolkit
  1. Install dependencies:
yarn install
  1. Link the package for local testing:
yarn link
  1. In your testing project:
yarn link <package_name>

Development Workflow

Watch Mode

Run the library in watch mode to rebuild changes automatically:

yarn start

Build for Production

Compile the library for distribution:

yarn build

Usage

Example Setup

To use the toolkit, initialize it with your network configuration and contract paths:

import { createToolkit, airdropAccount } from "<package_name>";

const toolkitLoader = createToolkit({
  adminSecret: process.env.ADMIN_SECRET_KEY!,
  contractPaths: {
  some_contract: "./target/wasm32-unknown-unknown/release/some_contract.wasm"
  },
  customNetworks: [
  {
    network: "standalone",
    friendbotUrl: "http://localhost:8000/friendbot",
    horizonRpcUrl: "http://localhost:8000",
    sorobanRpcUrl: "http://localhost:8000/soroban/rpc",
    networkPassphrase: "Standalone Network ; February 2017",
  },
  ],
  verbose: "full",
});

const toolkit = toolkitLoader.getNetworkToolkit("standalone");

await airdropAccount(toolkit, toolkit.admin);

const account = await toolkit.horizonRpc.loadAccount(toolkit.admin.publicKey());
console.log("Account details:", account);

Features and Modules

1. Toolkit Loader

createToolkit initializes the toolkit with your configuration:

const toolkitLoader = createToolkit({
  adminSecret: 'your_admin_secret',
  contractPaths: {
    contract_name: 'path_to_wasm_file',
  },
  customNetworks: [
    {
      network: 'standalone',
      friendbotUrl: 'http://localhost:8000/friendbot',
      horizonRpcUrl: 'http://localhost:8000',
      sorobanRpcUrl: 'http://localhost:8000/soroban/rpc',
      networkPassphrase: 'Standalone Network ; February 2017',
    },
  ],
  verbose: 'full',
});

2. Address Book

The toolkit integrates an AddressBook to manage deployed contracts:

toolkit.addressBook.setContractId('contractKey', 'contractId');
toolkit.addressBook.getContractId('contractKey'); // Returns the contract ID
toolkit.addressBook.listKeys(); // Lists all keys in the address book

3. Contract Deployment

Deploy and manage contracts:

await deploySorobanToken(toolkit, toolkit.admin);

4. Verbose Logging

Adjust verbosity during toolkit initialization:

  • none: No logs
  • some: Basic logs
  • full: Full details (e.g., XDRs, hashes)

Testing

Run tests with:

yarn test

Publishing to NPM

  1. Build the library:
yarn build
  1. Publish to NPM:
yarn publish

Directory Structure

src
├── config
│   ├── defaultNetworks.ts      # Default network configurations
│   ├── loader.ts               # Toolkit loader
│   └── toolkit.ts              # Toolkit core
├── index.ts                    # Entry point
├── managers
│   ├── contract.ts             # Contract deployment and management
│   ├── token.ts                # Token contract utilities
│   └── transaction.ts          # Transaction utilities
├── soroban_token.wasm          # Token contract WASM file
├── utils
│   ├── accountUtils.ts         # Account utilities (e.g., airdrop)
│   ├── addressBook.ts          # Address book for tracking deployed contracts
│   └── utils.ts                # General utilities

Additional Notes

  • Ensure soroban_token.wasm is included in your build. Use the rollup-plugin-copy configuration to copy it to dist.
  • Use yarn link for testing local changes and yarn unlink to remove links.