#account #buddy #link #transfer #system #reward #on-chain

buddy-link

用于与BuddyLink链上推荐系统交互的库

3 个版本 (破坏性)

0.3.0 2024年5月14日
0.2.0 2024年1月17日
0.1.0 2023年8月3日

#11 in #buddy

Download history 110/week @ 2024-05-09 21/week @ 2024-05-16 4/week @ 2024-05-23 1/week @ 2024-05-30

每月下载 162

MIT 许可证

650KB
786

以下是调用SPL SDK的示例

在这里,由签署者直接进行转账,如果您的“from account”由PDA拥有,则需要提供转账种子。

let cpi_context = CpiContext::new(
    buddy_link_program.to_account_info(),
    buddy_link::cpi::TransferCheckedGlobalOnlyReward {
        buddy_link_program: buddy_link_program.to_account_info(),
        authority: authority.to_account_info(),
        system_program: None,
        mint:  Some(mint.to_account_info()),
        token_program: Some(token_program.to_account_info()),
        from_token_account: Some(user_token_account.to_account_info()),
        referrer_token_account: Some(remaining_accounts[0].to_account_info()),
        global_referrer_treasury: referrer_treasury.to_account_info(),
        global_referrer_treasury_for_reward: referrer_treasury_for_reward.to_account_info(),
        referee_buddy_profile: buddy_profile.to_account_info(),
        referee_buddy: buddy.to_account_info(),
    },
);

buddy_link::cpi::transfer_checked_global_only_reward(
    cpi_context,
    amount_referral,
    & [],
);

以下是调用SOL SDK的示例

在这里,由签署者直接进行转账,如果您的“from account”由PDA拥有,则需要提供转账种子。

let cpi_context = CpiContext::new(
    buddy_link_program.to_account_info(),
    buddy_link::cpi::TransferCheckedGlobalOnlyReward {
        buddy_link_program: buddy_link_program.to_account_info(),
        authority: authority.to_account_info(),
        system_program: Some(system_program.to_account_info()),
        mint: None,
        token_program: None,
        from_token_account: None,
        referrer_token_account: None,
        global_referrer_treasury: referrer_treasury.to_account_info(),
        global_referrer_treasury_for_reward: referrer_treasury_for_reward.to_account_info(),
        referee_buddy_profile: buddy_profile.to_account_info(),
        referee_buddy: buddy.to_account_info(),
    },
);

buddy_link::cpi::transfer_checked_global_only_reward(
    cpi_context,
    amount_referral,
    &[],
)

如何测试

  1. yarn install
  2. amman start
  3. cargo test

依赖项

~18–27MB
~461K SLoC