Compiled bytecode and deployment helpers for May Prog EVM contracts
npm install @mayflower-fi/evm-bytecodeCompiled bytecode and deployment helpers for May Prog EVM contracts.
``bash`
npm install @mayflower-fi/evm-bytecodeor
yarn add @mayflower-fi/evm-bytecodeor
pnpm add @mayflower-fi/evm-bytecode
`typescript
import { ethers } from 'ethers';
import { ContractDeployer, contracts } from '@mayflower-fi/evm-bytecode';
// Connect to network
const provider = new ethers.JsonRpcProvider('http://localhost:8545');
const signer = await provider.getSigner();
// Create deployer
const deployer = new ContractDeployer(signer);
// Deploy TenantFactory
const tenantFactory = await deployer.deploy(contracts.TenantFactory);
console.log('TenantFactory deployed at:', await tenantFactory.getAddress());
`
`typescript
import { deployProtocol, deployTenant, deployMarketGroup, deployMarket } from '@mayflower-fi/evm-bytecode';
// Deploy complete protocol
const protocol = await deployProtocol({ signer });
// Deploy a tenant
const tenant = await deployTenant({
signer,
tenantFactory: protocol.tenantFactory,
name: 'My Tenant',
symbol: 'MTNT',
platformFeeRate: 100000n, // 10% in micro-basis points
});
// Deploy a market group
const marketGroup = await deployMarketGroup({
signer,
tenant: tenant.tenant,
marketGroupFactory: protocol.marketGroupFactory,
name: 'My Markets',
buyFeeRate: 2500n, // 0.25%
sellFeeRate: 2500n, // 0.25%
});
`
`typescript
import { verifyBytecode, getContractStats, contracts } from '@mayflower-fi/evm-bytecode';
// Get on-chain bytecode
const onchainBytecode = await provider.getCode(contractAddress);
// Verify it matches expected bytecode
const matches = verifyBytecode(
onchainBytecode,
contracts.TenantFactory.deployedBytecode,
true // Allow metadata changes
);
// Get contract statistics
const stats = getContractStats(contracts.TenantFactory);
console.log('Contract size:', stats.bytecodeSize, 'bytes');
console.log('Functions:', stats.functionCount);
console.log('Events:', stats.eventCount);
`
`typescript
import {
getBytecodeSize,
isWithinSizeLimit,
getInitCodeHash,
encodeConstructorArgs
} from '@mayflower-fi/evm-bytecode';
// Check bytecode size
const size = getBytecodeSize(contracts.MarketFactory.bytecode);
const withinLimit = isWithinSizeLimit(contracts.MarketFactory.deployedBytecode);
// Encode constructor arguments
const args = encodeConstructorArgs(
['string', 'string', 'address', 'uint256'],
['My Token', 'MTK', '0x...', 1000000n]
);
// Get init code hash for CREATE2
const initHash = getInitCodeHash(contracts.MarketFactory.bytecode, args);
`
- TenantFactory - Factory for deploying tenant contractsTenantImplementation
- - Implementation contract for tenantsMarketGroupFactory
- - Factory for deploying market groupsMarketGroupImplementation
- - Implementation contract for market groupsMarketFactory
- - Factory for deploying marketsLinearMarketImplementation
- - Implementation contract for linear bonding curve marketsMarketToken
- - ERC20 token for market derivativesCallOptionToken
- - ERC20 token for call optionsMockERC20
- - Mock ERC20 token for testing (if available)
- Deploy complete protocol infrastructure
- deployTenant() - Deploy a new tenant
- deployMarketGroup() - Deploy a new market group
- deployMarket() - Deploy a new market$3
- getBytecodeSize() - Get bytecode size in bytes
- isWithinSizeLimit() - Check if bytecode is within EIP-170 limit (24KB)
- getInitCodeHash() - Get init code hash for CREATE2
- extractConstructorArgs() - Extract constructor args from deployed bytecode
- verifyBytecode() - Verify on-chain bytecode matches expected
- encodeConstructorArgs() - Encode constructor arguments
- decodeConstructorArgs() - Decode constructor arguments
- getContractStats() - Get contract statisticsExamples
See the
examples/ directory for complete examples:
- deploy-protocol.ts - Deploy the complete protocol
- verify-deployment.ts` - Verify deployed contractsMIT