Skip to content

Commit

Permalink
Merge pull request #616 from lukso-network/rpc-api
Browse files Browse the repository at this point in the history
Add additional RPC API methods
  • Loading branch information
Hugoo authored Sep 7, 2023
2 parents b0d16a8 + 1e7ed32 commit 0026ea6
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 6 deletions.
23 changes: 23 additions & 0 deletions docs/guides/browser-extension/web3-onboard.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Connect users' wallets to your Dapp with web3-onboard

### The easiest way to connect a wallet 🚀

![web3-onboard-view](/img/extension/web3-onboard.png)

Web3-onboard configuration allows the detection of the Universal Profiles (UP) Extension, along with any other installed browser extensions. Developers can integrate it into their Dapp to handle the routing for the different browser extensions.

Web3-onboard is an open-source, framework-agnostic JavaScript library to onboard users to web3 apps. This package can be used to integrate LUKSO [Universal Profiles Extension](https://chrome.google.com/webstore/detail/universal-profiles/abpickdkkbnbcoepogfhkhennhfhehfn?hl=en) support into web3-onboard's "Connect Wallet" modal. With this module, **the LUKSO Universal Profile Extension option will be shown even if the extension is not installed on the user's browser**. If selected the user will be taken to a download screen where they can install the extension.

### Installation

Developers can install web3-onboard in their Dapp using npm, from the [following package](https://www.npmjs.com/package/@lukso/web3-onboard-config). The implementation can be found in the [web3-onboard-config LUKSO GitHub repo](https://github.com/lukso-network/web3-onboard-config).

```
npm i @web3-onboard/core @lukso/web3-onboard-config @web3-onboard/injected-wallets
```

You can find a link to web3-onboard's official npm documentation here: [@web3-onboard/core official npm documentation](https://www.npmjs.com/package/@web3-onboard/core)

### Where can I test it out?

Users can experiment with LUKSO's web3-onboard implementation in a sandbox environment using [up-test-dapp.lukso.tech](https://up-test-dapp.lukso.tech/).
114 changes: 108 additions & 6 deletions docs/standards/rpc-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,115 @@ This page is under active development.

:::

The [LUKSO Extension](../guides/browser-extension/install-browser-extension.md) uses new RPC API which are described here.
The [LUKSO Extension](../guides/browser-extension/install-browser-extension.md) uses the RPC API methods from the table below. The methods are grouped by category: signing methods, standard methods, and LUKSO-specific methods.

## Supported Methods

<table>
<tr>
<td>Name</td>
<td>Type</td>
</tr>
<tr>
<td><a href="#eth_sign">eth_sign</a></td>
<td>signing</td>
</tr>
<tr>
<td><a href="#personal_sign">personal_sign</a></td>
<td>signing</td>
</tr>
<tr>
<td><a href="#eth_accounts">eth_accounts</a></td>
<td>standard</td>
</tr>
<tr>
<td><a href="#eth_requestAccounts">eth_requestAccounts</a></td>
<td>standard</td>
</tr>
<tr>
<td><a href="#eth_sendTransaction">eth_sendTransaction</a></td>
<td>standard</td>
</tr>
<tr>
<td><a href="#wallet_switchEthereumChain">wallet_switchEthereumChain</a></td>
<td>standard</td>
</tr>
<tr>
<td><a href="#up_addTransactionRelayer">up_addTransactionRelayer</a></td>
<td>LUKSO specific</td>
</tr>
<tr>
<td><a href="#up_import">up_import</a></td>
<td>LUKSO specific</td>
</tr>
<tr>
<td><a href="#up_generateLsp23Address">up_generateLsp23Address</a></td>
<td>LUKSO specific</td>
</tr>
</table>

## Signing

### eth_sign

:::tip

We encourage developers to use `eth_sign` for signing purposes.

## Methods
:::

While a security issue potentially existed in the initial implementation on Ethereum, the current implementation has no such potential exploit. As such usage of this method is preferable to [personal_sign](#personal_sign).

This method returns a [EIP-191](https://eips.ethereum.org/EIPS/eip-191) signature over the data provided to the call.
It requests that the user provides an Ethereum address that should sign the transaction as well as the data (encoded bytes) that are to be executed.

#### Returns

`string` - on a successful call the method returns a signature, a string representing hex encoded bytes or an error with code `4001` - if the user rejects the requets

### personal_sign

The `personal_sign` endpoint is enabled to allow for backward compatibility. However, its use is not recommended.
Some libraries such as Ethers.js end up using `personal_sign` under the hood. That is why, for compatibility reasons, `personal_sign` is left enabled. Note however that `personal_sign` ultimately acts as a proxy, redirecting the call to the [eth_sign](#eth_sign) method.

## Standard

### eth_sendTransaction {#eth_sendTransaction}

Creates new message call transaction and signs it using the account specified in `from`. This method requires that the user has granted permission to interact with their account first.
The transaction will not be signed by the UP itself, but by a controller address that has sufficient permissions.

### eth_requestAccounts {#eth_requestAccounts}

This method is specified by [EIP-1102](https://eips.ethereum.org/EIPS/eip-1102).
Calling this method may trigger a user interface that allows the user to approve or reject account access for a given DApp.

#### Returns

### up_addTransactionRelayer
`string[]` - an array of accounts or throws an error with code `4001` if the request was rejected by the user.

### wallet_switchEthereumChain {#wallet_switchEthereumChain}

This method implements [EIP-3326](https://eips.ethereum.org/EIPS/eip-3326).
It allows Dapps to request that a wallet switches its active chain (connection).

The method requires that a target chain ID is provided

#### Returns

`null` or `error` - the method will return null if successful or throw an error otherwise

### eth_accounts {#eth_accounts}

Similar to the `eth_requestAccounts` this method returns all of the addresses that are controlled by the application.

#### Returns

`string[]` - a successful request returns an array of hexadecimal Ethereum address strings

## LUKSO Specific

### up_addTransactionRelayer {#up_addTransactionRelayer}

Add a custom relayer.

Expand Down Expand Up @@ -47,7 +151,7 @@ params: [

It returns an array of Universal Profile addresses.

### up_import
### up_import {#up_import}

Add a Universal Profile address.

Expand All @@ -64,5 +168,3 @@ params: ['0x311611C9A46a192C14Ea993159a0498EDE5578aC'];
#### Returns

##### 1. `String` - New controller address, to be added to the profile by the dapp.

TODO
Binary file added static/img/extension/web3-onboard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0026ea6

Please sign in to comment.