Skip to content
Trustworthiness clue for Winding Tree based on a smart contract registered Líf token deposits
JavaScript Solidity Shell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
contracts
docs
management
migrations
src
test
.babelrc
.eslintrc.js
.gitattributes
.gitignore
.npmignore
.nvmrc
.solhint.json
.solhintignore
.travis.yml
LICENSE
README.md
package-lock.json
package.json
truffle.js
webpack.config.js

README.md

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.

You can’t perform that action at this time.