@galliun/sofi-sdk
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

Galliun SoFi SDK

A TypeScript SDK for interacting with the Galliun SoFi protocol on the Sui blockchain.

Installation

npm install @galliun/sofi-sdk

Requirements

  • Node.js >= 16
  • Sui version >= 1.21.2

Usage

First, initialize the SDK with your package ID and network:

import { GalliunSoFiSDK } from '@galliun/sofi-sdk';

const sdk = new GalliunSoFiSDK({
	packageId: 'YOUR_PACKAGE_ID',
	network: 'mainnet', // or 'testnet', 'devnet'
});

Profile Management

// Create a profile
const createProfileTx = await sdk.createProfile(
	signer,
	'username',
	'Display Name',
	'Bio',
	'profile_picture_url',
	'background_picture_url',
);

// Update profile
const updateProfileTx = await sdk.updateProfile(
	signer,
	profileId,
	'New Display Name',
	'New Bio',
	'new_profile_picture_url',
	'new_background_picture_url',
);

// Follow/Unfollow
const followTx = await sdk.followProfile(myProfileId, targetProfileId);
const unfollowTx = await sdk.unfollowProfile(myProfileId, targetProfileId);

Goal Management

// Create a goal
const createGoalTx = await sdk.createGoal(
	signer,
	profileId,
	'SUI',
	BigInt(1000000), // amount in smallest unit
	'Goal description',
	false, // overFund
	[], // nominatedPayers
	BigInt(Date.now() + 86400000), // expires in 24h
);

// Pay a goal
const payGoalTx = await sdk.payGoal(goalId, coinObjectId, BigInt(100000));

// Claim a goal
const claimGoalTx = await sdk.claimGoal(goalId);

// Cancel a goal
const cancelGoalTx = await sdk.cancelGoal(goalId);

Tip Management

// Create a tip
const createTipTx = await sdk.createTip(
	signer,
	profileId,
	recipientAddress,
	'SUI',
	BigInt(1000000),
	'Tip description',
);

// Pay a tip
const payTipTx = await sdk.payTip(tipId, coinObjectId, BigInt(100000));

// Claim a tip
const claimTipTx = await sdk.claimTip(tipId);

// Cancel a tip
const cancelTipTx = await sdk.cancelTip(tipId);

Query Methods

// Get single object details
const profile = await sdk.getProfile(profileId);
const goal = await sdk.getGoal(goalId);
const tip = await sdk.getTip(tipId);

// Get all profiles owned by an address
const profiles = await sdk.getProfilesByOwner(ownerAddress);

// Get all goals for a profile
const goals = await sdk.getGoalsByProfile(profileId);

// Get all tips for a profile
const tips = await sdk.getTipsByProfile(profileId);

Transaction Execution

All methods that modify state return a Transaction that needs to be signed and executed:

import { Transaction } from '@mysten/sui/transactions';

// Create the transaction
const tx = await sdk.createProfile(/* ... */);

// Sign and execute the transaction using your preferred wallet or signer
const result = await wallet.signAndExecuteTransactionBlock({
	transactionBlock: tx,
});

Error Handling

All methods may throw errors if:

  • The network is unavailable
  • The contract call fails
  • Invalid parameters are provided
  • The user lacks necessary permissions

Always wrap calls in try-catch blocks and handle errors appropriately.

Data Types

The SDK uses the following main types:

interface Profile {
	id: string;
	owner: string;
	username: string;
	displayName: string;
	bio: string;
	profilePicture: string;
	backgroundPicture: string;
	links: ProfileLink[];
	followers: string[];
	following: string[];
	acceptTips: boolean;
}

interface Goal {
	id: string;
	profile: string;
	creator: string;
	coinType: string;
	amount: bigint;
	status: GoalStatus;
	totalPaymentsMade: bigint;
	totalAmountPaid: bigint;
	totalAmountClaimed: bigint;
	totalFeeAmount: bigint;
	totalAmountRefunded: bigint;
	description: string;
	expiresAt?: bigint;
	overFund: boolean;
}

interface Tip {
	id: string;
	creator: string;
	recipient: string;
	profile: string;
	coinType: string;
	amount: bigint;
	status: TipStatus;
	totalAmountPaid: bigint;
	totalAmountClaimed: bigint;
	totalFeeAmount: bigint;
	totalAmountRefunded: bigint;
	description: string;
}

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Package Sidebar

Install

npm i @galliun/sofi-sdk

Weekly Downloads

8

Version

0.1.2

License

none

Unpacked Size

503 kB

Total Files

117

Last publish

Collaborators

  • galliun