Skip to main content

Split

Learn how to interact with your Split contract in the SDK.

Create a Split Contract

Deploys a new Split contract
const sdk = useSDK();

const contractAddress = await sdk.deployer.deploySplit({
name: "My Split",
primary_sale_recipient: "your-address",
recipients: [
{
address: "your-address",
sharesBps: 80 * 100, // 80%
},
{
address: "another-address",
sharesBps: 20 * 100, // 20%
},
],
});

Getting the contract in your application

To start using your Split contract inside your application, you'll need to use its contract address. You can get the contract address from the dashboard.

import { useSplit } from '@thirdweb-dev/react'

export default function Component() {
const split = useSplit("<YOUR-CONTRACT-ADDRESS>")

// Now you can use the split contract in the rest of the component
}

View Recipients

Get Recipients of this splits contract
const recipients = await contract.getAllRecipients();
console.log(recipients);

View Balance

Native Token Balance

Use this if you have been tokens native to the network (e.g., Ether on the Ethereum network).

Get Funds owed to a particular wallet
// The address to check the funds of
const address = "{{wallet_address}}";
const funds = await contract.balanceOf(address);
console.log(funds);

Non-Native Token Balance

Use this if you have been sent custom tokens to the address.

Get non-native Token Funds owed to a particular wallet
// The address to check the funds of
const address = "{{wallet_address}}";
// The address of the currency to check the contracts funds of
const tokenAddress = "0x..."
const funds = await contract.balanceOfToken(address, tokenAddress);
console.log(funds);

Distribute funds

This distributes funds held by the contract to all recipients.

Native Token

await contract.distribute();

Non-Native Token

// The address of the currency to distribute funds
const tokenAddress = "0x..."
await contract.distributeToken(tokenAddress);

Withdraw Funds

// the wallet address that wants to withdraw their funds
const walletAddress = "{{wallet_address}}"
await contract.withdraw(walletAddress);