Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support "Pay What You Want" Collects #4865

Open
iPaulPro opened this issue Apr 24, 2024 · 15 comments
Open

Support "Pay What You Want" Collects #4865

iPaulPro opened this issue Apr 24, 2024 · 15 comments
Labels

Comments

@iPaulPro
Copy link
Collaborator

iPaulPro commented Apr 24, 2024

Summary

I have created a new type of Collect Module that allows users to "pay what you want". This affords collectors the ability to use any denomination of any ERC-20 token to collect a publication.

Mainnet: 0x7fbD7496CaE2DAcad7a62350DA8488E31eC026eA

Testnet: 0x3d06AA6ca4FC7eE0D5581B85CB52CA7714175e43

Notes

  • This is a Collect Module, NOT a standalone Open Action Module. It is meant to be used with the core CollectPublicationAction module.
  • The publication author can optionally specify a desired currency and price floor.

Implement

The init calldata is almost identical to MultirecipientFeeCollectModule :

[
  { type: "uint160", name: "amountFloor" },
  { type: "uint96", name: "collectLimit" },
  { type: "address", name: "currency" },
  { type: "uint16", name: "referralFee" },
  { type: "bool", name: "followerOnly" },
  { type: "uint72", name: "endTimestamp" },
  {
    type: "tuple(address,uint16)[5]",
    name: "recipients",
    components: [
      { type: "address", name: "recipient" },
      { type: "uint16", name: "split" },
    ],
  },
]

and the process calldata:

[
  { type: "address", name: "currency" },
  { type: "uint256", name: "amount" },
]

CollectPublicationAction

This Collect Module is registered with the CollectPublicationAction (the same module used with SimpleFeeCollectModule and MultirecipientFeeCollectModule). The init calldata is just the Collect Module address and the encoded collect init calldata (above):

[
    { type: 'address', name: 'collectModule' },
    { type: 'bytes', name: 'collectModuleInitData' },
]

And to process:

[
  { type: "address", name: "collectNftRecipient" },
  { type: "bytes", name: "collectData" },
]

Testnet

I have completed a successful act call with the PWYW module: https://amoy.polygonscan.com/tx/0xceff77ea12000814d07d3e8bc2b0218ae6ff91e286a08d91872e97b817f4a259

@jamesfinnerty
Copy link

This is a feature that should be available in all Lens front-end apps. Giving collectors the flexibility to pay what they want using their token of choice will allow creators to expand their offerings to a wider user base.

@punkess
Copy link

punkess commented Apr 24, 2024

what @jamesfinnerty wrote.
Sounds very fun, imho more fun and interesting ways to collect is sth we should experiment with more.

@mrsalitre
Copy link

this is genius, agnostic tokens fits perfectly with the permissionless philosophy. I want to see this across the whole lensverse.

@whoisanku
Copy link

Amazing feature Paul. Would love to see this implemented!! ❤️

@carstenpoetter
Copy link

this is a great initiative! I applaud this 👏

@metatxn
Copy link

metatxn commented Apr 25, 2024

Totally make sense. How to integrate it?

@mvanhalen
Copy link

mvanhalen commented Apr 25, 2024

Integrating on Orna

@iPaulPro
Copy link
Collaborator Author

iPaulPro commented Apr 25, 2024

Totally make sense. How to integrate it?

It can be added to publications just like any other other Open Action. Only difference with Collect Modules is that they're registered with the existing CollectPublicationAction rather than as their own Actions.

Here's a code snippet on how to create the init calldata:

import { encodeData } from '@lens-protocol/client';
import { ZeroAddress } from 'ethers';

const EMPTY_RECIPIENT = [ZeroAddress, '0'];

