in

Ethereum : web3x v1.2.1 – TypeScript port of web3.js released, for type safe contracts and tiny builds.

Ethereum update: web3x v1.2.1 – TypeScript port of web3.js released, for type safe contracts and tiny builds.



Hello.

web3x is a port of web3.js to TypeScript with a focus on tiny builds (~160k for most cases), perfect types (including with contracts) and clean modular code. Visit the Github link below to see a beautiful gif of IDE autocompletion.

Version 1.2.1 is now feature complete including support for ENS, Swarm and Whisper. More importantly it enables type safe contract interactions with a simple code generator and configuration file. Given a `contracts.json` file which points to your ABIs (either remote such as on etherscan, or local such as from Truffle), the generator will create contract classes that follow the web3.js APIs but now with full type safety. Read more about it [here](https://github.com/xf00f/web3x).

An example of a configuration file to create a DAI contract looks like:
“`json
{
“outputPath”: “./src/contracts”,
“contracts”: {
“DaiContract”: “http://api.etherscan.io/api?module=contract&action=getabi&address=0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359&format=raw”
}
}
“`

Using the generated class with full type safety on method calls and return values/event logs is as simple as:
“`typescript
const daiContract = new DaiContract(eth, DAI_CONTRACT_ADDRESS);
const receipt = await daiContract.methods.transfer(ZERO_ADDRESS, toWei(‘1’, ‘ether’)).send();
const amount = receipt.events!.Transfer[0].returnValues.wad;
const to = receipt.events!.Transfer[0].returnValues.dst;
console.log(`Transferred ${fromWei(amount, ‘ether’)} to ${to}.`);
“`

Github (please star):
[https://github.com/xf00f/web3x](https://github.com/xf00f/web3x)

Packages:
[https://www.npmjs.com/package/web3x](https://www.npmjs.com/package/web3x)
[https://www.npmjs.com/package/web3x-es](https://www.npmjs.com/package/web3x-es)




View the link

About Ethereum



Ethereum is a decentralized platform that runs smart contracts: applications that run exactly as programmed without any possibility of downtime, censorship, fraud or third-party interference.

Author: xf00f

Score: 2

Don’t forget to share the post if you love it !

Bitcoin : Night of the Living HODLers: Halloween 2018’s Best Crypto Costumes

Ethereum : Can anyone explain this? A flat report then the current goes in a circle?