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.
Type Definition
Branded Uint8Array representing pure runtime bytecode without constructor logic or compiler metadata.
import type { brand } from '@tevm/voltaire/brand';
export type RuntimeCodeType = Uint8Array & {
readonly [brand]: "RuntimeCode";
};
Runtime code is the actual bytecode executed when calling a contract after deployment. It excludes:
- Constructor logic
- Solidity compiler metadata
- Creation-time initialization
Quick Reference
import * as RuntimeCode from '@tevm/voltaire/RuntimeCode';
// From hex string
const code = RuntimeCode.from("0x6001600155");
// From Uint8Array
const code = RuntimeCode.from(new Uint8Array([0x60, 0x01, 0x60, 0x01, 0x55]));
// Compare runtime codes
if (RuntimeCode.equals(code1, code2)) {
console.log("Runtime codes match");
}
// Convert to hex
const hex = RuntimeCode.toHex(code);
API Methods
Constructors
Utilities
Usage Patterns
Contract Verification
import * as RuntimeCode from '@tevm/voltaire/RuntimeCode';
import * as ContractCode from '@tevm/voltaire/ContractCode';
// Get deployed code and strip metadata
const deployed = ContractCode.from(await provider.getCode(address));
const deployedRuntime = ContractCode.stripMetadata(deployed);
// Compare with compiled runtime code
const expectedRuntime = RuntimeCode.from(compiledRuntimeCode);
if (RuntimeCode.equals(deployedRuntime, expectedRuntime)) {
console.log("Contract verified: runtime code matches");
} else {
console.log("Verification failed: runtime code differs");
}
Bytecode Analysis
import * as RuntimeCode from '@tevm/voltaire/RuntimeCode';
import * as Bytecode from '@tevm/voltaire/Bytecode';
const runtime = RuntimeCode.from(runtimeBytecode);
// Analyze runtime code
const analysis = Bytecode.analyze(runtime);
console.log(`Instructions: ${analysis.instructions.length}`);
console.log(`Valid: ${analysis.valid}`);
console.log(`Jump destinations: ${analysis.jumpDestinations.size}`);
// Pretty print
const disassembly = Bytecode.prettyPrint(runtime, {
showGas: true,
showStack: true,
});
console.log(disassembly);
Comparing Contract Versions
import * as RuntimeCode from '@tevm/voltaire/RuntimeCode';
// Compare different versions of a contract
const v1 = RuntimeCode.from(contractV1RuntimeCode);
const v2 = RuntimeCode.from(contractV2RuntimeCode);
if (!RuntimeCode.equals(v1, v2)) {
console.log("Runtime code changed between versions");
console.log(`v1 hex: ${RuntimeCode.toHex(v1)}`);
console.log(`v2 hex: ${RuntimeCode.toHex(v2)}`);
}
Specification