This project allows you to run Solidity smart contracts using TypeScript
npm install --legacy-peer-deps
- Run a local Hardhat node:
npm run node
- In a separate terminal, deploy your contract:
npm run deploy
- Create a
.env
file in the root directory with the following content:
INFURA_API_KEY=your_infura_api_key_here
PRIVATE_KEY=your_private_key_here
-
Get some Sepolia ETH from a faucet like Sepolia Faucet
-
Deploy to Sepolia:
npm run deploy:sepolia
- Create a
.env
file in the root directory with the following content:
INFURA_API_KEY=your_infura_api_key_here
PRIVATE_KEY=your_private_key_here
-
Make sure your wallet has enough ETH to cover the deployment gas costs.
-
Deploy to Mainnet:
npm run deploy:mainnet
The deployment script includes:
- Clear warnings when deploying to mainnet
- Timeouts to prevent accidental deployments
- Gas price configuration (default: 0.58 gwei)
- Verification of read-only vs state-changing methods
Check scripts/deploy.ts
.
import { ContractInterpreter } from "../src/ContractInterpreter";
// Example Solidity contract
const contractSource = `
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract MySmartContract {
uint256 public myValue;
constructor() {
myValue = 42;
}
function setMyValue(uint256 newValue) public {
myValue = newValue;
}
}
`;
async function main() {
// Create interpreter
const interpreter = new ContractInterpreter(contractSource, 'MySmartContract');
// Compile contract
const runner = await interpreter.compile();
// Deploy contract
await runner.deploy();
// Call contract function
const currentValue = await runner.call('myValue');
console.log('Current value:', currentValue.toString());
// Set new value
await runner.call('setMyValue', 100);
// Verify changes
const newValue = await runner.call('myValue');
console.log('New value:', newValue.toString());
}
main().catch(console.error);
- Node.js v20.19.0 or newer (Node.js v18 is reaching End-Of-Life on April 30, 2025.)
- Local Hardhat node HTTP and WebSocket JSON-RPC server running at http://127.0.0.1:8545/
- NPM 10.8.2 or newer
- For testnet/mainnet: Infura API key and wallet with ETH
- Solidity contract compilation
- Contract deployment to supported networks by Infura (Local, Testnet, Mainnet)
- Interaction with deployed contracts
- Support for all Solidity contract functions
- Gas price management for mainnet transactions
'failed with 8856989 gas: max fee per gas less than block base fee: address 0xC08314D6E1e1CfF0787a51a12F7eEB8FF9921eDC, maxFeePerGas: 580000000, baseFee: 600524959'
Answer> Modify hardhat.config.cjs
gasPrice: 580000000 to gasPrice: 600524959
'Can we use OpenZeppelin or Solidity libraries?'
Answer> This is the future of iteration I'm looking for, I will put this into consideration
You can donate to my main address fzn0x.eth / 0xC08314D6E1e1CfF0787a51a12F7eEB8FF9921eDC
MIT