Claim

Struct Claim 

Source
#[repr(C)]
pub struct Claim { pub epoch: [u8; 8], pub payment_proof_length: u8, pub seal_proof_length: u8, pub participant_type: u8, pub has_social: u8, pub _padding: [u8; 4], }
Expand description

Claim instruction data for Dual Merkle Tree system with optional social rewards.

This instruction allows users to claim rewards based on their activity contributions for a specific epoch using the Dual Merkle Tree verification system. The claim is verified using both a payment merkle proof and a seal merkle proof, with the payment root embedded in the seal proof data for explicit verification. Optionally, users can also claim social marketing rewards for the same epoch if they have verified social media engagement.

§Dual Merkle Verification

  1. Payment Proof: Verifies user’s activity within the epoch
  2. Seal Proof: Verifies the payment merkle root is authentic (from oracle)
  3. Payment Root: Embedded in seal proof data for explicit verification
  4. Dual Verification: Both proofs must pass for a valid claim

§Social Rewards Support

  • Payment-First: Social rewards require payment activity verification
  • Oracle Verification: Social posts must be verified by oracle signature
  • Optional: Users can choose payment-only or payment+social claims
  • Unified: Single instruction supports both reward types

§Data Structure

The instruction uses a hybrid approach with fixed-size fields followed by variable-length data:

// Fixed-size struct (23 bytes)
struct Claim {
    epoch: [u8; 8],              // 8 bytes - Epoch number for the claim
    payment_proof_length: u8,    // 1 byte - Length of payment merkle path
    seal_proof_length: u8,       // 1 byte - Length of seal merkle path
    participant_type: u8,        // 1 byte - 0 for customer, 1 for merchant
    has_social: u8,              // 1 byte - 0=payment only, 1=has social data
    _padding: [u8; 4],           // 4 bytes - Padding for alignment
}

// Variable-size additional data (appended after fixed struct)
// participant_data: DailyParticipantData  // Variable size - Actual participant data for verification
// payment_proof: Vec<[u8; 32]>  // payment_proof_length * 32 bytes
// payment_indices: Vec<u8>      // payment_proof_length * 1 byte
// seal_proof: Vec<[u8; 32]>     // seal_proof_length * 32 bytes
// seal_indices: Vec<u8>         // seal_proof_length * 1 byte
// payment_root: [u8; 32]        // Payment root (embedded in seal proof data)
// epoch_data: EpochClaimData    // Epoch-specific data for accurate historical reward calculation
// social_data: SocialClaimData  // Optional: only if has_social = 1

§Security Features

  • Payment Proof: Ensures claim data integrity within an epoch
  • Seal Proof: Ensures payment merkle root is authentic (from oracle)
  • Payment Root: Explicitly provided for verification
  • Dual Verification: Both proofs must pass for a valid claim
  • Oracle Verification: Social posts verified by authorized oracle
  • Unlimited History: No storage limits for historical claims

§On-Chain Reward Calculation

The reward amount is calculated on-chain using the transparent formula: payment_reward = (activity_count * customer_reward_pool) / total_customer_activity social_reward = base_reward_per_post * (1 + engagement_score / 1000)

Where:

  • activity_count is extracted from the payment merkle proof
  • customer_reward_pool and total_customer_activity are read from the Snapshot
  • base_reward_per_post and engagement data come from social verification

§Historical Claims Support

For historical epoch claims, the instruction includes epoch-specific data:

  • Current Epoch: Uses on-chain snapshot data for reward calculation
  • Historical Epochs: Uses epoch-specific data embedded in the instruction
  • No On-Chain Storage: Historical data comes with the claim instruction
  • Accurate Rewards: Users get correct rewards for historical activity

This enables the Dual Merkle Tree’s promise of unlimited claim history without requiring expensive on-chain storage of historical snapshots.

§Off-Chain Development

When building claim instructions off-chain:

  1. Set payment_proof_length and seal_proof_length to actual path lengths
  2. Set has_social to 1 if social data is included, 0 otherwise
  3. Append payment proof data after the fixed struct
  4. Append payment indices data (1 = right, 0 = left)
  5. Append seal proof data
  6. Append seal indices data (1 = right, 0 = left)
  7. Append payment root data (32 bytes)
  8. Append epoch-specific data (EpochClaimData) for accurate historical calculations
  9. If has_social = 1, append SocialClaimData
  10. Verify total instruction size doesn’t exceed Solana limits

See DUAL_MERKLE_TREE_DESIGN.md for detailed implementation examples.

Fields§

§epoch: [u8; 8]§payment_proof_length: u8§seal_proof_length: u8§participant_type: u8§has_social: u8§_padding: [u8; 4]

Implementations§

Source§

impl Claim

Source

pub fn try_from_bytes(data: &[u8]) -> Result<&Self, ProgramError>

Source§

impl Claim

Source

pub fn to_bytes(&self) -> Vec<u8>

Trait Implementations§

Source§

impl Clone for Claim

Source§

fn clone(&self) -> Claim

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Claim

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Discriminator for Claim

Source§

impl Zeroable for Claim

Source§

fn zeroed() -> Self

Source§

impl Copy for Claim

Source§

impl Pod for Claim

Auto Trait Implementations§

§

impl Freeze for Claim

§

impl RefUnwindSafe for Claim

§

impl Send for Claim

§

impl Sync for Claim

§

impl Unpin for Claim

§

impl UnwindSafe for Claim

Blanket Implementations§

Source§

impl<T> AccountDeserialize for T
where T: Discriminator + Pod,

Source§

impl<T> AccountHeaderDeserialize for T
where T: Discriminator + Pod,

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Az for T

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<T> CheckedBitPattern for T
where T: AnyBitPattern,

Source§

type Bits = T

Self must have the same layout as the specified Bits except for the possible invalid bit patterns being checked during is_valid_bit_pattern.
Source§

fn is_valid_bit_pattern(_bits: &T) -> bool

If this function returns true, then it must be valid to reinterpret bits as &Self.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<Src, Dst> LosslessTryInto<Dst> for Src
where Dst: LosslessTryFrom<Src>,

Source§

fn lossless_try_into(self) -> Option<Dst>

Performs the conversion.
Source§

impl<Src, Dst> LossyInto<Dst> for Src
where Dst: LossyFrom<Src>,

Source§

fn lossy_into(self) -> Dst

Performs the conversion.
Source§

impl<T> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> AnyBitPattern for T
where T: Pod,

Source§

impl<T> NoUninit for T
where T: Pod,