dmihal / maker-devcon-burner-wallet

1 stars 1 forks source link

Burner Wallet 2.0

The Burner Wallet 2.0 is a modular, extendable and cusomizable web application for seamless crypto payments.

Create a burner wallet in just a few lines of code:

const core = new BurnerCore({
  signers: [new InjectedSigner(), new LocalSigner()],
  gateways: [new InfuraGateway(process.env.REACT_APP_INFURA_KEY), new XDaiGateway()],
  assets: [xdai, dai, eth],
});

const exchange = new Exchange({ pairs: [xdaiBridge, uniswapDai] });

const BurnerWallet = () =>
  <BurnerUI
    core={core}
    plugins={[exchange, new LinkPlugin()]}
  />

Running the wallet

Simple, customized wallet

Do you want to customize your own version of the wallet? Check out the simple application in the basic-wallet directory.

Alternatively, visit https://burnerfactory.com to create your own wallet without writing any code!

Setting Infura key

By default, basic-wallet uses the InfuraGateway for connecting to commonly used Etherum chains.

The entry point takes an Infura key from the REACT_APP_INFURA_KEY environment variable. For your wallet to function correctly, you must create a file named .env in the basic-wallet folder with the follwing value:

REACT_APP_INFURA_KEY=<your infura key>

You can generate an Infura key at https://infura.io/

Add a custom token

You can add any ERC20 token to your wallet by constructing a new ERC20Asset and adding it to the asset list.

The id paramater is the internal ID used by the wallet, while the name paramater is the display name that will be displayed to the user. network is the chain ID of the chain the token is deployed to ('1' for mainnet, '100' xDai, etc). address is the address where the token contract is deployed.

import { xdai, dai, eth, ERC20Asset } from '@burner-wallet/assets';

const bos = new ERC20Asset({
  id: 'bos',
  name: 'Boston Token',
  network: '100',
  address: '0x52ad726d80dbb4A9D4430d03657467B99843406b',
});

const core = new BurnerCore({
  assets: [bos, xdai, dai, eth],
});

Developer wallet

Are you a developer, hoping to test changes to other modules in this project (burner-ui, exchange or plugins)?

The local-wallet diretory has a wallet that will connect to a local Ganache instance and transfer 10 Ganache ETH to your wallet.

To start this wallet, cd into the local-wallet directory, run yarn install-all to install dependencies, then run yarn start.

Note that Metamask will override the local account, disable it or open in incognito mode for local development.

Alternatively, the code in the wallet directory will let you develop locally, while connecting to Mainnet and xDai.

Customization

The wallet can be visually customized by passing theme and title props to the BurnerUI component.

const theme = {
  background: '#282325',
  titleFont: '"workSans", sans-serif',
  paperBackground: '#282325',
  accentColor: '#E84441',
  homeButtonColor: '#BBBBBB',
};

const BurnerWallet = () =>
  <BurnerUI
    title="daedalus industries"
    theme={theme}
    core={core}
  />

Packages

This is a monorepo that contains the following packages:

The Burner Wallet 2 is dependent on the burner-core packages (@burner-wallet/core and @burner-wallet/assets) for handling core blockchain functionality.

Plugin Development

The burner wallet functionality can be extended by passing plugin objects to the BurnerUI component.

Sample Plugins

The following plugins are part of the @burner-wallet/plugins package, and can be considered "offically supported"

There are also a number of other plugins that have been developed, which may be useful for reference:

Plugin Context

When the wallet is loaded, the wallet will call the initializePlugin(pluginContext) function for each plugin. The plugin has access to the following methods of pluginContext object:

Burner Plugin Props

Pages (added with pluginContext.addPage) and elements (added with pluginContext.addElement) will receive the following props: