Pay delegate
Before implementing, learn about delegates here. Also see snow-delegate-template.
Specs
A contract can become a treasury pay delegate by adhering to ISNWPayDelegate3_1_1:
interface ISNWPayDelegate3_1_1 is IERC165 {
function didPay(SNWDidPayData3_1_1 calldata data) external payable;
}
When extending pay functionality with a delegate, the protocol will pass a SNWDidPayData3_1_1 to the didPay(...) function:
struct SNWDidPayData3_1_1 {
address payer;
uint256 projectId;
uint256 currentFundingCycleConfiguration;
SNWTokenAmount amount;
SNWTokenAmount forwardedAmount;
uint256 projectTokenCount;
address beneficiary;
bool preferClaimedTokens;
string memo;
bytes dataSourceMetadata;
bytes payerMetadata;
}
struct SNWTokenAmount {
address token;
uint256 value;
uint256 decimals;
uint256 currency;
}
The msg.sender to the delegate will be the payment terminal that facilitated the payment.
In payment terminals based on the SNWPayoutRedemptionPaymentTerminal3_1_1, such as SNWETHPaymentTerminal3_1_1's and SNWERC20PaymentTerminal3_1_1's, the pay delegate hook gets called after the project's tokens have been minted and distributed. View the docs.
Make sure to only allow trusted contracts to access the didPay(...) transaction.
Attaching
New delegate contracts should be deployed independently. Once deployed, its address can be returned from a data source hook. See how to build a data source for more.
Examples
Last updated
Was this helpful?