Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@constellation-labs/core-utils

Package Overview
Dependencies
Maintainers
3
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@constellation-labs/core-utils

[Optimism] Core typescript utilities

  • 0.9.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
270
increased by6.3%
Maintainers
3
Weekly downloads
 
Created
Source

codecov

@constellation-labs/core-utils

What is this?

@constellation-labs/core-utils contains the Optimistic Virtual Machine core utilities.

Getting started

Building and usage

After cloning and switching to the repository, install dependencies:

$ yarn

Use the following commands to build, use, test, and lint:

$ yarn build
$ yarn start
$ yarn test
$ yarn lint

L2 Fees

TxGasLimit can be used to encode and decode the L2 Gas Limit locally.

import { TxGasLimit } from '@constellation-labs/core-utils'
import { JsonRpcProvider } from 'ethers'

const L2Provider = new JsonRpcProvider('https://mainnet.optimism.io')
const L1Provider = new JsonRpcProvider('http://127.0.0.1:8545')

const l2GasLimit = await L2Provider.send('eth_estimateExecutionGas', [tx])
const l1GasPrice = await L1Provider.getGasPrice()

const encoded = TxGasLimit.encode({
  data: '0x',
  l1GasPrice,
  l2GasLimit,
  l2GasPrice: 10000000,
})

const decoded = TxGasLimit.decode(encoded)
assert(decoded.eq(gasLimit))

const estimate = await L2Provider.estimateGas()
assert(estimate.eq(encoded))

Keywords

FAQs

Package last updated on 21 Jul 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc