Creating a Token Claim using the Hedgey APIs

Reference: https://github.com/hedgey-finance/Locked_VestingTokenPlans/blob/master/contracts/Periphery/ClaimCampaigns.sol The Hedgey smart contract for token claims.

The token claim contract uses a merkle tree to efficiently manage many thousands of addresses and amounts that can claim.

This merkle tree can be created manually using something like the following library

https://github.com/OpenZeppelin/merkle-tree

Or the Hedgey API can be used, if the API is used a CSV file is uploaded and Hedgey will manage the process of creating the merkle tree and storing the proofs (which are needed for claiming).

Make a POST request to https://rk4p3mmjrretp4yiummnl4vpcy0fiwxw.lambda-url.us-east-1.on.aws the content type should multipart form data, this should include a uuid (generated by the client), the csv data, decimals (the number of decimals the token uses) and endDate (the date the token claim is to end)

The CSV file should contain a list with two columns: address and amount:

address,amount
0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2,0.1
0xBE0eB53F46cd790Cd13851d5EFf43D12404d33E8,0.1
0x40B38765696e3d5d8d9d834D8AaD4bB6e418E489,0.1
0x47ac0Fb4F2D84898e4D9E7b4DaB3C24507a6D503,0.1
0xDf9Eb223bAFBE5c5271415C75aeCD68C21fE3D7F,0.1
0xDf9Eb223bAFBE5c5271415C75aeCD68C21fE3D7F,0.1
0xAa9c3a194C9E78085260dfC7EAcFef51653412Bf,1
0xC9067B440f60A94170b9490c88d2efDBA1a7c536,0.1
0x169691e59538e80fa2a01adf5b21ded376730335,0.1
0xC622Cd2D887031526E4802d37Cba6E77f057211e,0.1

This endpoint will return the following response on success:

{
  "containsDuplicates":true,
  "totalAmount":"1900000000000000000",
  "userCount":9,
  "root":"0x25e627438b3031c6115d846cfa97c33aff869d5cc3a6aca20565f902f7e9eb8d"
}

Below is an example of using FormData to build up the request and post it.

const id = uuidv4();

const formData = new FormData();
formData.append('uuid', id);
if (!file) {
  throw new Error('No file provided');
}

formData.append('csv', file);
if (decimals) {
  formData.append('decimals', decimals.toString());
}

if (endDate) {
  formData.append('endDate', getUnixTime(new Date(endDate)).toString());
}

try {
  const response = await fetch(endpointURL, {
    method: 'POST',
    body: formData,
  });

  if (!response.ok) {
    throw new Error('Unable to verify recipient list from Campaign Verification service');
  }

When this request has been done the root can be used in the web3 call to create the token claim.

Last updated