Using the Hedgey APIs for Token Claims

Use these instructions to build your own claim button.

The simplest way to get started is to use the Hedgey Claims app to setup your token claim. Then you can use our API endpoint to pull the merkle tree proof and data to display the amount of tokens claimable, and format the proof and information required to create and send the on-chain transaction for your users to make their claim of tokens or vesting stream.

Once you have setup your claim, we will auto-generate a claim page for you. The claim page URL contains the unique UUID required by the API and the smart contract for making claims. This unique ID can be found in the URL or in the space for copying the claim page URL.

For example the id value will look something like fe48cfdd-5809-4bc1-a47f-1c526b36cf5f

The token claim product uses a merkle tree to compress the information to claim, as a result the wallet claiming needs a proof value. This proof value can be obtained by using an API.

The endpoint URL is

https://hibxjljwpk.execute-api.us-east-1.amazonaws.com/serverless_lambda_stage/proof

A post request should be made to this endpoint with the following JSON data.

{
	"address":<INSERT CLAIMANT WALLET ADDRESS>,
	"uuid":"fe48cfdd-5809-4bc1-a47f-1c526b36cf5f"
}

The uuid value is the id of the claim and the address is the address of the wallet that is making the claim.

Below is a response example, if the wallet can carry out a claim.

{
	"canClaim": true,
	"proof": [
	"0x1f14d0d899eb52d9467e3d3888cc2741d4d915ff13e29a1aac99dfcfea6a0d0f",
	"0x54ada740ae82a2249e2ce9827394e765937e62a128f25045605c255ea7d42f24",
	"0xbf3ee7814439a23ac477953252877c633372fe8c7fde8c0d2ece57a4eca3904f",
	"0x5db1bea240bf7d6de115167e18e2d88e070e79e859a326b6bf7b4e21947a8302"
	],
	"amount": "1000000000000000000"
}

Below is a response example, if the wallet cannot carry out a claim.

{
  "canClaim": false,
  "amount": "0"
}

Once the user has the proof value from the above call they can then make a web3 call using the wallet that is eligible to claim.

A stripped down version of the ABI required to make the call

[
	{
		inputs: [
			{
				internalType: 'bytes16',
				name: 'campaignId',
				type: 'bytes16',
			},
			{
				internalType: 'bytes32[]',
				name: 'proof',
				type: 'bytes32[]',
			},
			{
				internalType: 'uint256',
				name: 'claimAmount',
				type: 'uint256',
			},
		],
		name: 'claimTokens',
		outputs: [],
		stateMutability: 'nonpayable',
		type: 'function',
	}
]

campaignId: The uuid converted to a hex array.

proof: The proof string array retrieved from the endpoint.

claimAmount: The claim amount retrieved from the endpoint.

Converting the uuid to a hex array using viem and uuid

Step one, parse the uuid string into a byte array using parse

Step two, parse the byte array into a hex value.

import { parse } from 'uuid';
import { bytesToHex } from 'viem';

const bytesArray = parse('fe48cfdd-5809-4bc1-a47f-1c526b36cf5f');
const hexId = bytesToHex(bytesArray);

The hexId value can then be used in the contract call.

An example of calling this web3 method using viem:

const hash = await walletClient.writeContract({
  abi: claimCampaignAbi,
  address: contractAddress,
  functionName: 'claimTokens',
  args: [hexId, proof, amount],
  account: claimant,
  chain,
});

For AirVest and AirStream the wallet will receive a plan they can use to redeem locked tokens according to the configured schedule.

For AirClaim there is an option for the tokens to be transferred directly to the claimant.

Last updated