Skip to content

Instantly share code, notes, and snippets.

import requests
import csv
API_URL = "https://api.merkl.xyz/v4/opportunities"
CHAIN_ID = 143
ITEMS_PER_PAGE = 100
CSV_PATH = "campaigns_report.csv"
@BaptistG
BaptistG / rewards.json
Last active November 14, 2025 16:19
Rewards json
{
"rewardToken": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
"rewards": {
"0x37305B1cD40574E4C5Ce33f8e8306Be057fD7341": {
"season1": {
"amount": "1000000000000000000",
"timestamp": "1741370722"
}
},
"0x38AAEF3782910bdd9eA3566C839788Af6FF9B200": {
@BaptistG
BaptistG / data_endpoint.json
Created November 14, 2025 14:33
Encompassing campaigns, data endpoint
{
"tvl": "0",
"apr": "0",
"opportunityName": "My very custom campaign running on Merkl"
}
import datetime
import requests
# Write a function to transform a timestamp into a date string in 'DD/MM/YYYY HH:MM' format
def timestamp_to_date(timestamp: int) -> str:
dt = datetime.datetime.fromtimestamp(timestamp)
return dt.strftime('%d/%m/%Y')
def get_unclaimed_rewards(campaign_id: int):
campaign_info_url = f"https://api.merkl.xyz/v4/campaigns/{campaign_id}"
import requests
import json
from web3 import Web3
import os
RPC_URL = "RPC"
CHAIN_ID = 130
CREATOR_ADDRESS = "0x0000000000000000000000000000000000000000"
CREATOR_ADDRESS_PRIVATE_KEY = "XXX"
@BaptistG
BaptistG / campaigns_to_csv.py
Created August 26, 2025 08:33
Export Merkl campaign to CSV
import requests
import csv
campaign_id = "0x..." # CampaignId (can be found in the advanced tab under an opportunity in the Merkl app)
chainId= 1 # ChainId (eg. 1 for Ethereum)
blacklist_addresses = [] # Addresses to exclude from the file
decimals_reward_token = 18 # Decimals of the reward token, it's 18 most of the time
def get_campaigns_rewards(chainId, campaignId, decimals_reward_token):
result = {}
@BaptistG
BaptistG / createMerklCampaign.py
Created July 30, 2025 16:49
Creating a Merkl campaign using python
import requests
import json
from web3 import Web3
RPC_URL = "RPC"
CHAIN_ID = 999
CREATOR_ADDRESS = "0xB0F6e8f4bE7CbCAD2FC107471e7F6C9d37e742Ef"
CREATOR_ADDRESS_PRIVATE_KEY = "XXX"
w3 = Web3(Web3.HTTPProvider(RPC_URL))
@BaptistG
BaptistG / veloratest.json
Last active June 4, 2025 12:47
Velora Test campaign
{
"tvl": "0",
"apr": "0",
"opportunityName": "Velora Trading Campaign - Week 1"
}
{
"Hanji HJLP Etherlink 0x1cd88fBD530281Ad6c639E2B897c4E239003A930": "12000000000000000000000000",
"Hanji XTZ/USDC Etherlink 0xd0bc067cf877f7b76ceb331891331d9e6acda1a7": "7212000000000000000000000",
"Hanji WETH/USDC Etherlink 0x65ea4dd7f789c71c0f57ed84b3bdc3062898d3cb": "7212000000000000000000000",
"Hanji WBTC/USDC Etherlink 0xbb6b01d94e3f6ebae8647cb56d544f57928ab758": "7212000000000000000000000",
"Iguana mTBILL/USDC Etherlink 0x643D7CF86262b287b8548e840b4081c1A1525355": "34300000000000000000000000",
"Iguana mBASIS/USDC Etherlink 0xc2AF49072611f63894F761c8a354419dD0486826": "34300000000000000000000000",
"Iguana USDC/USDT Etherlink 0x86456e2E2A203Da82E61ed34eF4137Fbe545f0DC": "29700000000000000000000000",
"Iguana WETH/WXTZ Etherlink 0x478F067b0Ed73d120BBcd8c6f4f33438FC483912": "12800000000000000000000000",
"Iguana XTZ/USDT Etherlink 0x508060A01f11d6a2Eb774B55aEba95931265E0cc": "12800000000000000000000000",
@BaptistG
BaptistG / campaign.py
Created January 22, 2025 14:09
ERC20CampaignWithBoost
import json
import requests
import base64
from eth_abi import encode
PoolChainId = 1
RewardsChainId = 1
BoostTokenChainId = 1
BoostMultiplicator = 3
campaign = {