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

selfkey-staking

v1.0.0

Published

Contracts that provide access to a marketplace based on the staking of KEY by participants

Downloads

2

Readme

staked-access

Contracts that provide access to a marketplace based on the staking of KEY by participants

  • developCircleCI codecov
  • masterCircleCI codecov

Overview

The StakedAccess contract provides the following functionality.

  1. Addresses are able to "stake" KEY into a smart contract, reserving an amount of tokens to indicate their willingness to participate in a particular Selfkey Marketplace. The tokens staked in this manner are kept "locked" for a set amount of time defined by the period attribute in the StakedAccess contract.

  2. Staked tokens can only be retrieved by the owner once the staking period has passed.

  3. For the staking functionality to work, owner (or ID-Wallet in our specific case) has to invoke approve(stakingContractAddress, stakingPrice) against on the token contract, passing the staking contract address and the corresponding staking price (including all decimal places). This is to allow the staking contract to spend funds (up to the limit set) on behalf of its owner.

StakedAccess Contract Interface

All staking functionality is implemented by the StakedAccess contract, which includes the following attributes:

Public State Variables

  • releaseDates[address]: A mapping from addresses to a datetime in Unix format, stating the moment at which the staking can be released.

  • price: The token amount to be staked. This number should include all 18 decimals (e.g. for a staking price of 30 KEY, price should be set to 30000000000000000000).

  • period: The minimum amount of seconds that each stake should be locked for before allowing token retrieval.

Public Functions

  • stake(): On invoking the stake() function, an mount of tokens defined by price will be deducted from the sender address balance, and be kept locked in the staking contract until the due staking period has been fulfilled. For the contract to be able to deduct tokens on behalf of the user, the user must previously call the approve method of the token contract.

  • retrieve(): If the corresponding release date for the sender has already been reached, the sender can invoke the retrieve() function, in which case the staked amount is sent back to the owner wallet.

  • hasStake(address): returns true if the given address has a stake above zero on the contract, otherwise it returns false.

  • setPrice(uint) (only owner): Staking price can be changed anytime by the contract owner.

  • setPeriod(uint) (only owner): Staking period can be changed anytime by the contract owner. This won't affect the release date of stakes already in place.

Events

  • KEYStaked(address by, uint amount): Emitted when an address has successfully staked an amount of KEY.

  • KEYRetrieved(address to, uint amount): Emitted when a KEY owner has released the tokens previously staked.

Development

The smart contracts are being implemented in Solidity 0.4.19.

Prerequisites

  • NodeJS, version 9.5+ (I use nvm to manage Node versions — brew install nvm.)
  • truffle, which is a comprehensive framework for Ethereum development. npm install -g truffle — this should install Truffle v4+. Check that with truffle version.
  • Access to the KYC_Chain Jira

Initialization

npm install

Testing

Standalone

npm test

or with code coverage

npm run test:cov

From within Truffle

Run the truffle development environment

truffle develop

then from the prompt you can run

compile
migrate
test

as well as other Truffle commands. See truffleframework.com for more.

Linting

We provide the following linting options

  • npm run lint:sol — to lint the Solidity files, and
  • npm run lint:js — to lint the Javascript.

Deployment

Deploy the contracts as follows

(TO DO)

Contributing

Please see the contributing notes.