Getting Started
Get up and running with the Puffer SDK in just a few steps.
Overview
Puffer SDK is a TypeScript library for interacting with Puffer smart contracts. It provides an API and helper functions to execute smart contracts in the browser.
The SDK is focused on providing a smooth developer experience.
Installation
- npm
- yarn
- pnpm
npm install @pufferfinance/puffer-sdk
yarn add @pufferfinance/puffer-sdk
pnpm install @pufferfinance/puffer-sdk
Quick Start
1. Setup the Puffer Client
PufferClient
is the main entry point of the SDK and contains the core functionality provided by the SDK.
import {
PufferClientHelpers,
PufferClient,
Chain,
} from '@pufferfinance/puffer-sdk';
const walletClient = PufferClientHelpers.createWalletClient({
chain: Chain.Holesky,
provider: window.ethereum,
});
const pufferClient = new PufferClient(Chain.Holesky, walletClient);
2. Connect to the Wallet
A wallet can be connected to by requesting its address from the SDK.
const [walletAddress] = await pufferClient.requestAddresses();
3. Interact with the Contract
Mint pufETH to your walletAddress
or set a target recipient:
const { transact, estimate } = pufferClient.vault.depositETH(walletAddress);
// Returns gas estimate of the transaction.
const gasEstimate = await estimate();
// Execute the transaction for depositing ETH.
const txHash = await transact(BigInt(1e18));