# @polywrap/ethereum-plugin-js

> Polywrap Ethereum Javascript Plugin

Latest version **0.9.7** (published 2023-03-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install @polywrap/ethereum-plugin-js
pnpm add @polywrap/ethereum-plugin-js
yarn add @polywrap/ethereum-plugin-js
bun add @polywrap/ethereum-plugin-js
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.9.7 |
| Published | 2023-03-28 |
| First published | 2022-06-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 250 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 168 |
| Maintainers | polywrap-build-bot, dorgjelli |

## Links

- npm: https://www.npmjs.com/package/@polywrap/ethereum-plugin-js
- Repository: https://github.com/polywrap/monorepo
- npm.io page: https://npm.io/package/@polywrap/ethereum-plugin-js

## Dependencies (4)

- [ethers](https://npm.io/package/ethers.md) 5.0.7
- [@polywrap/core-js](https://npm.io/package/@polywrap/core-js.md) 0.9.7
- [@ethersproject/address](https://npm.io/package/@ethersproject/address.md) 5.0.7
- [@ethersproject/providers](https://npm.io/package/@ethersproject/providers.md) 5.0.7

## Recent versions

- 0.9.7 (latest) — 2023-03-28
- 0.10.0-pre.8 (pre) — 2023-02-16
- 0.9.6 — 2023-02-19
- 0.9.5 — 2023-02-10
- 0.10.0-pre.7 — 2023-01-11
- 0.10.0-pre.6 — 2022-12-20
- 0.10.0-pre.5 — 2022-11-22
- 0.10.0-pre.4 — 2022-11-16
- 0.10.0-pre.3 — 2022-11-13
- 0.10.0-pre.1 — 2022-11-12
- 0.10.0-pre.0 — 2022-11-05
- 0.9.4 — 2022-11-04
- 0.9.3 — 2022-10-20
- 0.9.2 — 2022-10-13
- 0.9.1 — 2022-10-12
- … 19 more at https://npm.io/package/@polywrap/ethereum-plugin-js/versions

## README

# @polywrap/ethereum-plugin-js

The Ethereum plugin wrapper allows the Polywrap JS Client to interact with any [EVM based blockchain](https://ethereum.org/).

## Usage

``` typescript
import {
  ethereumPlugin,
  Connections,
  Connection
} from "@polywrap/ethereum-plugin-js";

export async function main() {

  const uri = "wrap://ens/ethereum.polywrap.eth"

  // initialize Ethereum Connections store
  const connections: Connections = new Connections({
    networks: {
      mainnet: new Connection({
        provider: "..."
      }),
      matic: new Connection({
        provider: window.ethereum
      })
    },
    defaultNetwork: "matic"
  });

  // initialize the client with the ethereum plugin
  client = new PolywrapClient({
    plugins: [
      {
        uri: uri,
        plugin: ethereumPlugin({ connections })
      }
    ]
  });

  // now you can invoke the ethereum plugin by its URI
  // NOTE: uses default network "matic"
  const getSignerAddress = await client.invoke<string>({
    uri,
    method: "getSignerAddress",
  });

  if (!getSignerAddress.ok) throw getSignerAddress.error;

  const address = getSignerAddress.value;

  // Get a balance from mainnet, by passing in the optional
  // "connection" argument.
  const getBalance = await client.invoke<string>({
    uri,
    method: "getBalance",
    args: {
      address: "0x...",
      connection: {
        networkNameOrChainId: "mainnet"
      }
    },
  });

  if (!getBalance.ok) throw getBalance.error;

  const balance = getBalance.value;

  console.log("Matic Signer: ", address);
  console.log("Mainnet Balance: ", balance);
}
```

For more usage examples see `src/__tests__`.

## API

Full API in `src/schema.graphql`

---
_Source: https://npm.io/package/@polywrap/ethereum-plugin-js · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
