@passon-io/core-sdk
v0.1.9
Published
Pass On's Core SDK provides JS/TS abstractions which make it easy to integrate into other applications.
Downloads
14
Readme
Pass On Core SDK
Pass On's Core SDK provides JS/TS abstractions which make it easy to integrate into other applications.
Usage
Add the dependency to your project and instantiate the SDK by passing your signer object.
import { CoreSDK } from '@passon/core-sdk';
const signer = useSigner();
const coreSdk = new CoreSDK({
signer,
chainId,
});
import { Signer, providers } from "ethers5";
import { useChainId, useWalletClient } from "wagmi";
export function useSigner() {
const { data: walletClient } = useWalletClient();
const chainId = useChainId();
if (!walletClient) return undefined;
const { account, transport } = walletClient;
const provider = new providers.Web3Provider(transport, chainId);
return provider.getSigner(account.address) as Signer;
}
You can now execute the various functions provided by the SDK, for example:
// Generate Referral Code for Campaign
const tx = await coreSdk.generateReferralCode(campaignId);
// Wait for a transaction to finish to get created referral code
const { referralCode } = await coreSdk.generateReferralCodeTx(tx);
Gasless
The SDK also provides a gasless abstraction to allow users to interact with the blockchain without needing to pay gas fees. This is done by using a relayer service to pay for the gas fees on behalf of the user.
import { CoreSDK } from '@passon/core-sdk';
const signer = useSigner();
const coreSdk = new CoreSDK({
signer,
chainId,
gelatoKey: YOUR_GELATO_API_KEY,
});
Helpers
The SDK also provides a set of helper functions to make it easier to interact with the blockchain.
// Has Affiliate/Referee registered for specific Campaign
await coreSdk.hasAffiliateRegistered(affiliateAddress, campaignId);
await coreSdk.hasRefereeRegistered(affiliateAddress, campaignId);
Development
Repository & Prerequisites
To work with this project you must have NodeJS (>= v18.12.1
) & Yarn installed before cloning the repository. Assuming you have already done this, run the following in your terminal:
git clone https://github.com/passon-io/core-sdk.git
Dependencies & Build
To install the project's dependencies & build the code, run the following command:
yarn install && yarn build