Guides
Add Payments to Your Replit Agent
Set up Wallgent in a Replit project with copy-paste code.
Prerequisites
- A Wallgent account and API key (get one here)
1. Create a Replit
Create a new Node.js Repl on replit.com. Select the Node.js template.
2. Install the SDK
In the Shell tab, run:
npm install @wallgent/sdk3. Set Your API Key
- Open the Secrets tab (lock icon in the sidebar)
- Add a new secret:
- Key:
WALLGENT_API_KEY - Value: your
wg_test_...key
- Key:
- Click Add Secret
Your API key is now available as process.env.WALLGENT_API_KEY without being exposed in source code.
4. Copy-Paste Example
Replace the contents of index.ts with:
import { Wallgent } from '@wallgent/sdk';
const wg = new Wallgent(process.env.WALLGENT_API_KEY!);
async function main() {
// Create a wallet
const wallet = await wg.wallets.create({
name: 'Replit Agent',
agentName: 'replit-bot',
});
console.log('Wallet created:', wallet.id);
// Fund it
await wg.wallets.fund(wallet.id, { amount: '100.00' });
console.log('Funded $100.00');
// Check balance
const balance = await wg.wallets.getBalance(wallet.id);
console.log('Balance:', balance.available, balance.currency);
// Send a payment
const payment = await wg.payments.send({
fromWalletId: wallet.id,
toWalletId: 'wal_recipient_id', // replace with a real wallet ID
amount: '10.00',
description: 'Test payment from Replit',
});
console.log('Payment sent:', payment.id, payment.state);
// List transactions
const txns = await wg.wallets.getTransactions(wallet.id);
console.log('Transactions:', txns.data.length);
}
main().catch(console.error);Click Run. You should see the wallet creation, funding, and payment output in the console.
Next Steps
- Add spending policies to control your agent's budget
- Set up webhooks for real-time notifications
- Explore the full SDK Reference