Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mobile specific RPC method section #161

Merged
merged 3 commits into from
Aug 10, 2020
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions docs/guide/rpc-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -353,3 +353,47 @@ ethereum
)
.catch((error) => console.log(error.message));
```

## Mobile Specific RPC Methods

### wallet_scanQRCode

#### Parameters

- `Array`

0. `'REGEX'` - Optional regex for scanning arbitrary (non ETH address) QR code strings.


#### Returns

`string` - A string representing the QR code that was scanned.

#### Description

Allows dApps to request QR code scanning from MetaMask Mobile.
Metamask previously introduced this feature via [EIP 945](https://github.com/ethereum/EIPs/issues/945), although it was later removed due a modification of the provider architecture. dApp developers may now access the functionality via this RPC method directly.

Returns a Promise that resolves to a string corresponding to the scanned QR code.

The contents of the QR code must equal one of the following:
1. An ethereum address
2. a string that matches the optionally provided regex parameter
rekmarks marked this conversation as resolved.
Show resolved Hide resolved

The method will throw an error if one of these two criteria are not met.

The request activates the user's camera, so they may scan the QR code.

#### Example

```javascript
ethereum
.request({
method: 'wallet_scanQRCode',
params: ['\\D'], //Write the regex as a string, don't forget to use the escape character '\' if it uses backslashes
})
.then((result) => {
console.log(result)})
.catch((error) => {
console.log(error)});
```