Alejandro Betancourt (@Ale_Beta) header
Alejandro Betancourt (@Ale_Beta) profile picture

Web3 × AI Engineer · Rust + Anchor on Solana · Solidity on Ethereum & Base · Cairo on Starknet · Building in public with Claude Code · Open to remote roles

Panamá City
Joined April 2010
Photo by Alejandro Betancourt (@Ale_Beta)Photo by Alejandro Betancourt (@Ale_Beta)Photo by Alejandro Betancourt (@Ale_Beta)Photo by Alejandro Betancourt (@Ale_Beta)Photo by Alejandro Betancourt (@Ale_Beta)Photo by Alejandro Betancourt (@Ale_Beta)Photo by Alejandro Betancourt (@Ale_Beta)Photo by Alejandro Betancourt (@Ale_Beta)Photo by Alejandro Betancourt (@Ale_Beta)Photo by Alejandro Betancourt (@Ale_Beta)
Spent two weeks building a rug-pull detector on Solana. Not the "we flag suspicious tokens" kind — one with a measured number next to every alert. The signal: the creator adds liquidity to its own token. 97.9% of those ended in a drain (422 of 431, 431 distinct wallets), median 8 minutes of warning before the pool went to zero. The part nobody publishes: it only catches 65.3% of pool rugs. The other 35% are dev dumps and migration pulls, where the drain IS the event — there is nothing to warn about beforehand. That's on the dashboard, not buried in a footnote. I also killed four of my own hypotheses with data. ">10 launches in 24h" as a signal: 1.0% precision. Sell-share before the drain: inverted once I fixed the liquidity metric. Both documented as discarded, with the numbers that killed them. Calibrated against 17M frames from one full night of mainnet, over Solami's Blur stream. TypeScript, 242 tests, docker compose up and it runs. Without an API key it replays a real recorded hour through the same detector. @useSolami
6
1
2
727
🔍 Practice audit #2 on CodeHawks done: Thunder Loan, the flash-loan protocol from Cyfrin's security course. Flash loans, an AMM price oracle and a UUPS proxy, all new to me. 📊 3 High · 2 Medium · 3 Low, each with a Foundry PoC. 🐛 The worst: repaying a flash loan with deposit() instead of repay(). The balance check passes, and you get LP tokens on top. Put in 0.15 in fees, walk out with ~50 of the LPs' money. 🙈 What I missed: a High I had written in my own notes as an open question. Second audit in a row. 🔑 An unanswered question in your notes is an uninvestigated bug. 📄 Report + PoCs: github.com/alebeta06/codehaw…
2
108
CodeHawks Practice audit #2: Thunder Loan, the flash-loan protocol from Cyfrin's security course. It sits behind a UUPS proxy. The bug: the planned upgrade deletes one variable. V1: s_feePrecision, s_flashLoanFee V2: s_flashLoanFee, FEE_PRECISION (now a constant) Constants take no storage, so everything after it moves up one slot. After the upgrade, s_flashLoanFee reads the old precision: 1e18. The flash loan fee jumps from 0.3% to 100%. V2's initialize() sets the fee back to 0.3%. It never runs: the proxy was already initialized. Found it with forge inspect <Contract> storage on both versions, comparing slot by slot. 🔑 In an upgrade, variables are positions, not names.
2
1
3
217
Verifiable build for my Solana program: six weeks of mismatched hashes, fixed by one flag. The official 4.2.2 image defaults to platform-tools v1.56. My build uses v1.57. Different compiler, different bytecode. solana-verify build --cargo-build-sbf-args="--tools-version v1.57 --arch v3" Now the Docker build is byte-for-byte my devnet deployment. The explorer badge still won't show: remote verification is mainnet-only. If you're moving to sBPFv3 on 4.2.x, check which platform-tools your build actually uses. teapawt.net/SolPlay_jonas/status/2…
4
3
2
16
2,022
18.6 ETH in fees. totalFees() returns 0.153. uint64 tops out at ~18.44 ETH, and an explicit cast doesn't revert: it keeps the low 64 bits. withdrawFees() requires balance == totalFees, which never holds again. Fees locked. 0.8 wouldn't save you here. It checks overflow, not downcasts. Trace from my PoC 👇 github.com/alebeta06/codehaw… teapawt.net/Ale_Beta/status/211553…
I practiced auditing on Puppy Raffle, CodeHawks' First Flight #1. Found 6 of its 16 known issues and wrote 4 Foundry PoCs. The one I missed taught me the most. refund() looks fine on its own. So does selectWinner(). But refund() doesn't remove you from players[]. It writes address(0) in your slot. selectWinner() still counts that slot: → the winner can be address(0) → the prize math counts ETH that was already refunded I reviewed each function separately. The bug lives in the state they share. 🔑 Audit the system, not the functions. Findings + PoCs: github.com/alebeta06/codehaw…
1
1
106
Most reentrancy posts show the code. This is what it looks like when it runs. Puppy Raffle's refund() sends ETH before zeroing your slot. My attacker's receive() calls refund() again with the same index. 1 ETH in. 5 ETH out. Each step to the right is another refund() inside the previous one, until there's nothing left. It works because sendValue forwards all the gas. With transfer() and its 2300 gas, the re-entry would fail. The fix: zero the slot first, then send. PoC: github.com/alebeta06/codehaw… @CodeHawks @cyfrin
1
1
3
169
I practiced auditing on Puppy Raffle, CodeHawks' First Flight #1. Found 6 of its 16 known issues and wrote 4 Foundry PoCs. The one I missed taught me the most. refund() looks fine on its own. So does selectWinner(). But refund() doesn't remove you from players[]. It writes address(0) in your slot. selectWinner() still counts that slot: → the winner can be address(0) → the prize math counts ETH that was already refunded I reviewed each function separately. The bug lives in the state they share. 🔑 Audit the system, not the functions. Findings + PoCs: github.com/alebeta06/codehaw…
1
34
I practiced auditing on Puppy Raffle, CodeHawks' First Flight #1. Found 6 of its 16 known issues and wrote 4 Foundry PoCs. The one I missed taught me the most. refund() looks fine on its own. So does selectWinner(). But refund() doesn't remove you from players[]. It writes address(0) in your slot. selectWinner() still counts that slot: → the winner can be address(0) → the prize math counts ETH that was already refunded I reviewed each function separately. The bug lives in the state they share. 🔑 Audit the system, not the functions. Findings + PoCs: github.com/alebeta06/codehaw…
1
1
2
265
My property tests passed with 256 cases. At 50,000, one failed. No sabotage. The property said: if a swap works at a low price, it works at a higher one. The counterexample: amount = 0. Price 1 → Ok(0). A huge price → MathOverflow. In the reverse swap the price sits in the denominator. With 20+ decimals, price × 10^dec_b overflows u128 even when the real result fits. The function wasn't unsafe: typed error, no panic, nothing leaves the pool. My property was false. So I kept the half that's true, and documented the limit instead of reworking the math for 20+ decimal mints nobody uses. 🔑 proptest's default case count looks like a performance setting. It's a correctness setting. teapawt.net/Ale_Beta/status/211002… Repo: github.com/alebeta06/solana-…
New project: my first Solana program, coming from Solidity. A fixed-price SPL token swap in Rust + Anchor, deployed on devnet, with a Next.js frontend. Anyone can create a market for two tokens and set its price. Anyone can add liquidity, and users swap in both directions at that price. Stack: Rust + Anchor 1.2 for the program. Next.js, TypeScript and wallet adapter on the frontend. Devnet test tokens with Metaplex metadata and a public faucet that pays for your token accounts, so you can try it without asking anyone. Inside, it made me deal with: - Thinking in accounts instead of storage: PDA vaults and a canonical mint order, so one pair can't end up as two markets - Not trusting the caller: token decimals are read from the Mint account, not passed as a parameter - Property-based tests over the swap math: 500,000 generated cases found a panic that 27 integration tests missed - A CI I sabotaged on purpose to check it can actually fail 5 instructions, 9 typed errors, 133 tests across three suites, and known limitations written down in the README. Educational code, not audited. Try it on devnet (you'll need a little devnet SOL to swap), read the code, and tell me what you'd do differently: Demo: solana-token-swap.vercel.app Code: github.com/alebeta06/solana-… Audio note: I recorded the video in Spanish. The English you hear is YouTube's auto-dubbed track, not my voice. #Solana #rustlang
3
239
I sabotaged my CI and it stayed green. That was the correct result. Same type error, two runs: ❌ without `yarn typecheck` → green ✅ with it → red, tests never ran Vitest doesn't check types. It strips them and runs the JavaScript. So typecheck is its own step, before the tests. 🔑 A green check means nothing until you've seen it go red. Repo: github.com/alebeta06/solana-… teapawt.net/Ale_Beta/status/211002…
New project: my first Solana program, coming from Solidity. A fixed-price SPL token swap in Rust + Anchor, deployed on devnet, with a Next.js frontend. Anyone can create a market for two tokens and set its price. Anyone can add liquidity, and users swap in both directions at that price. Stack: Rust + Anchor 1.2 for the program. Next.js, TypeScript and wallet adapter on the frontend. Devnet test tokens with Metaplex metadata and a public faucet that pays for your token accounts, so you can try it without asking anyone. Inside, it made me deal with: - Thinking in accounts instead of storage: PDA vaults and a canonical mint order, so one pair can't end up as two markets - Not trusting the caller: token decimals are read from the Mint account, not passed as a parameter - Property-based tests over the swap math: 500,000 generated cases found a panic that 27 integration tests missed - A CI I sabotaged on purpose to check it can actually fail 5 instructions, 9 typed errors, 133 tests across three suites, and known limitations written down in the README. Educational code, not audited. Try it on devnet (you'll need a little devnet SOL to swap), read the code, and tell me what you'd do differently: Demo: solana-token-swap.vercel.app Code: github.com/alebeta06/solana-… Audio note: I recorded the video in Spanish. The English you hear is YouTube's auto-dubbed track, not my voice. #Solana #rustlang
1
190
I fixed a vulnerability in my Solana swap and opened a panic. A property-based test found it, not me. The fix first. The reference code took token decimals as an instruction parameter, even though the Mint accounts were right there. Declare decimals_a = 0 on a 9-decimal mint and the math is wrong forever, because the value is stored when the market is created. Two lines fixed it: read the decimals from the Mint. What that fix opened: the caller can no longer lie about decimals, but the program now accepts whatever the Mint says. And an SPL mint can have any u8, from 0 to 255. 10^38 fits in a u128. 10^39 doesn't. The code did 10u128.pow(decimals) unchecked, so with a mint of 39+ decimals every swap panicked instead of returning the MathOverflow error the program already had for exactly that case. 27 integration tests never saw it. They all use 6 and 9 decimals, the range real tokens live in, which is the range anyone tests by hand. The property tests sample decimals across the full 0..255. Capping them at 38 would have been a test designed to pass. proptest shrank the failure to the smallest case that still broke: amount = 0, price = 1, dec_a = 0, dec_b = 39. The fix is a pow10() that uses checked_pow and returns the typed error. Side effect I didn't expect: the program binary shrank by 1,984 bytes. How the tests were made: Claude Code wrote them. I chose the four properties the math had to obey and checked each one by breaking the code on purpose until it went red. What I take from it: moving trust from the caller to the Mint doesn't remove the input. It widens it. Validating where a value comes from means validating its range too. teapawt.net/Ale_Beta/status/211002…
New project: my first Solana program, coming from Solidity. A fixed-price SPL token swap in Rust + Anchor, deployed on devnet, with a Next.js frontend. Anyone can create a market for two tokens and set its price. Anyone can add liquidity, and users swap in both directions at that price. Stack: Rust + Anchor 1.2 for the program. Next.js, TypeScript and wallet adapter on the frontend. Devnet test tokens with Metaplex metadata and a public faucet that pays for your token accounts, so you can try it without asking anyone. Inside, it made me deal with: - Thinking in accounts instead of storage: PDA vaults and a canonical mint order, so one pair can't end up as two markets - Not trusting the caller: token decimals are read from the Mint account, not passed as a parameter - Property-based tests over the swap math: 500,000 generated cases found a panic that 27 integration tests missed - A CI I sabotaged on purpose to check it can actually fail 5 instructions, 9 typed errors, 133 tests across three suites, and known limitations written down in the README. Educational code, not audited. Try it on devnet (you'll need a little devnet SOL to swap), read the code, and tell me what you'd do differently: Demo: solana-token-swap.vercel.app Code: github.com/alebeta06/solana-… Audio note: I recorded the video in Spanish. The English you hear is YouTube's auto-dubbed track, not my voice. #Solana #rustlang
2
1
6
320
New project: my first Solana program, coming from Solidity. A fixed-price SPL token swap in Rust + Anchor, deployed on devnet, with a Next.js frontend. Anyone can create a market for two tokens and set its price. Anyone can add liquidity, and users swap in both directions at that price. Stack: Rust + Anchor 1.2 for the program. Next.js, TypeScript and wallet adapter on the frontend. Devnet test tokens with Metaplex metadata and a public faucet that pays for your token accounts, so you can try it without asking anyone. Inside, it made me deal with: - Thinking in accounts instead of storage: PDA vaults and a canonical mint order, so one pair can't end up as two markets - Not trusting the caller: token decimals are read from the Mint account, not passed as a parameter - Property-based tests over the swap math: 500,000 generated cases found a panic that 27 integration tests missed - A CI I sabotaged on purpose to check it can actually fail 5 instructions, 9 typed errors, 133 tests across three suites, and known limitations written down in the README. Educational code, not audited. Try it on devnet (you'll need a little devnet SOL to swap), read the code, and tell me what you'd do differently: Demo: solana-token-swap.vercel.app Code: github.com/alebeta06/solana-… Audio note: I recorded the video in Spanish. The English you hear is YouTube's auto-dubbed track, not my voice. #Solana #rustlang
1
4
1,036
Someone in my replies read my code and found a bug I had documented as a design decision. My Northwind demo runs its backend on Render's free tier, which sleeps after 15 minutes idle. The frontend handles that: retries plus a "server is waking up" notice. But only until the server had answered once: const coldStartPossible = !answeredOnce.current; The comment above it explained why: once it answers, it's awake. True, until it falls asleep again with the tab still open. Before touching anything, I measured it. Tab open for 20 minutes, Render logged the shutdown, then I sorted a column: 12.3 s of loading, then a 200, and no notice. Not the red error I expected from reading the code. Render holds the request while it boots. The fix tracks when the server last answered, not whether it ever did. Any load after 10 minutes of silence gets the notice and the retries back. Verified on the live deploy: notice at 3 s, then data. What I take from it: the comment wasn't wrong when I wrote it. The assumption under it stopped being true. The README made the same promise, so that changed too. teapawt.net/Ale_Beta/status/210567…
New project: Northwind Customer Management. A REST API in Rust with a Next.js admin panel on top. Full CRUD over the classic Northwind database (93 customers, 16,282 orders): filter, sort, create, edit and delete customers. Stack: Rust + Rocket, rusqlite (SQLite) and Docker on the backend. Next.js 15, TypeScript, Tailwind and shadcn/ui on the frontend. Backend on Render, frontend on Vercel. A CRUD looks boring from the outside. Inside, it made me deal with: - Concurrency: rusqlite's Connection isn't Sync, so Rocket won't even compile until it's behind a Mutex - Referential integrity: deleting a customer with orders returns a 409, shown as a business rule, not as an error - SQLite traps that only show up when you actually run things - A free-tier backend that goes to sleep, handled in the UI with retries instead of a red error 15 tests, clippy clean with -D warnings, and a README that explains why each decision was made. Try it, read the code, and tell me what you'd do differently: Demo: northwind-fullstack.vercel.a… (the first load can take up to a minute while the backend wakes up) Code: github.com/alebeta06/northwi… Audio note: I recorded the video in Spanish. The English you hear is YouTube's auto-dubbed track, not my voice. #rustlang
253
New project: Northwind Customer Management. A REST API in Rust with a Next.js admin panel on top. Full CRUD over the classic Northwind database (93 customers, 16,282 orders): filter, sort, create, edit and delete customers. Stack: Rust + Rocket, rusqlite (SQLite) and Docker on the backend. Next.js 15, TypeScript, Tailwind and shadcn/ui on the frontend. Backend on Render, frontend on Vercel. A CRUD looks boring from the outside. Inside, it made me deal with: - Concurrency: rusqlite's Connection isn't Sync, so Rocket won't even compile until it's behind a Mutex - Referential integrity: deleting a customer with orders returns a 409, shown as a business rule, not as an error - SQLite traps that only show up when you actually run things - A free-tier backend that goes to sleep, handled in the UI with retries instead of a red error 15 tests, clippy clean with -D warnings, and a README that explains why each decision was made. Try it, read the code, and tell me what you'd do differently: Demo: northwind-fullstack.vercel.a… (the first load can take up to a minute while the backend wakes up) Code: github.com/alebeta06/northwi… Audio note: I recorded the video in Spanish. The English you hear is YouTube's auto-dubbed track, not my voice. #rustlang
2
1
713
I don't write most of my code by hand. Claude Code does, and I approve it. The part nobody talks about: six times in one project, the agent read the code and told me my own instruction was wrong 🧵
1
278
The instruction that produced all six is one line: Read the code and report back before you write anything. It turns every request into something checked against the repo instead of executed blind. The report comes back before a single line changes.
1
41
I moved off the saturated public RPC to a dedicated provider, like people in the replies told me to. The deploy problem went away. Then my faucet started returning 502 after 26 seconds, while the mint was working fine 🧵
1
223
Method 'signatureSubscribe' not found, code -32601. confirmTransaction in @solana/web3.js confirms over WebSocket: it subscribes to the signature and waits to be told. The HTTPS URL of a provider doesn't have to expose that. Mine has a separate wss:// endpoint.
1
39
I built an Ethereum wallet as a Chrome extension from scratch. 37 of 37 specs, BIP-39/44, EIP-1193, EIP-6963, EIP-712. The interesting part isn't the wallet. It's that the build fails if a private key could ever reach the UI 🧵
1
1
384
The rule: the mnemonic and the keys live only in the service worker. The popup and the approval windows are interface. They send messages and render results, but never import ethers, derive a wallet or sign. Three process hops between a page and a key, and none carries it.
1
32
My swaps failed about 4 times in 10 with "Blockhash not found". Same code, same RPC, no pattern. The cause wasn't my code. It was which node answered each request 🧵
1
1
194
My first guess: the frontend was falling back to the saturated public RPC. Wrong. The network tab showed every request going to Alchemy. Third wrong hypothesis in the same phase. The log keeps answering in a second what reasoning doesn't in half an hour.
1
36
I wrote four tests for the new Solana Explorer MCP and designed two of them expecting it to fail. It passed all four. Ran them against my own devnet deployment, where I already know every value it should return 🧵
2
2
3
461
Trap 1: one swap transaction with two inner transfers. The first is authorized by my wallet. The second by the market PDA, which has no private key. Telling those apart is where automated tooling usually flattens everything into "a wallet signed it".
1
2
68
27 tests passing. 15 type errors. Same repo, same moment, both true. I ran npx tsc --noEmit for the first time after finishing my deploy scripts. Fifteen errors. anchor test had been green the whole time. They measure different things: anchor test → ts-mocha → ts-node in transpile-only mode → types stripped, never checked npx tsc --noEmit → checks everything Transpile-only is a deliberate performance tradeoff and a reasonable one. It also means your test code can rot with nothing warning you. Coming from Foundry this can't happen: forge test compiles with solc, and if it doesn't compile, it doesn't run. One file had been broken for months. migrations/deploy.ts imported a package that stopped being a dependency back in phase 2. It never ran, because Mocha only loads tests/**. Deleted. Then the finding I would not have got on my own. Claude Code caught it: Some .accounts({ market, authority }) calls in my tests compiled fine, even though the client isn't supposed to pass those. It looked like it was allowed there. It wasn't. In set_price both accounts resolve to never — market because the IDL marks it as a pda, authority because of relations. The expected type is {}, and TypeScript doesn't run excess property checks against an empty type. It compiled because there was nothing to compare against. The same fields in the swap instructions, where the type isn't empty, failed with TS2353. And four of the seven places didn't need a cast at all. The tests were passing seven accounts where the program needs three. One test went from twenty lines to six and now says exactly what its name claims. Result: tsc clean, still 27 passing, one irreducible any, and a "typecheck": "tsc --noEmit" script so it can't drift again. The line I'm keeping: a .accounts() call compiling tells you nothing about whether the account set is the one the program expects. github.com/alebeta06/solana-…
1
1
363
My program validates everything. My frontend could throw all of it away, and the failure would be silent. The program checks that the vault belongs to the market, that decimals come from the mint, that mints are in canonical order. None of that stops the client from calling swap_a_to_b when the user asked for the opposite. The transaction would succeed. The program does exactly what you tell it. The user sees a confirmed swap in the explorer, in the wrong direction, with no error to look up. Why it's so easy to get wrong: the user thinks "I want to sell DEMO9". The program thinks swap_a_to_b or swap_b_to_a. The translation depends on which mint won a comparison of 32 bytes when the market was created. Not decimals, not name, not value. In my deployment, DEMO9 is token A. That is not a property of DEMO9. With different mints it would have come out the other way. This already bit me twice. In phase 4 I wrote a test assuming token A was the 6-decimal one; it failed, and the fix was choosing the direction at runtime. In phase 6, naming the mints by their decimals instead of TokenA/TokenB turned out to be the right call, because the deploy confirmed TokenA would have been token B. Third time around, with the highest stakes: in a test you see the failure. In the frontend you don't. So the defense is structural: - the manifest is the single source of truth for which symbol is A and which is B - one module translates symbol to side, and nothing else in the app derives it - one module calls the instructions Plus a test that fails if anyone ever derives the side from decimals again: swapped decimals, A/B assignment intact, the swap direction must not change. The phase 4 bug turned into a permanent barrier. And the interface shows the instruction it is about to call: Instruction: swap_a_to_b Selling DEMO9 says swap_a_to_b. Flip the direction and it says swap_b_to_a. Showing the instruction turns an invisible decision into something anyone can check at a glance. "The contract is secure" and "the dApp is correct" are two different claims. Both images are the same swap: the UI before signing, and the two inner transfers on chain. 1 DEMO9 in with 0.5% slippage, 2 DEMO6 out. explorer.solana.com/tx/24V6r… github.com/alebeta06/solana-…
1
2
244