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

@tokenysolutions/trex-compliance

v1.2.4

Published

Generate and manage TREX compliance contracts

Downloads

16

Readme

TREX Compliance Contracts

Get Started

Installation

  • Install package npm i @tokenysolutions/trex-compliance
  • If you plan to use compilation features, you must install solc as well (solc is a peer dependency, version 0.7.3 or above): npm i solc

Generate and compile a Compliance contract

  • Require package in you code base:
    const { Compliance, Features } = require('@tokenysolutions/trex-compliance');
  • Create a new Compliance object and define the base features you wish to use:
    const compliance = Compliance.createWithFeatures({
     features: [Features.CountryRestrictions, Features.DayMonthLimits],
     name: 'MySuperCompliance'
    });
  • Generate the contract code:
    await compliance.generate();
    
    console.log(compliance.contract);
  • Compile the contract with solc:
    await compliance.compile();
    
    console.log(compliance.compiled);

Example with Ethers

const path = require('path');
const { promises: fs } = require('fs');

const { Compliance, Features } = require('@tokenysolutions/trex-compliance');
const ethers = require('ethers');

(async () => {
  const compliance = Compliance.createWithFeatures({
    features: [Features.CountryRestrictions, Features.DayMonthLimits],
    name: 'MySuperCompliance',
  });

  await compliance.generate();
  await fs.writeFile(path.join(__dirname, 'MySuperCompliance.sol'), compliance.contract);

  await compliance.compile();
  await fs.writeFile(path.join(__dirname, 'MySuperCompliance.json'), JSON.stringify(compliance.compiled));

  const provider = new ethers.providers.JsonRpcProvider('http://localhost:8545');
  const signer = new ethers.Wallet('0xb2f04239d862961f94f36b4508955e95c9028e2738e1d7eaf1910bac739ff7da', provider);

  const factory = new ethers.ContractFactory(compliance.compiled.abi, compliance.compiled.evm.bytecode, signer);
  const contract = await factory.deploy();
  await contract.deployed();

  console.log(contract.address);
})();

Load an existing compliance contract

Contracts Development

Compliance LimitsDMAndCountryRestrictions uses blockchain technology to limits transactions on T-REX Tokens through smart contract code on the Ethereum blockchain.

LimitsDMAndCountryRestrictions Contract is built on the Ethereum blockchain and uses T-REX Ethereum smart contracts to apply restrictions based on daily and monthly limits, and country.

Prerequisites

  • IdentityStorage: address, IdentityRegistryStorage smart contracts linked to the Compliance Contract. ⚠️ Must be deployed first

Restrictions

  • Countries: uint16, numeric ISO 3166-1 of the country restricted
  • DailyLimits: uint256, amount of tokens allowed to be transferred daily.
  • MonthlyLim: uint256, amount of tokens allowed to be transferred monthly.

Some important functions

  • canTransfer: Tokens transfers are submitted to this function to check if Compliance policies have been followed.
  • addTokenAgent: Allow an agent to bypass daily and monthly restrictions, but it will still be impossible for the receiver to receive tokens if it's from an restricted country.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Requirements

Node >= v10

Installing

Firstly, you need to clone this repo. You can do so by downloading the repo as a zip and unpacking or using the following git command

git clone https://github.com/tokenyICO/trex-compliance.git

Now, It's time to install the dependencies. Enter the NexusMutual directory and use

npm install

Make sure you have truffle installed globally, if not run

npm install -g truffle

We need to compile the contracts before deploying. We'll be using truffle for that (You can use Remix or solc directly).

npm run build

Now, You should start a private network on port 8545 using Ganache-cli or something similar. To run the local network

npm run test

If you want, you can run the coverage test cases using

npm run coverge