Spaces:
Running
Running
| // One-time: generate a fresh Stellar testnet keypair, fund it via friendbot, | |
| // and print the keys so you can save them to .env. | |
| import { Keypair } from "@stellar/stellar-sdk"; | |
| const kp = Keypair.random(); | |
| const pub = kp.publicKey(); | |
| const sec = kp.secret(); | |
| console.log("Generated new testnet keypair:"); | |
| console.log(` Public: ${pub}`); | |
| console.log(` Secret: ${sec}`); | |
| console.log(); | |
| console.log("Funding via friendbot..."); | |
| const res = await fetch(`https://friendbot.stellar.org?addr=${pub}`); | |
| if (!res.ok) { | |
| console.error(`Friendbot failed: ${res.status}`); | |
| console.error(await res.text()); | |
| process.exit(1); | |
| } | |
| console.log("✓ Funded with 10,000 testnet XLM"); | |
| console.log(); | |
| console.log("Add to .env:"); | |
| console.log(` AGENT_OWNER_SECRET_TESTNET=${sec}`); | |
| console.log(); | |
| console.log(`Verify: https://stellar.expert/explorer/testnet/account/${pub}`); | |