more tests, finish readme

This commit is contained in:
stjet
2024-06-28 03:46:43 +00:00
parent 4b525aab6b
commit d4ef861ea2
64 changed files with 294 additions and 149 deletions

View File

@@ -3,22 +3,64 @@
> ~~how to buy banani from beatrice~~
> how to install banani on react.js
Banani is a library for the Banano cryptocurrency that will support sending, receiving, changing rep, RPC calls, message signing, wallet management, etc. It aims to be a more powerful and sensible version of @bananocoin/bananojs. Banani takes heavy inspiration from [bananopie](https://github.com/stjet/bananopie) (which I also wrote), which in turn takes some inspiration from my experiences with ethers.js.
Banani is a library for the Banano cryptocurrency that will support sending, receiving, changing rep, RPC calls, message signing, wallet management, etc. It aims to be a more powerful and sensible version of @bananocoin/bananojs. Banani takes heavy inspiration from the Python [bananopie](https://github.com/stjet/bananopie) (which I also wrote), which in turn takes some inspiration from my experiences with ethers.js.
The docs are hosted at https://banani.prussia.dev.
**Please report any bugs or request features by opening an Github issue.** You can ask for help or ask questions in the #frankensteins-lab channel of the Banano discord and people will be typically be eager to assist if they can.
Currently being written, and heavy work in progress.
## Installing
## Examples
```
npm install banani
```
Embedding in the browser is easy to - just download and add `banani-browser.js` to your website:
```html
<script src="/path/to/banani-browser.js"></script>
```
Take a look in `browser_test/index.html` for an example.
## Documentation
The docs are hosted at https://banani.prussia.dev (can also be accessed at https://stjet.github.io/banani/).
## Examples
Banani allows you to send, receive, and change representative. If you are using Banani on the web, replace `banani` with `window.banani`.
```js
let rpc = new banani.RPC("https://kaliumapi.appditto.com/api");
console.log(await rpc.get_block_count());
let wallet = new banani.Wallet(rpc, process.env.seed);
let zero_index_address = wallet.address;
wallet.index = 1;
let send_hash = await wallet.send(zero_index_address, "1"); //send 1 banano
wallet.index = 0;
await wallet.receive(send_hash); //receive the bananos we just send (can also do `await wallet.receive_all()`)
await wallet.change_rep("placeholder");
```
Banani also comes with some useful utilities, and message signing:
```js
let rpc = new banani.RPC("https://kaliumapi.appditto.com/api");
let random_wallet = banani.Wallet.gen_random_wallet(rpc);
console.log(banani.whole_to_raw("4.20069") === 420069000000000000000000000000n);
console.log(random_wallet.sign_message("test message\ntest test"));
```
## Contributing
```
git clone https://github.com/stjet/banani.git
cd banani
...
<make your changes>
<make your changes with your favourite editor>
...
npm run build
```
@@ -46,3 +88,7 @@ Tweetnacl is not listed as a dependency in the package.json because it has been
Banani also has many dev dependencies for contributing/developing the package (see the "Contributing" section), but they are not needed for regular users of the package.
## Todo
- More extensive testing
- Example work generating function