smart-contracts
Develop and deploy secure smart contracts on blockchain platforms using Solidity and Web3 technologies.
What this skill does
# smart-contracts
## Purpose
This skill focuses on developing, compiling, deploying, and interacting with secure smart contracts using Solidity for writing code and Web3.js for blockchain interactions, targeting platforms like Ethereum.
## When to Use
Use this skill for tasks involving decentralized applications (dApps), token creation, or automated agreements on EVM-compatible blockchains. Apply it when you need to ensure code security, handle transactions, or integrate with Web3 ecosystems, such as building NFTs or DeFi protocols.
## Key Capabilities
- Write and compile Solidity contracts with features like inheritance, modifiers, and events.
- Deploy contracts to testnets (e.g., Sepolia) or mainnets using Web3.js providers.
- Interact with deployed contracts via RPC calls, including reading state and executing functions.
- Perform security audits by integrating tools like Slither for vulnerability detection.
- Handle Web3 transactions with gas estimation and error checking.
## Usage Patterns
To use this skill, structure your workflow as follows: First, write Solidity code in a .sol file. Then, compile it using a tool like Hardhat or solc. Deploy via a Web3 provider, and interact using JavaScript. Always test on a local node (e.g., Ganache) before mainnet. For integration, pass provider URLs as environment variables, like `$ETHEREUM_PROVIDER_URL`. Example pattern: Import Web3.js, connect to a provider, and call contract methods in a Node.js script.
## Common Commands/API
Use solc for compilation: `solc --optimize --bin input.sol -o build/`. For deployment with Hardhat, run `npx hardhat run scripts/deploy.js --network sepolia`. Web3.js API: Create a provider with `const web3 = new Web3($ETHEREUM_PROVIDER_URL);` and call `web3.eth.getBalance(address)`. For contract interaction, use ABI: `contract.methods.myFunction().send({from: account, gas: 200000})`. Config format: In Hardhat.config.js, define networks like `networks: { sepolia: { url: process.env.SEPOLIA_URL, accounts: [process.env.PRIVATE_KEY] } }`, where `$SEPOLIA_URL` and `$PRIVATE_KEY` are env vars. Authenticate with Infura by setting `$INFURA_API_KEY` in the provider URL.
## Integration Notes
Integrate this skill by installing dependencies like `npm install hardhat web3`. Set up a .env file for sensitive data (e.g., `ETHEREUM_PRIVATE_KEY=$YOUR_PRIVATE_KEY`). For external APIs, use providers like Infura or Alchemy with URLs formatted as `https://mainnet.infura.io/v3/$INFURA_API_KEY`. Ensure compatibility by using Web3.js version 1.x for Etherscan verification. To link with other skills, export contract ABIs as JSON for downstream use, e.g., in a frontend with React.
## Error Handling
Handle compilation errors by checking solc output for messages like "ParserError: Expected token". For deployment, catch Web3.js errors with try-catch blocks, e.g., `try { await contract.deploy({data: bytecode}); } catch (e) { if (e.message.includes('gas')) console.error('Insufficient gas'); }`. Common issues: Reverted transactions (check with `web3.eth.getTransactionReceipt(txHash)` for status); use events for asynchronous error logging. For security, validate inputs in Solidity with require statements, e.g., `require(msg.sender == owner, "Not authorized");`. Always use a funded account and monitor gas limits.
## Concrete Usage Examples
1. **Write and Deploy a Simple Storage Contract**: Create a file `SimpleStorage.sol` with `pragma solidity ^0.8.0; contract SimpleStorage { uint storedData; function set(uint x) public { storedData = x; } }`. Compile with `solc --bin SimpleStorage.sol`. Deploy using Hardhat: In `deploy.js`, write `const SimpleStorage = await ethers.getContractFactory("SimpleStorage"); const contract = await SimpleStorage.deploy(); await contract.deployed();`. Run `npx hardhat run deploy.js --network localhost`.
2. **Interact with an ERC20 Token Contract**: Assume a deployed token at address `0xTokenAddress`. In a Node.js script: `const web3 = new Web3($ETHEREUM_PROVIDER_URL); const contract = new web3.eth.Contract(ABI, '0xTokenAddress'); await contract.methods.transfer('0xRecipient', 100).send({from: '0xYourAddress', gas: 50000});`. Handle with error checking for insufficient funds.
## Graph Relationships
- Related to cluster: "blockchain" (e.g., shares tools with other blockchain skills).
- Connected via tags: "solidity" (links to language-specific tools), "smart-contracts" (cross-references deployment patterns), "blockchain" (integrates with general blockchain APIs).
- Outgoing edges: To "web3" for provider interactions, to "ethereum" for network specifics.
Related in Cloud & DevOps
appbuilder-action-scaffolder
IncludedCreate, implement, deploy, and debug Adobe Runtime actions with consistent layout, validation, and error handling. Use this skill whenever the user needs to add actions to an App Builder project, understand action structure (params, response format, web/raw actions), configure actions in the manifest, use App Builder SDKs (State, Files, Events, database), deploy and invoke actions via CLI, debug action issues, or implement patterns such as webhook receivers, custom event providers, journaling consumers, large payload redirects, action sequence pipelines, and Asset Compute workers. Also trigger when users mention serverless functions in Adobe context, action logging, IMS authentication for actions, or cron-style scheduled actions.
orchestrating-datacloud
IncludedSalesforce Data Cloud product orchestrator for connect→prepare→harmonize→segment→act workflows. Use this skill when the user needs a multi-step Data Cloud pipeline, cross-phase troubleshooting, or data space and data kit management. TRIGGER when: user needs a multi-step Data Cloud pipeline, asks to set up or troubleshoot Data Cloud across phases, manages data spaces or data kits, or wants a cross-phase sf data360 workflow. DO NOT TRIGGER when: work is isolated to a single phase (use the matching phase-specific skill), the task is STDM/session tracing/parquet telemetry (use observing-agentforce), standard CRM SOQL (use querying-soql), or Apex implementation (use generating-apex).
github-project-automation
IncludedAutomate GitHub repository setup with CI/CD workflows, issue templates, Dependabot, and CodeQL security scanning. Includes 12 production-tested workflows and prevents 18 errors: YAML syntax, action pinning, and configuration. Use when: setting up GitHub Actions CI/CD, creating issue/PR templates, enabling Dependabot or CodeQL scanning, deploying to Cloudflare Workers, implementing matrix testing, or troubleshooting YAML indentation, action version pinning, secrets syntax, runner versions, or CodeQL configuration. Keywords: github actions, github workflow, ci/cd, issue templates, pull request templates, dependabot, codeql, security scanning, yaml syntax, github automation, repository setup, workflow templates, github actions matrix, secrets management, branch protection, codeowners, github projects, continuous integration, continuous deployment, workflow syntax error, action version pinning, runner version, github context, yaml indentation error
sf-datacloud
IncludedSalesforce Data Cloud product orchestrator for connect→prepare→harmonize→segment→act workflows. TRIGGER when: user needs a multi-step Data Cloud pipeline, asks to set up or troubleshoot Data Cloud across phases, manages data spaces or data kits, or wants a cross-phase `sf data360` workflow. DO NOT TRIGGER when: work is isolated to a single phase (use the matching sf-datacloud-* skill), the task is STDM/session tracing/parquet telemetry (use sf-ai-agentforce-observability), standard CRM SOQL (use sf-soql), or Apex implementation (use sf-apex).
fabric-cli
IncludedUse this skill for Fabric.so CLI workflows with the `fabric` terminal command: diagnose/install/login, search or browse a Fabric library, save notes/links/files, create folders, ask the Fabric AI assistant, manage tasks/workspaces, generate shell completion, check subscription usage, produce JSON output, and use Fabric as persistent agent memory. Do not use for Microsoft Fabric/Azure/Power BI `fab`, Daniel Miessler's Fabric framework, Python Fabric SSH, Fabric.js, or textile/fashion fabric.
lark
IncludedLark/Feishu CLI skills: lark-cli operations for docs, markdown, sheets, base, calendar, im, mail, task, okr, drive, wiki, slides, whiteboard, apps, approval, attendance, contact, vc, minutes, event. Use when the user needs to operate Lark/Feishu resources via lark-cli, send messages, manage documents, spreadsheets, calendars, tasks, OKRs, deploy web pages, or any Feishu/Lark workspace operations.