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:
- Logger Plugin
wrap://ens/wraps.eth:logger@1.0.0
- HTTP Plugin
ens/wraps.eth:http@1.1.0
ens/wraps.eth:http@1.0.0
- FileSystem Plugin
ens/wraps.eth:file-system@1.0.0
- Concurrency Plugin
ens/wraps.eth:concurrent@1.0.0
- Ethereum Provider Plugin
- V1
ens/wraps.eth:ethereum-provider@1.1.0
ens/wraps.eth:ethereum-provider@1.0.0
- V2
ens/wraps.eth:ethereum-provider@2.0.0
- V1
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);