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

@windingtree/trust-clue-lif-deposit

v0.2.0

Published

Trustworthiness clue for Winding Tree based on Líf deposited in a smart contract

Downloads

88

Readme

Winding Tree Trustworthiness Clue - Líf Deposit

Greenkeeper badge

Trustworthiness clue for Winding Tree based on a smart contract tracking Líf token deposits.

Installation

npm install @windingtree/trust-clue-lif-deposit
# or
git clone https://github.com/windingtree/trust-clue-lif-deposit
nvm install
npm install

Usage

This library is best used with @windingtree/wt-js-libs where it can be combined with other trust clues which can be used to determine a trust level towards an ORG.ID.

import Web3 from 'web3';
import { WtJsLibs } from '@windingtree/wt-js-libs';
import { TrustClueLifDeposit } from '@windingtree/trust-clue-lif-deposit';

const libs = WtJsLibs.createInstance({
  onChainDataOptions: {
    provider: 'http://localhost:8545',
  },
  trustClueOptions: {
    clues: {
      'lif-deposit': {
        options: {
          provider: 'http://localhost:8545',
          address: '0x...',
          interpret: (value) => {
            return value > 1000; // 1000 Lif limit
          }
        },
        create: async (options) => {
          const aa = new TrustClueLifDeposit(options);
        },
      },
    },
  },
});

To use this as a standalone package, you would do something like this:

import Web3 from 'web3';
import { TrustClueLifDeposit } from '@windingtree/trust-clue-lif-deposit';

const list = new TrustClueLifDeposit({
  // Web3 provider
  provider: 'http://localhost:8545',
  // Address of a deployed instance of LifDeposit contract
  address: '0x...',
  // interpret function - this allows you to do something with the raw
  // value returned by the clue during the interpretation. You can use
  // it to convert all clues to a boolean to easily work with multiple
  // clues in your software.
  interpret: (value) => {
    return value > 1000; // 1000 Lif limit
  }
});

Placing a deposit

To place a deposit you need an ethereum wallet and some LífToken. On test networks, you can get a supply from the faucet.

Next you need to approve token transfer to the deposit contract for a desired value:

let depositValue = web3.utils.toWei('10', 'wei');
await tokenContract.approve(depositContract.address, depositValue, {
  from: myAccount,
  gas: 6000000,
});

Then LifDeposit is able to make the transfer from your account to the deposit:

await depositContract.addDeposit(organizationAddress, depositValue, {
  from: myAccount,
  gas: 6000000,
});

Check to make sure:

await depositContract.getDepositValue(organizationAddress);

See an example in tests.

Deposit withdrawal

Deposit is available for withdrawal after a delay period. After using askForDepositWithdrawal the requested value is not counted towards the deposit value anymore. Each organization can have only one withdrawal request at a time, asking for a new withdrawal will overwrite the previous request.

await depositContract.askForDepositWithdrawal(organizationAddress, depositValue, {
  from: myAccount,
  gas: 600000,
});

Call withdrawDeposit to initiate a transfer to your account. It will throw if the delay period has not passed yet. Use getWithdrawalDelay to get current delay value.

await depositContract.withdrawDeposit(organizationAddress, depositValue, {
  from: myAccount,
  gas: 600000,
});

We do not expect to change the delay unless there is either

  • a significant demand from the community to change the current time period (~1 month)
  • a significant change in average Ethereum block time. This is expected in Casper.

LífToken

Deployment of this contract references LifToken on the corresponding network (e.g. mainnet, ropsten). To use LifToken in tests, deploy LifTokenTest instead. It contains a faucet allowing to get a supply of tokens. See tests for a full example.