Created
June 22, 2021 16:12
-
-
Save critesjosh/3436fa92ca807f3f5f6238ac65e7122a to your computer and use it in GitHub Desktop.
@celo/wallet-walletconnect create react app demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import './App.css'; | |
import React from "react"; | |
import ReactDOM from "react-dom"; | |
import { WalletConnectWallet } from '@celo/wallet-walletconnect' | |
import QRCode from 'qrcode.react' | |
class App extends React.Component { | |
constructor(props){ | |
super(props) | |
this.state = { | |
wallet: null, | |
uri: "" | |
} | |
} | |
componentDidMount(){ | |
this.connect() | |
} | |
async connect() { | |
const wallet = new WalletConnectWallet({ | |
connect: { | |
metadata: { | |
name: 'The name of your awesome DApp', | |
description: 'Your DApp description', | |
url: 'https://example.com', | |
icons: ['https://example.com/favicon.ico'], | |
}, | |
}, | |
}) | |
const uri = await wallet.getUri() | |
this.setState({ | |
uri: uri | |
}) | |
console.log(uri) | |
wallet.init() | |
// display this uri as a QR code to the user | |
} | |
render(){ | |
return ( | |
<div className="App"> | |
<header className="App-header"> | |
<div> | |
<QRCode value={this.state.uri} size="200"/> | |
</div> | |
</header> | |
</div> | |
); | |
} | |
} | |
export default App; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment