Skip to main content

Quick Start

PureFi offers various implementation options, particularly in terms of message signing, which you can either manage yourself or assign to us in terms of delegated signing.

note

Use this starting solution if you have a specific process around signing messages or you want to sign messages by yourself.

const { ethers } = require('ethers');
const { PureFI, AddressType } = require('@purefi/verifier-sdk');

const privateKey = '<private_key>';
const infuraApiKey = '<infura_api_key>';
const provider = new ethers.providers.InfuraProvider('homestead', infuraApiKey);
const wallet = new ethers.Wallet(privateKey, provider);

const addresses = [
{
address: '0xaAaAAAAaaAAaaaAAAaaaaaAAAAAaaAaAaAAAAaaa',
type: AddressType.WALLET,
},
{
address: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB',
type: AddressType.CONTRACT,
},
{
address: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC',
},
];

const message = JSON.stringify(addresses);

wallet
.signMessage(message)
.then((signature) => {
const purefiPayload = {
message,
signature,
};
return Promise.all([
PureFI.checkRisk(purefiPayload),
PureFI.downloadReport(purefiPayload),
]);
})
.then(([checkRiskResponse, downloadReportResponse]) => {
// process checkRiskResponse
checkRiskResponse.forEach((item) => {
const { address, riskScore, connections } = item;
console.log(address, riskScore, connections);
});

// process downloadReportResponse
const { buffer } = downloadReportResponse;
console.log(buffer);
})
.catch((error) => {
console.log(error);
});