From a8a9328cc11ded8f4c3a694e9afa62ac03c0fac7 Mon Sep 17 00:00:00 2001 From: Dmitry Yakimov Date: Fri, 2 Aug 2024 15:16:44 +0100 Subject: [PATCH] Ethereum: Delegation Tracking Section --- book/README.md | 14 +++--- book/SUMMARY.md | 1 + .../ethereum/delegation-tracking.md | 49 +++++++++++++++++++ .../ethereum/methods.md | 18 ++++++- .../ethereum/overview.md | 8 +++ book/ethereum-tutorial/3-staking.md | 9 ++++ packages/ethereum/src/staker.ts | 10 ++-- 7 files changed, 95 insertions(+), 14 deletions(-) create mode 100644 book/build-your-staking-dapp/ethereum/delegation-tracking.md diff --git a/book/README.md b/book/README.md index aa32393..5a2c6a5 100644 --- a/book/README.md +++ b/book/README.md @@ -240,7 +240,9 @@ const validatorAddress = CHORUS_ONE_ETHEREUM_VALIDATORS.ethereum.mevMaxVault const { tx } = await staker.buildStakeTx({ delegatorAddress, validatorAddress, - amount: '1' // 1 ETH + amount: '1', // 1 ETH + // Optional - Unique Ethereum address for tracking + referrer: '0xReferrerAddressHere' }) // Signing the transaction with Fireblocks @@ -576,11 +578,6 @@ console.log(status) // 'success' import { SubstrateStaker, RewardDestination, CHORUS_ONE_SUBSTRATE_VALIDATORS } from '@chorus-one/substrate' -import { FireblocksSigner } from '@chorus-one/signer-fireblocks' - -const signer = new FireblocksSigner({...}) -await signer.init() - const staker = new SubstrateStaker({ rpcUrl: 'wss://rpc.polkadot.io', denomMultiplier: 1000000000000, @@ -609,6 +606,11 @@ const { tx: nominateTx } = await staker.buildNominateTx({ // Signing the transactions with Fireblocks // ---------------------------------------- +import { FireblocksSigner } from '@chorus-one/signer-fireblocks' + +const signer = new FireblocksSigner({...}) +await signer.init() + const { signedTx: signedStakeTx } = await staker.sign({ signerAddress: delegatorAddress, tx: stakeTx diff --git a/book/SUMMARY.md b/book/SUMMARY.md index 52e32b9..d293a9a 100644 --- a/book/SUMMARY.md +++ b/book/SUMMARY.md @@ -13,6 +13,7 @@ - [Ethereum](build-your-staking-dapp/ethereum/README.md) - [Overview](build-your-staking-dapp/ethereum/overview.md) - [Methods](build-your-staking-dapp/ethereum/methods.md) + - [Delegation Tracking](build-your-staking-dapp/ethereum/delegation-tracking.md) - [NEAR](build-your-staking-dapp/near/README.md) - [Overview](build-your-staking-dapp/near/overview.md) - [Methods](build-your-staking-dapp/near/methods.md) diff --git a/book/build-your-staking-dapp/ethereum/delegation-tracking.md b/book/build-your-staking-dapp/ethereum/delegation-tracking.md new file mode 100644 index 0000000..50b3ee4 --- /dev/null +++ b/book/build-your-staking-dapp/ethereum/delegation-tracking.md @@ -0,0 +1,49 @@ +# Delegation Tracking + +## Introduction + +In today's competitive landscape, understanding the origin and impact of your staking transactions is important for maximizing marketing efforts and partnership strategies. Delegation tracking enables businesses to precisely attribute staking activities to specific campaigns, partners, or sources. By gaining invaluable insights into the performance of your marketing campaigns and partner engagements, you can ensure that your resources are directed towards the most effective initiatives and generate accurate revenue reports. This section will show you how to implement delegations tracking. + +## How It Works + +The `referrer` field in the SDK allows you to associate transactions with a specific Ethereum address, representing the source of the delegation or minting, such as a marketing campaign or integration partner. Including this field as a parameter in both the `buildStakeTx` and `buildMintTx` methods provides detailed insights and accurate attribution of delegations and minting transactions, tailored to your specific needs. + +{% hint style="info" %} + +To ensure precise tracking and management of transaction origins, it's important to use unique addresses for different customers or campaigns. Generate a unique Ethereum address for each referrer or use your own Ethereum address to track transactions. + +{% endhint %} + +### Example Usage + +Here's an example of how to use the `referrer` field when building a staking transaction: + +```javascript +const { tx } = await staker.buildStakeTx({ + delegatorAddress: '0x70aEe8a9099ebADB186C2D530F72CF5dC7FE6B30', + validatorAddress: '0xe6d8d8ac54461b1c5ed15740eee322043f696c08', + amount: '1', // 1 ETH + referrer: '0xReferrerAddressHere' // Unique Ethereum address for tracking +}) +``` + +And here's an example of how to use the `referrer` field when building a minting transaction: + +```javascript +const { tx } = await staker.buildMintTx({ + delegatorAddress: '0x70aEe8a9099ebADB186C2D530F72CF5dC7FE6B30', + validatorAddress: '0xe6d8d8ac54461b1c5ed15740eee322043f696c08', + amount: '1', // 1 osETH + referrer: '0xReferrerAddressHere' // Unique Ethereum address for tracking +}) +``` + +## Benefits for Your Business + +- Ensure accurate revenue tracking to the right partners or campaigns and provide clear revenue reports for different referral sources. +- Evaluate partner performance by tracking staking transaction volume and value, and measure campaign success by analyzing which referrers generate the most delegations. +- Track customer behavior and preferences to improve engagement strategies and implement retention strategies for high-value customers based on delegation data. + +## Conclusion + +Delegation tracking optimizes marketing strategies and partnerships by providing accurate attribution and insights into customer behavior. It also enables precise revenue reporting. Use delegation tracking to stay competitive and allocate resources effectively. \ No newline at end of file diff --git a/book/build-your-staking-dapp/ethereum/methods.md b/book/build-your-staking-dapp/ethereum/methods.md index f69aa24..dff8e1b 100644 --- a/book/build-your-staking-dapp/ethereum/methods.md +++ b/book/build-your-staking-dapp/ethereum/methods.md @@ -12,13 +12,20 @@ The `buildStakeTx` method helps you create a transaction for staking tokens with To build a staking transaction, you need to specify the amount to stake, the delegator's address (your wallet), and the validator's address where you want to stake your tokens. Optionally, you can also specify a referrer address for tracking purposes. +{% hint style="info" %} + +For more information on tracking and attributing staking transactions to specific sources, such as marketing campaigns or integration partners, refer to the [Delegation Tracking](./delegation-tracking.md) section. + +{% endhint %} + ### Example ```javascript const { tx } = await staker.buildStakeTx({ delegatorAddress: '0x70aEe8a9099ebADB186C2D530F72CF5dC7FE6B30', validatorAddress: '0xe6d8d8ac54461b1c5ed15740eee322043f696c08', - amount: '1' // 1 ETH + amount: '1', // 1 ETH + referrer: '0xReferrerAddressHere' // Unique Ethereum address for tracking }) ``` @@ -100,13 +107,20 @@ The `buildMintTx` method helps you create a transaction for minting shares (osET To build a minting transaction, you need to specify the amount of osETH to mint, the delegator's address, and the validator's address where you want to mint your shares. Optionally, you can also specify a referrer address for tracking purposes. +{% hint style="info" %} + +For more information on tracking and attributing minting transactions to specific sources, such as marketing campaigns or integration partners, refer to the [Delegation Tracking](./delegation-tracking.md) section. + +{% endhint %} + ### Example ```javascript const { tx } = await staker.buildMintTx({ delegatorAddress: '0x70aEe8a9099ebADB186C2D530F72CF5dC7FE6B30', validatorAddress: '0xe6d8d8ac54461b1c5ed15740eee322043f696c08', - amount: '1' // 1 osETH + amount: '1', // 1 osETH + referrer: '0xReferrerAddressHere' // Unique Ethereum address for tracking }) ``` diff --git a/book/build-your-staking-dapp/ethereum/overview.md b/book/build-your-staking-dapp/ethereum/overview.md index 1b24312..6f0ff9c 100644 --- a/book/build-your-staking-dapp/ethereum/overview.md +++ b/book/build-your-staking-dapp/ethereum/overview.md @@ -121,6 +121,14 @@ const { tx } = await staker.buildStakeTx({ }) ``` +{% hint style="info" %} + +**Delegation Tracking** + +For more information on tracking and attributing staking transactions to specific sources, such as marketing campaigns or integration partners, refer to the [Delegation Tracking](./delegation-tracking.md) section. + +{% endhint %} + ### Ensuring Correct Amount Format for Staking The `amount` parameter must be a string representing the amount of ETH to deposit. For example, `'1'` represents 1 ETH. diff --git a/book/ethereum-tutorial/3-staking.md b/book/ethereum-tutorial/3-staking.md index 57ef7fc..ec9b2ee 100644 --- a/book/ethereum-tutorial/3-staking.md +++ b/book/ethereum-tutorial/3-staking.md @@ -96,6 +96,15 @@ const stake = async ({ await walletClient.sendTransaction(request) } ``` +{% hint style="info" %} + +**Delegation Tracking** + +If you would like to learn how to track and attribute staking transactions to +specific sources, such as marketing campaigns or integration partners, refer to the [Delegation Tracking](../build-your-staking-dapp/ethereum/delegation-tracking.md) section. + +{% endhint %} + The `Transaction` object returned by `buildStakeTransaction` includes the following parameters: diff --git a/packages/ethereum/src/staker.ts b/packages/ethereum/src/staker.ts index 3b04de2..41594e1 100644 --- a/packages/ethereum/src/staker.ts +++ b/packages/ethereum/src/staker.ts @@ -77,9 +77,8 @@ export class EthereumStaker { * @param params.delegatorAddress - The delegator (wallet) address to stake from * @param params.validatorAddress - The validator (vault) address to stake with * @param params.amount - The amount to stake, specified in `ETH`. E.g. "1" - 1 ETH - * @param params.referrer - (Optional) The address of the referrer. This is used to track the origin of transactions, - * providing insights into which sources or campaigns are driving activity. This can be useful for analytics and - * optimizing user acquisition strategies + * @param params.referrer - (Optional) A unique Ethereum address representing the source of the delegation, such as a + * marketing campaign or integration partner. This allows precise tracking and management of transaction origins. * * @returns Returns a promise that resolves to an Ethereum staking transaction. */ @@ -168,9 +167,8 @@ export class EthereumStaker { * @param params.delegatorAddress - The delegator (wallet) address * @param params.validatorAddress - The validator (vault) address to mint shares for * @param params.amount - The amount to mint, specified in `osETH`. E.g. "1" - 1 osETH - * @param params.referrer - (Optional) The address of the referrer. This is used to track the origin of - * transactions, providing insights into which sources or campaigns are driving activity. This can be useful for - * analytics and optimizing user acquisition strategies. + * @param params.referrer - (Optional) A unique Ethereum address representing the source of the delegation, such as a + * marketing campaign or integration partner. This allows precise tracking and management of transaction origins. * * @returns Returns a promise that resolves to an Ethereum mint transaction. */