holaplex / wonka

GNU Affero General Public License v3.0
8 stars 1 forks source link

Add support for fanout wallet creation #16

Closed echohtp closed 2 years ago

echohtp commented 2 years ago

Problem

Need support for more than metaplex creator wallet limit

Solution

"Use a hydra/fanout wallet"

Example code (from the hydra docs)

const connection = new Connection("mainnet-beta", "confirmed");
let fanoutSdk: FanoutClient;

authorityWallet = Keypair.generate(); // put our own wallet here

fanoutSdk = new FanoutClient(
  connection,
  new NodeWallet(new Account(authorityWallet.secretKey))
);

const init = await fanoutSdk.initializeFanout({
  totalShares: 100,
  name: `Test${Date.now()}`,
  membershipModel: MembershipModel.Wallet,
});

// if you want to use a SPL token use this section as well
const mintPublicKey = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"; // USDC

const { fanoutForMint, tokenAccount } = await fanoutSdk.initializeFanoutForMint(
  {
    fanout,
    mint: mintPublicKey,
  }
);
// end of SPL token setting

const members = [{publicKey: "AbCdEfG", shares: 50}, {publicKey: "123456", shares: 50}];

members.map((member) => {
    const {membershipAccount} = await fanoutSdk.addMemberWallet({
    fanout: init.fanout,
    fanoutNativeAccount: init.nativeAccount,
    membershipKey: member.publicKey,
    shares: member.shares
    });
});

Concern

A record of member wallets needs to be kept to dispense funds