@evmts/bun-plugin
TypeScript icon, indicating that this package has built-in type declarations

0.11.2 • Public • Published

@evmts/plugin-bun

A bun plugin for importing solidity files.

Installation

Install build dependencies

bun install -D bun-types @evmts/bun-plugin @evmts/ts-plugin @evmts/core solc

Setup

first create a plugins.ts file

import { evmtsBunPlugin } from "@evmts/bun-plugin";
import { plugin } from 'bun'

plugin(evmtsBunPlugin())

Next load your plugin.ts file in your bunfig.toml

preload = ["./plugins.ts"]

# add to [test] to use plugin in bun test too
[test]
preload = ["./plugins.ts"]

Usage

Once set up you can import solidity files directly from node modules such as openzepplin/contracts or your source code. You can use with viem ethersjs or any other library.

import { http, createPublicClient } from 'viem'
import { optimismGoerli } from 'viem/chains'
import { ExampleContract } from './ExampleContract.sol'

export const publicClient = createPublicClient({
  chain: optimismGoerli,
  transport: http('https://goerli.optimism.io'),
})

const owner = '0x8f0ebdaa1cf7106be861753b0f9f5c0250fe0819'

publicClient.readContract(
  ExampleContract.read({ chainId: optimismGoerli.id }).balanceOf(owner)
).then(console.log)

License 📄

Package Sidebar

Install

npm i @evmts/bun-plugin

Weekly Downloads

1

Version

0.11.2

License

MIT

Unpacked Size

34.7 kB

Total Files

17

Last publish

Collaborators

  • fucory