Skip to content

Your referral link and earnings

Tested on BSC testnet before every release

This is an example. Every value in it (names, amounts, addresses) is there to show you how; change any of them to suit you. It’s referral-link.mjs, exactly as our tests run it on testnet. Point it at testnet with MM_API, or leave it for mainnet.

referral-link.mjs
// Your referral link, and what it has earned. Share it: every trade through it
// pays you a share of the fee inside the trade, and wallets it brings pay you a
// lifetime share every week.
// ADDRESS=0x… node referral-link.mjs
const API = process.env.MM_API ?? 'https://marketmayhem.co/api/v1';
const address = process.env.ADDRESS;
const res = await fetch(`${API}/referrals/${address}`);
const me = await res.json();
if (!res.ok) throw new Error(`${me.error.code}: ${me.error.message}`);
if (!me.eligible) console.log('Not earning yet: register once (free) with GET /referrals/challenge and POST /referrals/register.');
console.log(`your link: ${me.links.site}`);
console.log(`a token page: ${me.links.token.replace('{token}', '0x…')}`);
console.log(`earned, all time: $${me.instant.earnings.all.usd.toFixed(2)} inside trades; ${me.lifetime.referred} wallets referred for life`);
console.log('RESULT', JSON.stringify({ link: me.links.site, eligible: me.eligible }));