技能创建器
skill-creator
创建、改进和评估自定义技能,把专业流程转化为可重复使用的 AI 能力。
jb-pay-hook【数据与研究】Generate custom Juicebox V5 pay hooks from natural language specifications. Creates Solidity contracts implementing IJBPayHook and/or IJBRulesetDataHook with Foundry tests. First evaluates if off-the-shelf solutions (buyback hook, 721 hook, Revnet) fit the use case.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Generate custom pay hooks for Juicebox V5 projects based on natural language specifications.
Always evaluate if an off-the-shelf solution fits the user's needs:
| User Need | Recommended Solution |
|---|---|
| Token buybacks via Uniswap | Deploy nana-buyback-hook-v5 directly |
| Tiered NFT rewards on payment | Deploy nana-721-hook-v5 directly |
| Autonomous tokenized treasury | Deploy a Revnet via revnet-core-v5 |
| Revnet with NFT tiers | Use Tiered721RevnetDeployer |
| Revnet with custom pay hooks | Use PayHookRevnetDeployer |
If off-the-shelf solutions fit, guide the user to deploy them instead of generating custom code.
Pay hooks in V5 follow a two-stage pattern:
IJBRulesetDataHookIJBPayHookA contract can implement both interfaces (like the buyback hook) or just the pay hook.
struct JBAfterPayRecordedContext {
address payer; // Payment originator
uint256 projectId; // Project being paid
uint256 rulesetId; // Current ruleset ID
JBTokenAmount amount; // Payment amount
JBTokenAmount forwardedAmount; // Amount forwarded to hook
uint256 weight; // Token minting weight
uint256 newlyIssuedTokenCount; // Tokens minted
address beneficiary; // Token recipient
bytes hookMetadata; // Data from data hook
bytes payerMetadata; // Data from payer
}
Use when you only need to execute logic after payment without modifying minting behavior.
contract SimplePayHook is IJBPayHook, ERC165 {
function afterPayRecordedWith(JBAfterPayRecordedContext calldata context) external payable {
// Validate caller is a project terminal
// Execute custom logic
}
function supportsInterface(bytes4 interfaceId) public view override returns (bool) {
return interfaceId == type(IJBPayHook).interfaceId || super.supportsInterface(interfaceId);
}
}
Use when you need to modify weight, intercept funds, or control hook routing.
contract FullPayHook is IJBRulesetDataHook, IJBPayHook, ERC165 {
function beforePayRecordedWith(JBBeforePayRecordedContext calldata context)
external view returns (uint256 weight, JBPayHookSpecification[] memory hookSpecifications)
{
// Analyze payment, determine routing
// Return weight and hook specs
}
function afterPayRecordedWith(JBAfterPayRecordedContext calldata context) external payable {
// Execute with forwarded funds
}
function beforeCashOutRecordedWith(JBBeforeCashOutRecordedContext calldata context)
external view returns (uint256, uint256, uint256, JBCashOutHookSpecification[] memory)
{
// Pass through if not handling cash outs
return (context.ruleset.cashOutTaxRate, context.cashOutCount, context.totalSupply, new JBCashOutHookSpecification[](0));
}
function hasMintPermissionFor(uint256) external pure returns (bool) {
return false; // Only true if hook needs to mint
}
}
Use when the project needs to be autonomous with structured rules and delegated permissions.
Reference: revnet-core-v5 (REVDeployer)
Generate:
src/src/interfaces/ if neededtest/script/ if requestedUse Foundry project structure with forge-std.