Building Polysend: How We Simplified Solana Wallet Management for Our Ecosystem

2025-03-29

Building Polysend: How We Simplified Solana Wallet Management for Our Ecosystem

A journey through creating a developer-friendly bash script to automate Solana wallet operations, token creation, and transaction management—streamlining the development workflow for Polysend's multi-token payment browser extension.

Building Polysend: How We Simplified Solana Wallet Management for Our Ecosystem

At Polysend, we’re on a mission to create seamless multi-token payments for the modern web. Our browser extension enables users to make one-click payments directly on websites without leaving the page, transforming how users interact with content creators, digital services, and online platforms.

When our development team began building the Polysend browser extension on Solana, we quickly encountered a challenge. Alice, our lead developer, expressed frustration during our weekly standup: “Testing the extension’s payment flows is incredibly time-consuming. For each test scenario, we need different wallets with various token balances, and manually managing all this through the CLI is taking up half our development time!”

Bob, our DevOps engineer, nodded in agreement. “The Solana CLI is powerful, but remembering all those commands and parameters is slowing down our progress on the extension. We need a better way to handle test wallets and tokens.”

That’s when we decided to create a foundational tool for our development workflow: the Solana Wallet Manager, now available in the Polysend GitHub organization. This bash script simplifies wallet and token operations, allowing us to focus on building our browser extension rather than wrestling with command-line complexities. This blog post shares our journey and the tool we’ve built, which has become essential to developing the Polysend ecosystem.

The Challenge of Developing a Multi-Token Payment Extension

When building Polysend, our browser extension for one-click cryptocurrency payments, we faced several technical challenges:

  • Creating and managing multiple test wallets to simulate different user scenarios
  • Generating various token types to test cross-token payment functionality
  • Simulating different balance states for feature and UI testing
  • Setting up wallet security levels for testing our tiered security model
  • Creating reproducible test environments for our CI/CD pipeline

Each of these operations required specific Solana CLI commands with various parameters and options. While the CLI is comprehensive, it wasn’t optimized for our rapid development cycles and testing needs.

Introducing the Solana Wallet Manager

Our solution was to create a script that wraps the Solana CLI tools into a more intuitive interface. The Solana Wallet Manager handles everything from wallet creation to token management with simple, memorable commands that align with our development workflow.

Let me walk you through a typical development scenario to show how it streamlines our work on the Polysend extension.

A Day in the Life: Building the Polysend Extension

Alice and Bob are working on a new feature for the Polysend browser extension: the ability to automatically detect and suggest appropriate tokens for specific websites based on metadata. Let’s follow their workflow using our Wallet Manager tool.

Setting Up the Development Environment

First, they start their local Solana validator for testing:

docker run -ti --name solana-test-validator -p 8899:8899 -p 8900:8900 -p 8001:8001 --rm tchambard/solana-test-validator:latest solana-test-validator

Then they set the script to use their local cluster:

./solana-wallet-manager.sh set-cluster local

Bob verifies the connection:

./solana-wallet-manager.sh check-cluster

And sees:

Checking availability of cluster: http://localhost:8899
Cluster is available!
Cluster version: 1.18.22

“Perfect,” says Bob. “The validator is up and running. Now let’s create some test wallets that match our extension’s multi-wallet architecture.”

Creating Test Wallets for Different Security Levels

For testing their extension, Alice and Bob need to simulate different user wallets with varying security levels:

./solana-wallet-manager.sh create-wallet everyday-wallet
./solana-wallet-manager.sh create-wallet savings-wallet
./solana-wallet-manager.sh create-wallet subscription-wallet

They check the wallets they’ve created:

./solana-wallet-manager.sh list-wallets
Available wallets:
  everyday-wallet - CRKL2q4S9FfBhjbhUCRjXNx4EPUFZDRcWjQG4K3UHyV3
  savings-wallet - Eo87sYSuDaQ18FwZWpUhAu84jPW5Ziae2HoCGM6qa6Tr
  subscription-wallet - FQRq5VwZqAyUidyryr1KwDf369Q4bgnAwHC8776n9YNo

“Look at how easy that was,” Alice remarks. “Each wallet has its own directory at ~/solana-wallets/ with the keypair safely stored. We can now import these wallets into our extension for testing the wallet switching functionality.”

Funding the Wallets

Now they need some SOL to work with:

./solana-wallet-manager.sh use-wallet everyday-wallet
./solana-wallet-manager.sh airdrop 2

“On mainnet, we’d be transferring real SOL here,” Bob explains to the new intern watching over his shoulder. “But on devnet and localnet, we can airdrop SOL for testing the extension’s balance display and transaction fee handling.”

They fund the other wallets too:

./solana-wallet-manager.sh airdrop 1 savings-wallet
./solana-wallet-manager.sh airdrop 5 subscription-wallet

Creating Custom Tokens for Payment Testing

Now comes the important part. To test Polysend’s multi-token payment capabilities, they need to create some custom tokens:

