PactLabs.Sdk.Toolkit 0.1.0-alpha4

This is a prerelease version of PactLabs.Sdk.Toolkit.
dotnet add package PactLabs.Sdk.Toolkit --version 0.1.0-alpha4
                    
NuGet\Install-Package PactLabs.Sdk.Toolkit -Version 0.1.0-alpha4
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="PactLabs.Sdk.Toolkit" Version="0.1.0-alpha4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PactLabs.Sdk.Toolkit" Version="0.1.0-alpha4" />
                    
Directory.Packages.props
<PackageReference Include="PactLabs.Sdk.Toolkit" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add PactLabs.Sdk.Toolkit --version 0.1.0-alpha4
                    
#r "nuget: PactLabs.Sdk.Toolkit, 0.1.0-alpha4"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package PactLabs.Sdk.Toolkit@0.1.0-alpha4
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=PactLabs.Sdk.Toolkit&version=0.1.0-alpha4&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=PactLabs.Sdk.Toolkit&version=0.1.0-alpha4&prerelease
                    
Install as a Cake Tool

PactLabs.Sdk

C# SDK for EVM blockchain interactions via Pact Labs' account abstraction infrastructure. Build server-side applications that send gasless transactions through ERC-4337 smart accounts powered by Kernel v3.3.

Architecture

┌──────────────────────────────────────────────────────┐
│  Your Application                                    │
├──────────────────────────────────────────────────────┤
│  PactClient  →  IPactAccount  →  PactTransaction     │  High-level SDK
├──────────────────────────────────────────────────────┤
│  UserOpPipeline  →  ABI Encoding  →  Signing         │  UserOp lifecycle
├──────────────────────────────────────────────────────┤
│  Kernel v3.3 Encoding  →  PackedUserOperation        │  ERC-4337 / ERC-7579
├──────────────────────────────────────────────────────┤
│  AA Service (JSON-RPC)  →  Bundler / Paymaster       │  Pact Infrastructure
└──────────────────────────────────────────────────────┘

Four abstraction layers:

  1. High-level SDK (PactClient, IPactAccount) — one-line transfers, contract calls, and token operations with automatic gas management.
  2. UserOp lifecycle (UserOpPipeline) — orchestrates nonce tracking, paymaster sponsorship, gas estimation, and signing.
  3. Kernel encoding (KernelEncoder, PackedUserOperation) — ERC-4337 v0.7 UserOp construction with Kernel v3.3 execute/executeBatch encoding.
  4. RPC transport (AaServiceClient) — JSON-RPC communication with the Pact bundler, paymaster, and public RPC endpoints.

Installation

# Core SDK — transfers, contract calls, account abstraction
dotnet add package PactLabs.Sdk

# AWS KMS signer — sign with AWS Key Management Service keys
dotnet add package PactLabs.Sdk.Signing.Aws

# Standalone toolkit — Kernel encoding & UserOp building without the full SDK
dotnet add package PactLabs.Sdk.Toolkit

# Code generator — generate typed C# contract wrappers from Solidity ABIs
dotnet tool install --global PactLabs.Sdk.CodeGen

Quick Start

Basic Transfer

using PactLabs.Sdk;
using PactLabs.Sdk.Signing;
using PactLabs.Sdk.Tokens;
using PactLabs.Sdk.Models;

// Create a signer (use AwsKmsSigner in production)
var signer = new PrivateKeySigner("0xYourPrivateKey");

// Initialize the client
using var client = new PactClient("pk_live_your_api_key", signer, new PactOptions
{
    Chain = Chain.Base,
    GasPolicy = GasPolicy.Sponsored,
});

// Get or create the smart account
var account = await client.GetAccountAsync();
Console.WriteLine($"Account: {account.Address}");

// Send a gasless ETH transfer
var tx = await account.TransferAsync("0xRecipient...", NativeAmount.Ether(0.1m));
var receipt = await tx.WaitForConfirmationAsync();
Console.WriteLine($"Confirmed in block {receipt.BlockNumber}");

ERC-20 Token Transfer

// Look up a token
var usdc = await client.Tokens.GetBySlugAsync("usdc");

// Or create token info manually
var token = new TokenInfo("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", Chain.Ethereum, 6);

// Transfer tokens
var amount = TokenAmount.FromDecimal(100m, token.Decimals);
var tx = await account.TransferTokenAsync(token, "0xRecipient...", amount);

Contract Call

// Write (sends a UserOp)
var tx = await account.ExecuteAsync(
    "0xContractAddress",
    "approve(address,uint256)",
    "0xSpender...",
    BigInteger.Parse("1000000"));

// Read (free eth_call)
var balance = await account.ReadAsync<BigInteger>(
    "0xContractAddress",
    "balanceOf(address) returns (uint256)",
    account.Address);

Dependency Injection

builder.Services.AddPact(opts =>
{
    opts.ApiKey = "pk_live_your_api_key";
    opts.Chain = Chain.Base;
    opts.GasPolicy = GasPolicy.Sponsored;
});
builder.Services.AddPactSigner<MyCustomSigner>();

// Inject IPactClient wherever needed
public class MyService(IPactClient pact)
{
    public async Task DoWork()
    {
        var account = await pact.GetAccountAsync();
        // ...
    }
}

AWS KMS Signer

Use AWS Key Management Service for production signing with HSM-backed keys:

using Amazon.KeyManagementService;
using PactLabs.Sdk.Signing.Aws;

var kmsClient = new AmazonKeyManagementServiceClient();
var signer = new AwsKmsSigner(kmsClient, "alias/my-signing-key");

using var client = new PactClient("pk_live_your_api_key", signer, new PactOptions
{
    Chain = Chain.Base,
    GasPolicy = GasPolicy.Sponsored,
});

The KMS key must be an asymmetric signing key with ECC_SECG_P256K1 key spec.

Code Generator

Generate typed C# contract wrappers from Solidity ABI JSON:

# From a Hardhat artifact
pact-codegen --input artifacts/MyContract.json --output MyContract.cs

# With custom namespace and class name
pact-codegen --input abi.json --output Generated/Erc20.cs --namespace MyApp.Contracts --class Erc20

The generated class extends TypedContractHandle and provides strongly-typed methods for each ABI function.

Configuration

Property Default Description
ApiKey (required) Pact API key (pk_live_* or pk_test_*)
Chain Chain.Ethereum Target EVM chain
GasPolicy GasPolicy.Sponsored Gas payment strategy
PlatformUrl https://api.pactlabs.xyz Platform API base URL
EnableTokenRegistry true Enable/disable token registry
TimeoutMs 30000 HTTP request timeout in milliseconds

Supported Chains

Chain Chain ID Enum
Ethereum 1 Chain.Ethereum
Arbitrum One 42161 Chain.Arbitrum
Avalanche C-Chain 43114 Chain.Avalanche
Sepolia 11155111 Chain.Sepolia
Arbitrum Sepolia 421614 Chain.ArbitrumSepolia
Avalanche Fuji 43113 Chain.AvalancheFuji

License

MIT

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.0-alpha4 151 4/27/2026
0.1.0-alpha3 131 3/24/2026
0.1.0-alpha2 125 3/19/2026
0.1.0-alpha.1 82 3/19/2026