ethers.js/packages/experimental/README.md

81 lines
2.4 KiB
Markdown
Raw Permalink Normal View History

2019-05-14 18:25:46 -04:00
Experimental Playground
=======================
This package is a collection of quick little ideas, which may be half-baked.
If you find a particular feature piques your interest, please feel free to open
an issue on GitHub to discuss it.
Also, if you have any system that requires an object from this package, make sure
you specify the **exact npm version** in your package.json, as backwards compatibility
2021-04-18 02:48:05 -04:00
is **NOT** guaranteed for this package; APIs may change and classes may disappear.
2019-05-14 18:25:46 -04:00
Items
-----
**BrainWallet**
2021-04-18 02:48:05 -04:00
In general, a Brain Wallet is not recommended, but it is a feature we offered in v3
2019-05-14 18:25:46 -04:00
and below. It allows a wallet to be described and recovered using a username and a
password. However, anyone who can guess a username and password can steal the funds,
and the password cannot be changed. But for backwards compatibility and for simple
testing, we provide it here.
```javascript
2021-04-18 02:48:05 -04:00
import { BrainWallet } from "@ethersproject/experimental/brain-wallet";
2019-05-14 18:25:46 -04:00
// This is optional, but since a Brain Wallet can take 5-10s to generate,
// helps keep your users informed
function showProgress(percent) {
if (percent === 1) {
console.log("Done.");
} else {
console.log("Completed: " + Math.trunc(100 * percent) + "%");
}
}
// Generate a legacy-compatible Brain Wallet
BrainWallet.generateLegacy(username, password, showProgress).then((wallet) => {
console.log(wallet);
});
// Generate a new-style Brain Wallet, which contains a Mnemonic Phrase too
BrainWallet.generate(username, password, showProgess).then((wallet) => {
console.log(wallet);
});
```
**NonceManager**
```javascript
2021-04-18 02:48:05 -04:00
import { NonceManager } from "@ethersproject/experimental/nonce-manager";
2019-05-14 18:25:46 -04:00
let signer = "... any way you get a signer ...";
// The NonceManager Signer will automatically manage the nonce for you
// so you may blast the network with as many transactions as you would
// like. Transactions which have not been mined within XXX timeout and
// will be rebroadcast; keep in mind that unmined transactions remain
// in memory.
2021-04-18 02:48:05 -04:00
const managedSigner = new NonceManager(signer);
2019-05-14 18:25:46 -04:00
```
2021-04-18 02:48:05 -04:00
**Eip1193Bridge**
2019-05-14 18:25:46 -04:00
```javascript
2021-04-18 02:48:05 -04:00
import { Eip1193Bridge } from "@ethersproject/experimental/retry-provider";
2019-05-14 18:25:46 -04:00
2021-04-18 02:48:05 -04:00
const signer = "... any way you get an ethers Signer...";
const provider = "... any way you get an ethers Provider...";
2019-05-14 18:25:46 -04:00
2021-04-18 02:48:05 -04:00
const eip1193Provider = new Eip1193Provider(signer, provider);
2019-05-14 18:25:46 -04:00
```
License
-------
MIT License.