1.0.99 • Published 2 years ago
@agreewe-dev/solana-blockchain-contracts v1.0.99
Introduction
This package is derived from the Rust program found in programs/SolSplitter via a script using Solita.
How to use
The interface for functions from the rust programs are found in /packages/sdk/generated. These files should NOT have to be touched unless necessary. The interactions with these functions can be found in packages/sdk/index.ts.
The general idea of the functions found in index.ts is as follows:
- Call functions to generated instructions
- Signing of instructions/transaction
- Send to Solana blockchain
Initializing a Fanout Wallet
const connection = new Connection("devnet", "confirmed");
let fanoutSdk: FanoutClient;
authorityWallet = useWallet() // wallet instance
fanoutSdk = new FanoutClient(
connection,
new NodeWallet(new Account(authorityWallet.secretKey))
);
const init = await fanoutSdk.initializeFanout({
totalShares: 100,
name: `Test${Date.now()}`,
membershipModel: MembershipModel.Wallet,
phaseLimits: []
});
Adding Members
For adding members, a sample usecase is as follows. Input parameters for function can be found in index.ts
const member = new Keypair()
const {membershipAccount} = await fanoutSdk.addMemberWallet({
fanout: init.fanout,
fanoutNativeAccount: init.nativeAccount,
membershipKey: member.publicKey,
shares: [50]
});
Distribution
To distribute all, call the distributeAll function as shown below.
await fanoutSdk.distributeAll(
{
fanout: init.fanout,
payer: signer
}
)