@aixweb3/evi-contracts
v1.0.1
Published
AI-powered smart contract generator and deployer for Arbitrum networks with Gemini 2.0 Flash LLM integration
Downloads
10
Maintainers
Readme
EVI Contracts
AI-powered smart contract generator and deployer for Arbitrum networks with Gemini 2.0 Flash LLM integration.
Features
- AI Smart Contract Generation: Generate Solidity contracts using Google Gemini 2.0 Flash LLM or OpenAI
- Template-based Generation: Create contracts from pre-defined templates
- Multi-Network Deployment: Deploy to Arbitrum One and Arbitrum Sepolia
- Contract Verification: Verify contracts on Arbiscan
- Multiple Interfaces: Command-line and web interfaces
- Secure Key Management: Private key or mnemonic for deployment
Installation
npm install -g evi-contractsQuick Start
Generate a Contract
Using Gemini (default):
evi generate --description "Create an ERC20 token with a fixed supply of 1000000 tokens" --output MyToken.solUsing OpenAI:
evi generate --description "Create an ERC20 token with a fixed supply of 1000000 tokens" --provider openai --output MyToken.solDeploy a Contract
evi deploy --file MyToken.sol --network arbitrumSepolia --args '[1000000]'Verify a Contract
evi verify --address 0xContractAddress --file MyToken.sol --network arbitrumSepoliaSetup
- Create a
.envfile with your API keys:
# API Keys
OPENAI_API_KEY=your_openai_api_key
GEMINI_API_KEY=your_gemini_api_key
ARBISCAN_API_KEY=your_arbiscan_api_key
# Deployment Credentials (use only one of these)
PRIVATE_KEY=your_private_key
MNEMONIC=your_mnemonic_phrase
# Web Server Configuration
PORT=3001CLI Usage
For detailed CLI usage instructions, see CLI-USAGE.md.
API Usage
Generate a Contract
const { generateFromDescription } = require('evi-contracts/src/generator');
async function generateContract() {
const description = "Create an ERC20 token with a fixed supply of 1000000 tokens";
const options = { provider: 'gemini' }; // or 'openai'
const contractSource = await generateFromDescription(description, options);
console.log(contractSource);
}Deploy a Contract
const { deployContract } = require('evi-contracts/src/deployer');
async function deployMyContract() {
const contractSource = `...your contract source code...`;
const options = {
network: 'arbitrumSepolia',
constructorArgs: [1000000]
};
const result = await deployContract(contractSource, options);
console.log(`Contract deployed to: ${result.address}`);
}Testing Your Installation
After installing the package, follow these steps to verify it works correctly:
Step 1: Check Installation
# Verify the installed version
npx evi --versionStep 2: Explore Available Commands
# View all available commands
npx evi --help
# Get help for specific commands
npx evi generate --help
npx evi deploy --helpStep 3: List Available Templates
# View all contract templates
npx evi list-templatesStep 4: Generate a Contract
# Generate using a template
npx evi generate --template ERC20Token --output TokenFromTemplate.sol
# Or generate using AI (requires API keys in .env)
npx evi generate --description "Create an ERC20 token with 1000000 supply" --provider gemini --output AIToken.solStep 5: Review Generated Contract
# View the generated contract
cat TokenFromTemplate.solStep 6: Test as a JavaScript Library
Create a test file (test-lib.js):
const { generateFromTemplate } = require('@aixweb3/evi-contracts/src/generator');
async function testLib() {
try {
const contract = await generateFromTemplate('ERC20Token', {
name: 'TestToken',
symbol: 'TST',
decimals: 18,
totalSupply: 1000000
});
console.log('Successfully generated contract:');
console.log(contract.slice(0, 300) + '...');
} catch (error) {
console.error('Error testing library:', error);
}
}
testLib();Run the test:
node test-lib.jsLicense
MIT
Credits
EVI Contracts is built and maintained by EVI Contributors.