./solana-wallet-manager.sh use-wallet everyday-wallet
./solana-wallet-manager.sh create-token "Content Creator Token" CONTENT 6

“I’m making CONTENT with 6 decimal places, like most standard tokens,” Alice explains. “It’s for our test case where websites can specify preferred tokens for creator payments.”

The output shows what’s happening behind the scenes:

Creating new token: Content Creator Token (CONTENT) with 6 decimals
Generating token keypair...
...
Token created successfully!
Token address: ELui9ZRhrP7qWgcPyPkjkbxa9PzSTSy2fpmvKVmQZr5o
Token information saved to /home/alice/solana-wallets/everyday-wallet/tokens/CONTENT.json
Creating token account...
Token account created successfully!

“That’s amazing,” says Bob. “The script just generated a new keypair specifically for this token, created the token on-chain, created a token account in our wallet, and saved all the information for later. That would have been at least four separate CLI commands.”

They create a few more tokens for testing different extension scenarios:

./solana-wallet-manager.sh create-token "Subscription Payment Token" SUBSCRIBE 2
./solana-wallet-manager.sh create-token "Microtip Token" MICROTIP 9

“SUBSCRIBE only has 2 decimal places because it’s for whole subscription units,” Alice notes. “And MICROTIP has 9 because we need to test extremely small tip amounts in the extension’s UI.”

Understanding Token Metadata for the Extension

“Let me explain what’s happening with the token metadata,” Alice tells the team. “When we create a token, several important pieces of information are stored:

  1. The token name (“Content Creator Token”) - this will appear in the extension’s token selector
  2. The token symbol (“CONTENT”) - this is used in the UI for shorthand references
  3. The decimals value (6) - this affects how we display balances in the extension
  4. The token address - this is used for on-chain identification and transactions
  5. The keypair file - this gives us authority to mint more tokens for testing”

“The script stores all of this in a JSON file, making it easy to reference later. Without this, we’d need to manually keep track of all these values ourselves, which would be error-prone when testing the extension’s token display and conversion features.”

Minting Tokens to Simulate User Balances

Now they mint some tokens to simulate different user balance scenarios in the extension:

./solana-wallet-manager.sh mint-token CONTENT 1000000

“That’s a million CONTENT tokens with 6 decimal places, so actually 1,000,000.000000 tokens,” Alice clarifies. “Let’s mint some of our other tokens too.”

./solana-wallet-manager.sh mint-token SUBSCRIBE 50000
./solana-wallet-manager.sh mint-token MICROTIP 9999999999

“For MICROTIP, we’re minting nearly 10 billion tokens because we need to test how the extension handles very small denominations and large numbers in the UI,” Bob explains.

Distributing Tokens to Test Multi-Wallet Functionality

Now they need to distribute tokens across the different test wallets to simulate a user with multiple wallets in the Polysend extension:

./solana-wallet-manager.sh transfer-token CONTENT 100000 savings-wallet

The output shows:

Using wallet as recipient: savings-wallet - CRKL2q4S9FfBhjbhUCRjXNx4EPUFZDRcWjQG4K3UHyV3
Transferring 100000 CONTENT tokens from everyday-wallet to CRKL2q4S9FfBhjbhUCRjXNx4EPUFZDRcWjQG4K3UHyV3
...
Attempting transfer with automatic recipient account funding...
Token transfer successful

“Notice something really important here,” Alice points out. “The script automatically created the token account for savings-wallet. Normally that’s a separate step we’d have to remember, but the script handled it for us with the --fund-recipient flag. This is exactly the kind of logic we’re implementing in the extension’s token transfer flow.”

They send more tokens to different wallets:

./solana-wallet-manager.sh transfer-token SUBSCRIBE 1000 subscription-wallet
./solana-wallet-manager.sh transfer-token MICROTIP 500000000 everyday-wallet

Testing the Extension’s Balance Display

Bob switches to the everyday-wallet to check balances:

./solana-wallet-manager.sh use-wallet everyday-wallet
./solana-wallet-manager.sh list-tokens
Tokens owned by wallet: everyday-wallet
...
Token                                         Balance
-----------------------------------------------------
ELui9ZRhrP7qWgcPyPkjkbxa9PzSTSy2fpmvKVmQZr5o  900000   (CONTENT)
HNgcDc2cogpS12iW9pZWnimPiMSCd4hL3dVD2RhZeW9z  500000000 (MICROTIP)

“Perfect!” says Alice. “Now I can verify that our extension’s balance display formatter correctly handles both large amounts of standard tokens and astronomical amounts of microtip tokens.”

Simulating Payment Flows

Now they can test the core payment functionality of the Polysend extension:

./solana-wallet-manager.sh use-wallet everyday-wallet
./solana-wallet-manager.sh transfer-token CONTENT 50 subscription-wallet

“This simulates a content payment from the user’s everyday wallet,” explains Alice. “In the extension, this would be triggered by the user clicking the pay button on a webpage with the appropriate payment meta tags.”

They also test a subscription payment:

