Deploying Contracts
Overviewβ
Learn how to deploy smart contracts to Circle Layer testnet.
Network Configurationβ
Circle Layer Testnetβ
- RPC URL: https://testnet-rpc.circlelayer.com
- Chain ID: 28525
- Currency Symbol: CLAYER
- Gas Price: Minimum 0.000021 CLAYER (adjusts based on network consumption)
- Block Gas Limit: 10,000,000,000,000 per block
- Block Explorer: https://explorer-testnet.circlelayer.com/
Deployment Methodsβ
1. Using Hardhatβ
// hardhat.config.js
require('@nomiclabs/hardhat-ethers');
module.exports = {
solidity: "0.8.19",
networks: {
circleLayerTestnet: {
url: "https://testnet-rpc.circlelayer.com",
chainId: 28525,
accounts: [process.env.PRIVATE_KEY],
gasPrice: 21000000000, // 0.000021 CLAYER in wei
gas: 10000000000000 // Block gas limit
}
}
};
// deploy.js
async function main() {
const [deployer] = await ethers.getSigners();
console.log("Deploying with account:", deployer.address);
console.log("Account balance:", (await deployer.getBalance()).toString());
const Contract = await ethers.getContractFactory("MyContract");
const contract = await Contract.deploy({
gasPrice: ethers.utils.parseUnits('21', 'gwei'), // 0.000021 CLAYER
});
await contract.deployed();
console.log("Contract deployed to:", contract.address);
console.log("Transaction hash:", contract.deployTransaction.hash);
}
main()
.then(() => process.exit(0))
.catch(error => {
console.error(error);
process.exit(1);
});
2. Using Truffleβ
// truffle-config.js
const HDWalletProvider = require('@truffle/hdwallet-provider');
module.exports = {
networks: {
circleLayerTestnet: {
provider: () => new HDWalletProvider(
process.env.PRIVATE_KEY,
'https://testnet-rpc.circlelayer.com'
),
network_id: 28525,
gas: 10000000000000,
gasPrice: 21000000000, // 0.000021 CLAYER in wei
confirmations: 2,
timeoutBlocks: 200,
skipDryRun: true
}
},
compilers: {
solc: {
version: "0.8.19"
}
}
};
// migrations/1_deploy_contracts.js
const MyContract = artifacts.require("MyContract");
module.exports = function(deployer) {
deployer.deploy(MyContract);
};
3. Using Remix IDEβ
- Open Remix IDE
- Connect to Circle Layer testnet:
- Environment: "Injected Provider - MetaMask"
- Ensure MetaMask is connected to Circle Layer Testnet
- Compile your contract
- Deploy with appropriate gas settings
Example Deployed Contractβ
For reference, here's an example contract deployed on Circle Layer testnet:
- Contract Address: 0xfCb4Ce5953dE22cbF04d015df88a3a9895E86bEB
- Explorer: View Contract
- ABI: Contract ABI
Deployment Checklistβ
1. Pre-deploymentβ
- Test thoroughly on Circle Layer testnet
- Get CLAYER from faucet
- Check gas estimates with current network conditions
- Verify constructor arguments
2. During Deploymentβ
- Monitor transaction on explorer
- Use appropriate gas price (minimum 0.000021 CLAYER)
- Verify deployment address
- Save deployment info
3. Post-deploymentβ
- Verify contract on block explorer
- Test functionality with CLAYER
- Update documentation
- Monitor events
Gas Calculationβ
Circle Layer follows Ethereum's standard gas calculation:
Total Fee = Gas Price Γ Gas Used
With current parameters:
- Minimum Gas Price: 0.000021 CLAYER
- Block Gas Limit: 10,000,000,000,000
- Average Block Time: 3 seconds
Best Practicesβ
1. Securityβ
- Use secure private keys
- Test on Circle Layer testnet first
- Verify contract code on explorer
- Monitor deployment transactions
2. Cost Optimizationβ
- Optimize contract size for lower deployment costs
- Use appropriate gas price based on network conditions
- Consider gas efficiency in contract design
- Monitor CLAYER token costs
3. Integrationβ
- Same as EVM blockchain integration
- Compatible with existing Ethereum development tools
- Use standard Web3 libraries (Web3.js, Ethers.js)
4. Maintenanceβ
- Keep deployment records
- Monitor contract activity on explorer
- Update documentation
- Plan for upgrades