// First, create the PWYW Collect Module init data
const collectInitData = encodeData([
    { type: 'uint160', name: 'amountFloor' },
    { type: 'uint96', name: 'collectLimit' },
    { type: 'address', name: 'currency' },
    { type: 'uint16', name: 'referralFee' },
    { type: 'bool', name: 'followerOnly' },
    { type: 'uint72', name: 'endTimestamp' },
    {
        type: 'tuple(address,uint16)[5]',
        name: 'recipients',
        components: [
            { type: 'address', name: 'recipient' },
            { type: 'uint16', name: 'split' },
        ],
    },
], [
    '0', // amount floor, zero to allow free collects
    '10', // number of mints allowed
    ZeroAddress, // optionally limit to a specific token
    '10', // mirror referral percentage
    false, // minting only for followers
    '0', // optional end date
    [
        ['0x10E1DEB36F41b4Fad35d10d0aB870a4dc52Dbb2c', '10000'], // the recipient
        EMPTY_RECIPIENT, // can be up to 5 recipients
        EMPTY_RECIPIENT,
        EMPTY_RECIPIENT,
        EMPTY_RECIPIENT
    ],
]);

// Next, create the CollectPublicationAction init data
const data = encodeData(
    [
        { type: 'address', name: 'collectModule' },
        { type: 'bytes', name: 'collectModuleInitData' },
    ],
    [
       '0x7fbD7496CaE2DAcad7a62350DA8488E31eC026eA', // the PWYW Collect Module address
       collectInitData
    ],
);

// Add as an `unknownOpenAction` to the publication
openActionModules.push({
    unknownOpenAction: {
        address: '0x0D90C58cBe787CD70B5Effe94Ce58185D72143fB', // the CollectPublicationAction address
        data,
    },
});

@Supersigil
Copy link

I've been pestering devs about PWYW for NFTs for years! Makes so much sense, especially for music, given how successful this feature has been on Bandcamp (when given this option, ~50% of fans pay more than the minimum price). I hope this gets implemented across the web3 ecosystem.

@Prateekrajput1999
Copy link

Prateekrajput1999 commented Apr 29, 2024

hey @iPaulPro i very well understood the part of implementation
could u share the act implementation as well...it would be helpful
i am going to integrate it to SOCLLY soon 🚀

@iPaulPro
Copy link
Collaborator Author

iPaulPro commented Apr 29, 2024

hey @iPaulPro i very well understood the part of implementation could u share the act implementation as well...it would be helpful i am going to integrate it to SOCLLY soon 🚀

Sure thing! The main thing to note is that the act is on the CollectPublicationAction (0x0D90C58cBe787CD70B5Effe94Ce58185D72143fB) and not the Collect Module, itself, however, the allowance approval must be done with the Collect Module.

Here's an example of process for a 1 BONSAI collect:

import { ethers } from "ethers";
import { encodeData } from "@lens-protocol/client";

const processCollectData = encodeData([
  { type: "address", name: "currency" },
  { type: "uint256", name: "amount" },
], [
  "0x3d2bD0e15829AA5C362a4144FdF4A1112fa29B5c",
  ethers.utils.parseUnits("1", 18).toString(),
]);

const processActionData = encodeData(
  [
    { type: "address", name: "collectNftRecipient" },
    { type: "bytes", name: "collectData" },
  ],
  [RECIPIENT, processCollectData],
);

Where RECIPIENT is the address receiving the Collect NFT.

@ludmila-omlopes
Copy link

Up vote to have this feature applied to Hey!

While I don't believe all actions should be implemented by all apps on Lens, Hey is usually the first and main contact with the protocol and so suitable for this new monetization feature.

@hugoreno
Copy link

hugoreno commented May 6, 2024

Awesome feature - would love to see it implemented. We would support with creator tokens on P00LS

@iPaulPro
Copy link
Collaborator Author

iPaulPro commented May 7, 2024

I created a standalone repository for the PWYW Collect module, with integration instructions:

https://github.com/iPaulPro/pwyw-collect-module

If you want to test it out locally, there's also a branch with it in Scaffold Lens:

https://github.com/iPaulPro/scaffold-lens/tree/feat/pwyw-collect

@Prateekrajput1999
Copy link

Deployed on SOCLLY too! ✨

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: No status
Development

No branches or pull requests