Slope Finance
Search…
⌃K
Links

Integrate with Slope Wallet on Ethereum (Extension)

Slope Wallet injects a global API into websites visited by its users at window.slope.
This API specification borrows heavily from API MetaMask provided, considering the massive adoption. So Web3 site developers can easily connect their dApps with the Slope Wallet. The APIs allow websites to request users' Ethereum addresses, read data from the blockchain the user is connected to, and prompt the users to sign messages and transactions.
The presence of the provider object window.slope indicates a Slope Wallet user.
The API this extension wallet provides includes API specified by EIP-1193 and API defined by MetaMask (does not including some massively relied legacy ones).

Difference with MetaMask

Please read through this section if you are a web3 developer who has integrated with MetaMask and interested in integrating with Slope Wallet.

Inpage injected object

The biggest difference between Slope Wallet and MetaMask is we inject slope rather than ethereum (or web3) to the web page. So user could keep two extensions at the same time.

slope.request({ method: "eth_sign", params: ["address", "message"] })

We haven't supported the full complex signing data APIs MetaMask provided, while we only provide standard eth_sign JSON-RPC call.
The message item in params for this request on MetaMask has to be hex-encoded keccak256 hash (otherwise the API would silent failure for dapp https://www.reddit.com/r/Metamask/comments/9wp7kj/eth_sign_not_working/). In contrast, web3 developers could pass any message in plaintext to this method, and our UI would render it as it is to the wallet users.

slope.request({ method: "eth_accounts" })

When this API is invoked without the user's approval, MetaMask would return an empty array.
In contrast, we would ask the user to unlock his wallet and return the address user connected to.

Basic Usage

For any non-trivial Ethereum web application — a.k.a. web3 site — to work, you will have to:
  1. 1.
    Detect the Slope Wallet provider (window.slope)
  2. 2.
    Detect which Ethereum network the user is connected to
  3. 3.
    Get the user's Ethereum account(s)
The provider API is all you need to create a full-featured web3 application.
That said, many developers use a convenience library, such as ethers and web3.js, instead of using the provider directly. If you need higher-level abstractions than those provided by this API, we recommend that you use a convenience library.