Skip to content

Files

This branch is 1638 commits behind ethereum-optimism/optimism:develop.

contracts-ts

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Oct 17, 2023
Jul 19, 2023
Jul 19, 2023
Jul 19, 2023
Apr 2, 2024
Dec 13, 2023
Jul 19, 2023
Jul 19, 2023
Oct 12, 2023
Oct 12, 2023
Jul 19, 2023
Apr 10, 2024
Jul 19, 2023
Jul 19, 2023
Jul 19, 2023
Jul 19, 2023
Dec 9, 2023

Contracts TS

codecov

ABI and Address constants + generated code from @eth-optimism/contracts-bedrock/ for use in TypeScript.

Much of this package is generated. See CODE_GEN.md for instructions on how to generate.

@eth-optimism/contracts-ts

The main entrypoint exports constants related to contracts bedrock as const. As const allows it to be used in TypeScript with stronger typing than importing JSON.

  • Exports contract abis.
  • Exports contract addresses
import {
  l2OutputOracleProxyABI,
  l2OutputOracleAddresses,
} from '@eth-optimism/contracts-ts'

console.log(l2OutputOracleAddresses[10], abi)

Addresses are also exported as an object for convenience.

import { addresses } from '@eth-optimism/contracts-ts'

console.log(addresses.l2OutputOracle[10])

@eth-optimism/contracts-ts/react

import { useAddressManagerAddress } from '@eth-optimism/contracts-ts/react'

const component = () => {
  const { data, error, loading } = useAddressManagerAddress()
  if (loading) {
    return <div>Loading</div>
  }
  if (err) {
    return <div>Error</div>
  }
  return <div>{data}</div>
}

@eth-optimism/contracts-ts/actions

import { readSystemConfig } from '@eth-optimism/contracts-ts/actions'
console.log(await readSystemConfig())

See Also