From bef5bee9c10c98c1ac804adaddcf08988d32fba6 Mon Sep 17 00:00:00 2001 From: Etienne Dusseault Date: Mon, 10 Aug 2020 10:34:37 +0800 Subject: [PATCH] Add mobile specific RPC method section (#161) * add mobile specific RPC method section Co-authored-by: Austin Akers Co-authored-by: Erik Marks --- docs/guide/rpc-api.md | 44 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/docs/guide/rpc-api.md b/docs/guide/rpc-api.md index c8b528b4445..19ed660c55d 100644 --- a/docs/guide/rpc-api.md +++ b/docs/guide/rpc-api.md @@ -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); + }); +```