Deploying Contracts on GateLayer
Prerequisites
- Configure RPC endpoint (testnet:
https://gatelayer-testnet.gatenode.cc, mainnet:https://gatelayer-mainnet.gatenode.cc) - Store private keys in Foundry's encrypted keystore — never commit keys
- Obtain testnet GT from faucet (testnet only)
Security
- Never commit private keys to version control — use Foundry's encrypted keystore (
cast wallet import) - Never hardcode API keys in source files — use environment variables or
foundry.tomlwith${ENV_VAR}references - Never expose
.envfiles — add.envto.gitignore - Use production RPC providers (not public endpoints) for mainnet deployments to avoid rate limits and data leaks
- Verify contracts on GateScan to enable public audit of deployed code
Input Validation
Before constructing shell commands, validate all user-provided values:
- contract-path: Must match
^[a-zA-Z0-9_/.-]+\.sol:[a-zA-Z0-9_]+$. Reject paths with spaces, semicolons, pipes, or backticks. - rpc-url: Must be a valid HTTPS URL (
^https://[^\s;|&]+$). Reject non-HTTPS or malformed URLs. - keystore-account: Must be alphanumeric with hyphens/underscores (
^[a-zA-Z0-9_-]+$).
Do not pass unvalidated user input into shell commands.
Obtaining Testnet GT
Testnet GT is required to pay gas on GateLayer Testnet. Use the Gatelayer Faucet to claim it. Supported token :GT claims are capped at 0.1 GT per claim, 1 claims per 24 hours.
Gatelayer UI (recommended for quick setup)
Agent behavior: If you have browser access, navigate to the portal and claim directly. Otherwise, ask the user to complete these steps and provide the funded wallet address.
- Go to Gatelayer Faucets
- Select Gatelayer network
- Enter the wallet address and click Claim
- Verify on Gatelayer Testnet Scan that the funds arrived
Deployment and Verify Commands
Testnet
forge create src/MyContract.sol:MyContract \
--rpc-url https://gatelayer-testnet.gatenode.cc \
--account <keystore-account> \
--verify \
--verifier-url 'https://www.gatescan.org/gatelayer-testnet/api' \
--verifier blockscout
Mainnet
forge create src/MyContract.sol:MyContract \
--rpc-url https://gatelayer-mainnet.gatenode.cc \
--account <keystore-account> \
--verify \
--verifier-url 'https://www.gatescan.org/gatelayer/api' \
--verifier blockscout
Key Notes
- Contract format:
<contract-path>:<contract-name> - Explorers: www.gatescan.org/gatelayer (mainnet), www.gatescan.org/gatelayer-testnet (testnet)
Common Issues
| Error | Cause |
|---|---|
nonce has already been used | Node sync incomplete |
| Transaction fails | Insufficient GT for gas — obtain from faucet |
| Verification fails | Wrong RPC endpoint for target network |