0.4.0 • Published 5 years ago

web3-yeet v0.4.0

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

Web3 YEET

Making web3 libraries usable

Build Status npm version MIT license Donate with Ethereum

Web3js is a very powerful package, but as it stands, it is difficult to use. Web3 YEET wraps the most common operations used in web3 projects and makes them accessible in one line.

Demo

Check the functions at https://web3-yeet.github.io/.

The buttons (basically) call:

  sendCehh = async () => {
    await this.wallet.sendERC20(this.bag, 20, this.token); 
  }

  sendEth = async () => {
    await this.wallet.sendEther(this.bag, 0.024); /* Donations appreciated  */
  }
  
  accessLedger = async () => {
    await this.wallet.setLedger();
    this.setState({ledgerAccess: true});
  }

  sign = async () => {
    const signature = await this.wallet.signMessage("this message");
    this.setState({signature: signature})
  }

  check = async () => {
    const isYou = await this.wallet.checkMessage("this message", this.state.signature);
    this.setState({isYou: isYou});
  }

Listen to account changes!

  this.wallet.on('accountChange', (account) => {
    this.setState({account: accounts});
  });

Note: Remember to handle exceptions and give feedback to the user!

Installation

Yarn:

yarn add web3-yeet

Usage example

Require the package.

const web3 = require('web3-yeet');

Create a token instance

const cehhCoin = new web3.ERC20('0x4f38f4229924bfa28d58eeda496cc85e8016bccc');

Create a wallet instance

const userWallet = new web3.Wallet();

Ask the user to send tokens

const myAddress = '0x6a0d0ebf1e532841baf224e1bd6a1d4489d5d78d';
userWallet.sendERC20(myAddress, 2, cehhCoin);

Ask the user to sign a message

const msg = 'check-in id: 41923';
const signature = await userWallet.signMessage(msg).catch((error) => { /* error handling */ });

Switch the wallet to

const msg = 'check-in id: 41923';
const signature = await userWallet.signMessage(msg).catch((error) => { /* error handling */ });

Check if the user is the original signer of a message

const msg = 'check-in id: 41923';
const isSigner = await userWallet.checkMessage(msg, signature).catch((error) => { /* error handling */ });

if(isSigner) {
   /* the user's wallet is the signer of the message */
} else {
   /* the user's wallet didn't sign the message */
}

Release History

  • 0.4.0

    • Add event-based address change and Ledger access
  • 0.3.21

    • Include .enable calls when possible
  • 0.3.19
    • Add tests
  • 0.3.18
    • Add error return for Wallet.sign()
  • 0.3.16
    • Add Wallet.isAvailable()
  • 0.3.11
    • Add signatures
  • 0.3.10
    • Check BN type

Web3 Token-Based Authetication

With web3-yeet it is easier to implement the modern WTBA, shown below.

web3 token based authentication

Meta

Cehhiro – @Cehhiro – cehhiro@cehhiro.com

Contributing

  1. Fork it (https://github.com/web3-yeet/web3-yeet/fork)
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Commit your changes (git commit -am 'Add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Request
0.4.0

5 years ago

0.3.23

5 years ago

0.3.22

5 years ago

0.3.20

5 years ago

0.3.19

5 years ago

0.3.18

5 years ago

0.3.17

5 years ago

0.3.16

5 years ago

0.3.15

5 years ago

0.3.14

5 years ago

0.3.14-0

5 years ago

0.3.13-0

5 years ago

0.3.12

5 years ago

0.3.12-0

5 years ago

0.3.11

5 years ago

0.3.10

5 years ago

0.3.9

5 years ago

0.3.8

5 years ago

0.3.7

5 years ago

0.3.6

5 years ago

0.3.5

5 years ago

0.3.4

5 years ago

0.3.3

5 years ago

0.3.2

5 years ago

0.3.1

5 years ago

0.3.0

5 years ago

0.2.6

5 years ago

0.2.5

5 years ago

0.2.4

5 years ago

0.2.3

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.42

5 years ago