web3-yeet v0.4.0
Web3 YEET
Making web3 libraries usable
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
- Include
- 0.3.19
- Add tests
- 0.3.18
- Add error return for
Wallet.sign()
- Add error return for
- 0.3.16
- Add
Wallet.isAvailable()
- Add
- 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.
Meta
Cehhiro – @Cehhiro – cehhiro@cehhiro.com
Contributing
- Fork it (https://github.com/web3-yeet/web3-yeet/fork)
- Create your feature branch (
git checkout -b feature/fooBar
) - Commit your changes (
git commit -am 'Add some fooBar'
) - Push to the branch (
git push origin feature/fooBar
) - Create a new Pull Request
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago