AlphaCapture Protocol
  • Getting Started
    • Overview
    • Use Cases
  • Basic Concepts
    • Proof of Performance
      • Proof of Idea
      • Proof of Trade
    • Pricing
      • Stop Losses
      • Supported Assets
    • Access Control
    • zkSubscription
      • Marketplaces
    • Verification
    • FAQs
  • SDK Reference
    • Installation
    • Strategies
      • Retrieving Strategies
        • My Strategies
        • Accessible Strategies
        • All Strategies
        • Creator Strategies
      • Get Strategy (Signal)
      • Get Strategy (Rebalance)
        • Get Rebalances
        • Get Rebalance (Single)
        • Get Current Portfolio
    • Ideas
      • Retrieving Ideas
      • Creating Ideas
        • Proof of Idea
        • Proof of Trade
        • Estimated Costs
        • Asset Price Check
      • Adjusting Idea
      • Closing Ideas
        • Proof of Idea
        • Proof of Trade
      • Share of Token
      • Miscellaneous
  • D2 Execution
    • Overview
Powered by GitBook
On this page
  • Install the AlphaCapture SDK
  • Install External Dependencies (Required)
  • Initial Setup
  • Configure Keys
  • Configure Chain
  • Initialise SDK
  • Ready to go...
  1. SDK Reference

Installation

PreviousFAQsNextStrategies

Last updated 1 year ago

The AlphaCapture Protocol is currently in the process of being upgraded to use the Lit Protocol Mainnet (Habanero).

The AlphaCapture Protocol (previously IXily) SDK allows the creation and retrieval of Investment Ideas and Strategies, together with supporting methods for Access Control.

There are two SDKs, one intended for server side use such as algorithmic creation of ideas and a second for use in dApps, primarily for the display of ideas.

Please ensure Node >v18.x.x installed.

Install the AlphaCapture SDK

npm i @ixily/activ
npm i @ixily/activ-web

Install External Dependencies (Required)

Lit Protocol

Lit Protocol is used for Investment Idea NFT encryption/decryption and access control. See more at

npm i @lit-protocol/lit-node-client-nodejs@2.1.123

SIWE (Sign In With Ethereum)

npm i siwe

JIMP (Javascript Image Manipulation)

JIMP is used to support the processing of images that are associated with the creator's profile and/or with the asset created.

npm i jimp

Initial Setup

Import the required libraries.

import { CacheNodeStorageModule, LitNodeProviderModule } from "@ixily/activ/dist/sdk";

import {
  SDK,
  CONTRACT,
} from "@ixily/activ";

import v4 = SDK.v4;
import CI = CONTRACT.CONTRACT_INTERFACES;

import { EnvModule } from "@ixily/activ/dist/sdk/activ-v4";

export type NetworkType = 'amoy' | 'polygon';

const {ActivV4Module} = v4;
const activ = ActivV4Module;

Configure Keys

Wallet

Please specify the wallet to create Investment Ideas (or that which has access to Ideas) and ensure it is sufficiently funded if creating Ideas (with MATIC).

  const PRIVATE_KEY = 'your_private_wallet_key';

IPFS Storage

Supplementary Investment Idea data, such as detailed pricing data, is stored on IPFS. Please provide your own key to store the data.

  const nftStorageKey = 'your_nft_storage_key';

Configure Chain

Currently the Polygon (PoS) Mainnet and Amoy Testnet are supported.

const POLYGON_CONFIG: v4.IActivConfig = {
  defaultBlockchainNetwork: 'polygon',
  defaultContract: 'v4',
  web3AuthorizationOptions: {
    userWalletPrivateKey: PRIVATE_KEY,
  },
  litConfig: {
      litProvider: LitNodeProviderModule,
      mock: false,
  },
  nftStorageKey,
  mockNftStorage: false,
  skipPricingSignature: false,
  ipfsProxyEnabled: true,
  showLogsToDebug: true,
  cacheStorageConfig: {
      isBrowser: false,
      module: CacheNodeStorageModule,
      dbParams: {
          provider: 'none',
      }
  }
};

const AMOY_CONFIG: v4.IActivConfig = {
  defaultBlockchainNetwork: 'amoy',
  defaultContract: 'v4',
  web3AuthorizationOptions: {
    userWalletPrivateKey: PRIVATE_KEY,
  },
  litConfig: {
      litProvider: LitNodeProviderModule,
      mock: false,
  },
  nftStorageKey,
  mockNftStorage: false,
  skipPricingSignature: false,
  ipfsProxyEnabled: true,
  showLogsToDebug: true,
  cacheStorageConfig: {
      isBrowser: false,
      module: CacheNodeStorageModule,
      dbParams: {
          provider: 'none',
      }
  }
};

const state = {
    configured: {
        amoy: false as boolean,
        polygon: false as boolean,
    },
    instance: {
        amoy: (null as any) as string,
        polygon: (null as any) as string,
    },
    privateKey: {
        amoy: (null as any) as string,
        polygon: (null as any) as string,
    }
}

Cache Storage Configuration

Requesting content directly from chain can be slow, particularly as Ideas need to be decrypted. There are several options to cache data using standard tools such as Redis. If you are considering implementing a cache, please contact us for further details.

Initialise SDK

export const getActiv = async (
  network: NetworkType = 'polygon'
): Promise<typeof activ> => {
  if (!state.configured[network]) {

      const initObj = {
          LitJsSdkInstance: LitJsSdk,
          SiweInstance: Siwe,
          backendWalletPrivateKey: '',
      }

      // NOTE: maybe each account have a differents private keys, for this reason we are adding the set (PRIVATE_KEY) multiples time

      switch (network) {
          case 'amoy':
              initObj.backendWalletPrivateKey = PRIVATE_KEY;
              await (LitNodeProviderModule as any).init(initObj);
              await v4.ImagesModule.init({ JimpInstance: Jimp });
              await EnvModule.set('isProd', false);
              await activ.config(AMOY_CONFIG);
              break;
          case 'polygon':
              initObj.backendWalletPrivateKey = PRIVATE_KEY;
              await (LitNodeProviderModule as any).init(initObj);
              await v4.ImagesModule.init({ JimpInstance: Jimp });
              await EnvModule.set('isProd', true);
              await activ.config(POLYGON_CONFIG);
              break;
      }

      (state as any).configured[network] = true;
      (state as any).instance[network] = activ;
      (state as any).privateKey[network] = initObj.backendWalletPrivateKey;      
  };

  const networkChainObj = {
      amoy: 'amoy',
      polygon: 'polygon',
  };

  await activ.selectChainContract(networkChainObj[network], 'v4', {
      userWalletPrivateKey: state.privateKey[network],
  })

  return activ
}

Ready to go...

You should now be able to connect to a network and view the SDK contract.

const activ = await getActiv();
console.log('View contract', activ);

const version = await activ.getVersion();
console.log('SDK version', version);

Keys can be created at:

https://litprotocol.com/
https://nft.storage