promisify-smart-contract-func
A simple npm package to help you Promisify your Web3 calls that requires a callback
What is this for
When you try to do function calls (such as from Metamask) such as
var balance = web3.eth.getBalance(yourEthAddress);
You will get the following error
Uncaught Error: The MetaMask Web3 object does not support synchronous methods like eth_getBalance without a callback parameter.
This package allows you to get around the callback requirements by wrapping your functions into a Promise
.
This allows you to avoid what Javascript developers like to call as callback hell
Installation
Run
npm install --save promisify-smart-contract-func
Example usage
;
Using With Parameters
promisifySmartContractFunc
With ;try const balance = await ; const approveTransactionHash = await ; if approveTransactionHash console; console; // Do something catch error console; throwerror;
promisifySmartContractFunc
Without web3eth;
Using Without Parameters
promisifySmartContractFunc
With ;try const tokenDeposited = await ; console catch error console; throwerror;
promisifySmartContractFunc
Without contract;