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 all 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. `string` - (optional) A regular expression for matching arbitrary QR code strings

#### Returns

`string` - The string corresponding to the scanned QR code.

#### Description

Requests that the user scans a QR code using their device camera.
Returns a Promise that resolves to a string, matching either:

1. The regex parameter, if provided
2. An ethereum address, if no regex parameter was provided

If neither condition is met, the Promise will reject with an error.

MetaMask previously introduced this feature per the proposed [EIP-945](https://github.com/ethereum/EIPs/issues/945).
The functionality was temporarily removed before being reintroduced as this RPC method.

#### Example

```javascript
ethereum
.request({
method: 'wallet_scanQRCode',
// The regex string must be valid input to the RegExp constructor, if provided
params: ['\\D'],
})
.then((result) => {
console.log(result);
})
.catch((error) => {
console.log(error);
});
```