The Arweave ecosystem is currently inherently insecure for users since the only way to interact with Dapps is to provide your private key to each dapp for every interaction and trust that the dapp isn't going to do something malicious with your funds. This browser extension is a proof of concept for an injectable wallet interface similar to Ethereum's model of injectable wallet providers that popular Web3 wallets like Metamask and the various Web3 mobile wallets provide. As this is just a proof of concept, it doesn't deal with any of the niceties of wallet management but is evidence that this is a workable approach that should be more fully explored by the Arweave ecosystem.
- Check if your Node.js version is >= 14.
- Clone this repository.
- Run
npm install
to install the dependencies. - Run
npm start
- Load your extension on Chrome following:
- Access
chrome://extensions/
- Check
Developer mode
- Click on
Load unpacked extension
- Select the
build
folder.
- Access
- Pin the extension to your browser extensions list in browser
- Run
npm run-demo-app
- Navigate to localhost:3001
- Click on the extension's browser icon and then the "Load Wallet" button in the popup.
- Now, click on the "connect wallet" button
- Enter any appropriate data for your transaction
- Click "Submit transaction" and monitor the console logs to see your transaction post
This extension injects an interface into every page that can be intereacted with as follows:
window.injectedWallet.publicKey
- this returns the public key in JWK format for the Arweave wallet stored by the extension
and as such can be used in arweave-js
anywhere a JWK is required with the exception that you cannot sign transactions with it.
// Get the injected wallet's address
const address = await arweave.wallets.jwkToAddress(
window.injectedWallet.publicKey
);
window.injectedWallet.sign(transaction)
- this method takes a Transaction
objected created by arweave.createTransaction.sign
, signs it, and then posts to the blockchain. No status codes or transaction IDs are returned by this method so it's up to the dapp to detect the transaction
// Create a transaction
const txn = await arweave.createTransaction({ data: Buffer.from('my magical message','utf8'), window.injectedWallet.publicKey})
// Send transaction to extension to sign/post to chain
window.injectedWallet.sign(txn)