Getting Started

The Getting Started section provides instructions for developers to start using the Molecule Protocol. It includes installation and setup instructions for the Molecule Protocol and a quick start guide

Installation and setup instructions

General AML Molecule contract

Molecule Protocol provides two options for installation and setup. The first option is to use the already deployed General AML (Anti-Money Laundering) Molecule Controller smart contract, which is regularly updated by the Molecule oracle. This smart contract has a check() function that takes an Ethereum address and a region ID array (country code as per M49 code UN statistics) as input parameters. It returns true if the account/address is not sanctioned under any of these input IDs, and false if the account is sanctioned under any of the IDs.It also has a check() that takes the Ethereum address as input and will check the address sanction status against a preset list of country codes, users can use either of these two to check the status of an address.

import "@moleculeprotocol/molecule-core/src/v2/interfaces/IMoleculeController.sol";

contract MyContract { 
  safeTransfer(address _to) {
    require(IMoleculeController(_molecule_address).check(_to), "MyContract: access denied.");
    // implementation
  }
}

The second option is to use the Molecule Smart Contract template and deploy your own Controller (i.e. Molecule Controller Smart Contract) and integrate several Logic contracts, such as MoleculeLogicList or MoleculeLogicNFT, to that controller. This allows for more customised rule engines for your specific use case. The IMoleculeController interface can be imported into your smart contract, and an instance of the MoleculeController smart contract can be created to call the check function inside a require statement to allow access to functions inside the smart contract.

Deploying a Custom Controller Smart Contract:

  1. Create your own Controller smart contract using the MoleculeController template.

  2. Deploy the Controller smart contract to the EVM network.

  3. Deploy the Logic* Contracts to the EVM network.

  4. Integrate the Logic* contracts for the specific use case, such as MoleculeLogicList or MoleculeLogicNFT onto Molecule Controller smart contract.

  5. Import the interface for your custom controller smart contract into your DApp or smart contract code.

  6. Create an instance of your custom controller smart contract.

  7. Call the check function with appropriate input parameters to perform the desired compliance checks.

pragma solidity ^0.8.0;

import "@moleculeprotocol/molecule-core/src/v2/interfaces/IMoleculeController.sol";
import "./MyCustomController.sol";

contract MyContract {
    MyCustomController public myCustomController;
    IMoleculeController public moleculeAddress;
    uint[] public regionalIds;

    constructor(MyCustomController _myCustomController, IMoleculeController _moleculeAddress) {
        myCustomController = _myCustomController;
        moleculeAddress = _moleculeAddress;
    }

    function addRegionalId(uint _regionalId) external {
        regionalIds.push(_regionalId);
    }

    function myFunction() external {
        require(moleculeAddress.check(regionalIds, msg.sender), "Address is sanctioned.");
        require(myCustomController.check(msg.sender), "Address is not authorized.");
        // Access allowed to function code here
    }
}

Quick start guide

Using the General Sanction List:

To use the General Sanction List provided by Molecule, import the IMoleculeController.sol interface into your smart contract.

Create an instance of the General sanctions MoleculeController smart contract using the below smart contracts

Call the check() function on the MoleculeController smart contract with the regional ID array uint as the first parameter and ethereum address you want to check as the second parameter. Or you can use the preset list by passing the ethereum address only

Steps

  1. Import the IMoleculeController interface into your smart contract.

  2. Create an instance of the MoleculeController smart contract.

  3. Call the check function inside a require statement to ensure the address is not sanctioned.

  4. Allow access to your functions inside the smart contract.

pragma solidity ^0.8.17;

import "@moleculeprotocol/molecule-core/src/v2/interfaces/IMoleculeController.sol";

contract MyContract {
    IMoleculeController public moleculeController;

    constructor(IMoleculeAddress _moleculeController) {
        moleculeController = _moleculeController;
    }

    function myFunction() external {
        // 840 - code for US sanction list 
        require(moleculeController.check([840],msg.sender), "Sender is sanctioned.");
        // Access allowed to function code here
    }
    function mySecondFunction() external {
        // use preset list 
        require(moleculeController.check(msg.sender), "Sender is sanctioned.");
        // Access allowed to function code here
    }
}

Last updated