Skip to content
LogoLogo

Prebuilt contract exports

Five Contract values, each with real compiled bytecode and deployedBytecode, exported from the package root.

import {
  SimpleContract,
  ERC20,
  ERC721,
  ErrorContract,
  AdvancedContract,
} from '@tevm/contract'

None of them has an address — call withAddress first.

For usage examples see the prebuilt contracts guide. This page is the surface summary.

SimpleContract

Name: SimpleContract. A counter with storage, a getter, a setter, and an event.

MemberSignature
constructorconstructor(uint256 initialValue)
readget() view returns (uint256)
writeset(uint256 newValue)
eventsValueSet(uint256 newValue)

ERC20

Name: OzERC20. The OpenZeppelin ERC-20 implementation.

MemberSignature
constructorconstructor(string name, string symbol)
readname(), symbol(), decimals(), totalSupply(), balanceOf(address), allowance(address, address)
writeapprove(address spender, uint256 value), transfer(address to, uint256 value), transferFrom(address from, address to, uint256 value)
eventsTransfer(address indexed, address indexed, uint256), Approval(address indexed, address indexed, uint256)
errorsERC20InsufficientBalance, ERC20InsufficientAllowance, ERC20InvalidApprover, ERC20InvalidReceiver, ERC20InvalidSender, ERC20InvalidSpender

ERC721

Name: OzERC721. The OpenZeppelin ERC-721 implementation, with the standard NFT surface, Transfer/Approval/ApprovalForAll events, and the OZ ERC-721 custom errors.

MemberSignature
constructorconstructor(string name, string symbol)

ErrorContract

Name: ErrorContract. Every revert flavour behind a zero-argument function — custom errors with and without parameters, string reverts, bare reverts, and the four panic codes. No constructor arguments.

ErrorsSimpleError(), ErrorWithSingleParam(uint256), ErrorWithMultipleParams(string, bytes32, address[])
RevertsrevertWithSimpleCustomError, revertWithCustomErrorSingleParam, revertWithCustomErrorMultipleParams, revertWithStringError, revertWithRequireAndMessage, revertWithRequireNoMessage, revertWithoutMessage
PanicspanicWithAssertFailure, panicWithArithmeticOverflow, panicWithDivisionByZero, panicWithArrayOutOfBounds
OthererrorOutOfGas, errorWithInvalidOpcode

AdvancedContract

Name: AdvancedContract. Multiple storage types, an external call, and a delegatecall. Its constructor deploys a math-helper contract as a side effect.

MemberSignature
constructorconstructor(uint256 initialNumber, bool initialBool, string initialString, address initialAddress)
readgetNumber(), getBool(), getString(), getAddress(), getAllValues(), mathHelperAddress()
writesetNumber(uint256), setBool(bool), setString(string), setAddress(address), setAllValues(uint256, bool, string, address), setMathHelperAddress(address), callMathHelper(uint256), delegateCallMathHelper(uint256)
eventsNumberSet, BoolSet, StringSet, AddressSet, AllValuesSet, ExternalCallResult, DelegateCallResult