Links

Installation & Setup

Prerequisites

  • Personal web3 provider url (Alchemy or other) if you need to use your own web3 provider instance to run a model during development.
  • Visual studio 2019+ installed for Windows users. For Mac OS X, we recommend Visual Studio Code.

Fork and Clone Repository

For the repository using Github

  1. 1.
    To fork the Credmark Models repository, first go to the credmark-models-py repository in Github.
Note: credmark-models-py is publically available, so anyone can see it, fork it, and contribute to it.
2. Fork the repository by clicking on Fork
You will be directed to Create a new Fork page
Give a name to your Repository and click on Create Fork.

Clone the new form using the CLI

# git clone https://github.com/<owner>/credmark-models
-py.git

Virtual Environment Setup

Setting up a virtual environment for your work isn't required but we highly recommend it. Following are instructions for both Conda and venv. Use the one you prefer.

Conda

  • Install Conda.
  • Create an environment named "cmf" with the system's default using the system's default version of Python:
conda create -y --name "cmf"
or
  • create it specifying a particular version of Python:
conda create -y --name "cmk" python="3.10"*
  • Install pip and other support packages in the Conda environment:
conda install -y --name cmk ipython jupyterlab nb_conda_kernels jupyterlab_code_formatter ipywidgetsNow, the credmarksdk has all the packages and programs that are required to create the correct Model according to the Credmark set of rules, so it is important that you call the credmarksdk before starting working on your Model.
  • Activate the environment and follow the CMK installation instructions below:
conda activate cmk

venv

The best place to create your venv environment is in the project directory you cloned.
Assuming your cwd is the one above the repository you've just cloned, create and activate your virtual environment:
cd credmark-models-py
python3 -m venv venv
source venv/bin/activate

Install Dependencies

Run:
# pip install -r requirements.txt
For development, you should also run:
# pip install -r requirements-dev.txt

Configure your environment

When using the CMF, we need two bits of information:
  1. 1.
    Your API key.
  2. 2.
    The URL of a blockchain node.

Getting an API key

In order to run models only in your local environment, you don't need an API key, but chances are you'll need one. You can purchase a DeFi API key on our website. If you're just exploring, don't worry, you get a 30 day free trial.

Getting a blockchain node URL

If you happen to be running a node of the chain you'll be working with, use that one. If not, you can rent one from Infura or Alchemy.
We've provided instructions for Infura below. Note that websites change often, so the screenshot may be out of date.

Setting the variables

You can set your environment variables in memory or in a configuration file.

Memory

This assumes a bash or similar shell
# export CREDMARK_API_KEY=<key>
# export CREDMARK_WEB3_PROVIDER_CHAIN_ID_<x>=<url>
'x' is the chain ID. For Ethereum mainnet, for example, the chain ID is 1. You should set a chain provider for every chain with which you'll be working.

Configuration File

The best place to put your configuration file is in the project root, i.e., credmark-models-py.
The file should be called ".env" and should contain the following:
CREDMARK_API_KEY=<key>
CREDMARK_WEB3_PROVIDER_CHAIN_ID_<x>=<url>

Getting an Infura node

Test your Setup

credmark-dev run chain.get-latest-block -j
Your output should look something like:
2022-10-14 22:49:32,092 - credmark.cmf.engine.context - INFO - Using latest block number 15746805
{
"slug": "chain.get-latest-block",
"version": "0.1",
"chainId": 1,
"blockNumber": 15746805,
"output": {
"blockNumber": 15747036,
"timestamp": 1665758807
},
"dependencies": {
"chain.get-latest-block": {
"0.1": 1
}
}
}