Skip to main content

Plugins

Polywrap plugins, or "plugin wrappers", enable existing SDKs implemented in the client's language (e.g. JavaScript) to be queried as if they were Wasm wrappers.

For information on how to create your own Polywrap plugin, read the guide here.

Plugins can be used to enable any native client functionality that cannot be implemented in WebAssembly, such as sending HTTP requests, or signing blockchain transactions with a private key.

Default Plugin wrappers

The Polywrap client has a default configuration that enables developers to use the following plugins and the interfaces they implement:

Configuring Plugins

Some plugins, like the Ethereum Provider, require additional configuration in certain environments like the browser.

We can configure the Ethereum Provider plugin to use MetaMask (or any other Ethereum JS provider) for its provider & signer using the Client Config Builder:

import {
ClientConfigBuilder,
IWrapPackage,
PolywrapClient,
} from "@polywrap/client-js";
import {
Connection,
Connections,
ethereumProviderPlugin,
} from "@polywrap/ethereum-provider-js";

// Enable Metamask
const ethereum = (window as any).ethereum;
await ethereum.request({
method: "eth_requestAccounts",
});

// Configure the Ethereum plugin w/ MetaMask
const config = new ClientConfigBuilder()
.addDefaults()
.addPackages({
"wrapscan.io/polywrap/ethereum-wallet@1.0": ethereumProviderPlugin({
connections: new Connections({
networks: {
goerli: new Connection({
provider: ethereum,
}),
},
defaultNetwork: "goerli",
}),
}) as IWrapPackage,
})
.build();

const client = new PolywrapClient(config);