From blockchain-web3-pro
Smart contracts, dApps, DeFi, NFT, testing, security, gas optimization. Use when building or auditing Web3 or blockchain projects.
How this skill is triggered — by the user, by Claude, or both
Slash command
/blockchain-web3-pro:blockchain-web3-proThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Build secure, efficient blockchain applications. Covers Solidity smart contracts, dApp architecture, DeFi patterns, gas optimization, testing, and security auditing.
Build secure, efficient blockchain applications. Covers Solidity smart contracts, dApp architecture, DeFi patterns, gas optimization, testing, and security auditing.
Use this when:
Use this ESPECIALLY when:
Don't skip when:
// contracts/ProjectToken.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
contract ProjectToken is ERC20, Ownable, ReentrancyGuard {
uint256 public constant MAX_SUPPLY = 1_000_000 * 10**18;
mapping(address => uint256) public lastClaimed;
event TokensClaimed(address indexed user, uint256 amount);
constructor() ERC20("ProjectToken", "PRJ") Ownable(msg.sender) {}
function claim() external nonReentrant {
require(lastClaimed[msg.sender] == 0, "Already claimed");
require(totalSupply() + 100 * 10**18 <= MAX_SUPPLY, "Exceeds max supply");
lastClaimed[msg.sender] = block.timestamp;
_mint(msg.sender, 100 * 10**18);
emit TokensClaimed(msg.sender, 100 * 10**18);
}
function withdraw() external onlyOwner {
uint256 balance = address(this).balance;
(bool sent,) = owner().call{value: balance}("");
require(sent, "Transfer failed");
}
}
// ❌ Expensive
function sumArray(uint[] memory arr) public pure returns (uint) {
uint sum = 0;
for (uint i = 0; i < arr.length; i++) {
sum += arr[i];
}
return sum;
}
// ✅ Cheaper (cache array length, unchecked increments)
function sumArray(uint[] calldata arr) public pure returns (uint) {
uint sum = 0;
uint len = arr.length;
for (uint i = 0; i < len; ) {
sum += arr[i];
unchecked { i++; }
}
return sum;
}
// ✅ Checks-Effects-Interactions pattern (prevents reentrancy)
function withdraw() external nonReentrant {
uint256 amount = balances[msg.sender];
require(amount > 0, "No balance");
// 1. Effects (state change first)
balances[msg.sender] = 0;
// 2. Interactions (external calls after)
(bool sent,) = msg.sender.call{value: amount}("");
require(sent, "Transfer failed");
}
// ✅ Access control
modifier onlyRole(bytes32 role) {
require(hasRole(role, msg.sender), "Unauthorized");
_;
}
// ✅ Emergency stop (circuit breaker)
bool public paused;
modifier whenNotPaused() { require(!paused, "Paused"); _; }
function pause() external onlyOwner { paused = true; }
function unpause() external onlyOwner { paused = false; }
import { expect } from 'chai'
import { ethers } from 'hardhat'
describe('ProjectToken', () => {
it('should mint tokens on claim', async () => {
const [owner, user] = await ethers.getSigners()
const token = await ethers.deployContract('ProjectToken')
await token.connect(user).claim()
const balance = await token.balanceOf(user.address)
expect(balance).to.equal(ethers.parseEther('100'))
})
it('should prevent double claim', async () => {
const [_, user] = await ethers.getSigners()
const token = await ethers.deployContract('ProjectToken')
await token.connect(user).claim()
await expect(token.connect(user).claim()).to.be.revertedWith('Already claimed')
})
it('should respect max supply', async () => {
// Test edge case: minting at supply limit
})
})
dapp/
contracts/ ← Solidity source
test/ ← Hardhat tests
scripts/ ← Deployment scripts
frontend/
app/
wallet/ ← Wagmi / Web3Modal
contracts/
hooks.ts ← useProjectToken
abi/ ← Generated ABIs
components/
ConnectWallet.tsx
ClaimTokens.tsx
lib/
wagmi.ts ← Chain config
hardhat.config.ts
Provides CDSS development patterns for drug interaction checking, dose validation, clinical scoring (NEWS2, qSOFA), and alert classification integrated into EMR workflows.
npx claudepluginhub haj1t/senior-dev-squad-skills --plugin blockchain-web3-pro