Privy Integration (Aptos)

Privy handles auth + Ed25519 wallet creation. SmoothSend handles fee-payer sponsorship. Your users get gasless Aptos transactions without downloading any wallet.

How it works

Aptos natively supports sponsored transactions (fee-payer model). No bundlers, no UserOps, no paymaster contracts.

  1. Your hook builds the transaction with withFeePayer: true
  2. Privy signs the sender portion (Ed25519)
  3. SmoothSend relayer adds fee-payer signature and submits to Aptos

This is simpler than the AVAX flow — Aptos has native gas sponsorship built into the protocol.

1) Install
Terminal
npm install @smoothsend/sdk @privy-io/react-auth @aptos-labs/ts-sdk
2) Root provider
Wrap your app with both Privy and SmoothSend providers.
providers.tsx
TypeScript (React)
1import { PrivyProvider } from '@privy-io/react-auth';
2import { SmoothSendAptosProvider } from '@smoothsend/sdk/aptos';
3 
4export function Providers({ children }: { children: React.ReactNode }) {
5 return (
6 <PrivyProvider
7 appId={process.env.NEXT_PUBLIC_PRIVY_APP_ID!}
8 config={{
9 embeddedWallets: {
10 ethereum: { createOnLogin: 'users-without-wallets' },
11 },
12 }}
13 >
14 <SmoothSendAptosProvider
15 apiKey={process.env.NEXT_PUBLIC_SMOOTHSEND_API_KEY!}
16 // network defaults to "testnet"; set "mainnet" for production
17 >
18 {children}
19 </SmoothSendAptosProvider>
20 </PrivyProvider>
21 );
22}
3) One hook, one button
Use useSmoothSendPrivyWrite from @smoothsend/sdk/aptos. Every submitTransaction call goes through SmoothSend — gas is free.
GaslessButton.tsx
TypeScript (React)
1import { useSmoothSendPrivyWrite } from '@smoothsend/sdk/aptos';
2import { usePrivy } from '@privy-io/react-auth';
3import { toHex } from 'viem';
4 
5function GaslessButton() {
6 const { user, signMessage } = usePrivy();
7 
8 // Privy creates an Aptos wallet with Ed25519 keys
9 const aptosWallet = user?.linkedAccounts?.find(
10 (a) => a.type === 'wallet' && a.chainType === 'aptos'
11 );
12 
13 const { submitTransaction, isPending } = useSmoothSendPrivyWrite({
14 publicKey: aptosWallet?.publicKey ?? '',
15 address: aptosWallet?.address ?? '',
16 signTransaction: async ({ message }) => {
17 // Privy signs the raw transaction bytes
18 const sig = await signMessage(toHex(message));
19 return sig;
20 },
21 });
22 
23 return (
24 <button
25 disabled={isPending || !aptosWallet}
26 onClick={() =>
27 submitTransaction({
28 function: '0x1::coin::transfer',
29 typeArguments: ['0x1::aptos_coin::AptosCoin'],
30 functionArguments: ['0xRecipientAddress', 100],
31 })
32 }
33 >
34 {isPending ? 'Sponsoring...' : 'Send Gasless'}
35 </button>
36 );
37}
Notes

apiKey is required on SmoothSendAptosProvider. network is optional and defaults to "testnet".

Privy Aptos wallets use Ed25519 keys. publicKey must be the 32-byte hex key from wallet.public_key.

No relayer or gateway changes needed — the hook uses the same /api/v1/relayer/gasless-transaction endpoint as the standard Wallet Adapter integration.

All transactions are developer-sponsored (gasless). The Aptos fee-payer model does not have a user-pays-ERC20 equivalent — the developer always pays APT gas via SmoothSend credits.