Documentation Index
Fetch the complete documentation index at: https://voltaire.tevm.sh/llms.txt
Use this file to discover all available pages before exploring further.
Generates ERC-3448 MetaProxy bytecode with embedded metadata.
Extends ERC-1167 minimal proxy by appending metadata after the proxy code, enabling factory patterns with embedded configuration.
Parameters:
implementation: Uint8Array - 20-byte implementation address
metadata: Uint8Array - Metadata to embed (arbitrary length)
Returns: Uint8Array - Complete MetaProxy bytecode (55 + metadata.length + 32 bytes)
Throws:
Error - If implementation address is not 20 bytes
Example:
import { generateErc3448 } from '@tevm/voltaire/Proxy';
import { Address } from '@tevm/voltaire/Address';
// Prepare metadata
const metadata = new TextEncoder().encode(JSON.stringify({
creator: '0xCreatorAddress...',
salt: '0x1234...',
version: 1,
timestamp: Date.now()
}));
// Generate MetaProxy bytecode
const implementation = Address.from('0x1234567890123456789012345678901234567890');
const bytecode = generateErc3448(implementation, metadata);
console.log('Bytecode size:', bytecode.length);
// 55 (ERC-1167) + metadata.length + 32 (length) bytes
Defined in: src/primitives/Proxy/generateErc3448.js
import { generateErc3448 } from '@tevm/voltaire/Proxy';
import { Address } from '@tevm/voltaire/Address';
import { keccak256 } from '@tevm/voltaire/crypto';
class MetaProxyFactory {
async createProxy(
implementation: string,
config: {
creator: string;
salt: string;
chainId: number;
}
) {
// Encode configuration as metadata
const metadata = new TextEncoder().encode(
JSON.stringify(config)
);
// Generate bytecode
const bytecode = generateErc3448(
Address.from(implementation),
metadata
);
// Calculate CREATE2 address
const factoryAddress = Address.from(this.address);
const saltBytes = keccak256(
new TextEncoder().encode(config.salt)
);
const proxyAddress = Address.calculateCreate2Address(
factoryAddress,
saltBytes,
bytecode
);
return {
bytecode,
address: proxyAddress.toHex(),
metadata: config
};
}
}
See Also