Skip to content

Commit

Permalink
Ethereum: Delegation Tracking Section
Browse files Browse the repository at this point in the history
  • Loading branch information
welldan97 committed Aug 2, 2024
1 parent 7b47f2c commit a8a9328
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 14 deletions.
14 changes: 8 additions & 6 deletions book/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions book/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
49 changes: 49 additions & 0 deletions book/build-your-staking-dapp/ethereum/delegation-tracking.md
Original file line number Diff line number Diff line change
@@ -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.
18 changes: 16 additions & 2 deletions book/build-your-staking-dapp/ethereum/methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
```

Expand Down Expand Up @@ -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
})
```

Expand Down
8 changes: 8 additions & 0 deletions book/build-your-staking-dapp/ethereum/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
9 changes: 9 additions & 0 deletions book/ethereum-tutorial/3-staking.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
10 changes: 4 additions & 6 deletions packages/ethereum/src/staker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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.
*/
Expand Down

0 comments on commit a8a9328

Please sign in to comment.