@metamask/ethereum-provider-example-snap

2.1.2 • Public • Published

@metamask/ethereum-provider-example-snap

This snap demonstrates the use of the endowment:ethereum-provider permission and the corresponding ethereum global. This is similar to the window.ethereum API, but it does not have access to all methods.

Snap manifest

Note: Using ethereum requires the endowment:ethereum-provider permissions. Refer to the documentation for more information.

Along with other permissions, the manifest of this snap includes the endowment:ethereum-provider permission:

{
  "initialPermissions": {
    "endowment:ethereum-provider": {}
  }
}

This permission does not require any additional configuration.

Snap usage

This snap exposes an onRpcRequest handler, which supports the following JSON-RPC methods:

  • getGasPrice: Get the current recommended gas price from an Ethereum provider.
  • getVersion: Get the Ethereum network version from an Ethereum provider.
  • getAccounts: Get the Ethereum accounts made available to the snap from an Ethereum provider.

For more information, you can refer to the end-to-end tests.

Readme

Keywords

none

Package Sidebar

Install

npm i @metamask/ethereum-provider-example-snap

Weekly Downloads

22,559

Version

2.1.2

License

(MIT-0 OR Apache-2.0)

Unpacked Size

66.7 kB

Total Files

7

Last publish

Collaborators

  • mcmire
  • nicholasellul
  • lgbot
  • naugtur
  • ritave
  • danfinlay
  • kumavis
  • rekmarks
  • metamaskbot
  • gudahtt
  • sethkfman