@openfort/openfort-node
v0.10.1
Published
Openfort Node SDK
Readme
Table of Contents
Overview
The Openfort Node.js SDK provides convenient access to the Openfort API for server-side applications. It enables developers to:
- Create and manage EVM and Solana backend wallets
- Sign messages, typed data, and transactions
- Execute gasless transactions with gas sponsorship policies
- Manage users, accounts, and transaction intents
- Integrate with smart contracts and token swaps
Installation
Requires Node.js 18 or higher.
npm install @openfort/openfort-nodeyarn add @openfort/openfort-nodepnpm add @openfort/openfort-nodeQuickstart
Get your API key from the Openfort Dashboard.
import Openfort from "@openfort/openfort-node";
const openfort = new Openfort("sk_test_...", {
walletSecret: "your-wallet-secret", // Required for signing operations
});
// Create an EVM backend account
const account = await openfort.accounts.evm.backend.create();
console.log("Account address:", account.address);
// Sign a message (methods are on the account object)
const signature = await account.signMessage({
message: "Hello, Openfort!",
});
console.log("Signature:", signature);Features
Wallet Management
Create and manage wallets across EVM chains and Solana:
// EVM backend accounts
const evmAccount = await openfort.accounts.evm.backend.create();
// Solana backend accounts
const solanaAccount = await openfort.accounts.solana.backend.create();
// Import existing wallet
const imported = await openfort.accounts.evm.backend.import({
privateKey: "0x...",
});Signing
Sign messages, typed data, and transactions. Methods are called directly on the account object:
// Sign message
const signature = await account.signMessage({
message: "Hello, Openfort!",
});
// Sign EIP-712 typed data
const typedSig = await account.signTypedData({
domain: { name: "MyApp", version: "1", chainId: 1 },
types: {
Person: [
{ name: "name", type: "string" },
{ name: "wallet", type: "address" },
],
},
primaryType: "Person",
message: { name: "Alice", wallet: "0x..." },
});Gas Sponsorship
Sponsor gas fees for your users. Create a policy with criteria-based rules, then link it to a fee sponsorship:
// 1. Create a policy that accepts transactions on Polygon
const policy = await openfort.policies.create({
scope: "project",
rules: [
{
action: "accept",
operation: "sponsorEvmTransaction",
criteria: [
{ type: "evmNetwork", operator: "in", chainIds: [137] },
],
},
],
});
// 2. Create a fee sponsorship linked to that policy
const sponsorship = await openfort.feeSponsorship.create({
name: "Free gas for users",
strategy: { sponsorSchema: "pay_for_user" },
policyId: policy.id,
});IAM & Authentication
Manage users and verify sessions:
// List authenticated users
const users = await openfort.iam.users.list({ limit: 10 });
// Verify session from access token
const session = await openfort.iam.getSession({ accessToken });
console.log("User ID:", session.user.id);
console.log("Session expires:", session.session.expiresAt);Examples
The SDK includes comprehensive examples for all features. See the examples directory for runnable code.
| Category | Examples | | ---------------- | -------------------------------------------------- | | EVM Wallets | Create, import, export, sign messages/transactions | | Solana Wallets | Create, import, export, sign messages/transactions | | Policies | Criteria-based rules for EVM and Solana operations | | Fee Sponsorship | Create, update, enable/disable gas sponsorship | | Transactions | Create intents, estimate gas | | IAM | User management, session verification |
Run examples:
cd examples
cp .env.example .env
# Edit .env with your API key
pnpm example evm/accounts/createAccount.tsDocumentation
Support
- GitHub Issues - Report bugs and request features
- Twitter - Follow for updates
- Website - Learn more about Openfort
New features and bug fixes are released on the latest major version. We recommend upgrading to the latest version for security updates and new functionality.
License
This project is licensed under the MIT License.
