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

parkingsv-contract

v0.0.26

Published

ParkingSV library

Downloads

129

Readme

sCrypt Project Boilerplate

Guide

sCrypt is a high-level programming language for writing smart contracts on Bitcoin SV. This project provides examples to help developers learn and integrate sCrypt smart contracts to their Javascript-based projects. Our recommended procedure of developing smart contract based applications is as follows:

  1. Contract Development and Test

The sCrypt Visual Studio Extension is a tool for developers to write, test, and debug sCrypt smart contracts.

  1. Contract Integration and Application Launch

After developing and unit testing the smart contracts, the next step is to integrate them into your application which is written in other languages such as Javascript or Python. Integration tests should be run on Bitcoin SV Testnet or Scaling Test Network(STN) before launching the application to the public on mainnet.

Quickstart

npm install
npm test

Directory layout

Prepare

Before trying to run an example, you should have the contract been compiled to produce a description json file, which would be used for building contract class. This could be done automatically by running a daemon process with command npm run watch. It will monit contract files' change and compile it when necessary. All generated description files are located at tests/fixture/autoGen. Make sure it's up to date with the contract before running any test.

How to write test for a sCrypt contract

The major steps to write a sCrypt test are exemplified by tests/demo.scrypttest.js.

  1. Install and import / require scryptlib libary, which is a javascript SDK for integrating sCrypt smart contract.
npm install scryptlib
import { buildContractClass } from 'scryptlib';
  1. Use the imported function buildContractClass to get a reflected contract, which has same properties and methods as defined in the specified sCrypt contract.
const Demo = buildContractClass(loadDesc('demo_desc.json'));

Note that demo_desc.json is the description file name of the compiled contract, which will be generated automatically if you run npm run watch and its name follows the rule $contractName_desc.json.

  1. Initialize the contract.
demo = new Demo(4, 7);
  1. Write tests for the instantiated contract as you would do in Javascript.
expect(demo.unlock(4 + 7).verify()).to.equal(true);
expect(() => { demo.unlock(4 + 6).verify() }).to.throws(/failed to verify/);

How to run tests locally

Run using sCrypt Extension

Run unit tests file within the editor/explorer context menu.

Screenshot

Note: The test files must be suffixed by .scrypttest.js or .scrypttest.ts, otherwise the "Run sCrypt Test" option would not appear in the menu.

Run from console

Tests could also be run from the console by executing npm test, just like regular Javascript/TypeScript tests.

How to run examples on testnet

When your tests succeed locally, you can run them on testnet.

  1. Provide a private key with funds in privateKey.js
const key = '$YOUR_PRIVATE_KEY_HERE'
  1. Run an example file on testnet by commands like node deployments/demo.js, and the output would appear in the console:
locking txid:      8d58ff9067f5fa893b5c695179559e108ebf850d0ce4fd1e42bc872417ffd424
unlocking txid:    c60b57e93551a6c52282801130649c6a97edcca5d2b28b8b4ae2afe0ee59bf79
Succeeded on testnet