./solana-wallet-manager.sh use-wallet subscription-wallet
./solana-wallet-manager.sh transfer-token SUBSCRIBE 10 savings-wallet

“With the Wallet Manager script, we can quickly set up and execute all these test scenarios without dealing with the complexity of the Solana CLI directly,” Bob notes.

The Magic Behind the Scenes

What makes this script so valuable for Polysend development is what happens behind the scenes. Let me explain a few key technical aspects:

Token Creation Process Explained

When Alice created the CONTENT token, here’s what actually happened:

  1. A unique keypair was generated: This becomes the “mint authority” - the only identity allowed to create new tokens. The script created a file at ~/solana-wallets/everyday-wallet/tokens/CONTENT_keypair.json containing this authority.

  2. The token was created on-chain: The script used the Solana CLI’s spl-token create-token command, configuring it with the keypair and decimal precision.

  3. A token account was created: Unlike Ethereum, Solana requires separate accounts for each token type. The script automatically created this account in the everyday-wallet.

  4. Metadata was saved locally: All token information was saved to CONTENT.json, making it easy to reference later when building the extension’s token handling logic.

“Without the script, we’d need to manually track all these files and addresses,” Bob says. “I used to keep spreadsheets of this information, which was error-prone and slowed down our extension development.”

Configuration Management

“Another subtle but crucial feature,” Alice points out, “is how the script handles Solana configuration.”

For each operation, the script:

  1. Saves your current Solana configuration
  2. Sets the right wallet as the default signer
  3. Performs the operation
  4. Restores your original configuration

“This means we can use the script alongside regular Solana CLI commands without disrupting our setup,” Alice explains. “That’s a huge quality-of-life improvement when we’re working on the extension’s transaction signing code.”

Real-World Impact: How This Tool Changed Our Development Process

Before creating this script, setting up a test environment for our browser extension took Alice and Bob nearly a full day. With multiple wallets, tokens, and complex configurations, there were frequent errors and lost time.

“Remember when we had to redo all our test wallets because we forgot to save one of the keypairs?” Bob reminds Alice.

Alice nods. “Or the time we sent tokens to an address that didn’t have a token account set up yet, and the transaction failed. That delayed our OAuth integration by a day.”

Now, setting up a complete test environment for the Polysend extension takes less than 15 minutes. The script handles all the tedious work, preventing common errors and ensuring consistency across our development team.

Beyond Simple Testing: Advanced Usage Scenarios

The Solana Wallet Manager isn’t just for basic testing. Here are some advanced ways our team uses it for Polysend development:

Testing Security Levels

The Polysend extension implements different security levels for wallets. Using the Wallet Manager, we can:

  • Create wallets representing different security tiers
  • Transfer specific amounts to simulate security threshold tests
  • Validate the extension’s protection mechanisms for high-value transfers

“The script made it easy to reproduce exact balance scenarios for testing our security confirmations,” Alice explains.

Integration Testing

For testing the browser extension’s integration with websites, we needed to simulate different token ownership patterns:

“We created a script that uses the Wallet Manager to set up standardized test environments with predictable wallets and token balances,” Bob explains. “This lets us validate how the extension interacts with various website payment metadata.”

CI/CD Pipeline

Bob integrated the script into our CI/CD pipeline:

“For each pull request, we spin up a clean test environment with freshly created wallets and tokens,” he explains. “The automated tests verify the extension’s behavior with various token types and balance configurations, then tear down the environment afterward.”

This approach ensures that our tests don’t interfere with each other and always run in a consistent state.

Developer Onboarding

“When new developers join the Polysend project, we have them work through a tutorial using the script,” Alice says. “It helps them understand Solana’s account model and token system without getting bogged down in CLI complexity.”

New team members can be productive on day one, focusing on extension features rather than infrastructure details.

Security Considerations and Best Practices

While the Solana Wallet Manager significantly improves the development experience, it’s important to understand its limitations:

“This script is designed for development and testing,” Bob emphasizes. “It stores keypairs as plain JSON files, which isn’t secure enough for production use, but is perfect for our development needs.”

For the actual Polysend extension, we implement much more robust security:

  • Local encryption with PBKDF2 and AES-GCM
  • Tiered security levels for different wallet types
  • Transaction signing confirmation UI
  • Spending limits and automatic locks

Conclusion: Building Developer-Friendly Tools for Better Products

Our journey creating the Solana Wallet Manager taught us an important lesson: investing in developer tools pays enormous dividends when building complex products like the Polysend extension.

“The hours we spent building this script have saved us weeks of development time,” Alice reflects. “And more importantly, it’s reduced frustration and made development more enjoyable, letting us focus on the user experience of our extension.”

By sharing this tool with the community, we hope to make Solana development more accessible to everyone, from experienced blockchain engineers to developers just getting started with Web3.

The full script and documentation are available on our GitHub. We welcome contributions and suggestions from the community!


Note: The token examples in this blog post (CONTENT, SUBSCRIBE, and MICROTIP) are fictional and created for demonstration purposes only. Any resemblance to actual tokens is coincidental.