@tokenysolutions/trex-compliance
TypeScript icon, indicating that this package has built-in type declarations

1.2.4 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i @tokenysolutions/trex-compliance

Weekly Downloads

12

Version

1.2.4

License

GPL-3.0-or-later

Unpacked Size

130 kB

Total Files

25

Last publish

Collaborators

  • nakasar
  • intech-kevin