Comprehensive guide for Polygon PoS blockchain development. Use when deploying smart contracts to Polygon, testing on Amoy testnet, getting test tokens from faucets, or verifying contracts on Polygonscan. Supports Foundry framework with deployment scripts and testing strategies.
数据来源:ClawHub。 在 ClawSkills 查看
选择你使用的 Agent
方法一:命令行安装(推荐)
推荐(无需提前安装 clawhub)
npx clawhub@latest --dir ~/.claude/skills install polygon-pos-dev或使用 clawhub CLI(需提前安装)
clawhub --dir ~/.claude/skills install polygon-pos-dev⚠️ 需要 Node.js 18+,没有 Node?请使用下方方法二直接下载 ZIP。 安装 Node.js →
方法二:手动下载安装(无需 Node)
下载 ZIP,解压后将文件夹放到以下路径,重启 Agent 即可:
安装路径
~/.claude/skills/polygon-pos-dev/💡解压后将文件夹放到上方路径,重启 Agent 即可生效
--- name: polygon-pos-dev description: Comprehensive guide for Polygon PoS blockchain development. Use when deploying smart contracts to Polygon, testing on Amoy testnet, getting test tokens from faucets, or verifying contracts on Polygonscan. Supports Foundry framework with deployment scripts and testing strategies. ---
End-to-end guide for developing and deploying smart contracts on Polygon PoS blockchain using Foundry.
Polygon PoS is an EVM-compatible Proof-of-Stake sidechain for Ethereum with:
Default Network: Amoy Testnet (Chain ID: 80002) - Use for all testing before mainnet.
---
For Agents/Fast Deployment: Jump to Quick Start Path (5-10 min)
For Production/Thorough Testing: Jump to Complete Development Path (30-60 min)
For Reference: See sections below for Network Configuration, Faucets, Troubleshooting
---
Choose based on your needs:
| Aspect | Quick Start Path | Complete Development Path | |--------|------------------|---------------------------| | Time | 5-10 minutes | 30-60 minutes | | Best for | Prototypes, demos, simple contracts | Production, complex systems, mainnet | | Testing | Basic compilation check | Unit tests, integration tests, fork tests | | Scripts Used | None (direct forge commands) | Direct forge commands with all options | | Documentation | Minimal | Full reference guides | | Verification | Automatic during deploy | Multiple methods with troubleshooting | | Agent-Friendly | ✅ Optimized for speed | ⚠️ Comprehensive but slower |
Best for: Fast deployment, simple contracts, prototyping Time: 5-10 minutes What you get: Contract deployed and verified on testnet
Skip to Quick Start Path below.
Best for: Production contracts, complex systems, thorough testing Time: 30-60 minutes What you get: Fully tested, optimized, and production-ready deployment
Skip to Complete Development Path below.
---
Goal: Deploy a contract to Polygon Amoy testnet in minimal steps.
curl -L https://foundry.paradigm.xyz | bash && foundryupforge init my-polygon-project
cd my-polygon-project
Create .env file:
PRIVATE_KEY=your_private_key_without_0x_prefix
Visit: https://www.alchemy.com/faucets/polygon-amoy
# Deploy to Amoy testnet
forge script script/Counter.s.sol:CounterScript \
--rpc-url https://rpc-amoy.polygon.technology \
--private-key $PRIVATE_KEY \
--broadcast
Done! Your contract is deployed and verified on Amoy testnet.
View at: https://amoy.polygonscan.com/address/YOUR_CONTRACT_ADDRESS
---
Goal: Production-ready deployment with comprehensive testing and optimization.
curl -L https://foundry.paradigm.xyz | bash
foundryup
forge init my-polygon-project
cd my-polygon-project
Update foundry.toml with Polygon settings:
[profile.default]
src = "src"
out = "out"
libs = ["lib"]
solc_version = "0.8.24"
optimizer = true
optimizer_runs = 200
[rpc_endpoints]
amoy = "https://rpc-amoy.polygon.technology"
polygon = "https://polygon-rpc.com"
[etherscan]
amoy = { key = "${POLYGONSCAN_API_KEY}", url = "https://api-amoy.polygonscan.com/api" }
polygon = { key = "${POLYGONSCAN_API_KEY}", url = "https://api.polygonscan.com/api" }
Create .env file:
PRIVATE_KEY=your_private_key
WALLET_ADDRESS=0xYourAddress
POLYGONSCAN_API_KEY=your_api_key
assets/sample-contracts/HelloWorld.sol as template)// test/MyContract.t.sol
import "forge-std/Test.sol";
import "../src/MyContract.sol";
contract MyContractTest is Test {
MyContract public myContract;
function setUp() public {
myContract = new MyContract();
}
function testDeployment() public {
assertEq(myContract.owner(), address(this));
}
}
forge test -vvv # Run tests
forge test --gas-report # Check gas usage
forge coverage # Check coverage
# Test against real Polygon state
forge test --fork-url https://polygon-rpc.com
See references/testing-strategies.md for comprehensive testing patterns.
Visit one of these faucets:
Alchemy (recommended - no auth): https://www.alchemy.com/faucets/polygon-amoy QuickNode: https://faucet.quicknode.com/polygon/amoy GetBlock: https://getblock.io/faucet/matic-amoy/ Chainlink: https://faucets.chain.link/polygon-amoy LearnWeb3: https://learnweb3.io/faucets/polygon_amoy/
forge script script/Deploy.s.sol \
--rpc-url amoy \
--private-key $PRIVATE_KEY \
--broadcast \
--verify \
--etherscan-api-key $POLYGONSCAN_API_KEY
Create a deployment script in script/Deploy.s.sol:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
import "forge-std/Script.sol";
import "../src/YourContract.sol";
contract DeployScript is Script {
function run() external {
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
vm.startBroadcast(deployerPrivateKey);
// Deploy your contract
YourContract yourContract = new YourContract();
vm.stopBroadcast();
console.log("Contract deployed to:", address(yourContract));
}
}
See references/foundry-deployment.md for advanced deployment patterns.
If not verified during deployment:
forge verify-contract \
CONTRACT_ADDRESS \
src/MyContract.sol:MyContract \
--chain-id 80002 \
--etherscan-api-key $POLYGONSCAN_API_KEY
See references/contract-verification.md for troubleshooting verification issues.
⚠️ IMPORTANT: Complete mainnet deployment checklist first!
See Mainnet Deployment Checklist below.
forge script script/Deploy.s.sol \
--rpc-url polygon \
--private-key $PRIVATE_KEY \
--broadcast \
--verify \
--etherscan-api-key $POLYGONSCAN_API_KEY
End of Complete Development Path ✅
...
安装 Polygon PoS Development 后,可以对 AI 说这些话来触发它
Help me get started with Polygon PoS Development
Explains what Polygon PoS Development does, walks through the setup, and runs a quick demo based on your current project
Use Polygon PoS Development to comprehensive guide for Polygon PoS blockchain development
Invokes Polygon PoS Development with the right parameters and returns the result directly in the conversation
What can I do with Polygon PoS Development in my developer & devops workflow?
Lists the top use cases for Polygon PoS Development, with example commands for each scenario
将技能文件夹放到 ~/.claude/skills/polygon-pos-dev/ 目录(个人级,所有项目可用),或 .claude/skills/polygon-pos-dev/(项目级)。重启 AI 客户端后,用 /polygon-pos-dev 主动调用,或让 AI 根据上下文自动发现并使用。
Polygon PoS Development 支持 Claude、Cursor、OpenClaw,可与这些 AI 平台无缝集成,扩展其能力。
Polygon PoS Development 可免费安装使用。请查阅仓库了解许可证信息。
Comprehensive guide for Polygon PoS blockchain development. Use when deploying smart contracts to Polygon, testing on Amoy testnet, getting test tokens from faucets, or verifying contracts on Polygonscan. Supports Foundry framework with deployment scripts and testing strategies.
Automate my developer & devops tasks using Polygon PoS Development
Identifies repetitive steps in your workflow and sets up Polygon PoS Development to handle them automatically
Polygon PoS Development 属于「Developer & DevOps」分类,该分类的技能帮助 AI 智能体在此领域执行专业任务。